|
|
@@ -19,6 +19,7 @@ use app\common\model\recharge\RechargeOrder;
|
|
|
use app\common\model\user\User;
|
|
|
use app\common\model\user\UserAuth;
|
|
|
use app\common\model\works\ServiceWork;
|
|
|
+use app\common\model\works\ServiceWorkLog;
|
|
|
use app\common\service\ConfigService;
|
|
|
use app\common\service\FileService;
|
|
|
use GuzzleHttp\Client;
|
|
|
@@ -440,6 +441,48 @@ class DouYinService
|
|
|
throw new \Exception($e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public static function refundOrderNotify($params = [])
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ // 抖音单取消
|
|
|
+ $douyinOrder = DouyinOrder::where(['order_number'=>$params['out_order_no']??0])->findOrEmpty();
|
|
|
+ if(!$douyinOrder->isEmpty()){
|
|
|
+ $douyinOrder->status = 4;
|
|
|
+ $douyinOrder->save();
|
|
|
+ // 有工单则工单取消
|
|
|
+ if($douyinOrder->work_id){
|
|
|
+ // 工单信息
|
|
|
+ $service_work = ServiceWork::where('id',$douyinOrder->work_id)->findOrEmpty();
|
|
|
+ if($service_work->isEmpty()) return true;
|
|
|
+ // 取消工单
|
|
|
+ if($service_work->work_status < 7){
|
|
|
+ //更新工单状态为已取消并退款
|
|
|
+ $service_work->service_status = 4;
|
|
|
+ $service_work->work_status = 9;
|
|
|
+ $service_work->user_confirm_status = 5;
|
|
|
+ $service_work->save();
|
|
|
+ ServiceWorkLog::create([
|
|
|
+ 'work_id' => $service_work->id,
|
|
|
+ 'master_worker_id' => $service_work->master_worker_id,
|
|
|
+ 'opera_log' => "工单:{$service_work->work_sn} 取消并终止结束服务"
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return [
|
|
|
+ "out_order_no" => $params['out_order_no'],
|
|
|
+ "order_entry_schema" => [
|
|
|
+ "path" => "pages/order/detail",
|
|
|
+ "params" => json_encode(['order_number' => $params['out_order_no']])
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ throw new \Exception($e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// ++++++++++++++++++++ 首次创单
|
|
|
/**
|
|
|
* 预下单扩展点-子
|
|
|
@@ -817,22 +860,43 @@ class DouYinService
|
|
|
// $params['order_number']
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
- $order = DouyinOrder::where('order_number', $params['order_number'])->findOrEmpty();
|
|
|
- if(!$order->isEmpty()){
|
|
|
- if($order->order_status == 1 && $order->pay_status == 0){
|
|
|
- $order->order_status = 4;
|
|
|
- $order->save();
|
|
|
+ $douyinOrder = DouyinOrder::where('order_number', $params['order_number'])->findOrEmpty();
|
|
|
+ if(!$douyinOrder->isEmpty()){
|
|
|
+ if($douyinOrder->order_status == 1 && $douyinOrder->pay_status == 0){
|
|
|
+ $douyinOrder->order_status = 4;
|
|
|
+ $douyinOrder->save();
|
|
|
+
|
|
|
+ // 有工单则工单取消
|
|
|
+ if($douyinOrder->work_id){
|
|
|
+ // 工单信息
|
|
|
+ $service_work = ServiceWork::where('id',$douyinOrder->work_id)->findOrEmpty();
|
|
|
+ if($service_work->isEmpty()) return true;
|
|
|
+ // 取消工单
|
|
|
+ if($service_work->work_status < 7){
|
|
|
+ //更新工单状态为已取消并退款
|
|
|
+ $service_work->service_status = 4;
|
|
|
+ $service_work->work_status = 9;
|
|
|
+ $service_work->user_confirm_status = 5;
|
|
|
+ $service_work->save();
|
|
|
+ ServiceWorkLog::create([
|
|
|
+ 'work_id' => $service_work->id,
|
|
|
+ 'master_worker_id' => $service_work->master_worker_id,
|
|
|
+ 'opera_log' => "工单:{$service_work->work_sn} 取消并终止结束服务"
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
}else{
|
|
|
throw new \Exception('订单状态不可取消!');
|
|
|
}
|
|
|
}
|
|
|
Db::commit();
|
|
|
- return $order['id'];
|
|
|
+ return $douyinOrder['id'];
|
|
|
} catch (\Exception $e) {
|
|
|
Db::rollback();
|
|
|
throw new \Exception($e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
+ // 申请退款
|
|
|
public static function refund($params)
|
|
|
{
|
|
|
Db::startTrans();
|
|
|
@@ -859,13 +923,15 @@ class DouYinService
|
|
|
]);
|
|
|
|
|
|
Db::commit();
|
|
|
-
|
|
|
+ // 默认审核通过
|
|
|
+ self::refundExamine(['is_examine_ok'=>'pass','order_number'=>$params['order_number']]);
|
|
|
return true;
|
|
|
} catch (\Exception $e) {
|
|
|
Db::rollback();
|
|
|
throw new \Exception($e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
+ // 后台退款审核
|
|
|
public static function refundExamine($params)
|
|
|
{
|
|
|
Db::startTrans();
|
|
|
@@ -908,6 +974,7 @@ class DouYinService
|
|
|
throw new \Exception($e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
+ // 后台审核通过 - 发送抖音退款申请
|
|
|
public static function sendRefundCreate($order_number)
|
|
|
{
|
|
|
try {
|