77 lines
2.9 KiB
PHP
77 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace app\admin\behavior;
|
|
|
|
use app\admin\controller\SendMailLogic;
|
|
use app\admin\model\OrderDispatch;
|
|
use app\admin\model\TtsLog;
|
|
use app\common\Logic\NoticeLogic;
|
|
use app\common\model\Order;
|
|
use think\Exception;
|
|
use think\Lang;
|
|
|
|
class OrderDispatchLog
|
|
{
|
|
//记录订单任务日志
|
|
public function run(&$response)
|
|
{
|
|
try {
|
|
|
|
Lang::load(APP_PATH . 'admin/lang/zh-cn/orders/dispatch2.php');
|
|
|
|
$Model = new \app\admin\model\OrderDispatch();
|
|
$statusList = $Model->getStatusList();
|
|
$dispatch = $response['dispatch']; //订单对象
|
|
$remark = $response['remark'] ?? ''; //备注
|
|
$data = [
|
|
'dispatch_id' => $dispatch->id,
|
|
'order_id' => $dispatch->order_id,
|
|
'worker_id' => $dispatch->worker_id,
|
|
'status' => $dispatch->status,
|
|
'status_text' => $statusList[$dispatch->status],
|
|
'remark' => $remark,
|
|
'images' => $dispatch->record_images??'',
|
|
'admin_user' => $dispatch->admin_user??'系统',
|
|
];
|
|
\app\admin\model\OrderDispatchLog::create($data);
|
|
|
|
|
|
if(!isset($dispatch->from_record)){ //不是来自于跟进
|
|
if($dispatch->status == OrderDispatch::STATUS_TOGET)
|
|
{
|
|
$alibaba_dyvms = config('alibaba_dyvms');
|
|
|
|
if($alibaba_dyvms['status']){
|
|
$data = [
|
|
'order_id' => $dispatch->order_id,
|
|
'dispatch_id' => $dispatch->id,
|
|
'type' => 1,
|
|
'outid' => md5(time().rand(1000,9999).rand(1000,9999)),
|
|
'create_time' => date('Y-m-d H:i:s'),
|
|
'status' => $alibaba_dyvms['sync']?1:0,
|
|
'mobile' => $dispatch->worker_tel,
|
|
];
|
|
$service = new NoticeLogic();
|
|
$service->dispatchNotice($dispatch);
|
|
TtsLog::create($data);
|
|
}
|
|
}
|
|
|
|
if($dispatch->type == 2){
|
|
if($dispatch->status == OrderDispatch::STATUS_GOTIT){
|
|
$Order = Order::get($dispatch->order_id);
|
|
SendMailLogic::sendToCustomStart($Order->tel,$dispatch->worker_name,$dispatch->worker_tel);
|
|
}
|
|
}elseif($dispatch->type == 1){
|
|
if($dispatch->status == OrderDispatch::STATUS_TOGET){
|
|
$Order = Order::get($dispatch->order_id);
|
|
SendMailLogic::sendToCustomStart($Order->tel,$dispatch->worker_name,$dispatch->worker_tel);
|
|
}
|
|
}
|
|
}
|
|
}catch (Exception $exception){
|
|
echo $exception->getMessage();
|
|
}
|
|
}
|
|
}
|