NewSalesmanController.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\modules\client\controllers\v1;
  8. use app\models\AggregateQrcode;
  9. use app\models\MerchantInfo;
  10. use app\models\StoreAliMini;
  11. use app\models\StoreAudit;
  12. use app\models\StoreMini;
  13. use app\models\StoreSchedule;
  14. use app\modules\admin\models\AlipayThirdForm;
  15. use app\modules\admin\models\WechatThirdForm;
  16. use app\modules\client\controllers\BaseController;
  17. use app\modules\client\models\v1\NewSalesmanForm;
  18. use app\utils\WechatMerchant\Merchant;
  19. use yii\helpers\Json;
  20. class NewSalesmanController extends BaseController
  21. {
  22. //TODO 商户逻辑 start
  23. //新增商户信息
  24. public function actionAddMerchant(){
  25. if(\Yii::$app->request->isPost){
  26. $form = new NewSalesmanForm();
  27. $form->contact_info = post_params("contact_info");
  28. $form->subject_info = post_params("subject_info");
  29. $form->business_info = post_params("business_info");
  30. $form->bank_account_info = post_params("bank_account_info");
  31. // $form->mini_apply_info = post_params("mini_apply_info");
  32. $form->bind_store_id = post_params("bind_store_id",136);
  33. $res = $form->saveMerchant();
  34. }else{
  35. $form = new NewSalesmanForm();
  36. $form->id = get_params('id');
  37. $res = $form->getMerchant();
  38. }
  39. return $this->asJson($res);
  40. }
  41. //快速注册小程序
  42. public function actionApplyMini(){
  43. $form = new NewSalesmanForm();
  44. $form->mini_apply_info = json_decode(post_params("mini_apply_info"));
  45. $form->bind_store_id = post_params("bind_store_id");
  46. $form->type = post_params("type",'weixin');
  47. $res = $form->applyMini();
  48. return $this->asJson($res);
  49. }
  50. //绑定小程序码
  51. public function actionBindPayQrcode(){
  52. $form = new NewSalesmanForm();
  53. $form->qrcode_id = post_params("qrcode_id");
  54. $form->type = post_params("type",'weixin');
  55. $form->bind_store_id = post_params("bind_store_id");
  56. $res = $form->bindPayQrcode();
  57. return $this->asJson($res);
  58. }
  59. //获取进度信息
  60. public function actionProgress(){
  61. $form = new NewSalesmanForm();
  62. $form->bind_store_id = post_params("bind_store_id");
  63. $form->type = post_params("type",'weixin');
  64. $res = $form->getProgress();
  65. return $this->asJson($res);
  66. }
  67. //查看个人中心信息
  68. public function actionGetUserInfo(){
  69. $form = new NewSalesmanForm();
  70. $res = $form->getUserInfo();
  71. return $this->asJson($res);
  72. }
  73. //查看店铺列表
  74. public function actionMchList(){
  75. $form = new NewSalesmanForm();
  76. $form->page = post_params("page");
  77. $form->status = post_params("status");
  78. $form->sort = post_params("sort");
  79. $form->category_id = post_params("category_id");
  80. $form->type = post_params("type",'weixin');
  81. $res = $form->merchantList();
  82. return $this->asJson($res);
  83. }
  84. //
  85. public function actionAudit(){
  86. $form = new NewSalesmanForm();
  87. $form->id = post_params("id");
  88. $form->status = post_params("status");
  89. $res = $form->audit();
  90. return $this->asJson($res);
  91. }
  92. //获取进件资料信息
  93. public function actionGetApplyInfo(){
  94. $form = new NewSalesmanForm();
  95. $form->bind_store_id = post_params("bind_store_id");
  96. $res = $form->getInfo();
  97. return $this->asJson($res);
  98. }
  99. ///
  100. /// 微信小程序
  101. ///
  102. //修改信息
  103. public function actionEditMiniInfo(){
  104. $form = new WechatThirdForm();
  105. $form->bind_store_id = post_params("bind_store_id");
  106. $form->mini_nickname = post_params("mini_nickname");
  107. $form->head_img_media_id = post_params("mini_url");
  108. $form->signature = post_params("signature");
  109. $res = $form->setHeadImage();
  110. if($res['code'] === 0){
  111. $res = $form->setSignature();
  112. if($res['code'] === 0){
  113. $res = $form->setMiniNianname();
  114. return $this->asJson($res);
  115. }
  116. }
  117. return $this->asJson($res);
  118. }
  119. //获取分类
  120. public function actionGetAllCategory(){
  121. $form = new WechatThirdForm();
  122. $form->bind_store_id = post_params("bind_store_id");
  123. $res = $form->getAllCategories();
  124. return $this->asJson($res);
  125. }
  126. //获取已经设置的分类
  127. public function actionGetCategory(){
  128. $form = new WechatThirdForm();
  129. $form->bind_store_id = post_params("bind_store_id");
  130. $res = $form->getCategories();
  131. return $this->asJson($res);
  132. }
  133. //修改分类
  134. public function actionSetCategory(){
  135. $form = new WechatThirdForm();
  136. $form->bind_store_id = post_params("bind_store_id");
  137. $form->categories = post_params("categories");
  138. $res = $form->addCategory();
  139. return $this->asJson($res);
  140. }
  141. //删除分类
  142. public function actionDelCategory(){
  143. $form = new WechatThirdForm();
  144. $form->bind_store_id = post_params("bind_store_id");
  145. $form->cate_first = post_params("cate_first");
  146. $form->cate_second = post_params("cate_second");
  147. $res = $form->delCategory();
  148. return $this->asJson($res);
  149. }
  150. //上传小程序
  151. public function actionUpMini(){
  152. $form = new WechatThirdForm();
  153. $form->bind_store_id = post_params("bind_store_id");
  154. $res = $form->upMini();
  155. return $this->asJson($res);
  156. }
  157. //审核小程序
  158. public function actionSubmitAudit(){
  159. $form = new WechatThirdForm();
  160. $form->bind_store_id = post_params("bind_store_id");
  161. $res = $form->submitAudit();
  162. return $this->asJson($res);
  163. }
  164. //审核撤回
  165. public function actionCancelSubmitAudit(){
  166. $form = new WechatThirdForm();
  167. $form->bind_store_id = post_params("bind_store_id");
  168. $res = $form->unDoCodeAudit();
  169. return $this->asJson($res);
  170. }
  171. //发布已经通过审核的小程序
  172. public function actionRelease(){
  173. $form = new WechatThirdForm();
  174. $form->bind_store_id = post_params("bind_store_id");
  175. $res = $form->release();
  176. return $this->asJson($res);
  177. }
  178. ///
  179. /// 支付宝小程序
  180. ///
  181. //获取支付宝进度
  182. public function actionAliProgress(){
  183. $form = new NewSalesmanForm();
  184. $form->bind_store_id = post_params("bind_store_id");
  185. $res = $form->getProgress();
  186. return $this->asJson($res);
  187. }
  188. //修改资料
  189. public function actionSetInfo(){
  190. $form = new AlipayThirdForm();
  191. $form->AppName = post_params("app_name");
  192. $form->AppEnglishName = post_params("app_english_name");
  193. $form->AppSlogan = post_params("app_slogan");
  194. $form->AppLogo = post_params("app_logo");
  195. $form->AppDesc = post_params("app_desc");
  196. $form->ServicePhone = post_params("service_phone");
  197. $form->ServiceEmail = post_params("service_email");
  198. $form->MiniCategoryIds = post_params("mini_categoryIds");
  199. $form->bind_store_id = post_params("bind_store_id");
  200. $res = $form->setMiniBaseInfo();
  201. return $this->asJson($res);
  202. }
  203. //上传代码
  204. public function actionUpAliMini(){
  205. $form = new AlipayThirdForm();
  206. $form->bind_store_id = post_params("bind_store_id");
  207. $res = $form->updateMiniVersion();
  208. return $this->asJson($res);
  209. }
  210. //签约流程
  211. public function actionSignContract(){
  212. $form = new AlipayThirdForm();
  213. $form->bind_store_id = post_params("bind_store_id");
  214. $res = $form->agentCreate();
  215. return $this->asJson($res);
  216. }
  217. //审核小程序
  218. public function actionAuditAliMini(){
  219. $form = new AlipayThirdForm();
  220. $form->bind_store_id = post_params("bind_store_id");
  221. $aliMini = StoreAliMini::find()->where(['store_id'=>post_params("bind_store_id")])->orderBy('id desc')->select('license_no,license_pic,app_name,app_english_name,app_slogan,app_logo,app_desc,service_phone,service_email,mini_categoryIds,license_name,license_date,is_long_effective')->one();
  222. $audit = [
  223. "AppName"=>$aliMini->app_name,
  224. "AppEnglishName"=>$aliMini->app_english_name,
  225. "AppSlogan"=>$aliMini->app_slogan,
  226. "AppLogo"=>$aliMini->app_logo,
  227. "AppDesc"=>$aliMini->app_desc,
  228. "ServicePhone"=>$aliMini->service_phone,
  229. "ServiceEmail"=>$aliMini->service_email,
  230. "MiniCategoryIds"=>$aliMini->mini_categoryIds,
  231. "license_no"=>$aliMini->license_no,
  232. "license_pic"=>$aliMini->license_pic,
  233. "license_name"=>$aliMini->license_name,
  234. "license_date"=>$aliMini->license_date,
  235. "is_long_effective"=>$aliMini->is_long_effective,
  236. ];
  237. $form->auditData = $audit;
  238. $res = $form->miniAuditApply();
  239. return $this->asJson($res);
  240. }
  241. //发布小程序
  242. public function actionPushMini(){
  243. $form = new AlipayThirdForm();
  244. $form->bind_store_id = post_params("bind_store_id");
  245. $res = $form->miniOnline();
  246. return $this->asJson($res);
  247. }
  248. //进件
  249. public function actionApply() {
  250. $StoreSchedule = StoreSchedule::find()->where(['store_id'=>post_params("bind_store_id")])->select('merchant_info,audit_id')->one();
  251. if(!empty($StoreSchedule->audit_id)){
  252. $StoreAudit = StoreAudit::find()->where(['id'=>$StoreSchedule->audit_id])->select('merchant_info_id')->one();
  253. }
  254. $appid = "";
  255. $StoreMini = StoreMini::find()->where(['store_id'=>post_params("bind_store_id")])->select('appid')->orderBy('id desc')->one();
  256. if(!empty($StoreMini->appid)){
  257. $appid = $StoreMini->appid;
  258. }
  259. $merchant_info = json_decode(post_params("merchant_info"),true);
  260. if(empty(post_params("merchant_info"))){
  261. if(!empty($StoreSchedule->merchant_info)){
  262. $merchant_info = json_decode($StoreSchedule->merchant_info,true);
  263. }
  264. }
  265. $contact_info = $merchant_info['contact_info'];
  266. $subject_info = $merchant_info['subject_info'];
  267. $business_info = $merchant_info['business_info'];
  268. $bank_account_info = $merchant_info['bank_account_info'];
  269. $apply_id = !empty($StoreAudit->merchant_info_id)?$StoreAudit->merchant_info_id:0;
  270. try {
  271. $merchant = new Merchant();
  272. } catch (\Exception $e) {
  273. return $this->asJson([
  274. 'code' => 1,
  275. 'msg' => $e->getMessage()
  276. ]);
  277. }
  278. return $this->asJson($merchant->submit($contact_info, $subject_info, $business_info, $bank_account_info, $apply_id,$appid));
  279. }
  280. }