Authored by 郭成尧

Merge branch 'feature/coupon' into release/180420

... ... @@ -111,7 +111,7 @@ class BuyNowController {
}
});
if (autoSelectCouponCodeStr) {
if (!orderInfo.coupon_code && autoSelectCouponCodeStr) {
orderInfo.coupon_code = autoSelectCouponCodeStr;
res.cookie('order-info', JSON.stringify(orderInfo), actCkOpthn);
}
... ...
... ... @@ -100,7 +100,7 @@ exports.orderEnsure = (req, res, next) => {
}
}
if (autoSelectCouponCodeStr) {
if (!orderInfo.coupon_code && autoSelectCouponCodeStr) {
orderInfo.coupon_code = autoSelectCouponCodeStr;
res.cookie('order-info', JSON.stringify(orderInfo), actCkOpthn);
}
... ...
... ... @@ -79,7 +79,10 @@ class cartModel extends global.yoho.BaseModel {
return Promise.all([
cartPayAPI, // 0. 订单数据
orderComputeAPI,
this.ctx.req.ctx(shoppingModel).getValidCouponCount(params.uid), // 2. 有效优惠券
this.ctx.req.ctx(shoppingModel).getValidCouponCount({
uid: params.uid,
delivery_way: orderInfoCookie.deliveryId
}), // 2. 有效优惠券
this.ctx.req.ctx(shoppingModel).countUsableGiftCard(params.uid) // 3 可用礼品卡数量
]).then(res => {
let pay = res[0];
... ...
... ... @@ -234,10 +234,11 @@ class shoppingModel extends global.yoho.BaseModel {
* @param uid int 用户uid
* @return see doc
*/
getValidCouponCount(uid) {
getValidCouponCount(params) {
let param = {
method: 'app.Shopping.countUsableCoupon',
uid
uid: params.uid,
delivery_way: params.delivery_way
};
return this.get({data: param});
... ... @@ -268,7 +269,7 @@ class shoppingModel extends global.yoho.BaseModel {
*/
useCoupon(uid, couponCode) {
let param = {
method: 'app.Shopping.useCoupon',
method: 'app.coupons.bindPCoupon',
coupon_code: couponCode,
uid
};
... ...