作者 郭鑫

订单生成修改

... ... @@ -51,9 +51,9 @@ class OrderController extends CommonController
$money = $info['pay_money'];
}
if($data['_type'] == 2) {
$info = $agency_model->where(['id'=>$data['need_id'],'user_id'=>$user_id])->find();
$need = $user_need_model->where(['id'=>$info['need_id'],'user_id'=>$user_id])->find();
if($need != 3) {
$info = $agency_model->where(['id'=>$data['need_id'],'agency_id'=>$user_id])->find();
$need = $user_need_model->where(['id'=>$info['need_id']])->find();
if($need['status'] != 3) {
$this->apiResponse(0,'该需求当前状态无法进行报价');
}
$need_id = $info['id'];
... ... @@ -101,7 +101,7 @@ class OrderController extends CommonController
* @method POST
* @param name:token type:char require:1 default: other: desc:用户token
* @param name:order_sn type:char require:1 default: other: desc:订单编号
* @param name:_type type:int require:1 default: other: desc:支付类型:1,pc微信;2,手机微信;3,pc支付宝;4,手机支付宝;5,余额
* @param name:_type type:int require:1 default: other: desc:支付类型:1,pc微信;2,手机微信;3,pc支付宝;4,手机支付宝
*
*/
public function changePayType()
... ... @@ -125,7 +125,7 @@ class OrderController extends CommonController
if($orderInfo['type'] == 2) {
$info = $agency_model->where(['id'=>$orderInfo['need_id'],'user_id'=>$user['id']])->find();
$need = $user_need_model->where(['id'=>$info['need_id'],'user_id'=>$user['id']])->find();
if($need != 3) {
if($need['status'] != 3) {
$this->apiResponse(0,'该需求当前状态无法进行报价');
}
$sort = '中介报价保证金支付';
... ... @@ -142,43 +142,43 @@ class OrderController extends CommonController
// $this->apiResponse(0,'余额不足');
// } else {
// $order_model->startTrans();
// $where = [
// 'order_sn' => $data['order_sn']
// ];
// $update = [
// 'status' => 2,
// 'pay_type' => 5,
// 'pay_time' => time()
// ];
// if($orderInfo['type'] == 1) {
// $pay = $order_model->where($where)->isUpdate(true)->save($update);
// $status = $user_need_model->where()->isUpdate(true)->save(['status'=>2,'pay_time'=>time()]);
// }
// if($orderInfo['type'] == 2) {
// $pay = $order_model->where($where)->isUpdate(true)->save($update);
// $status = $agency_model->where()->isUpdate(true)->save(['status'=>2,'pay_time'=>time()]);
// }
// if($orderInfo['type'] == 3) {
// $Intermediary = controller('Intermediary','controller');
// $agencyOffer = $Intermediary->agencyOffer($user['id'],$info['id']);
// $update['lower_price'] = $agencyOffer['money'];
// $pay = $order_model->where($where)->isUpdate(true)->save($update);
// $status = 1;
// }
// if(!$pay || !$status) {
// $order_model->rollback();
// $this->apiResponse(0,'支付失败');
// }
// $where = [
// 'order_sn' => $data['order_sn']
// ];
// $update = [
// 'status' => 2,
// 'pay_type' => 5,
// 'pay_time' => time()
// ];
// if($orderInfo['type'] == 1) {
// $pay = $order_model->where($where)->update($update);
// $status = $user_need_model->where()->update(['status'=>2,'pay_time'=>time()]);
// }
// if($orderInfo['type'] == 2) {
// $pay = $order_model->where($where)->update($update);
// $status = $agency_model->where()->update(['status'=>2,'pay_time'=>time()]);
// }
// if($orderInfo['type'] == 3) {
// $Intermediary = controller('Intermediary','controller');
// $agencyOffer = $Intermediary->agencyOffer($user['id'],$info['id']);
// $update['lower_price'] = $agencyOffer['money'];
// $pay = $order_model->where($where)->update($update);
// $status = 1;
// }
// if(!$pay || !$status) {
// $order_model->rollback();
// $this->apiResponse(0,'支付失败');
// }
// $order_model->commit();
// $this->apiResponse(1,'支付成功');
// $this->apiResponse(5,'支付成功');
// }
// } else
if($data['_type'] == 2) {
// }
if($data['_type'] == 1) {
$return = $this->wxpay(['order_sn'=>$data['order_sn']],$sort);
$qrcode_url = url('portal/Index/qrcode',['data'=>urlencode($return['code_url'])],true,true);
$qrcode_url = url('portal/Qrcode/qrcode',['data'=>urlencode($return['code_url'])],true,true);
$this->apiResponse(1,'微信支付',['type'=>1,'url'=>$qrcode_url]);
} elseif($data['_type'] == 3) {
$alipay_url = url('portal/Alipay/alipay',array('order_sn'=>$data['order_sn'],'name'=>$sort,'price'=>0.01),true,true);
$alipay_url = url('portal/Alipay/alipay',['order_sn'=>$data['order_sn'],'name'=>$sort,'price'=>0.01],true,true);
$this->apiResponse(1,'支付宝支付',['type'=>3,'url'=>$alipay_url]);
}
} else {
... ... @@ -220,4 +220,35 @@ class OrderController extends CommonController
$this->apiResponse(1,'成功',$orderInfo['money']);
}
}
/**
* @title 支付页面检测微信支付是否完成
* @description 接口说明
* @author 开发者
* @url /api/portal/Order/checkWechatWebPay
* @method POST
* @param name:token type:char require:1 default: other: desc:用户token
* @param name:order_sn type:char require:1 default: other: desc:订单编号
*
*/
public function checkWechatWebPay() {
if($this->request->isPost()) {
$data = $this->request->param();
$member_model = new MemberModel();
$user = $member_model->field(['id,money'])->where(['token'=>$data['token']])->find();
$order_sn = $data['order_sn'];
$order_model = new OrderModel();
$status = $order_model->where(['order_sn'=>$order_sn])->value('status');
if(empty($status)) {
$this->apiResponse(0,'订单不存在');
}
if($status == 1 || $status == 9) {
$this->apiResponse(0,'未支付成功');
}
if($status == 2) {
$this->apiResponse(1,'支付成功');
}
}
}
}
\ No newline at end of file
... ...