|
|
@@ -7,7 +7,9 @@ use app\api\controller\ApiController;
|
|
|
use app\api\model\taxi\MotorRecord;
|
|
|
use app\api\service\SmsCode;
|
|
|
use app\common\validate\IDMustBePositiveInt;
|
|
|
+use app\http\IResponse;
|
|
|
use EasyWeChat\Factory;
|
|
|
+use think\Db;
|
|
|
use think\facade\Cache;
|
|
|
|
|
|
class Taxi extends ApiController
|
|
|
@@ -355,6 +357,8 @@ class Taxi extends ApiController
|
|
|
if (time() - $row['created_at']['val'] < (60 * 10)) {
|
|
|
// return $this->ApiJson(-1, '10分钟内无法取消订单');
|
|
|
}
|
|
|
+
|
|
|
+ $taxiUid = isset($row['taxi_uid'])? intval($row['taxi_uid']) : 0;
|
|
|
if ($row['status'] == 2 || $row['status'] == 3) {
|
|
|
$config = Cache::get('system_config');
|
|
|
$total_price = $row->paylog['total_price'];
|
|
|
@@ -362,7 +366,6 @@ class Taxi extends ApiController
|
|
|
// 如果平台已指派司机,则扣除部分金额
|
|
|
$cost_price = 0;
|
|
|
$total = $total_price;
|
|
|
- $taxiUid = isset($row['taxi_uid'])? intval($row['taxi_uid']) : 0;
|
|
|
$createTime = isset($row['created_at'])? $row['created_at'] : 0;
|
|
|
$cancelTime = isset($config['store']['store_cancel_time'])? $config['store']['store_cancel_time'] : 0;
|
|
|
$taxiUser = model('common/TaxiUser')->where(['id'=> $taxiUid])->find();
|
|
|
@@ -461,10 +464,19 @@ class Taxi extends ApiController
|
|
|
'msg' => '有用户取消订单,点击前往!'
|
|
|
]);
|
|
|
|
|
|
+ Db::startTrans();
|
|
|
$row->status = 5;
|
|
|
$row->settle_price = $cost_price;
|
|
|
$row->remark = $param['result'];
|
|
|
- $row->save();
|
|
|
+ if(!$row->save()){
|
|
|
+ Db::rollback();
|
|
|
+ return IResponse::failure('取消失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!\app\common\model\Taxi::where(['taxi_user_id' => $taxiUid, 'id' => $row['taxi_id']])->update(['status' => 1])) {
|
|
|
+ Db::rollback();
|
|
|
+ return IResponse::failure('取消失败');
|
|
|
+ }
|
|
|
|
|
|
return $this->ApiJson(0, '取消成功', $row);
|
|
|
}
|