|
|
@@ -15,15 +15,12 @@ class ExternalPlatformLogic extends BaseLogic
|
|
|
public static function handleByScene($params)
|
|
|
{
|
|
|
try {
|
|
|
- switch ($params['scene']){
|
|
|
- case 'cancel_order':
|
|
|
- //self::cancelOrder($params['params']);
|
|
|
- break;
|
|
|
- case 'confirm_price':
|
|
|
- self::confirmPrice($params['params']);
|
|
|
- break;
|
|
|
- case 'service_finish':
|
|
|
- self::serviceFinish($params['params']);
|
|
|
+ switch ($params['send_code']){
|
|
|
+ case 1002:
|
|
|
+ case 1003:
|
|
|
+ case 1005:
|
|
|
+ case 1006:
|
|
|
+ self::generalServiceWork($params['send_code'],$params['params']);
|
|
|
break;
|
|
|
default:
|
|
|
throw new \Exception('场景不存在');
|
|
|
@@ -37,86 +34,40 @@ class ExternalPlatformLogic extends BaseLogic
|
|
|
}
|
|
|
|
|
|
|
|
|
- // 工程师报价通知
|
|
|
- private static function confirmPrice($params)
|
|
|
- {
|
|
|
- try {
|
|
|
-
|
|
|
- $work = ServiceWork::where(['id'=>$params['work_id']])->findOrEmpty();
|
|
|
- if($work->isEmpty()){
|
|
|
- throw new \Exception('工单不存在');
|
|
|
- }
|
|
|
- if($work->external_platform_id > 0){
|
|
|
- $externalPlatform = ExternalPlatform::find($work->external_platform_id);
|
|
|
-
|
|
|
- $order_amount = RechargeOrder::where([
|
|
|
- 'user_id'=>$work->user_id,
|
|
|
- 'work_id'=>$params['work_id'],
|
|
|
- 'pay_status'=>0,
|
|
|
- 'payment_type'=>2
|
|
|
- ])->value('order_amount');
|
|
|
-
|
|
|
- $data = [
|
|
|
- 'timestamp'=>time(),
|
|
|
- 'scene'=>'confirm_price',
|
|
|
- 'version'=>'1',
|
|
|
- 'notice_data'=>json_encode([
|
|
|
- 'work_sn'=>$work->work_sn,
|
|
|
- 'order_amount'=>$order_amount * 100, // 单位分
|
|
|
- ],JSON_UNESCAPED_UNICODE)
|
|
|
- ];
|
|
|
- $data['sign'] = ExternalPlatform::getSign($externalPlatform['appkey'],$data);
|
|
|
- if($externalPlatform['send_url']){
|
|
|
- $res = http_request($externalPlatform['send_url'],http_build_query($data));
|
|
|
- }else{
|
|
|
- $res = '未配置接口地址';
|
|
|
- }
|
|
|
- Log::info('ExternalPlatform-confirmPrice:'
|
|
|
- .'url:'.$externalPlatform['send_url']
|
|
|
- .'|data:'.json_encode($data,JSON_UNESCAPED_UNICODE)
|
|
|
- .'|res:'.json_encode([$res],JSON_UNESCAPED_UNICODE)
|
|
|
- );
|
|
|
- }
|
|
|
- return true;
|
|
|
- } catch (\Exception $e) {
|
|
|
- throw new \Exception($e->getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
- // 工程师服务完成通知
|
|
|
- private static function serviceFinish($params)
|
|
|
+ /**
|
|
|
+ * 工单统一处理
|
|
|
+ * @param $send_code
|
|
|
+ * @param $params
|
|
|
+ * @return bool
|
|
|
+ * @author liugc <466014217@qq.com>
|
|
|
+ * @date 2025/4/17 14:12
|
|
|
+ */
|
|
|
+ private static function generalServiceWork($send_code,$params)
|
|
|
{
|
|
|
try {
|
|
|
-
|
|
|
$work = ServiceWork::where(['id'=>$params['work_id']])->findOrEmpty();
|
|
|
if($work->isEmpty()){
|
|
|
throw new \Exception('工单不存在');
|
|
|
}
|
|
|
if($work->external_platform_id > 0){
|
|
|
- $externalPlatform = ExternalPlatform::find($work->external_platform_id);
|
|
|
-
|
|
|
+ $send_url = env('internal_api.api_url_host').'platf/performanceNotice';
|
|
|
$data = [
|
|
|
- 'timestamp'=>time(),
|
|
|
- 'scene'=>'service_finish',
|
|
|
- 'version'=>'1',
|
|
|
- 'notice_data'=>json_encode([
|
|
|
- 'work_sn'=>$work->work_sn
|
|
|
- ],JSON_UNESCAPED_UNICODE)
|
|
|
+ 'external_platform_id'=> $work->external_platform_id,
|
|
|
+ 'send_code'=> $send_code,
|
|
|
+ 'work_sn'=> $work->work_sn
|
|
|
];
|
|
|
- $data['sign'] = ExternalPlatform::getSign($externalPlatform['appkey'],$data);
|
|
|
- if($externalPlatform['send_url']){
|
|
|
- $res = http_request($externalPlatform['send_url'],http_build_query($data));
|
|
|
- }else{
|
|
|
- $res = '未配置接口地址';
|
|
|
- }
|
|
|
- Log::info('ExternalPlatform-serviceFinish:'
|
|
|
- .'url:'.$externalPlatform['send_url']
|
|
|
+ // 通过内部SDK服务 对外通知
|
|
|
+ $res = http_request($send_url,http_build_query($data));
|
|
|
+ Log::info('generalServiceWork:'
|
|
|
+ .'url:'.$send_url
|
|
|
.'|data:'.json_encode($data,JSON_UNESCAPED_UNICODE)
|
|
|
.'|res:'.json_encode([$res],JSON_UNESCAPED_UNICODE)
|
|
|
);
|
|
|
}
|
|
|
return true;
|
|
|
} catch (\Exception $e) {
|
|
|
- throw new \Exception($e->getMessage());
|
|
|
+ Log::info('generalServiceWork-error:'.$e->getMessage());
|
|
|
+ return false;
|
|
|
}
|
|
|
}
|
|
|
|