| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\alliance\controllers;
- use app\models\AggregateQrcode;
- use app\models\MerchantInfo;
- use app\models\Store;
- use app\models\StoreAliMini;
- use app\models\StoreAudit;
- use app\models\StoreMini;
- use app\models\StoreSchedule;
- use app\modules\alliance\models\AlipayThirdForm;
- use app\modules\alliance\models\WechatThirdForm;
- use app\modules\alliance\controllers\BaseController;
- use app\modules\alliance\models\NewSalesmanForm;
- use app\utils\WechatMerchant\Merchant;
- use yii\helpers\Json;
- class NewSalesmanController extends BaseController
- {
- //TODO 商户逻辑 start
- //新增商户信息
- public function actionAddMerchant(){
- if(\Yii::$app->request->isPost){
- $form = new NewSalesmanForm();
- $form->contact_info = post_params("contact_info");
- $form->subject_info = post_params("subject_info");
- $form->business_info = post_params("business_info");
- $form->bank_account_info = post_params("bank_account_info");
- // $form->mini_apply_info = post_params("mini_apply_info");
- $form->bind_store_id = post_params("bind_store_id",136);
- $res = $form->saveMerchant();
- }else{
- $form = new NewSalesmanForm();
- $form->id = get_params('id');
- $res = $form->getMerchant();
- }
- return $this->asJson($res);
- }
- //快速注册小程序
- public function actionApplyMini(){
- $form = new NewSalesmanForm();
- $form->mini_apply_info = json_decode(post_params("mini_apply_info"));
- $form->bind_store_id = post_params("bind_store_id");
- $form->type = post_params("type",'weixin');
- $res = $form->applyMini();
- return $this->asJson($res);
- }
- //绑定小程序码
- public function actionBindPayQrcode(){
- $form = new NewSalesmanForm();
- $form->qrcode_id = post_params("qrcode_id");
- $form->type = post_params("type",'weixin');
- $form->bind_store_id = post_params("bind_store_id");
- $res = $form->bindPayQrcode();
- return $this->asJson($res);
- }
- //获取进度信息
- public function actionProgress(){
- $form = new NewSalesmanForm();
- $form->bind_store_id = post_params("bind_store_id");
- $form->type = post_params("type",'weixin');
- $res = $form->getProgress();
- return $this->asJson($res);
- }
- //查看个人中心信息
- public function actionGetUserInfo(){
- $form = new NewSalesmanForm();
- $res = $form->getUserInfo();
- return $this->asJson($res);
- }
- //查看店铺列表
- public function actionMchList(){
- $form = new NewSalesmanForm();
- $form->page = post_params("page");
- $form->status = post_params("status");
- $form->sort = post_params("sort");
- $form->category_id = post_params("category_id");
- $form->type = post_params("type",'weixin');
- $res = $form->merchantList();
- return $this->asJson($res);
- }//
- //查看店铺列表
- public function actionMchNewList(){
- $form = new NewSalesmanForm();
- $form->page = post_params("page");
- $form->status = post_params("status");
- $form->sort = post_params("sort");
- $form->category_id = post_params("category_id");
- $form->type = post_params("type",'weixin');
- $form->store_id = get_store_id();
- //当前接口由商城管理员打开 直接获取商城管理员的商城id
- try {
- $payload = \Yii::$app->jwt->getPayload();
- $store_admin_id = $payload['store_admin_id'];
- if ($store_admin_id > 0) {
- $StoreMiniAdmin = \app\models\StoreAdmin::findOne(['id' => $store_admin_id, 'status' => 1, 'is_delete' => 0]);
- $store_id = $StoreMiniAdmin->store_id;
- } else {
- $admin = \app\models\Admin::findOne(['id' => $payload['admin_id']]);
- $store_id = $admin->type_id;
- }
- $form->store_id = $store_id;
- } catch (\Exception $e) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '需要重新登录'
- ]);
- }
- $res = $form->merchantNewList();
- return $this->asJson($res);
- }
- //
- public function actionAudit(){
- $form = new NewSalesmanForm();
- $form->id = post_params("id");
- $form->status = post_params("status");
- $form->business_model = post_params("business_model");
- $form->qrcode_id = post_params("qrcode_id");
- $res = $form->audit();
- return $this->asJson($res);
- }
- //
- public function actionGetQrcode(){
- $form = new NewSalesmanForm();
- $form->business_model = post_params("business_model");
- $res = $form->getQrcode();
- return $this->asJson($res);
- }
- //获取进件资料信息
- public function actionGetApplyInfo(){
- $form = new NewSalesmanForm();
- $form->bind_store_id = post_params("bind_store_id");
- $res = $form->getInfo();
- return $this->asJson($res);
- }
- ///
- /// 微信小程序
- ///
- //修改信息
- public function actionEditMiniInfo(){
- $form = new WechatThirdForm();
- $form->bind_store_id = post_params("bind_store_id");
- $form->mini_nickname = post_params("mini_nickname");
- $form->head_img_media_id = post_params("mini_url");
- $form->signature = post_params("signature");
- $res = $form->setHeadImage();
- if($res['code'] === 0){
- $res = $form->setSignature();
- if($res['code'] === 0){
- $res = $form->setMiniNianname();
- return $this->asJson($res);
- }
- }
- return $this->asJson($res);
- }
- //获取分类
- public function actionGetAllCategory(){
- $form = new WechatThirdForm();
- $form->bind_store_id = post_params("bind_store_id");
- $res = $form->getAllCategories();
- return $this->asJson($res);
- }
- //获取已经设置的分类
- public function actionGetCategory(){
- $form = new WechatThirdForm();
- $form->bind_store_id = post_params("bind_store_id");
- $res = $form->getCategories();
- return $this->asJson($res);
- }
- //修改分类
- public function actionSetCategory(){
- $form = new WechatThirdForm();
- $form->bind_store_id = post_params("bind_store_id");
- $form->categories = post_params("categories");
- $res = $form->addCategory();
- return $this->asJson($res);
- }
- //删除分类
- public function actionDelCategory(){
- $form = new WechatThirdForm();
- $form->bind_store_id = post_params("bind_store_id");
- $form->cate_first = post_params("cate_first");
- $form->cate_second = post_params("cate_second");
- $res = $form->delCategory();
- return $this->asJson($res);
- }
- //上传小程序
- public function actionUpMini(){
- $form = new WechatThirdForm();
- $form->bind_store_id = post_params("bind_store_id");
- $res = $form->upMini();
- return $this->asJson($res);
- }
- //审核小程序
- public function actionSubmitAudit(){
- $form = new WechatThirdForm();
- $form->bind_store_id = post_params("bind_store_id");
- $res = $form->submitAudit();
- return $this->asJson($res);
- }
- //审核撤回
- public function actionCancelSubmitAudit(){
- $form = new WechatThirdForm();
- $form->bind_store_id = post_params("bind_store_id");
- $res = $form->unDoCodeAudit();
- return $this->asJson($res);
- }
- //发布已经通过审核的小程序
- public function actionRelease(){
- $form = new WechatThirdForm();
- $form->bind_store_id = post_params("bind_store_id");
- $res = $form->release();
- return $this->asJson($res);
- }
- ///
- /// 支付宝小程序
- ///
- //获取支付宝进度
- public function actionAliProgress(){
- $form = new NewSalesmanForm();
- $form->bind_store_id = post_params("bind_store_id");
- $res = $form->getProgress();
- return $this->asJson($res);
- }
- //修改资料
- public function actionSetInfo(){
- $form = new AlipayThirdForm();
- $form->AppName = post_params("app_name");
- $form->AppEnglishName = post_params("app_english_name");
- $form->AppSlogan = post_params("app_slogan");
- $form->AppLogo = post_params("app_logo");
- $form->AppDesc = post_params("app_desc");
- $form->ServicePhone = post_params("service_phone");
- $form->ServiceEmail = post_params("service_email");
- $form->MiniCategoryIds = post_params("mini_categoryIds");
- $form->bind_store_id = post_params("bind_store_id");
- $res = $form->setMiniBaseInfo();
- return $this->asJson($res);
- }
- //上传代码
- public function actionUpAliMini(){
- $form = new AlipayThirdForm();
- $form->bind_store_id = post_params("bind_store_id");
- $res = $form->updateMiniVersion();
- return $this->asJson($res);
- }
- //签约流程
- public function actionSignContract(){
- $form = new AlipayThirdForm();
- $form->bind_store_id = post_params("bind_store_id");
- $res = $form->agentCreate();
- return $this->asJson($res);
- }
- //审核小程序
- public function actionAuditAliMini(){
- $form = new AlipayThirdForm();
- $form->bind_store_id = post_params("bind_store_id");
- $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();
- $audit = [
- "AppName"=>$aliMini->app_name,
- "AppEnglishName"=>$aliMini->app_english_name,
- "AppSlogan"=>$aliMini->app_slogan,
- "AppLogo"=>$aliMini->app_logo,
- "AppDesc"=>$aliMini->app_desc,
- "ServicePhone"=>$aliMini->service_phone,
- "ServiceEmail"=>$aliMini->service_email,
- "MiniCategoryIds"=>$aliMini->mini_categoryIds,
- "license_no"=>$aliMini->license_no,
- "license_pic"=>$aliMini->license_pic,
- "license_name"=>$aliMini->license_name,
- "license_date"=>$aliMini->license_date,
- "is_long_effective"=>$aliMini->is_long_effective,
- ];
- $form->auditData = $audit;
- $res = $form->miniAuditApply();
- return $this->asJson($res);
- }
- //发布小程序
- public function actionPushMini(){
- $form = new AlipayThirdForm();
- $form->bind_store_id = post_params("bind_store_id");
- $res = $form->miniOnline();
- return $this->asJson($res);
- }
- //进件
- public function actionApply() {
- $StoreSchedule = StoreSchedule::find()->where(['store_id'=>post_params("bind_store_id")])->select('merchant_info,audit_id')->one();
- if(!empty($StoreSchedule->audit_id)){
- $StoreAudit = StoreAudit::find()->where(['id'=>$StoreSchedule->audit_id])->select('merchant_info_id')->one();
- }
- $appid = "";
- $store = Store::findOne(post_params("bind_store_id"));
- if ($store->business_model === 1) {
- $StoreMini = StoreMini::find()->where(['store_id'=>post_params("bind_store_id")])->select('appid')->orderBy('id desc')->one();
- if(!empty($StoreMini->appid)){
- $appid = $StoreMini->appid;
- }
- } else {
- $appid = "";
- }
- $merchant_info = json_decode(post_params("merchant_info"),true);
- if(empty(post_params("merchant_info"))){
- if(!empty($StoreSchedule->merchant_info)){
- $merchant_info = json_decode($StoreSchedule->merchant_info,true);
- }
- }
- $contact_info = $merchant_info['contact_info'];
- $subject_info = $merchant_info['subject_info'];
- $business_info = $merchant_info['business_info'];
- $bank_account_info = $merchant_info['bank_account_info'];
- $apply_id = !empty($StoreAudit->merchant_info_id)?$StoreAudit->merchant_info_id:0;
- try {
- $merchant = new Merchant();
- } catch (\Exception $e) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => $e->getMessage()
- ]);
- }
- return $this->asJson($merchant->submit($contact_info, $subject_info, $business_info, $bank_account_info, $apply_id, $appid));
- }
- }
|