Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/master'

林海涛 1 gadu atpakaļ
vecāks
revīzija
e2b785536d

+ 1 - 1
app/adminapi/logic/works/ServiceWorkLogic.php

@@ -171,7 +171,7 @@ class ServiceWorkLogic extends BaseLogic
                 throw new Exception('订单错误');
             }
 
-            if($work->work_status != 3 || $work->user_confirm_status !=1 ){
+            if($work->work_status != 4){
                 throw new Exception('请勿重复操作');
             }
 

+ 2 - 3
app/api/lists/recharge/ServiceOrderLists.php

@@ -38,7 +38,6 @@ class ServiceOrderLists extends BaseApiDataLists
      */
     public function lists(): array
     {
-
         $where = [];
         $service_status = $this->params['service_status'];
         $work_ids = ServiceWork::where(['user_id' => $this->userId])->where(function ($query) use($service_status) {
@@ -54,11 +53,11 @@ class ServiceOrderLists extends BaseApiDataLists
         $lists = RechargeOrder::with(['order_goods'=>function ($query) {
             $query->visible(['goods_name','goods_image','goods_number','good_unit']);
         },'service_work'=>function ($query) {
-            $query->visible(['service_status','work_status','user_confirm_status'])->append(['service_status_text','work_status_text','user_confirm_status_text','user_service_status','user_service_status_text']);
+            $query->visible(['service_status','work_status','user_confirm_status','appointment_time'])->append(['service_status_text','work_status_text','user_confirm_status_text','user_service_status','user_service_status_text']);
         }])
             ->where($where)
             ->whereIn('work_id',$work_ids)
-            ->visible(['id','sn','order_total','order_amount','pay_status','create_time'])
+            ->visible(['id','sn','payment_type','order_total','order_amount','pay_status','create_time'])
             ->where([
                 'order_type' => 0,
                 'user_id' => $this->userId,

+ 1 - 1
app/api/logic/GoodsReviewsLogic.php

@@ -25,7 +25,7 @@ class GoodsReviewsLogic extends BaseLogic
     {
         Db::startTrans();
         try {
-            $order = RechargeOrder::findOrEmpty($params['order_id'])->toArray();
+            $order = RechargeOrder::where('sn',$params['sn'])->findOrEmpty()->toArray();
             $goods_id = OrderGoods::whereIn('sn', RechargeOrder::where('work_id',$order['work_id'])->column('sn'))->value('goods_id');
             $work = ServiceWork::findOrEmpty($order['work_id'])->toArray();
             if($work['work_status']==8){

+ 5 - 3
app/api/logic/ServiceOrderLogic.php

@@ -136,9 +136,9 @@ class ServiceOrderLogic extends BaseLogic
             $order_info =  \app\common\model\recharge\RechargeOrder::with(['order_goods'=>function ($query) {
                 $query->visible(['goods_name','goods_image','goods_number','good_unit']);
             },'service_work'=>function ($query) {
-                $query->visible(['real_name','mobile','address','service_status','appointment_time','master_worker_id'])->append(['service_status_text','user_service_status','user_service_status_text']);
+                $query->visible(['real_name','mobile','address','service_status','appointment_time','master_worker_id','work_images','finished_images','finished_time'])->append(['service_status_text','user_service_status','user_service_status_text']);
             }])
-                ->visible(['id','sn','order_total','order_amount','pay_status','create_time','title','work_id'])
+                ->visible(['id','sn','payment_type','order_total','order_amount','pay_status','create_time','title','work_id'])
                 ->where([
                     'order_type' => 0,
                     'user_id' => $params['user_id'],
@@ -244,7 +244,7 @@ class ServiceOrderLogic extends BaseLogic
 
             //更新工单状态为已取消
             $service_work = ServiceWork::find($work_id);
-            if($service_work->user_confirm_status==1){
+            if($service_work->user_confirm_status==2){
                 throw new Exception('请勿重复操作');
             }
             $service_work->work_status = 5;
@@ -296,6 +296,8 @@ class ServiceOrderLogic extends BaseLogic
             if(count($orders)==1 and $orders[0]['payment_type']==0 and $orders[0]['pay_status']==1){
                 $service_work->work_status = 7;
                 $service_work->user_confirm_status = 5;
+                $service_work->service_status = 3;
+                $service_work->work_pay_status = 1;
                 $service_work->work_total = $orders[0]['order_total'];
                 $service_work->work_amount = $orders[0]['order_amount'];
             }else{

+ 3 - 3
app/api/validate/GoodsReviewsValidate.php

@@ -18,7 +18,7 @@ class GoodsReviewsValidate extends BaseValidate
       * @var string[]
       */
     protected $rule = [
-        'order_id' => 'require',
+        'sn' => 'require',
         'rating' => 'require',
         'comment'=>'require',
     ];
@@ -29,7 +29,7 @@ class GoodsReviewsValidate extends BaseValidate
      * @var string[]
      */
     protected $field = [
-        'order_id' => '参数错误',
+        'sn' => '参数错误',
         'rating' => '星级',
         'comment' => '评论内容',
     ];
@@ -40,6 +40,6 @@ class GoodsReviewsValidate extends BaseValidate
      */
     public function sceneAdd()
     {
-        return $this->only(['order_id','rating','comment']);
+        return $this->only(['sn','rating','comment']);
     }
 }

+ 16 - 2
app/common/logic/PayNotifyLogic.php

@@ -99,9 +99,23 @@ class PayNotifyLogic extends BaseLogic
         $order->save();
 
         $work = ServiceWork::findOrEmpty($order->work_id);
+
         $work->work_pay_status = WorkEnum::IS_PAY_STATUS;
-        $work->work_total = $order->order_amount;
-        $work->work_amount = $order->order_amount;
+
+        $orders = \app\common\model\orders\RechargeOrder::where(['work_id'=>$order->work_id])->select()->toArray();
+        $order_total = 0;
+        $order_amount = 0;
+        foreach ($orders as $k=>$v){
+            $order_total += $v['order_total'];
+            $order_amount += $v['order_amount'];
+        }
+        $work->work_total = $order_total;
+        $work->work_amount = $order_amount;
+        $work->work_status = 7;
+        $work->user_confirm_status = 5;
+        $work->service_status = 3;
+        $work->work_pay_status = 1;
+        $work->finished_time = time();
         $work->save();
     }
 

+ 7 - 0
app/common/logic/PaymentLogic.php

@@ -145,6 +145,13 @@ class PaymentLogic extends BaseLogic
             if ($order->isEmpty()) {
                 throw new \Exception('订单不存在');
             }
+
+            //判断订单类型.服务订单尾款处理
+            if($order['order_type'] == 0 and $order['pay_status'] == PayEnum::ISPAID)//服务工单
+            {
+                $order = RechargeOrder::where(['work_id'=>$order['work_id'],'pay_status'=>0])->findOrEmpty();
+            }
+
             if ($order['pay_status'] == PayEnum::ISPAID) {
                 throw new \Exception('订单已支付');
             }

+ 14 - 10
app/common/model/works/ServiceWork.php

@@ -74,12 +74,9 @@ class ServiceWork extends BaseModel
         return $status[$data['user_confirm_status']];
     }
 
-    public function getUserServiceStatusAttr($value,$work)
+    public function getUserServiceStatusAttr($value,$work): int
     {
         $user_status = 0;
-        if($work['work_pay_status']==0){
-            return '待付款';
-        }
         //用户订单状态
         if($work['work_status']>=2 && $work['work_status']<4){
             $user_status = 1;//待上门,显示上门二维码
@@ -102,7 +99,7 @@ class ServiceWork extends BaseModel
         if($work['work_status']==7 && $work['user_confirm_status'] == 5){
             $user_status = 7;//待评价
         }
-        if($work['work_status']==7 && $work['user_confirm_status'] == 5){
+        if($work['work_status']==8 && $work['user_confirm_status'] == 5){
             $user_status = 8;//已评价
         }
         return $user_status;
@@ -110,9 +107,6 @@ class ServiceWork extends BaseModel
 
     public function getUserServiceStatusTextAttr($value,$work)
     {
-        if($work['work_pay_status']==0){
-            return '待付款';
-        }
         $user_status = '待联系';
         //用户订单状态
         if($work['work_status']>=2 && $work['work_status']<4){
@@ -136,7 +130,7 @@ class ServiceWork extends BaseModel
         if($work['work_status']==7 && $work['user_confirm_status'] == 5){
             $user_status = '待评价';//待评价
         }
-        if($work['work_status']==7 && $work['user_confirm_status'] == 5){
+        if($work['work_status']==8 && $work['user_confirm_status'] == 5){
             $user_status = '已评价';//已评价
         }
         return $user_status;
@@ -160,5 +154,15 @@ class ServiceWork extends BaseModel
     {
         return !empty($data['receive_time'])?date('Y-m-d H:i:s',$data['receive_time']):'';
     }
-    
+
+    public function getWorkImagesAttr($value)
+    {
+        return !empty($value)?json_decode($value,true):'';
+    }
+
+    public function getFinishedImagesAttr($value)
+    {
+        return !empty($value)?json_decode($value,true):'';
+    }
+
 }

+ 1 - 1
app/common/service/pay/WeChatPayService.php

@@ -318,7 +318,7 @@ class WeChatPayService extends BasePayService
     public function payDesc($from)
     {
         $desc = [
-            'order' => '商品',
+            'goods' => '商品',
             'recharge' => '充值',
         ];
         return $desc[$from] ?? '商品';

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

@@ -56,7 +56,7 @@ class MasterWorkerLogic extends  BaseLogic
             if (!$existUser->isEmpty()) {
                 throw new \Exception('该手机号已被使用');
             }
-            $user->password = $params['mobile'];
+            $user->mobile= $params['mobile'];
             $user->save();
             return true;
         } catch (\Exception $e) {