Browse Source

Merge branch 'master' of e.coding.net:zdap/weixiu/weixiu_api into m--douyin

liugc 10 months ago
parent
commit
89311ade16

+ 108 - 0
app/adminapi/controller/coupon/UserCouponController.php

@@ -0,0 +1,108 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+
+namespace app\adminapi\controller\coupon;
+
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\coupon\UserCouponLists;
+use app\adminapi\logic\coupon\UserCouponLogic;
+use app\adminapi\validate\coupon\UserCouponValidate;
+
+
+/**
+ * UserCoupon控制器
+ * Class UserCouponController
+ * @package app\adminapi\controller
+ */
+class UserCouponController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/05/28 11:42
+     */
+    public function lists()
+    {
+        return $this->dataLists(new UserCouponLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/05/28 11:42
+     */
+    public function add()
+    {
+        $params = (new UserCouponValidate())->post()->goCheck('add');
+        $result = UserCouponLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(UserCouponLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/05/28 11:42
+     */
+    public function edit()
+    {
+        $params = (new UserCouponValidate())->post()->goCheck('edit');
+        $result = UserCouponLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(UserCouponLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/05/28 11:42
+     */
+    public function delete()
+    {
+        $params = (new UserCouponValidate())->post()->goCheck('delete');
+        UserCouponLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/05/28 11:42
+     */
+    public function detail()
+    {
+        $params = (new UserCouponValidate())->goCheck('detail');
+        $result = UserCouponLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 39 - 4
app/adminapi/controller/works/ServiceWorkController.php

@@ -162,9 +162,6 @@ class ServiceWorkController extends BaseAdminController
                     ]
                 ]);
             }
-
-            //判断是否是美团订单,如果是,则取消美团订单
-            ThirdOrderLogic::merchantcancelorder($params['id']);
             return $this->success('取消工单成功!', [], 1, 1);
         }
 
@@ -270,7 +267,45 @@ class ServiceWorkController extends BaseAdminController
         return $this->success('操作成功', [], 1, 1);
     }
 
+    /**
+     * 给用户发券
+     */
+    public function userAddVoucher()
+    {
+        $params = request()->post();
+        $result = ServiceWorkLogic::userAddVoucher($params);
+        if (false === $result) {
+            return $this->fail(ServiceWorkLogic::getError());
+        }
+        return $this->success('发券成功', [], 1, 1);
+    }
 
+    /**
+     * 给用户加单
+     */
+    public function userExtendOrder()
+    {
+        $params = request()->post();
+        $result = ServiceWorkLogic::userExtendOrder($params);
+        if (false === $result) {
+            return $this->fail(ServiceWorkLogic::getError());
+        }
+        return $this->success('加单成功', [], 1, 1);
+    }
 
-
+    /**
+     * 代用户上门
+     */
+    public function confirmDoor()
+    {
+        $params = request()->post(); // work_sn user_id=master_worker_id  user_info .worker_number .real_name
+        $params['user_id'] = $params['master_worker_id'];
+        $params['user_info']['worker_number'] = $this->adminId;
+        $params['user_info']['real_name'] = $this->adminInfo['name'];
+        $result = ServiceWorkLogic::confirmDoor($params);
+        if (false === $result) {
+            return $this->fail(ServiceWorkLogic::getError());
+        }
+        return $this->success('操作成功', [], 1, 1);
+    }
 }

+ 87 - 0
app/adminapi/lists/coupon/UserCouponLists.php

@@ -0,0 +1,87 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\lists\coupon;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\coupon\UserCoupon;
+use app\common\lists\ListsSearchInterface;
+use app\common\model\user\User;
+
+
+/**
+ * UserCoupon列表
+ * Class UserCouponLists
+ * @package app\adminapi\lists
+ */
+class UserCouponLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2025/05/28 11:42
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['user_id', 'coupon_id', 'coupon_target',  'voucher_status', 'voucher_count', 'amount', 'amount_require', 'begin_use', 'discount_ratio', 'event_name', 'expire_time', 'max_deductible_price', 'mold_type', 'server_category_name', 'property_activity_id'],
+            '%like%' => ['code','event_name'],
+        ];
+    }
+    public function queryWhere()
+    {
+        $where = [];
+        if (isset($this->params['mobile']) && !empty($this->params['mobile'])) {
+            $user_ids = User::where([['mobile|real_name', 'like','%' .$this->params['mobile'] . '%']])->column('id')??[0];
+            $where[] = ['user_id','in' ,$user_ids];
+        }
+        return $where;
+    }
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2025/05/28 11:42
+     */
+    public function lists(): array
+    {
+        return UserCoupon::with(['user'])->where($this->searchWhere)->where($this->queryWhere())
+            ->field(['*'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2025/05/28 11:42
+     */
+    public function count(): int
+    {
+        return UserCoupon::where($this->searchWhere)->where($this->queryWhere())->count();
+    }
+
+}

+ 6 - 1
app/adminapi/lists/works/ServiceWorkLists.php

@@ -21,6 +21,7 @@ use app\common\model\master_worker\MasterWorker;
 use app\common\model\property\PropertyOrder;
 use app\common\model\works\ServiceWork;
 use app\common\lists\ListsSearchInterface;
+use app\common\model\works\ServiceWorkCustomerLog;
 use think\db\Query;
 use think\facade\Log;
 
@@ -123,6 +124,10 @@ class ServiceWorkLists extends BaseAdminDataLists implements ListsSearchInterfac
             $where[] = ['master_worker_id', '=', $this->params['workid']];
             $where[] = ['work_status', 'NOT IN', [7,8,9]];
         }
+        if(isset($this->params['customer_type']) && !empty($this->params['customer_type'])){
+            $customer_ids = ServiceWorkCustomerLog::where('type',$this->params['customer_type'])->column('work_id')??[0];
+            $where[] = ['id','in' ,$customer_ids];
+        }
         if (isset($this->params['update_time']) && !empty($this->params['goods_category_id'])) {
             $goodsCategoryId = end($this->params['goods_category_id']);
             $goodsCategoryData = GoodsCategory::where(['status'=>1])->order(['pid' => 'asc','weigh' => 'desc', 'id' => 'desc'])
@@ -185,7 +190,7 @@ class ServiceWorkLists extends BaseAdminDataLists implements ListsSearchInterfac
                 $query->field('id,work_id,opera_log,create_time');
             },
             'serviceWorkCustomerLog' =>function(Query $query){
-                $query->field('id,work_id,content,create_time');
+                $query->field('id,work_id,content,create_time,type');
             },
             'rechargeOrder' =>function(Query $query){
                 $query->field('id,work_id,tenant_id,order_type,payment_type,pay_way,pay_status,pay_time,coupon_id,coupon_price,order_total,order_amount,paid_amount,refund_status');

+ 124 - 0
app/adminapi/logic/coupon/UserCouponLogic.php

@@ -0,0 +1,124 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\logic\coupon;
+
+
+use app\adminapi\logic\user\UserLogic;
+use app\common\model\coupon\UserCoupon;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * UserCoupon逻辑
+ * Class UserCouponLogic
+ * @package app\adminapi\logic
+ */
+class UserCouponLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2025/05/28 11:42
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            //注册用户
+            $userId = UserLogic::getUserIdByMobile($params['mobile']);
+            $codes = [$params['code']];
+            if($codes){
+                \app\api\logic\UserCouponLogic::grant($codes,$userId,1);
+            }
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2025/05/28 11:42
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            /*UserCoupon::where('id', $params['id'])->update([
+                'user_id' => $params['user_id'],
+                'coupon_id' => $params['coupon_id'],
+                'coupon_target' => $params['coupon_target'],
+                'code' => $params['code'],
+                'voucher_status' => $params['voucher_status'],
+                'voucher_count' => $params['voucher_count'],
+                'amount' => $params['amount'],
+                'amount_require' => $params['amount_require'],
+                'begin_use' => $params['begin_use'],
+                'discount_ratio' => $params['discount_ratio'],
+                'event_name' => $params['event_name'],
+                'expire_time' => $params['expire_time'],
+                'max_deductible_price' => $params['max_deductible_price'],
+                'mold_type' => $params['mold_type'],
+                'server_category_name' => $params['server_category_name'],
+                'property_activity_id' => $params['property_activity_id'],
+            ]);*/
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2025/05/28 11:42
+     */
+    public static function delete(array $params): bool
+    {
+        return UserCoupon::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2025/05/28 11:42
+     */
+    public static function detail($params): array
+    {
+        return UserCoupon::findOrEmpty($params['id'])->toArray();
+    }
+}

+ 65 - 20
app/adminapi/logic/works/ServiceWorkLogic.php

@@ -15,6 +15,8 @@
 namespace app\adminapi\logic\works;
 
 use app\adminapi\logic\user\UserLogic;
+use app\api\logic\ServiceOrderLogic;
+use app\api\logic\UserCouponLogic;
 use app\common\enum\ThirdTypeEnum;
 use app\common\enum\worker\WorkerAccountLogEnum;
 use app\common\logic\ThirdOrderLogic;
@@ -208,23 +210,6 @@ class ServiceWorkLogic extends BaseLogic
             $work->work_status = 4;//已上门
             $work->save();
 
-            //如果是美团订单,且上门时间小于预约时间,则修改预约时间
-            if($work->third_type==1 and $work->finally_door_time<$work->appointment_time){
-                $third_order = ThirdOrders::where('work_id',$work->id)->order('id desc')->findOrEmpty();
-                if(!$third_order->isEmpty()){
-                    ThirdOrderLogic::merchantmodify([
-                        'reserveOrderId'=>$third_order['orderId'],
-                        'reserveUserName'=>$work['real_name'],
-                        "reservePhone"=>$work['mobile'],
-                        "reserveAddress"=>$work['address'],
-                        "bookStartTime"=>$work->finally_door_time*1000,
-                        "bookEndTime"=>($work->finally_door_time+2*3600)*1000,
-                        'request_msg'=>$third_order['request_msg']
-                    ]);
-                }
-            }
-
-
             //添加变更日志
             $work_log = [
                 'work_id'=>$work->id,
@@ -842,14 +827,13 @@ class ServiceWorkLogic extends BaseLogic
 
             ServiceWork::where('id', $params['id'])->update([
                 'work_status' => 9,
-                'service_status' => 4,
-                'remark' => $params['remark']??''
+                'service_status' => 4
             ]);
 
             ServiceWorkLog::create([
                 'work_id' => $params['id'],
                 'master_worker_id' => $serviceWorkInfo['master_worker_id'],
-                'opera_log' => "工单:{$serviceWorkInfo['work_sn']}已取消"
+                'opera_log' => "工单:{$serviceWorkInfo['work_sn']}已取消".($params['remark']??'')
             ]);
 
             Db::commit();
@@ -1081,6 +1065,7 @@ class ServiceWorkLogic extends BaseLogic
             }
             ServiceWorkCustomerLog::create([
                 'work_id'=>$serviceWork->id,
+                'type'=>$params['type']??0,
                 'content'=>$params['content']??'',
                 'admin_id'=>$params['admin_id']??0,
                 'create_time'=>time(),
@@ -1286,4 +1271,64 @@ class ServiceWorkLogic extends BaseLogic
             return false;
         }
     }
+
+
+    /**
+     * 给用户发券
+     */
+    public static function userAddVoucher($params): bool
+    {
+        try {
+            $serviceWork = ServiceWork::where('id',$params['id'])->findOrEmpty();
+            if(!$serviceWork->isEmpty()){
+                $codes = [];
+                foreach ($params['coupon_data'] as $coupon_data) {
+                    $coupon_data['code'] && $codes[] = $coupon_data['code'];
+                }
+                if($codes){
+                    UserCouponLogic::grant($codes,$serviceWork->user_id,$serviceWork->id);
+                }
+            }
+            return true;
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+    /**
+     * 给用户加单
+     */
+    public static function userExtendOrder($params): bool
+    {
+        try {
+            $serviceWork = ServiceWork::where('id',$params['id'])->findOrEmpty();
+            if(!$serviceWork->isEmpty()){
+                //goods_id ['user_info']['mobile'] user_id coupon_id=0  worker=1 terminal=1 pay_way=2 address contact_people=real_name contact_number=mobile appointment_time lon lat property_activity_id=0
+                ServiceOrderLogic::submitOrder([
+                    'goods_id' => $serviceWork->goods_id,
+                    'user_info' => [
+                        'mobile' => $serviceWork->mobile
+                    ],
+                    'user_id' => $serviceWork->user_id,
+                    'coupon_id' => 0,
+                    'worker' => 1,
+                    'terminal' => 1,
+                    'pay_way' => 2,
+                    'appointment_time' => $serviceWork->appointment_time,
+                    'address' => $serviceWork->address,
+                    'contact_people' => $serviceWork->real_name,
+                    'contact_number' => $serviceWork->mobile,
+                    'lon' => $serviceWork->lon,
+                    'lat' => $serviceWork->lat,
+                    'property_activity_id' => 0
+                ]);
+            }
+            return true;
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
 }

+ 116 - 0
app/adminapi/validate/coupon/UserCouponValidate.php

@@ -0,0 +1,116 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\validate\coupon;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * UserCoupon验证器
+ * Class UserCouponValidate
+ * @package app\adminapi\validate
+ */
+class UserCouponValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'user_id' => 'require',
+        'coupon_id' => 'require',
+        'coupon_target' => 'require',
+        'code' => 'require',
+        'voucher_status' => 'require',
+        'amount_require' => 'require',
+        'begin_use' => 'require',
+        'event_name' => 'require',
+        'expire_time' => 'require',
+        'mold_type' => 'require',
+
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'user_id' => '用户ID',
+        'coupon_id' => '优惠卷Id',
+        'coupon_target' => '优惠券使用目标',
+        'code' => '优惠券编码',
+        'voucher_status' => '使用状态',
+        'amount_require' => '满减金额',
+        'begin_use' => '生效时间',
+        'event_name' => '优惠卷名称',
+        'expire_time' => '到期时间',
+        'mold_type' => '折扣方式:优惠卷折扣现金卷方式',
+
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return UserCouponValidate
+     * @author likeadmin
+     * @date 2025/05/28 11:42
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['mobile','code']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return UserCouponValidate
+     * @author likeadmin
+     * @date 2025/05/28 11:42
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return UserCouponValidate
+     * @author likeadmin
+     * @date 2025/05/28 11:42
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return UserCouponValidate
+     * @author likeadmin
+     * @date 2025/05/28 11:42
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 12 - 3
app/api/lists/GoodsCategoryLists.php

@@ -1,6 +1,7 @@
 <?php
 namespace app\api\lists;
 
+use app\api\logic\GoodsLogic;
 use app\common\model\goods_category\GoodsCategory;
 use app\common\lists\ListsSearchInterface;
 
@@ -26,7 +27,15 @@ class GoodsCategoryLists extends BaseApiDataLists implements ListsSearchInterfac
 
         ];
     }
-
+    public function queryWhere()
+    {
+        $where = [];
+        if (isset($this->params['platform_appid']) && !empty($this->params['platform_appid'])) {
+            $ids = GoodsLogic::getPlatformCategoryIds($this->params['platform_appid']);
+            $where[] = ['id','in' ,$ids];
+        }
+        return $where;
+    }
 
     /**
      * @notes 获取列表
@@ -39,7 +48,7 @@ class GoodsCategoryLists extends BaseApiDataLists implements ListsSearchInterfac
      */
     public function lists(): array
     {
-        $lists = GoodsCategory::where($this->searchWhere)->where('status',1)
+        $lists = GoodsCategory::where($this->searchWhere)->where($this->queryWhere())->where('status',1)
             ->field(['id', 'pid' ,'picture', 'name'])
             ->order(['weigh' => 'desc'])
             ->select()
@@ -57,7 +66,7 @@ class GoodsCategoryLists extends BaseApiDataLists implements ListsSearchInterfac
      */
     public function count(): int
     {
-        return GoodsCategory::where($this->searchWhere)->count();
+        return GoodsCategory::where($this->searchWhere)->where($this->queryWhere())->count();
     }
 
 }

+ 17 - 1
app/api/logic/GoodsLogic.php

@@ -221,7 +221,23 @@ class GoodsLogic extends BaseLogic
         return ExternalPlatformGoods::where('external_platform_id',$platform_value)->where('goods_id',$goods_id)->value('service_fee');
     }
 
-
+    public static function getPlatformCategoryIds($platform_appid){
+        try{
+            $platform_value = ExternalPlatform::where('appid',$platform_appid)->value('id');
+            $goods_categorys= Goods::where('platform_value',$platform_value)
+                ->field('goods_category_ids')
+                ->group('goods_category_ids')
+                ->select()->toArray();
+            $res = [];
+            foreach ($goods_categorys as $goods_category) {
+                $res = array_unique(array_merge($res, $goods_category['goods_category_ids']));
+            }
+            return $res;
+        }catch(\Exception $e){
+            self::setError($e->getMessage());
+            return [0];
+        }
+    }
 
 
 }

+ 34 - 0
app/api/logic/UserCouponLogic.php

@@ -81,6 +81,7 @@ class UserCouponLogic extends BaseLogic
                 (new UserCoupon())->saveAll($createData);
             }
             Db::commit();
