| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\admin\controllers;
- use app\jobs\SyncSharerListJob;
- use app\models\StoreMini;
- use app\modules\admin\models\VideoShopForm;
- use app\modules\admin\models\VideoShopGoodsForm;
- use app\modules\admin\models\VideoShopOrderForm;
- use app\modules\admin\models\WechatThirdForm;
- use app\modules\client\models\v1\NewSalesmanForm;
- use app\utils\Wechat\WechatMini;
- use app\models\Option;
- class WechatThirdController extends BaseController
- {
- public function actionStoreMiniSelectList(){
- $res = WechatThirdForm::getStoreMiniSelectList(get_store_id());
- return $this->asJson($res);
- }
- /**
- * 快速注册小程序
- */
- public function actionFastRegisterMini(){
- $form = new WechatThirdForm();
- $form->name = post_params('name');
- $form->code = post_params('code');
- $form->code_type = post_params('code_type',1);
- $form->legal_persona_wechat = post_params('legal_persona_wechat');
- $form->license_pic = post_params('license_pic');
- $form->legal_persona_name = post_params('legal_persona_name');
- $res = $form->fastRegisterMini();
- return $this->asJson($res);
- }
- /**
- * 查询快速注册状态
- */
- public function actionGetFast(){
- $form = new WechatThirdForm();
- $form->getRegisterStatus();
- }
- /**
- * 获取授权方的帐号基本信息
- */
- public function actionGetAuthInfo(){
- $form = new WechatThirdForm();
- $form->mini_id = post_params("id");
- $res = $form->api_get_authorizer_info();
- return $this->asJson($res);
- }
- /**
- * @return \yii\web\Response
- * 获取扫码授权回调参数
- */
- public function actionGetBackInfo(){
- $form = new WechatThirdForm();
- $res = $form->backAuthInfo();
- return $this->asJson($res);
- }
- /**
- * @return \yii\web\Response
- * 通过auth_code(授权码)换取小程序信息
- */
- public function actionGetMiniInfo(){
- $form = new WechatThirdForm();
- $form->store_id = get_store_id();
- $res = $form->getAuthorization_info(post_params("auth_code"));
- return $this->asJson($res);
- }
- public function actionGetAuthorizers(){
- $form = new WechatThirdForm();
- $form->store_id = get_store_id();
- $res = $form->getAuthorizers();
- return $this->asJson($res);
- }
- /**
- * @return \yii\web\Response
- * 设置服务器域名
- */
- public function actionDomainName(){
- $form = new WechatThirdForm();
- $action = post_params("action",0);
- switch ($action){
- case 0:
- $action = "get";
- break;
- case 1:
- $action = "add";
- break;
- case 2:
- $action = "delete";
- break;
- case 3:
- $action = "set";
- break;
- }
- $form->action = $action;
- $form->requestdomain = post_params("requestdomain");
- $form->wsrequestdomain = post_params("wsrequestdomain");
- $form->uploaddomain = post_params("uploaddomain");
- $form->downloaddomain = post_params("downloaddomain");
- $form->udpdomain = post_params("udpdomain");
- $form->tcpdomai = post_params("tcpdomai");
- $res = $form->setDomainName();
- return $this->asJson($res);
- }
- /**
- * @return \yii\web\Response
- * 设置业务域名
- * @throws \GuzzleHttp\Exception\GuzzleException
- */
- public function actionWebviewDomain(){
- $form = new WechatThirdForm();
- $action = post_params("action",0);
- $form->mini_id = post_params("id")??get_params("id");
- switch ($action){
- case 0:
- $action = "get";
- break;
- case 1:
- $action = "add";
- break;
- case 2:
- $action = "delete";
- break;
- case 3:
- $action = "set";
- break;
- }
- $form->action = $action;
- $form->webviewdomain = post_params("webviewdomain");
- $res = $form->setWebviewDomainName();
- return $this->asJson($res);
- }
- /**
- * 设置名称
- * 使用各项media_id,设置名称
- */
- public function actionSetNickname(){
- $form = new WechatThirdForm();
- $form->mini_nickname = post_params("nick_name");
- $form->mini_id = post_params("id");
- $form->id_card = post_params("id_card");
- $form->license = post_params("license");
- $form->naming_other_stuff_1 = post_params("naming_other_stuff_1","");
- $form->naming_other_stuff_2 = post_params("naming_other_stuff_2","");
- $form->naming_other_stuff_3 = post_params("naming_other_stuff_3","");
- $form->naming_other_stuff_4 = post_params("naming_other_stuff_4","");
- $form->naming_other_stuff_5 = post_params("naming_other_stuff_5","");
- $res = $form->setMiniNianname();
- return $this->asJson($res);
- }
- /**
- * @return \yii\web\Response
- * 微信认证名称检测
- */
- public function actionCheckNickname(){
- $form = new WechatThirdForm();
- $form->mini_nickname = post_params("nick_name");
- $form->mini_id = post_params("id")??get_params("id");
- $res = $form->checkWxVerifyNickname();
- return $this->asJson($res);
- }
- //查询名称审核状态
- public function actionGetNicknameAuditStatus(){
- $form = new WechatThirdForm();
- $form->mini_id = post_params("id");
- $res = $form->getNicknameAuditStatus();
- return $this->asJson($res);
- }
- /**
- * 修改头像
- */
- public function actionSetHeadImage(){
- $form = new WechatThirdForm();
- $form->mini_id = post_params("id")??get_params("id");
- $form->head_img_media_id = post_params("head_img_media_id")??get_params("head_img_media_id");
- $form->x1 = post_params("x1");
- $form->y1 = post_params("y1");
- $form->x2 = post_params("x2");
- $form->y2 = post_params("y2");
- $res = $form->setHeadImage();
- return $this->asJson($res);
- }
- /**
- * 修改简介
- */
- public function actionSetSignature(){
- $form = new WechatThirdForm();
- $form->signature = post_params("signature");
- $form->mini_id = post_params("id")??get_params("id");
- $res = $form->setSignature();
- return $this->asJson($res);
- }
- /**
- * 获取可以设置的所有类目
- */
- public function actionGetAllCategories(){
- $form = new WechatThirdForm();
- $form->mini_id = post_params("id")??get_params("id");
- $res = $form->getAllCategories();
- return $this->asJson($res);
- }
- /**
- * 获取已经设置的类目
- */
- public function actionGetCategories(){
- $form = new WechatThirdForm();
- $form->mini_id = post_params("id")??get_params("id");
- $res = $form->getCategories();
- return $this->asJson($res);
- }
- /**
- * 添加类目
- */
- public function actionAddCategory(){
- $form = new WechatThirdForm();
- $form->categories = post_params("categories");
- $form->mini_id = post_params("id")??get_params("id");
- $res = $form->addCategory();
- return $this->asJson($res);
- }
- /**
- * 删除类目
- */
- public function actionDelCategory(){
- $form = new WechatThirdForm();
- $form->cate_first = post_params("cate_first");
- $form->cate_second = post_params("cate_second");
- $form->mini_id = post_params("id")??get_params("id");
- $res = $form->delCategory();
- return $this->asJson($res);
- }
- /**
- * 获取模版列表
- */
- public function actionTemplateList(){
- $form = new WechatThirdForm();
- $res = $form->getTemplateList();
- return $this->asJson($res);
- }
- /**
- * 上传小程序
- */
- public function actionCanUsePlug(){
- $form = new WechatThirdForm();
- $form->mini_id = input_params("id");
- $appid = input_params('appid', 'wx2b03c6e691cd7370');
- $aid = input_params('aid', 52);
- $res = $form->canUsePlugin($appid, $aid);
- return $this->asJson($res);
- }
- /**
- * 上传小程序
- */
- public function actionUpMini(){
- $form = new WechatThirdForm();
- $form->mini_id = post_params("id")??get_params("id");
- $form->user_version = post_params('user_version');
- $form->user_desc = post_params('user_desc');
- $useLive = input_params('is_live', 0);
- $useStudent = input_params('is_student', 0);
- $useB2b = input_params('is_b2b', 0);
- $res = $form->upMini($useLive, $useStudent, $useB2b);
- return $this->asJson($res);
- }
- //添加体验者
- public function actionAddTester(){
- $form = new WechatThirdForm();
- $form->mini_id = post_params("id")??get_params("id");
- $form->wechatId = post_params("wechatId");
- $res = $form->addTester();
- return $this->asJson($res);
- }
- /**
- * 获取体验版二维码
- */
- public function actionGetMiniQrcode(){
- $form = new WechatThirdForm();
- $form->mini_id = post_params("id")??get_params("id");
- $res = $form->getMiniQrcode();
- return $this->asJson($res);
- }
- /**
- * 获取小程序二维码
- */
- public function actionGetMiniQr(){
- $form = new WechatThirdForm();
- $form->mini_id = post_params("id")??get_params("id");
- $res = $form->getMiniQr();
- return $this->asJson($res);
- }
- /**
- * 提交审核
- */
- public function actionSubmitAudit(){
- $form = new WechatThirdForm();
- $form->user_version = post_params('user_version');
- $form->user_desc = post_params('user_desc');
- $form->mini_id = post_params("id")??get_params("id");
- $form->is_fast_audit = post_params('is_fast_audit',0);
- $form->mini_id = post_params("id")??get_params("id");
- $form->feedback_stuff = post_params("feedback_stuff");
- $form->feedback_info = post_params("feedback_info");
- $form->item_list = post_params("item_list");
- $res = $form->submitAudit();
- return $this->asJson($res);
- }
- /**
- * 撤回审核
- */
- public function actionUndoCodeAudit(){
- $form = new WechatThirdForm();
- $form->mini_id = post_params("id")??get_params("id");
- $res = $form->unDoCodeAudit();
- return $this->asJson($res);
- }
- /**
- * 查询最后一次提交审核的状态
- */
- public function actionLastAuditStatus(){
- $form = new WechatThirdForm();
- $form->mini_id = post_params("id")??get_params("id");
- $res = $form->lastAuditStatus();
- return $this->asJson($res);
- }
- /**
- * 发布已经通过审核的小程序
- */
- public function actionRelease(){
- $form = new WechatThirdForm();
- $form->mini_id = post_params("id")??get_params("id");
- $res = $form->release();
- return $this->asJson($res);
- }
- /**
- * 设置小程序用户隐私保护指引
- */
- public function actionSetPrivacySetting(){
- $form = new WechatThirdForm();
- $form->privacy_ver = post_params('privacy_ver');
- $form->owner_setting = post_params("owner_setting");
- $form->setting_list = post_params("setting_list");
- $form->mini_id = post_params("id")??get_params("id");
- $res = $form->setPrivacySetting();
- return $this->asJson($res);
- }
- /**
- * 查询小程序用户隐私保护指引
- */
- public function actionGetPrivacySetting(){
- $form = new WechatThirdForm();
- $form->privacy_ver = post_params('privacy_ver',2);
- $form->mini_id = post_params("id")??get_params("id");
- $res = $form->getPrivacySetting();
- return $this->asJson($res);
- }
- /**
- * 上传txt/上传小程序用户隐私保护指引
- */
- public function actionUpFile(){
- $filename = $_FILES['file']['name'];
- $tmpname = $_FILES['file']['tmp_name'];
- $path = \Yii::$app->basePath . '/web/temp/txt/';
- if(!is_dir($path)){
- mkdir($path, 0777, true);
- }
- $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
- if (($ext != 'txt') ) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '请上传txt文件'
- ]);
- }
- $file = time() . $this->store_id . '.' . $ext;
- $uploadfile = $path . $file;
- $result = move_uploaded_file($tmpname, $uploadfile);
- if($result){
- $form = new WechatThirdForm();
- $form->file_url = $uploadfile;
- $res = $form->uploadPrivacySetting();
- return $this->asJson($res);
- }
- return $this->asJson([
- 'code' => 1,
- 'msg' => '上传失败'
- ]);
- }
- /**
- * @return \yii\web\Response
- * 获取小程序列表
- */
- public function actionGetMiniList(){
- $form = new WechatThirdForm();
- $form->mini_nickname = get_params("mini_nickname");
- $form->status = get_params("status",0);
- $form->is_use = get_params("is_use",0);
- $form->fuwu_type = input_params("fuwu_type",0);
- $res = $form->getMiniList();
- return $this->asJson($res);
- }
- /**
- * @return \yii\web\Response
- * 获取小程序状态
- */
- public function actionGetMini(){
- $form = new WechatThirdForm();
- $form->mini_id = post_params("id")??get_params("id");
- $res = $form->getMini();
- return $this->asJson($res);
- }
- public function actionOpenGet(){
- $form = new WechatThirdForm();
- $form->mini_id = post_params("id")??get_params("id");
- $res = $form->openGet();
- return $this->asJson($res);
- }
- public function actionOpenCreate(){
- $form = new WechatThirdForm();
- $form->mini_id = post_params("id")??get_params("id");
- $res = $form->openCreate();
- return $this->asJson($res);
- }
- public function actionOpenBind(){
- $open_appid = input_params('open_appid');
- $form = new WechatThirdForm();
- $form->mini_id = post_params("id")??get_params("id");
- $res = $form->openBind($open_appid);
- return $this->asJson($res);
- }
- public function actionOpenUnbind(){
- $form = new WechatThirdForm();
- $form->mini_id = post_params("id")??get_params("id");
- $res = $form->openUnbind();
- return $this->asJson($res);
- }
- /**
- * @return \yii\web\Response
- * 获取小程序开始使用/暂停使用
- */
- public function actionMiniIsUse(){
- $form = new WechatThirdForm();
- $form->mini_id = post_params("id")??get_params("id");
- $form->is_use = post_params("is_use");
- $res = $form->unbind();
- return $this->asJson($res);
- }
- /**
- * @return \yii\web\Response
- * 微信支付进件
- */
- public function actionMchRegister(){
- $form = new WechatThirdForm();
- $form->mini_id = post_params("id")??get_params("id");
- $res = $form->mchRegister();
- return $this->asJson($res);
- }
- //绑定普通二维码
- public function actionBindQrcode(){
- $form = new NewSalesmanForm();
- $form->type = "weixin";
- $form->mini_id = post_params("id");
- $res = $form->bindPayQrcode();
- return $this->asJson($res);
- }
- //删除普通二维码
- public function actionDelBindQrcode(){
- $form = new WechatThirdForm();
- $form->mini_id = post_params("id");
- $res = $form->delQrcodeRules();
- return $this->asJson($res);
- }
- //获取小店指南
- public function actionShopHelp() {
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => [
- 'platform_wechat_fuwu_help_qrcode' => Option::get('platform_wechat_fuwu_help_qrcode', 0, 'saas', '')['value'],
- 'platform_wechat_fuwu_help_tel' => Option::get('platform_wechat_fuwu_help_tel', 0, 'saas', '')['value'],
- 'platform_wechat_fuwu_help_link' => Option::get('platform_wechat_fuwu_help_link', 0, 'saas', '')['value'],
- ],
- ]);
- }
- //添加小店
- public function actionAddShop() {
- $form = new VideoShopForm();
- $form->params = post_params("params");
- $form->store_id = get_store_id();
- $res = $form->addShop();
- return $this->asJson($res);
- }
- //删除小店
- public function actionDelShop() {
- $form = new VideoShopForm();
- $form->attributes = post_params();
- $form->store_id = get_store_id();
- $res = $form->delShop();
- return $this->asJson($res);
- }
- //邀请分享员
- public function actionInviteSharer() {
- $form = new VideoShopForm();
- $form->params = post_params("params");
- $base_ = new WechatMini();
- $form->miniProgram = $base_::getWechatConfig(get_store_id(), input_params('mini_id', (post_params("params")['mini_id'] ?: 0)), 1);
- $form->mini_id = $base_::$mini_id;
- $form->store_id = get_store_id();
- $res = $form->inviteSharer();
- return $this->asJson($res);
- }
- //修改分享员
- public function actionEditSharerInfo() {
- $form = new VideoShopForm();
- $form->params = post_params("params");
- $form->store_id = get_store_id();
- $res = $form->editSharerInfo();
- return $this->asJson($res);
- }
- //解绑小店分享员
- public function actionUnbindSharer() {
- $form = new VideoShopForm();
- $form->attributes = post_params();
- $form->miniProgram = (new WechatMini())::getWechatConfig(get_store_id(), input_params('mini_id', 0), 1);
- $form->store_id = get_store_id();
- $res = $form->unbindSharer();
- return $this->asJson($res);
- }
- // 获取小店分享员列表
- public function actionGetSharerList() {
- cache()->getOrSet('actionSyncVideoShopSharer_' . get_store_id(), function(){
- $res = $this->actionSyncVideoShopSharer();
- // debug_log(['actionGetSharerList', $res->data], __CLASS__ . '.log');
- return 1;
- });
- $form = new VideoShopForm();
- $form->attributes = get_params();
- $form->store_id = get_store_id();
- $res = $form->getSharerList();
- return $this->asJson($res);
- }
- // 获取同步小店产品
- public function actionSyncGoodsList() {
- $form = new VideoShopGoodsForm();
- $base_ = new WechatMini();
- $miniProgram = $base_::getWechatConfig(get_store_id(), get_mini_id(), 1);
- $form->miniProgram = $miniProgram;
- $form->store_id = get_store_id();
- $form->mini_id = $base_::$mini_id;
- $res = $form->syncGoodsList();
- return $this->asJson($res);
- }
- //获取小店同步产品列表
- public function actionShopGoodsList() {
- $form = new VideoShopGoodsForm();
- $form->attributes = get_params();
- $form->store_id = get_store_id();
- $res = $form->shopGoodsList(all_params());
- return $this->asJson($res);
- }
- public function actionShopProductListing() {
- $form = new VideoShopGoodsForm();
- $form->store_id = get_store_id();
- $res = $form->product_listing(input_params('product_id'), input_params('delisting'));
- return $this->asJson($res);
- }
- //修改小店产品分佣状态
- public function actionShopGoodsSetStatus() {
- $form = new VideoShopGoodsForm();
- $form->attributes = post_params();
- $form->store_id = get_store_id();
- $res = $form->setStatus();
- return $this->asJson($res);
- }
- //修改小店产品分佣
- public function actionShopGoodsSetRateParams() {
- $form = new VideoShopGoodsForm();
- $form->attributes = post_params();
- $form->store_id = get_store_id();
- $res = $form->setRateParams();
- return $this->asJson($res);
- }
- //获取分享员订单列表
- public function actionSharerOrderList() {
- $form = new VideoShopOrderForm();
- $form->attributes = get_params();
- $form->store_id = get_store_id();
- $res = $form->getSharerOrderList();
- return $this->asJson($res);
- }
- //同步分享员信息
- public function actionSyncVideoShopSharer() {
- $form = new VideoShopForm();
- $store_id = get_store_id();
- // 同步视频号小店
- queue_push(new SyncSharerListJob(['store_id' => $store_id, 'type' => 0]), 0, 1);
- return $this->asJson([
- 'code' => 0,
- 'msg' => '同步完成'
- ]);
- }
- //同步订单
- public function actionSyncVideoShopOrder() {
- $form = new VideoShopOrderForm();
- $store_id = get_store_id();
- queue_push(new SyncSharerListJob(['store_id' => $store_id, 'type' => 2]), 0, 1);
- return $this->asJson([
- 'code' => 0,
- 'msg' => '同步完成'
- ]);
- }
- public function actionSetWebviewDomain() {
- $form = new WechatThirdForm();
- $form->mini_id = input_params('mini_id');
- return $this->asJson($form->setWebviewDomain());
- }
- public function actionGetWebviewFile() {
- $form = new WechatThirdForm();
- $form->mini_id = get_params('mini_id');
- return $this->asJson($form->getWebviewFile());
- }
- //获取短链
- public function actionGetShortLink() {
- $form = new WechatThirdForm();
- $form->store_id = get_store_id();
- $path = post_params('path', '');
- $mini_id = post_params('mini_id', '');
- $is_platform = post_params('is_platform', '');
- $is_serve = post_params('is_serve', '');
- return $this->asJson($form->getShortLink($path, $mini_id, $is_platform, $is_serve));
- }
- }
|