修复结算提交接口缺失参数的bug,修复接口传参书写错误的bug
Code Review By Rock Zhang
Showing
3 changed files
with
26 additions
and
9 deletions
@@ -303,14 +303,15 @@ class CartData | @@ -303,14 +303,15 @@ class CartData | ||
303 | * @param int $paymentId 支付方式ID | 303 | * @param int $paymentId 支付方式ID |
304 | * @param int $paymentType 支付类型ID | 304 | * @param int $paymentType 支付类型ID |
305 | * @param string $remark 留言 | 305 | * @param string $remark 留言 |
306 | + * @param string $couponCode 优惠券码 | ||
306 | * @param mixed $yohoCoin 使用的YOHO币数量或为空 | 307 | * @param mixed $yohoCoin 使用的YOHO币数量或为空 |
307 | * @return array 接口返回的数据 | 308 | * @return array 接口返回的数据 |
308 | */ | 309 | */ |
309 | - public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin) | 310 | + public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin) |
310 | { | 311 | { |
311 | $param = Yohobuy::param(); | 312 | $param = Yohobuy::param(); |
312 | $param['method'] = 'app.Shopping.submit'; | 313 | $param['method'] = 'app.Shopping.submit'; |
313 | - $param['addressId'] = $addressId; | 314 | + $param['address_id'] = $addressId; |
314 | $param['cart_type'] = $cartType; | 315 | $param['cart_type'] = $cartType; |
315 | $param['delivery_time'] = $deliveryTime; | 316 | $param['delivery_time'] = $deliveryTime; |
316 | $param['delivery_way'] = $deliveryWay; | 317 | $param['delivery_way'] = $deliveryWay; |
@@ -324,6 +325,9 @@ class CartData | @@ -324,6 +325,9 @@ class CartData | ||
324 | $param['payment_id'] = $paymentId; | 325 | $param['payment_id'] = $paymentId; |
325 | $param['payment_type'] = $paymentType; | 326 | $param['payment_type'] = $paymentType; |
326 | $param['remark'] = $remark; | 327 | $param['remark'] = $remark; |
328 | + if (!empty($couponCode)) { | ||
329 | + $param['coupon_code'] = $couponCode; | ||
330 | + } | ||
327 | if (!empty($yohoCoin)) { | 331 | if (!empty($yohoCoin)) { |
328 | $param['use_yoho_coin'] = $yohoCoin; | 332 | $param['use_yoho_coin'] = $yohoCoin; |
329 | } | 333 | } |
@@ -314,8 +314,9 @@ class ShoppingCartController extends AbstractAction | @@ -314,8 +314,9 @@ class ShoppingCartController extends AbstractAction | ||
314 | $paymentId = $this->post('paymentTypeId', 15); | 314 | $paymentId = $this->post('paymentTypeId', 15); |
315 | $paymentType = $this->post('paymentType', 1); // 默认在线支付 | 315 | $paymentType = $this->post('paymentType', 1); // 默认在线支付 |
316 | $remark = $this->post('msg', null); | 316 | $remark = $this->post('msg', null); |
317 | + $couponCode = $this->post('couponCode', null); | ||
317 | $yohoCoin = $this->post('yohoCoin', 1); | 318 | $yohoCoin = $this->post('yohoCoin', 1); |
318 | - $result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin); | 319 | + $result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin); |
319 | } | 320 | } |
320 | 321 | ||
321 | if (empty($result)) { | 322 | if (empty($result)) { |
@@ -567,16 +567,28 @@ class CartModel | @@ -567,16 +567,28 @@ class CartModel | ||
567 | * @param int $paymentId 支付方式ID | 567 | * @param int $paymentId 支付方式ID |
568 | * @param int $paymentType 支付类型ID | 568 | * @param int $paymentType 支付类型ID |
569 | * @param string $remark 留言 | 569 | * @param string $remark 留言 |
570 | + * @param string $couponCode 优惠券码 | ||
570 | * @param mixed $yohoCoin 使用的YOHO币数量或为空 | 571 | * @param mixed $yohoCoin 使用的YOHO币数量或为空 |
571 | * @return array 接口返回的数据 | 572 | * @return array 接口返回的数据 |
572 | */ | 573 | */ |
573 | - public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin) | 574 | + public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin) |
574 | { | 575 | { |
575 | - $result = array(); | ||
576 | - | ||
577 | - $orderSubRes = CartData::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin); | ||
578 | - if ($orderSubRes && isset($orderSubRes['code'])) { | ||
579 | - $result = $orderSubRes; | 576 | + $result = array('code' => 400, 'message' => '出错啦'); |
577 | + | ||
578 | + if (empty($addressId)) { | ||
579 | + $result['code'] = 401; | ||
580 | + $result['message'] = '配送地址不能为空'; | ||
581 | + } elseif (empty($deliveryTime)) { | ||
582 | + $result['code'] = 402; | ||
583 | + $result['message'] = '请选择配送时间'; | ||
584 | + } elseif (empty($deliveryWay)) { | ||
585 | + $result['code'] = 403; | ||
586 | + $result['message'] = '请选择配送方式'; | ||
587 | + } else { | ||
588 | + $orderSubRes = CartData::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin); | ||
589 | + if ($orderSubRes && isset($orderSubRes['code'])) { | ||
590 | + $result = $orderSubRes; | ||
591 | + } | ||
580 | } | 592 | } |
581 | 593 | ||
582 | return $result; | 594 | return $result; |
-
Please register or login to post a comment