+            $errMsgArr && self::setError(implode(',',$errMsgArr));
             return $errMsgArr;
         }catch(\Exception $e){
             Db::rollback();
@@ -242,4 +243,37 @@ class UserCouponLogic extends BaseLogic
             return false;
         }
     }
+
+    public static function grant($codes = [],$user_id = 0,$order_id = 0)
+    {
+        try{
+            if($codes){
+                $userCouponLogic = UserCouponLogic::add(['codes'=>$codes,'user_id'=>$user_id]);
+                if($userCouponLogic === false) throw new \Exception(UserCouponLogic::getError());
+                if(empty(UserCouponLogic::getError())){
+                    // 通知用户公众号 跳转优惠券
+                    event('Notice',  [
+                        'scene_id' => 129,
+                        'params' => [
+                            'user_id' => $user_id??0,
+                            'order_id' => $order_id??0,
+                        ]
+                    ]);
+                }
+            }
+            return true;
+        }catch(\Exception $e){
+            throw new \Exception($e->getMessage());
+        }
+    }
+
+
+
+
+
+
+
+
+
+
 }

+ 3 - 0
app/common/logic/NoticeLogic.php

@@ -186,6 +186,9 @@ class NoticeLogic extends BaseLogic
             case 124: //返修工程师预约上门通知
                 $page = "/subPages/return_work_detail/return_work_detail?id={$extraId}";
                 break;
