Răsfoiți Sursa

美团订单履约流程

fang 1 an în urmă
părinte
comite
d9ab8ee625

+ 2 - 1
app/adminapi/controller/third/ThirdGoodsController.php

@@ -143,12 +143,13 @@ class ThirdGoodsController extends BaseAdminController
                 if(in_array($items['dealGroupId'], $product_ids)){
                 if(in_array($items['dealGroupId'], $product_ids)){
                     unset($data[$key]);
                     unset($data[$key]);
                 }else{
                 }else{
-                    $good_data[] = [
+                     $good_data[] = [
                         'third_type' => 1,
                         'third_type' => 1,
                         'goods_id' => 0,
                         'goods_id' => 0,
                         'product_id' => $items['dealGroupId'],
                         'product_id' => $items['dealGroupId'],
                         'product_name' => $items['title'],
                         'product_name' => $items['title'],
                         'product_price' => $items['price'],
                         'product_price' => $items['price'],
+                        'app_sku_id' =>$items['dealId']
                     ];
                     ];
                 }
                 }
             }
             }

+ 7 - 0
app/adminapi/logic/works/ServiceWorkLogic.php

@@ -14,6 +14,7 @@
 
 
 namespace app\adminapi\logic\works;
 namespace app\adminapi\logic\works;
 
 
+use app\common\enum\ThirdTypeEnum;
 use app\common\logic\ThirdOrderLogic;
 use app\common\logic\ThirdOrderLogic;
 use app\common\model\third\ThirdOrders;
 use app\common\model\third\ThirdOrders;
 use think\Exception;
 use think\Exception;
@@ -393,6 +394,12 @@ class ServiceWorkLogic extends BaseLogic
             ];
             ];
             ServiceWorkerAllocateWorkerLogic::add($work_log);
             ServiceWorkerAllocateWorkerLogic::add($work_log);
             Db::commit();
             Db::commit();
+
+            //美团的订单更新履约状态为已分配
+            if($work->third_type == 1){
+                ThirdOrderLogic::updateorderfulfillinfo($work->id,ThirdTypeEnum::MEITUAN_MEITUAN);
+            }
+
             // 工程师派单通知【给工程师的通知】【公众号通知,不发短信】
             // 工程师派单通知【给工程师的通知】【公众号通知,不发短信】
             $workDetail = ServiceWorkLogic::detail($params);
             $workDetail = ServiceWorkLogic::detail($params);
             $res = event('Notice',  [
             $res = event('Notice',  [

+ 3 - 0
app/api/controller/notify/MeiTuanNotifyController.php

@@ -4,6 +4,7 @@ namespace app\api\controller\notify;
 
 
 use app\api\controller\BaseApiController;
 use app\api\controller\BaseApiController;
 use app\common\enum\PayEnum;
 use app\common\enum\PayEnum;
+use app\common\enum\ThirdTypeEnum;
 use app\common\enum\WorkEnum;
 use app\common\enum\WorkEnum;
 use app\common\logic\ThirdOrderLogic;
 use app\common\logic\ThirdOrderLogic;
 use app\common\model\equity\UserEquity;
 use app\common\model\equity\UserEquity;
@@ -301,6 +302,8 @@ class MeiTuanNotifyController extends BaseApiController
                             $work->work_pay_status = 1;
                             $work->work_pay_status = 1;
                             $work->finished_time = time();
                             $work->finished_time = time();
                             $work->save();
                             $work->save();
+
+                            ThirdOrderLogic::updateorderfulfillinfo($work,ThirdTypeEnum::MEITUAN_COMPLETION);
                         }
                         }
                     }
                     }
                 }
                 }

+ 5 - 0
app/api/controller/notify/UserConfirmController.php

@@ -5,6 +5,8 @@ namespace app\api\controller\notify;
 use app\adminapi\logic\works\ServiceWorkLogic;
 use app\adminapi\logic\works\ServiceWorkLogic;
 use app\api\controller\BaseApiController;
 use app\api\controller\BaseApiController;
 use app\api\validate\UserConfirmValidate;
 use app\api\validate\UserConfirmValidate;
+use app\common\enum\ThirdTypeEnum;
+use app\common\logic\ThirdOrderLogic;
 use app\common\model\master_worker\MasterWorker;
 use app\common\model\master_worker\MasterWorker;
 use app\common\model\works\ServiceWork;
 use app\common\model\works\ServiceWork;
 use think\Exception;
 use think\Exception;
@@ -32,6 +34,9 @@ class UserConfirmController extends BaseApiController
             $params['user_info'] = MasterWorker::where('id',$work['master_worker_id'])->field('worker_number,real_name')->findOrEmpty();//工程师信息
             $params['user_info'] = MasterWorker::where('id',$work['master_worker_id'])->field('worker_number,real_name')->findOrEmpty();//工程师信息
             $params['work_sn'] = $work_sn;
             $params['work_sn'] = $work_sn;
             $result = ServiceWorkLogic::confirmDoor($params);
             $result = ServiceWorkLogic::confirmDoor($params);
