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' => '更新成功' ]); } }