| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\admin\controllers;
- use app\constants\OptionSetting;
- use app\jobs\StoreSyncJob;
- use app\models\Admin;
- use app\models\BonusPoolLevel;
- use app\models\Cash;
- use app\models\Form;
- use app\models\IntegralSetting;
- use app\models\MchBrands;
- use app\models\MchStaff;
- use app\models\OldUserTreePath;
- use app\models\Option;
- use app\models\Order;
- use app\models\OrderRefund;
- use app\models\SaaSLeaguePriceLog;
- use app\models\ShareDetail;
- use app\models\ShareHolder;
- use app\models\ShareHolderFrostLog;
- use app\models\ShareHolderLevelLog;
- use app\models\ShareHolderOutLog;
- use app\models\ShareHolderParentOutLog;
- use app\models\Store;
- use app\models\StoreTemplate;
- use app\models\SaasCategory;
- use app\models\StoreCopy;
- use app\models\User;
- use app\models\UserTreePath;
- use app\modules\admin\models\MchBrandsForm;
- use app\modules\admin\models\MerchantForm;
- use app\modules\admin\models\SubmitFormForm;
- use app\modules\client\models\v1\LoginForm;
- use app\utils\Delivery\Delivery;
- use Yii;
- use app\modules\admin\models\StoreForm;
- use app\modules\admin\models\SaasCategoryForm;
- use yii\base\BaseObject;
- use app\models\SaasUser;
- use app\models\Salesman;
- use yii\helpers\Json;
- use app\utils\IotCloudHelper;
- use app\constants\Kefu;
- use app\models\Supplier;
- use app\models\Mch;
- use app\modules\admin\models\MchForm;
- use app\models\MchGoodsCat;
- class MchController extends BaseController
- {
- public function actionTest()
- {
- $a = MchForm::accountMoneyAdd(Order::findOne(13303));
- var_dump($a);
- die;
- $form = new MchForm();
- $id = input_params('id');
- $status = input_params('status');
- $result = $form->goodsCatStatus($id, $status);
- return $this->asJson($result);
- }
- /**
- * 商户设置
- */
- public function actionSetting()
- {
- $store_id = get_store_id();
- $form = new MchForm();
- $form->attributes = all_params();
- $form->store_id = $store_id;
- $result = $form->mchSetting();
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'ok',
- 'data' => $result,
- ]);
- }
- /**
- * 商户设置
- */
- public function actionSettingSave()
- {
- $store_id = get_store_id();
- $form = new MchForm();
- $form->store_id = $store_id;
- $conf = input_params('conf', []);
- $result = $form->mchSettingSave($conf);
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'ok',
- ]);
- }
- /**
- * 商户
- */
- public function actionInfo()
- {
- $form = new MchForm();
- $form->mch_id = input_params('id', get_mch_id());
- $result = $form->mchInfo();
- return $this->asJson($result);
- }
- /**
- * 商户列表
- */
- public function actionList()
- {
- $store_id = get_store_id();
- $form = new MchForm();
- $form->attributes = all_params();
- $form->store_id = $store_id;
- $result = $form->mchList();
- return $this->asJson($result);
- }
- /**
- * 商户列表
- */
- public function actionSelectList()
- {
- $store_id = get_store_id();
- $form = new MchForm();
- $form->attributes = all_params();
- $form->store_id = $store_id;
- $result = $form->mchSelectList();
- return $this->asJson($result);
- }
- /**
- * 商户
- */
- public function actionSave()
- {
- $store_id = get_store_id();
- checkReplay([$store_id], 10);
- $form = new MchForm();
- $form->attributes = all_params();
- $form->store_id = $store_id;
- $result = $form->mchSave();
- return $this->asJson($result);
- }
- /**
- * 商户首页
- */
- public function actionHomeSave()
- {
- $form = new MchForm();
- $form->id = get_mch_id();
- $form->home_type = input_params('home_type');
- $result = $form->mchHomeSave();
- return $this->asJson($result);
- }
- /**
- * 修改商户营业状态
- */
- public function actionOpen()
- {
- $store_id = get_store_id();
- $form = new MchForm();
- $form->attributes = all_params();
- $form->store_id = $store_id;
- $result = $form->mchOpen();
- return $this->asJson($result);
- }
- /**
- * 商户删除
- */
- public function actionDel()
- {
- $store_id = get_store_id();
- $form = new MchForm();
- $form->attributes = all_params();
- $form->store_id = $store_id;
- $result = $form->mchDel();
- return $this->asJson($result);
- }
- /**
- * 商户申请列表
- */
- public function actionAuditList()
- {
- $store_id = get_store_id();
- $form = new MchForm();
- $form->attributes = all_params();
- $form->store_id = $store_id;
- $result = $form->mchAuditList();
- return $this->asJson($result);
- }
- /**
- * 商户审核
- */
- public function actionAuditStatus()
- {
- $store_id = get_store_id();
- $form = new MchForm();
- $form->attributes = all_params();
- $form->store_id = $store_id;
- $result = $form->mchAuditStatus();
- return $this->asJson($result);
- }
- /**
- * 商户申请删除
- */
- public function actionAuditDel()
- {
- $store_id = get_store_id();
- $form = new MchForm();
- $form->attributes = all_params();
- $form->store_id = $store_id;
- $result = $form->mchAuditDel();
- return $this->asJson($result);
- }
- /**
- * 商户分类列表
- */
- public function actionCommonCatList()
- {
- $store_id = get_store_id();
- $form = new MchForm();
- $form->attributes = all_params();
- $form->store_id = $store_id;
- $result = $form->mchCommonCatList();
- return $this->asJson($result);
- }
- /**
- * 商户分类列表
- */
- public function actionCommonCatSelectList()
- {
- $store_id = get_store_id();
- $form = new MchForm();
- $form->attributes = all_params();
- $form->store_id = $store_id;
- $result = $form->mchCommonCatSelectList(0);
- return $this->asJson($result);
- }
- /**
- * 商户分类
- */
- public function actionCommonCatSave()
- {
- $store_id = get_store_id();
- $form = new MchForm();
- $form->attributes = all_params();
- $form->store_id = $store_id;
- $result = $form->mchCommonCatSave();
- return $this->asJson($result);
- }
- /**
- * 商户分类展示
- */
- public function actionCommonCatShow()
- {
- $store_id = get_store_id();
- $form = new MchForm();
- $form->attributes = all_params();
- $form->store_id = $store_id;
- $result = $form->mchCommonCatShow();
- return $this->asJson($result);
- }
- /**
- * 商户分类删除
- */
- public function actionCommonCatDel()
- {
- $store_id = get_store_id();
- $form = new MchForm();
- $form->attributes = all_params();
- $form->store_id = $store_id;
- $result = $form->mchCommonCatDel();
- return $this->asJson($result);
- }
- /**
- * 商户商品审核
- */
- public function actionGoodsAudit()
- {
- $store_id = get_store_id();
- $form = new MchForm();
- $form->attributes = all_params();
- $form->store_id = $store_id;
- $result = $form->mchGoodsAudit();
- return $this->asJson($result);
- }
- /**
- * 获取分类列表
- */
- public function actionGoodsCatList()
- {
- $is_show = input_params('is_show', 1);
- $mch_id = get_mch_id();
- $form = new MchForm();
- $result = $form->goodsCatList($mch_id, $is_show);
- $is_add_goods = Option::get('is_add_goods', get_store_id(), 'store', 1)['value'];
- return $this->asJson([
- 'code' => 0,
- 'data' => [
- 'list' => $result,
- 'is_add_goods' => (int)$is_add_goods
- ]
- ]);
- }
- /**
- * 分类保存
- */
- public function actionGoodsCatSave()
- {
- $mch_id = get_mch_id();
- $form = new MchForm();
- $form->attributes = all_params();
- $form->mch_id = $mch_id;
- $result = $form->goodsCatSave();
- return $this->asJson($result);
- }
- /**
- * 分类 显示、隐藏、删除
- */
- public function actionGoodsCatStatus()
- {
- $form = new MchForm();
- $id = input_params('id');
- $status = input_params('status');
- $result = $form->goodsCatStatus($id, $status);
- return $this->asJson($result);
- }
- /**
- * 佣金
- */
- public function actionAccountLog()
- {
- $mch_id = get_mch_id();
- $form = new MchForm();
- $form->attributes = all_params();
- $form->mch_id = $mch_id;
- $result = $form->accountLog();
- return $this->asJson($result);
- }
- /**
- * 提现
- */
- public function actionMchCashSubmit()
- {
- $price = input_params('cash');
- $type = input_params('type');
- $name = input_params('name', '');
- $account = input_params('account', '');
- $bank = input_params('bank', '');
- $mch_id = get_mch_id();
- $form = new MchForm();
- $form->attributes = all_params();
- $form->mch_id = $mch_id;
- $result = $form->mchCashSubmit($price, $type, get_user_id(), $name, $account, $bank);
- return $this->asJson($result);
- }
- /**
- * 设置客服
- */
- public function actionSetKefuInfo()
- {
- $mch_id = get_mch_id();
- $form = new MchForm();
- $form->attributes = all_params();
- $form->mch_id = $mch_id;
- $result = $form->setKefuInfo();
- return $this->asJson($result);
- }
- /**
- * 设置客服
- */
- public function actionGetKefuInfo()
- {
- $mch_id = get_mch_id();
- $form = new MchForm();
- $form->attributes = all_params();
- $form->mch_id = $mch_id;
- $result = $form->getKefuInfo();
- return $this->asJson($result);
- }
- /**
- * 入住商品牌列表
- * @author: hankaige
- * @Time: 2025/5/12 15:04
- */
- public function actionGetBrandsList()
- {
- $form = new MchBrandsForm();
- $form->attributes = get_params();
- $result = $form->getBrandList();
- return $this->asJson(['code' => 0, 'msg' => '请求成功', 'data' => $result]);
- }
- /**
- * 获取一个入住商品牌分类数据
- * @author: hankaige
- * @Time: 2025/5/12 15:05
- */
- public function actionGetBrandsItem()
- {
- $form = new MchBrandsForm();
- $form->attributes = get_params();
- $result = $form->getBrandItem();
- return $this->asJson(['code' => 0, 'msg' => '请求成功', 'data' => $result]);
- }
- /**
- * 编辑一个入住商品牌分类
- * @author: hankaige
- * @Time: 2025/5/12 15:06
- */
- public function actionBrandsSave()
- {
- $form = new MchBrandsForm();
- $form->attributes = post_params();
- $result = $form->brandsSave();
- return $this->asJson($result);
- }
- /**
- * 删除一个品牌分类
- * @author: hankaige
- * @Time: 2025/5/12 15:06
- */
- public function actionBrandsDel()
- {
- $form = new MchBrandsForm();
- $form->attributes = get_params();
- $result = $form->deleteBrand();
- return $this->asJson($result);
- }
- /**
- * 修改品牌分类状态
- * @return \yii\web\Response
- * @author: hankaige
- * @Time: 2025/5/13 11:11
- */
- public function actionChangeBrandsStatus()
- {
- $form = new MchBrandsForm();
- $form->attributes = get_params();
- $result = $form->changeBrandsStatus();
- return $this->asJson($result);
- }
- /**
- * 入住商编辑的时品牌分类选择列表数据 无分页
- * @return \yii\web\Response
- * @author: hankaige
- * @Time: 2025/5/14 09:16
- */
- public function actionGetBrandsSelectList()
- {
- $form = new MchBrandsForm();
- $result = $form->getBrandsSelectList();
- return $this->asJson(['code' => 0, 'msg' => '请求成功', 'data' => $result]);
- }
- public function actionStaffList()
- {
- $name = get_params('name');
- $mobile = get_params('mobile');
- $start_time = get_params('start_time');
- $end_time = get_params('end_time');
- $mch_id = get_mch_id();
- $store_id = get_store_id();
- $query = MchStaff::find()->alias('ms')->leftJoin(['mch' => Mch::tableName()], 'mch.id=ms.mch_id')->where(['ms.is_delete' => 0])->orderBy("ms.created_at desc, ms.updated_at desc");
- if ($mch_id !== null) {
- if ($mch_id <= 0) {
- $query->andWhere(['AND', ['ms.mch_id' => [0, -1]], ['IS', 'mch.id', NULL]]);
- } else {
- $query->andWhere(['ms.mch_id' => $mch_id, 'mch.is_delete' => 0]);
- }
- }
- if ($store_id > 0) {
- $query->andWhere(['ms.store_id' => $store_id]);
- }
- if ($name) {
- $query->andWhere(['like', 'ms.name', $name]);
- }
- if ($mobile) {
- $query->andWhere(['like', 'ms.mobile', $mobile]);
- }
- if ($start_time) {
- $query->andWhere(['>=', 'ms.created_at', strtotime($start_time)]);
- }
- if ($end_time) {
- $query->andWhere(['<=', 'ms.created_at', strtotime($end_time)]);
- }
- $list = pagination_make($query);
- foreach ($list['list'] as &$val) {
- $user = User::findOne($val['user_id']);
- $val['avatar'] = $user->avatar_url;
- $val['mch_name'] = Mch::findOne($val['mch_id'])->name;
- if ($val['mch_id'] <= 0) {
- $val['mch_name'] = Store::findOne($val['store_id'])->name;
- }
- $val['nickname'] = $user->nickname;
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- 'data' => [
- 'data' => $list['list'],
- 'pageNo' => $list['pageNo'],
- 'totalCount' => $list['totalCount']
- ]
- ]);
- }
- public function actionStaffAdd()
- {
- $store_id = get_store_id();
- $mch_id = get_mch_id();
- $name = post_params('name');
- $mobile = post_params('mobile');
- $user_id = post_params('user_id');
- if (empty($name) || empty($mobile) || empty($user_id)) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '参数有误'
- ]);
- }
- $user = User::findOne($user_id);
- if (!$user) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '用户不存在'
- ]);
- }
- $staff = MchStaff::findOne(['store_id' => $store_id, 'user_id' => $user->id, 'is_delete' => 0]);
- if ($staff) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '该员工已在其他商户下,请重新绑定'
- ]);
- }
- $md_staff = new MchStaff();
- $md_staff->store_id = $store_id;
- $md_staff->mch_id = $mch_id;
- $md_staff->user_id = $user->id;
- $md_staff->name = $name;
- $md_staff->mobile = $mobile;
- if (!$md_staff->save()) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => $md_staff->errors[0]
- ]);
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => '保存成功'
- ]);
- }
- /**
- * 更新状态
- * @return \yii\web\Response
- */
- public function actionStaffStatus()
- {
- $id = post_params('id');
- $type = post_params('type');
- $status = post_params('status');
- if (empty($id) || !is_array($id)) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '参数有误'
- ]);
- }
- if (!in_array($status, [0, 1])) {
- return $this->asJson([
- 'code' => 1,
- 'msg' => '状态参数有误'
- ]);
- }
- if ($type == 'is_disable') {
- MchStaff::updateAll(['is_disable' => $status], ['in', 'id', $id]);
- }
- if ($type == 'is_delete') {
- MchStaff::updateAll(['is_delete' => $status], ['in', 'id', $id]);
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => '更新成功'
- ]);
- }
- }
|