...
|
...
|
@@ -534,40 +534,10 @@ class Order extends Api |
|
|
empty($order_id) && $this->error('缺少必需参数');
|
|
|
$order = $this->model->get($order_id);
|
|
|
empty($order) && $this->error('订单信息不存在');
|
|
|
$grab = $order['grab_success'];
|
|
|
$order['status'] != '3' && $this->error('订单不合法');
|
|
|
Db::startTrans();
|
|
|
try{
|
|
|
// 发单和抢单状态都改为已完成
|
|
|
$grab->save(['status'=>'4']);
|
|
|
$order->save(['status'=>'4']);
|
|
|
// 给抢单用户发送"已完成"通知
|
|
|
(new Message)->save([
|
|
|
'user_id' => $grab['user_id'],
|
|
|
'order_id' => $grab['order_id'],
|
|
|
'order_grab_id' => $grab['id'],
|
|
|
'type' => '1',
|
|
|
'grab_status' => '3',
|
|
|
]);
|
|
|
// 添加抢单价格到抢单用户余额
|
|
|
User::money($grab['grab_price'],$grab['user_id'],'订单完成',['order_id' => $order_id]);
|
|
|
// 把定金多余金额退回发单用户余额
|
|
|
if($order['deposit'] > $grab['grab_price']){
|
|
|
$dec = $order['deposit'] - $grab['grab_price'];
|
|
|
User::money($dec,$order['user_id'],'退定金余额',['order_id' => $order_id]);
|
|
|
}
|
|
|
// 订单完成通知
|
|
|
$send_data = [
|
|
|
"first" => '刚刚完成了一笔订单',
|
|
|
"keyword1" => $order['deposit'],
|
|
|
"keyword2" => $order['license_plate'],
|
|
|
"keyword3" => date('Y年m月d日H点i分'),
|
|
|
"keyword4" => $order['market_name'],
|
|
|
"remark" => ['请点击查看详情','#FF0000'],
|
|
|
];
|
|
|
$openid = Third::where('user_id',$grab['user_id'])->value('openid');
|
|
|
$templateid = config('tmplmsg.template')['order_complete'];
|
|
|
$url = config('tmplmsg.vue_url').'/indenta?id='.$grab['id'].'&type=4';
|
|
|
(new Wechat)->tmplmsg($openid,$send_data,$templateid,$url);
|
|
|
self::confirmAction($order);
|
|
|
Db::commit();
|
|
|
} catch (PDOException $e) {
|
|
|
Db::rollback();
|
...
|
...
|
@@ -580,6 +550,47 @@ class Order extends Api |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @ApiInternal
|
|
|
* @ApiTitle (待确认-确认-操作)
|
|
|
* @ApiSummary (待确认-确认-操作)
|
|
|
*/
|
|
|
public static function confirmAction($order){
|
|
|
$grab = $order['grab_success'];
|
|
|
// 发单和抢单状态都改为已完成
|
|
|
$grab->save(['status'=>'4']);
|
|
|
$order->save(['status'=>'4']);
|
|
|
// 给抢单用户发送"已完成"通知
|
|
|
(new Message)->save([
|
|
|
'user_id' => $grab['user_id'],
|
|
|
'order_id' => $grab['order_id'],
|
|
|
'order_grab_id' => $grab['id'],
|
|
|
'type' => '1',
|
|
|
'grab_status' => '3',
|
|
|
]);
|
|
|
// 添加抢单价格到抢单用户余额
|
|
|
User::money($grab['grab_price'],$grab['user_id'],'订单完成',['order_id' => $order['id']]);
|
|
|
// 把定金多余金额退回发单用户余额
|
|
|
if($order['deposit'] > $grab['grab_price']){
|
|
|
$dec = $order['deposit'] - $grab['grab_price'];
|
|
|
User::money($dec,$order['user_id'],'退定金余额',['order_id' => $order['id']]);
|
|
|
}
|
|
|
// 订单完成通知
|
|
|
$send_data = [
|
|
|
"first" => '刚刚完成了一笔订单',
|
|
|
"keyword1" => $order['deposit'],
|
|
|
"keyword2" => $order['license_plate'],
|
|
|
"keyword3" => date('Y年m月d日H点i分'),
|
|
|
"keyword4" => $order['market_name'],
|
|
|
"remark" => ['请点击查看详情','#FF0000'],
|
|
|
];
|
|
|
$openid = Third::where('user_id',$grab['user_id'])->value('openid');
|
|
|
$templateid = config('tmplmsg.template')['order_complete'];
|
|
|
$url = config('tmplmsg.vue_url').'/indenta?id='.$grab['id'].'&type=4';
|
|
|
(new Wechat)->tmplmsg($openid,$send_data,$templateid,$url);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @ApiWeigh (81)
|
|
|
* @ApiTitle (待确认-问题反馈)
|
|
|
* @ApiSummary (待确认-问题反馈)
|
...
|
...
|
|