ShopController.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <?php
  2. namespace hd\controllers;
  3. use biz\shop\classes\ShopClass;
  4. use biz\sj\services\MerchantExtendService;
  5. use bizHd\merchant\services\ShopService;
  6. use common\components\dirUtil;
  7. use common\components\util;
  8. use common\components\wxUtil;
  9. use Yii;
  10. class ShopController extends BaseController
  11. {
  12. //门店列表 shish 20202.2.29
  13. public function actionList()
  14. {
  15. $where = [];
  16. $where['merchantId'] = $this->sjId;
  17. $where['delStatus'] = 0;
  18. $list = ShopService::getShopList($where);
  19. util::success($list);
  20. }
  21. //更新门店 shish 2020.2.29
  22. public function actionUpdate()
  23. {
  24. $data = Yii::$app->request->post();
  25. $data['merchantId'] = $this->sjId;
  26. $id = isset($data['id']) ? $data['id'] : 0;
  27. unset($data['id']);
  28. $shop = ShopService::getById($id);
  29. ShopService::valid($shop, $this->sjId);
  30. ShopService::updateShop($id, $data);
  31. util::complete();
  32. }
  33. public function actionAdd()
  34. {
  35. $data = Yii::$app->request->post();
  36. $data['merchantId'] = $this->sjId;
  37. ShopService::addShop($data);
  38. util::complete();
  39. }
  40. //下载微信和支付宝收款码 shish 2020.2.29
  41. public function actionGatheringCode()
  42. {
  43. $id = Yii::$app->request->get('id', 0);
  44. $shop = ShopService::getById($id);
  45. ShopService::valid($shop, $this->sjId);
  46. $gatheringCode = ShopService::generateGatheringCode($this->sjId, $id);
  47. $file = dirUtil::getImgDir() . $gatheringCode;
  48. if (file_exists($file) == false) {
  49. util::fail('没有找到收款码');
  50. }
  51. $fileName = "门店({$id})收款码.jpg";
  52. $contentType = 'image/jpeg';
  53. header("Cache-control: private");
  54. header("Content-type: $contentType"); //设置要下载的文件类型
  55. header("Content-Length:" . filesize($file)); //设置要下载文件的文件大小
  56. header("Content-Disposition: attachment; filename=" . urldecode($fileName)); //设置要下载文件的文件名
  57. readfile($file);
  58. }
  59. //获取小程序的收款码 shish
  60. public function actionGatheringMiniCode()
  61. {
  62. $id = Yii::$app->request->get('id', 0);
  63. $extend = MerchantExtendService::getByMerchantId($this->sjId);
  64. if ($extend['miniAuth'] == 0) {
  65. util::fail('您的小程序还没有授权');
  66. }
  67. $shop = ShopService::getById($id);
  68. ShopService::valid($shop, $this->sjId);
  69. $applyMemberCode = wxUtil::generateGatheringMiniCode($this->sj, $id);
  70. $file = dirUtil::getImgDir() . $applyMemberCode;
  71. if (file_exists($file) == false) {
  72. util::fail('没有找到注册会员码');
  73. }
  74. $fileName = "门店({$id})小程序收款码.jpg";
  75. $contentType = 'image/jpeg';
  76. header("Cache-control: private");
  77. header("Content-type: $contentType"); //设置要下载的文件类型
  78. header("Content-Length:" . filesize($file)); //设置要下载文件的文件大小
  79. header("Content-Disposition: attachment; filename=" . urldecode($fileName)); //设置要下载文件的文件名
  80. readfile($file);
  81. }
  82. //下载会员注册码 shish 2020.2.29
  83. public function actionApplyMemberCode()
  84. {
  85. $id = Yii::$app->request->get('id', 0);
  86. $extend = MerchantExtendService::getByMerchantId($this->sjId);
  87. if ($extend['miniAuth'] == 0) {
  88. util::fail('您的小程序还没有授权');
  89. }
  90. $shop = ShopService::getById($id);
  91. ShopService::valid($shop, $this->sjId);
  92. $applyMemberCode = wxUtil::generateMemberCode($this->sj, $id);
  93. $file = dirUtil::getImgDir() . $applyMemberCode;
  94. if (file_exists($file) == false) {
  95. util::fail('没有找到注册会员码');
  96. }
  97. $fileName = "注册会员码{$id}.jpg";
  98. $contentType = 'image/jpeg';
  99. header("Cache-control: private");
  100. header("Content-type: $contentType"); //设置要下载的文件类型
  101. header("Content-Length:" . filesize($file)); //设置要下载文件的文件大小
  102. header("Content-Disposition: attachment; filename=" . urldecode($fileName)); //设置要下载文件的文件名
  103. readfile($file);
  104. }
  105. //删除门店 shish 2020.3.1
  106. public function actionDelete()
  107. {
  108. $id = Yii::$app->request->get('id', 0);
  109. util::fail('功能开发中');
  110. $shop = ShopService::getById($id);
  111. ShopService::valid($shop, $this->sjId);
  112. ShopService::deleteShop($shop);
  113. util::complete();
  114. }
  115. //获取商家的默认门店 shish 2019.12.6
  116. public function actionDetail()
  117. {
  118. $introUserId = Yii::$app->request->get('introUserId');
  119. //$merchant = $this->sj;
  120. //$shop = ShopService::getDefaultShop($merchant);
  121. //$ad = AdService::getValidAdList($this->sjId);
  122. //新人专享礼物
  123. $newUserGift = [
  124. [
  125. 'adImgUrl' => "https://img.huahb.com/uploads/12358/202006/03/20210120220152.jpg",
  126. 'adName' => '图片',
  127. ],
  128. ];
  129. if (!empty($introUserId)) {
  130. //$userInfo = UserService::getUserInfo($this->adminId);
  131. //$newUserGift = InviteService::hasNewGift($userInfo);
  132. }
  133. $ad = [];
  134. $shop = [
  135. 'address' => '福建省厦门市思明区后埭溪路128-5号',
  136. 'telephone' => '15280215347',
  137. 'openTime' => '09:00--18:00',
  138. 'shopName' => '国兰花尚',
  139. 'merchantName' => '国兰花尚2',
  140. 'introduction' => '门店介绍',
  141. ];
  142. util::success(['ad' => $ad, 'shop' => $shop, 'newUserGift' => $newUserGift]);
  143. }
  144. //提现信息更新 shish 2021.3.23
  145. public function actionCashUpdate()
  146. {
  147. $get = Yii::$app->request->get();
  148. $cashAccount = $get['cashAccount'] ?? '';
  149. $cashName = $get['cashName'] ?? '';
  150. if (empty($cashName)) {
  151. util::fail('请填写姓名');
  152. }
  153. if (empty($cashAccount)) {
  154. util::fail('请填写帐号');
  155. }
  156. $shopAdmin = $this->shopAdmin;
  157. $shopId = $shopAdmin['shopId'];
  158. if ($shopAdmin['super'] != 1) {
  159. util::fail('您没有权限修改');
  160. }
  161. ShopClass::updateById($shopId, ['cashAccount' => $cashAccount, 'cashName' => $cashName]);
  162. util::complete();
  163. }
  164. //获取所有门店linqh 2021.1.31
  165. public function actionAll()
  166. {
  167. $res = [];
  168. $shopAdmin = $this->shopAdmin;
  169. if ($shopAdmin['super'] == 1) {
  170. $res = ShopClass::getAllShop($this->sjId);
  171. }
  172. util::success($res);
  173. }
  174. }