From 860555eabcb351206750814ca077235e3235153c Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Mon, 5 Feb 2024 17:36:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=E9=85=92=E6=B0=B4?= =?UTF-8?q?=E5=8D=A1=E9=A2=9D=E5=BA=A6=E5=85=91=E6=8D=A2=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/model/user/User.php | 23 ++++++++++++++++ .../store/service/StoreServiceRepository.php | 26 +++++++++++-------- app/controller/api/Auth.php | 2 +- app/controller/api/store/merchant/Service.php | 7 +++-- app/controller/api/user/Exchange.php | 8 +++--- app/controller/merchant/Common.php | 7 +++++ .../merchant/store/service/StoreService.php | 5 +++- 7 files changed, 60 insertions(+), 18 deletions(-) diff --git a/app/common/model/user/User.php b/app/common/model/user/User.php index 35a38ab..36bae49 100644 --- a/app/common/model/user/User.php +++ b/app/common/model/user/User.php @@ -204,6 +204,7 @@ class User extends BaseModel ->hasWhere('merchant',function($query){ $query->where('is_del', 0) ->where('mer_state', 1) + ->where('merchant_type', 0) ->where('status', 1); }) ->where('uid',$this->uid) @@ -217,7 +218,26 @@ class User extends BaseModel return !empty($info) ? $info->toArray() : null; } + // 用户是否存在酒道馆 有效店员信息 + public function getShopMerServiceAttr($value){ + $info = (new StoreService()) + ->field('service_id,uid,nickname,avatar,customer,StoreService.mer_id,is_verify,is_goods,is_open') + ->hasWhere('merchant',function($query){ + $query->where('is_del', 0) + ->where('mer_state', 1) + ->where('merchant_type', 1) + ->where('status', 1); + }) + ->where('uid',$this->uid) + ->where('StoreService.mer_id','<>',0) + ->where('StoreService.is_del',0) + ->where('is_open',1) + ->order('StoreService.is_verify DESC,StoreService.customer DESC') + // ->fetchSql() + ->find(); + return !empty($info) ? $info->toArray() : null; + } public function topService() { @@ -229,6 +249,9 @@ class User extends BaseModel ->order('is_verify DESC,customer DESC'); } + + + public function getLockBrokerageAttr() { return app()->make(UserBillRepository::class)->lockBrokerage($this->uid) ?: 0; diff --git a/app/common/repositories/store/service/StoreServiceRepository.php b/app/common/repositories/store/service/StoreServiceRepository.php index 7c8dc49..ca827b0 100644 --- a/app/common/repositories/store/service/StoreServiceRepository.php +++ b/app/common/repositories/store/service/StoreServiceRepository.php @@ -85,10 +85,12 @@ class StoreServiceRepository extends BaseRepository Elm::switches('status', '客服状态', 1)->activeValue(1)->inactiveValue(0)->inactiveText('关')->activeText('开')->col(8), Elm::switches('customer', '订单管理', 1)->activeValue(1)->inactiveValue(0)->inactiveText('关')->activeText('开')->col(8), Elm::switches('is_goods', '商品管理', 1)->activeValue(1)->inactiveValue(0)->inactiveText('关')->activeText('开')->col(8), - Elm::switches('is_verify', '开启核销', 1)->activeValue(1)->inactiveValue(0)->inactiveText('关')->activeText('开')->col(8), + Elm::switches('is_verify', '核销权限', 1)->activeValue(1)->inactiveValue(0)->inactiveText('关')->activeText('开')->col(8), Elm::switches('is_user', '客户管理', 1)->activeValue(1)->inactiveValue(0)->inactiveText('关')->activeText('开')->col(8), - Elm::switches('staff_manage', '员工管理', 1)->activeValue(1)->inactiveValue(0)->inactiveText('关')->activeText('开')->col(8), - Elm::switches('qr_code_show', '推广二维码', 1)->activeValue(1)->inactiveValue(0)->inactiveText('关')->activeText('开')->col(8), + Elm::switches('staff_manage', '品牌管理', 1)->activeValue(1)->inactiveValue(0)->inactiveText('关')->activeText('开')->col(8), + Elm::switches('qr_code_show', '推广码', 1)->activeValue(1)->inactiveValue(0)->inactiveText('关')->activeText('开')->col(8), + Elm::switches('online_payment', '买单码', 1)->activeValue(1)->inactiveValue(0)->inactiveText('关')->activeText('开')->col(8), + Elm::switches('product_exchange', '商品兑换码', 1)->activeValue(1)->inactiveValue(0)->inactiveText('关')->activeText('开')->col(8), Elm::switches('notify', '订单通知', 1)->activeValue(1)->inactiveValue(0)->inactiveText('关')->activeText('开')->col(8)->control([ [ 'value' => 1, @@ -96,22 +98,24 @@ class StoreServiceRepository extends BaseRepository Elm::input('phone', '通知电话') ] ] - ]) - ]; + ]), + ]; $filed = [ "value" => 1, "rule" => [ - "status","customer","is_goods","is_verify","notify",'phone',"is_user","staff_manage",'qr_code_show' + "status","customer","is_goods","is_verify","notify",'phone',"is_user","staff_manage",'qr_code_show','online_payment','product_exchange' ] ]; }else if($merchantType == 1){ $adminRule = [ Elm::switches('is_verify', '核销权限', 1)->activeValue(1)->inactiveValue(0)->inactiveText('关')->activeText('开')->col(8), + Elm::switches('product_exchange', '商品兑换码', 1)->activeValue(1)->inactiveValue(0)->inactiveText('关')->activeText('开')->col(8), + Elm::switches('purchase_permission', '进货权限', 1)->activeValue(1)->inactiveValue(0)->inactiveText('关')->activeText('开')->col(8), ]; $filed = [ "value" => 1, "rule" => [ - "is_verify" + "is_verify",'product_exchange','purchase_permission' ] ]; }else if($merchantType == 2){ @@ -182,8 +186,8 @@ class StoreServiceRepository extends BaseRepository public function getServices($uid, array $where = [],$is_sys = 1){ $where['uid'] = $uid; $list = $this->dao->getSearch([]) - ->hasWhere('merchant',function($query){ - $query->where('is_del', 0)->where('merchant_type', 0); + ->hasWhere('merchant',function($query) use ($is_sys){ + $query->where('is_del', 0)->where('merchant_type', $is_sys == 2 ? 1 : 0); }) ->where('StoreService.is_del',0) ->where('StoreService.mer_id',$is_sys == 1 ? '=' : '>',0) @@ -204,7 +208,7 @@ class StoreServiceRepository extends BaseRepository }) ->with([ 'merchant' => function($query){ - $query->field('mer_id,mer_avatar,mer_name'); + $query->field('mer_id,mer_avatar,mer_name,merchant_type'); } ]) ->order('StoreService.mer_id DESC') @@ -309,7 +313,7 @@ class StoreServiceRepository extends BaseRepository public function isService(int $uid,int $id = 0,int $merId = 0):bool{ $count = $this->dao->getSearch([]) ->hasWhere('merchant',function($query){ - $query->where('is_del', 0); + $query->where('is_del', 0)->where('merchant_type', 0); }) ->where('StoreService.uid',$uid) ->where('StoreService.is_del', 0) diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index 7d61be6..4824e63 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -139,7 +139,7 @@ class Auth extends BaseController public function userInfo() { $user = $this->request->userInfo()->hidden(['label_id', 'group_id', 'pwd', 'addres', 'card_id', 'last_time', 'last_ip', 'create_time', 'mark', 'status', 'spread_uid', 'spread_time', 'real_name', 'birthday', 'brokerage_price']); - $user->append(['service', 'topService', 'total_collect_product', 'total_collect_store', 'total_coupon', 'total_visit_product', 'total_unread', 'total_recharge', 'lock_integral', 'total_integral']); + $user->append(['service', 'topService','shopMerService', 'total_collect_product', 'total_collect_store', 'total_coupon', 'total_visit_product', 'total_unread', 'total_recharge', 'lock_integral', 'total_integral']); $data = $user->toArray(); $data['total_consume'] = $user['pay_price']; $data['extension_status'] = systemConfig('extension_status'); diff --git a/app/controller/api/store/merchant/Service.php b/app/controller/api/store/merchant/Service.php index 5063999..d20d6c2 100644 --- a/app/controller/api/store/merchant/Service.php +++ b/app/controller/api/store/merchant/Service.php @@ -113,7 +113,10 @@ class Service extends BaseController{ 'avatar', 'phone', ['sort',0], - 'qr_code_show' + 'qr_code_show', + 'online_payment', + 'product_exchange', + 'purchase_permission' ]); if(is_array(json_decode($data['uid'], true))) $data['uid'] = json_decode($data['uid'], true); // 是否编辑 @@ -143,7 +146,7 @@ class Service extends BaseController{ $query->field('avatar,uid'); }, 'merchant' => function($query){ - $query->field('mer_id,mer_name,mer_avatar')->bind(['mer_name','mer_avatar']); + $query->field('mer_id,mer_name,mer_avatar,merchant_type')->bind(['mer_name','mer_avatar','merchant_type']); } ])->toArray(); if($service['user'] ?? null){ diff --git a/app/controller/api/user/Exchange.php b/app/controller/api/user/Exchange.php index 4d7c908..c4be946 100644 --- a/app/controller/api/user/Exchange.php +++ b/app/controller/api/user/Exchange.php @@ -190,7 +190,7 @@ class Exchange extends BaseController{ ->findOrEmpty() ->toArray(); // 判断:是否存在指定消费者,不存在则使用当前登录用户 - if ($service['uid'] == $uid) return app('json')->fail('操作员和消费用户不能是同一人!'); + // if ($service['uid'] == $uid) return app('json')->fail('操作员和消费用户不能是同一人!'); // 支付信息 $payInfo = $this->request->params(['pay_type', 'return_url']); $payInfo['money'] = (float)$data['diff_money_pay']; @@ -198,7 +198,9 @@ class Exchange extends BaseController{ // 添加兑换记录 try{ return Db::transaction(function () use ($data, $uid, $payInfo, $orderCreateRepository, $service) { - // 添加兑换记录 + // 商户类别:0=普通商户,1=酒道馆,2=供应商 + $merchantType = (int)app()->make(MerchantRepository::class)->getSearch(['mer_id'=>$service['mer_id']])->value('merchant_type'); + // 添加兑换记录 额度类型:1=酒卡额度,2=菜卡额度 $pickupRecordId = ExchangePickupRecord::insertGetId([ 'uid' => $uid, 'point_id' => $service['mer_id'], @@ -207,7 +209,7 @@ class Exchange extends BaseController{ 'use_integral' => $data['use_integral'], 'diff_money' => $data['diff_money'], 'diff_money_pay' => $data['diff_money_pay'], - 'quota_type' => $data['quota_type'] + 'quota_type' => $merchantType == 1 ? 1 : 2,// 酒道馆核销酒卡额度,普通商户核销菜卡额度 ]); // 判断:如果【差价应支付金额】大于0 生成支付订单 if((float)$payInfo['money'] > 0){ diff --git a/app/controller/merchant/Common.php b/app/controller/merchant/Common.php index 2776d81..e4b9493 100644 --- a/app/controller/merchant/Common.php +++ b/app/controller/merchant/Common.php @@ -6,6 +6,7 @@ namespace app\controller\merchant; +use app\common\repositories\system\merchant\MerchantRepository; use app\common\repositories\user\UserRepository; use crmeb\basic\BaseController; use app\common\repositories\store\order\StoreOrderProductRepository; @@ -269,6 +270,12 @@ class Common extends BaseController { $data = systemConfig(['tx_map_key','delivery_status','delivery_type','rmargin_emind_switch']); $data['mer_id'] = $this->request->merId(); + $data['merchant_type'] = 0; + // 判断:存在merid 判断商户类型 + if((int)$data['mer_id'] > 0){ + $data['merchant_type'] = (int)app()->make(MerchantRepository::class)->getSearch(['mer_id'=>$data['mer_id']])->value('merchant_type'); + } + return app('json')->success($data); } } diff --git a/app/controller/merchant/store/service/StoreService.php b/app/controller/merchant/store/service/StoreService.php index a2cc14c..3e6e20b 100644 --- a/app/controller/merchant/store/service/StoreService.php +++ b/app/controller/merchant/store/service/StoreService.php @@ -108,7 +108,10 @@ class StoreService extends BaseController 'avatar', 'phone', ['sort',0], - 'qr_code_show' + 'qr_code_show', + 'online_payment', + 'product_exchange', + 'purchase_permission' ]); if ($isUpdate) { $validate->update();