ShopController.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace business\controllers;
  3. use biz\merchant\services\ShopService;
  4. use common\components\dirUtil;
  5. use common\components\util;
  6. class ShopController extends BaseController
  7. {
  8. //门店列表 shish 20202.2.29
  9. public function actionList()
  10. {
  11. $where = [];
  12. $list = ShopService::getShopList($where);
  13. util::success($list);
  14. }
  15. //下载收款码 shish 2020.2.29
  16. public function actionDownloadGatheringCode()
  17. {
  18. $id = Yii::$app->request->get('id', 0);
  19. $shop = ShopService::getById($id);
  20. ShopService::valid($shop, $this->merchantId);
  21. $gatheringCode = isset($shop['gatheringCode']) ? $shop['gatheringCode'] : '';
  22. $file = dirUtil::getImgDir() . $gatheringCode;
  23. if (file_exists($file) == false) {
  24. util::fail('没有找到收款码');
  25. }
  26. $fileName = '收款码.jpg';
  27. $contentType = 'image/jpeg';
  28. header("Cache-control: private");
  29. header("Content-type: $contentType"); //设置要下载的文件类型
  30. header("Content-Length:" . filesize($file)); //设置要下载文件的文件大小
  31. header("Content-Disposition: attachment; filename=" . urldecode($fileName)); //设置要下载文件的文件名
  32. readfile($file);
  33. }
  34. //下载注册会员码 shish 2020.2.29
  35. public function actionDownloadApplyMemberCode()
  36. {
  37. $id = Yii::$app->request->get('id', 0);
  38. $shop = ShopService::getById($id);
  39. ShopService::valid($shop, $this->merchantId);
  40. $applyMemberCode = isset($shop['applyMemberCode']) ? $shop['applyMemberCode'] : '';
  41. $file = dirUtil::getImgDir() . $applyMemberCode;
  42. if (file_exists($file) == false) {
  43. util::fail('没有找到注册会员码');
  44. }
  45. $fileName = '注册会员码.jpg';
  46. $contentType = 'image/jpeg';
  47. header("Cache-control: private");
  48. header("Content-type: $contentType"); //设置要下载的文件类型
  49. header("Content-Length:" . filesize($file)); //设置要下载文件的文件大小
  50. header("Content-Disposition: attachment; filename=" . urldecode($fileName)); //设置要下载文件的文件名
  51. readfile($file);
  52. }
  53. }