+            case 129: //用户券页面
+                $page = "/pages/center/discounts?type=0";
+                break;
         }
 
         // 公众号主页路径

+ 5 - 0
app/common/model/coupon/UserCoupon.php

@@ -3,6 +3,7 @@
 namespace app\common\model\coupon;
 use app\common\model\BaseModel;
 use app\common\model\dict\DictData;
+use app\common\model\user\User;
 use think\facade\Cache;
 
 /**
@@ -15,6 +16,10 @@ class UserCoupon extends BaseModel
 
     protected $name = 'user_coupon';
 
+    public function user()
+    {
+        return $this->hasOne(User::class, 'id', 'user_id');
+    }
     public function couponCategory()
     {
         return $this->hasMany(CouponCategory::class, 'coupon_id', 'goods_category_id');

+ 1 - 1
app/workerapi/logic/LoginLogic.php

@@ -147,7 +147,7 @@ class LoginLogic extends BaseLogic
                 if(!$worker_register->isEmpty() && $worker_register->status==0){
                     throw new \Exception('您的入驻信息正在审核中,客服将在1-2个工作日内联系您进行入驻操作');
                 }
-                throw new \Exception('请点击下方的工程师入驻');
+                throw new \Exception($params['terminal'] == 5?'工程师不存在':'请点击下方的工程师入驻');
             }
 
             //更新登录信息