|
@@ -176,13 +176,7 @@ class UserOrder extends UserApi
|
|
|
if($order['coupon_id']){
|
|
|
UserCoupon::where('id',$order['coupon_id'])->save(['is_used'=>1]);
|
|
|
}
|
|
|
- if($order['pay_type']==1){
|
|
|
- $params='';
|
|
|
- $user->money(bcsub(0,$order['real_amount'],2),$user['id'],"订单[{$order['no']}]付款");
|
|
|
- \app\common\model\UserOrder::payed(['id'=>$order['id']]);
|
|
|
- }else {
|
|
|
- $params = Payment::pay($user, $order['real_amount'], UserOrder::class, 'payed', ['id' => $order['id']]);
|
|
|
- }
|
|
|
+ $params=$order->pay();
|
|
|
Db::commit();
|
|
|
$this->success('',$params);
|
|
|
}
|
|
@@ -212,7 +206,7 @@ class UserOrder extends UserApi
|
|
|
$query->where('status', UO::STATUS_WAIT_PAY);
|
|
|
break;
|
|
|
case 2:
|
|
|
- $query->whereBetween('status',[UO::STATUS_WAIT_GET,UO::STATUS_WAIT_SENDING]);
|
|
|
+ $query->whereBetween('status',[UO::STATUS_WAIT_GET,UO::STATUS_GIVED]);
|
|
|
break;
|
|
|
case 3:
|
|
|
$query->whereBetween('status',UO::STATUS_COMPLETE);
|
|
@@ -276,6 +270,7 @@ class UserOrder extends UserApi
|
|
|
/**
|
|
|
* 托运详情
|
|
|
* @ApiParams (name=id,decription=订单ID)
|
|
|
+ * @ApiReturnParams (name=addr,description="取宠地址")
|
|
|
* @ApiReturnParams (name=created_at,description="时间")
|
|
|
* @ApiReturnParams (name=status,description="状态")
|
|
|
* @ApiReturnParams (name=txt,description="描述")
|
|
@@ -288,11 +283,110 @@ class UserOrder extends UserApi
|
|
|
]);
|
|
|
$user=$this->auth->getUser();
|
|
|
$order=$user->orders()->findOrFail($data['id']);
|
|
|
- $log=$order->log()->select();
|
|
|
|
|
|
- $res['addr']=$order['to_addr']['address'];
|
|
|
- $res['log']=$log;
|
|
|
+ $this->success('',$order->send_detail);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 取消订单
|
|
|
+ * @ApiParams (name=id,decription=订单ID)
|
|
|
+ */
|
|
|
+ public function cancel(){
|
|
|
+ $data=input();
|
|
|
+ $this->validate($data,[
|
|
|
+ 'id'=>['require']
|
|
|
+ ]);
|
|
|
+ $user=$this->auth->getUser();
|
|
|
+ Db::startTrans();
|
|
|
+ $order=$user->orders()->lock(true)->findOrFail($data['id']);
|
|
|
+ $order->cancel();
|
|
|
+ Db::commit();
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 继续支付
|
|
|
+ * @ApiParams (name=id,decription=订单ID)
|
|
|
+ */
|
|
|
+ public function pay(){
|
|
|
+ $data=input();
|
|
|
+ $this->validate($data,[
|
|
|
+ 'id'=>['require']
|
|
|
+ ]);
|
|
|
+ $user=$this->auth->getUser();
|
|
|
+ Db::startTrans();
|
|
|
+ $order=$user->orders()->lock(true)->findOrFail($data['id']);
|
|
|
+ $params=$order->pay();
|
|
|
+ Db::commit();
|
|
|
+ $this->success('',$params);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 确认完成
|
|
|
+ * @ApiParams (name=id,decription=订单ID)
|
|
|
+ */
|
|
|
+ public function complete(){
|
|
|
+ $data=input();
|
|
|
+ $this->validate($data,[
|
|
|
+ 'id'=>['require']
|
|
|
+ ]);
|
|
|
+ $user=$this->auth->getUser();
|
|
|
+ Db::startTrans();
|
|
|
+ $order=$user->orders()->lock(true)->findOrFail($data['id']);
|
|
|
+ $params=$order->complete();
|
|
|
+ Db::commit();
|
|
|
+ $this->success('',$params);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取申请退款信息
|
|
|
+ * @ApiParams (name=id,decription=订单ID)
|
|
|
+ */
|
|
|
+ public function refund_info(){
|
|
|
+ $data=input();
|
|
|
+ $this->validate($data,[
|
|
|
+ 'id'=>['require'],
|
|
|
+ ]);
|
|
|
+ $user=$this->auth->getUser();
|
|
|
+ $order=$user->orders()->findOrFail($data['id']);
|
|
|
|
|
|
+ $res=[];
|
|
|
+ $res['fee']=[
|
|
|
+ 'land'=>config('site.order_refund_land'),
|
|
|
+ 'air'=>config('site.order_refund_air'),
|
|
|
+ ];
|
|
|
+ $res['refund_amount']=$order->refund_money;
|
|
|
$this->success('',$res);
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 申请退款
|
|
|
+ * @ApiParams (name=id,description=订单ID)
|
|
|
+ * @ApiParams (name=reason,description=原因必须)
|
|
|
+ * @ApiParams (name=images,description=图片可选)
|
|
|
+ */
|
|
|
+ public function refund(){
|
|
|
+ $data=input();
|
|
|
+ $this->validate($data,[
|
|
|
+ 'id'=>['require'],
|
|
|
+ 'reason'=>['require','max:200'],
|
|
|
+ 'images'=>['array'],
|
|
|
+ ]);
|
|
|
+ $user=$this->auth->getUser();
|
|
|
+ Db::startTrans();
|
|
|
+ $order=$user->orders()->lock(true)->findOrFail($data['id']);
|
|
|
+ $order->refund($data['reason'],$data['images']);
|
|
|
+ Db::commit();
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 删除订单
|
|
|
+ * @ApiParams (name=id,decription=订单ID)
|
|
|
+ */
|
|
|
+ public function delete(){
|
|
|
+ $data=input();
|
|
|
+ $this->validate($data,[
|
|
|
+ 'id'=>['require'],
|
|
|
+ ]);
|
|
|
+ $user=$this->auth->getUser();
|
|
|
+ $order=$user->orders()->findOrFail($data['id']);
|
|
|
+ $order->remove();
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
}
|