+            if($work->third_type == 1){
+                ThirdOrderLogic::updateorderfulfillinfo($work,ThirdTypeEnum::MEITUAN_ARRIVED);
+            }
             if (false === $result) {
             if (false === $result) {
                 throw new Exception(ServiceWorkLogic::getError());
                 throw new Exception(ServiceWorkLogic::getError());
             }
             }

+ 20 - 0
app/common/enum/ThirdTypeEnum.php

@@ -0,0 +1,20 @@
+<?php
+namespace app\common\enum;
+
+/**
+ * 第三个平台枚举
+ * Class LoginEnum
+ * @package app\common\enum
+ */
+class ThirdTypeEnum
+{
+    /**
+     * 美团履约
+     * MEITUAN_MEITUAN 已分配
+     * MEITUAN_ARRIVED 已到达
+     * MEITUAN_COMPLETION 履约完成
+     */
+    const MEITUAN_MEITUAN = 40001;
+    const MEITUAN_ARRIVED = 40002;
+    const MEITUAN_COMPLETION = 41001;
+}

+ 67 - 1
app/common/logic/ThirdOrderLogic.php

@@ -18,6 +18,7 @@ use app\common\{enum\GoodsEnum,
     model\works\ServiceWorkLog};
     model\works\ServiceWorkLog};
 use think\facade\Db;
 use think\facade\Db;
 use app\common\model\service_area\ServiceArea;
 use app\common\model\service_area\ServiceArea;
+use think\facade\Log;
 
 
 /**
 /**
  * 第三方平台下单逻辑层
  * 第三方平台下单逻辑层
@@ -595,7 +596,8 @@ class ThirdOrderLogic extends BaseLogic
     public static function merchantcancelorder($work_id)
     public static function merchantcancelorder($work_id)
     {
     {
         $third_order = ThirdOrders::where('work_id',$work_id)->findOrEmpty();
         $third_order = ThirdOrders::where('work_id',$work_id)->findOrEmpty();
-        if(!$third_order->isEmpty() && !empty($third_order['request_msg'])){
+        if(!$third_order->isEmpty() && !empty($third_order['request_msg']) && $third_order['third_type']==1){
+            Log::write('取消美团订单'.$work_id);
             $third_order->bookStatus = 3;
             $third_order->bookStatus = 3;
             $third_order->save();
             $third_order->save();
             $url = 'https://api-open-cater.meituan.com/ddzh/yuding/merchantcancelorder';
             $url = 'https://api-open-cater.meituan.com/ddzh/yuding/merchantcancelorder';
@@ -623,4 +625,68 @@ class ThirdOrderLogic extends BaseLogic
 
 
     }
     }
 
 
+    /**
+     * 更新履约状态
+     * @param $work_id
+     * @return string|void
+     */
+    public static function updateorderfulfillinfo($work,$orderFulfillStatus)
+    {
+        $third_order = ThirdOrders::where('work_id',$work['id'])->findOrEmpty();
+        if(!$third_order->isEmpty() && !empty($third_order['request_msg'])) {
+//        家政/维修更新顺序:已分配(40001)→ 已到达(40002)→ 履约完成(41001)
+            $app_sku_id = ThirdGoods::where('product_id',$third_order['productId'])->value('app_sku_id');
+            //判断当前履约状态
+            $pic_url = 'https://cdnweixiu.kyjlkj.com/uploads/images/20240914/2024091414471041c336653.png';
+            switch ($orderFulfillStatus){
+                case '40001':
+                    $describe = '已分配';
+                    break;
+                case '40002':
+                    $describe = '已到达';
+                    break;
+                case '41001':
+                    $describe = '履约完成';
+                    $pic_url = !empty($work['finished_images'][0])?$work['finished_images'][0]:$pic_url;
+                    break;
+                default:
+                    $describe = '未知';
+                    break;
+            }
+
+            $url = 'https://api-open-cater.meituan.com/ddzh/yuding/merchantcancelorder';
+            $opBizCode = !empty($third_order['request_msg']) ? json_decode($third_order['request_msg'], true)['opBizCode'] : '';
+            $accessToken = $opBizCode == 'AE7MKOJAV67338LIC3UD0K5TGIO' ? self::shop_token2['accessToken'] : self::shop_token1['accessToken'];
+            $data = [
+                'timestamp' => time(),
+                'appAuthToken' => $accessToken,
+                'charset' => 'utf-8',
+                'version' => '2',
+                'developerId' => self::developerId,
+                'businessId' => 58,
+                'biz' => json_encode([
+                    'orderId' => $third_order['orderId'],
+                    'attrKeyValue' => [
+                        'service_voucher' => [
+                            'detail_list' => [
+                                [
+                                    'app_sku_id' => $app_sku_id,
+                                    'describe' => $describe,
+                                    'pic_url' => $pic_url
+                                ]
+                            ]
+                        ],
+                        'delivery_info' => '无',
+                        'delivery_type' => 3
+                    ],
+                    "type" => 2,
+                    "orderFulfillStatus" => $orderFulfillStatus
+                ], JSON_UNESCAPED_UNICODE)
+            ];
+            $sign_data = self::get_sign(self::assessKey, $data);
+            $data['sign'] = $sign_data;
+            return http_request($url, http_build_query($data));
+        }
+    }
+
 }
 }