Commit 40bae0e59efff94763049559840f23a61510bb43
1 parent
a3e934a4
购物车要优化优惠促销 搭配促销 组合购 阶梯促销 的叠加顺序
Showing
1 changed file
with
71 additions
and
1 deletions
pages/cart/cart/cart.js
... | ... | @@ -548,7 +548,77 @@ Page({ |
548 | 548 | }) |
549 | 549 | item.goods_num = cbuy; |
550 | 550 | } |
551 | - | |
551 | + | |
552 | + //-- 如果有优惠促销,和阶梯促销,要看下有没有组合购,搭配购,看一下优惠促销和阶梯促销谁是指定商品参与的 -- | |
553 | + if(item.prom_type==3 || item.prom_type==10){ | |
554 | + | |
555 | + var c_prom_type=0; | |
556 | + var c_prom_id=0; | |
557 | + | |
558 | + //因为有全场优惠活动,商品参加的活动还未开始 | |
559 | + var url_ch_more_act = "/api/weshop/activitylist/getGoodActInfo"; | |
560 | + var req_data_m = { | |
561 | + store_id: os.stoid, goodsidlist: item.goods_id, is_detail: 1, user_id: user_id | |
562 | + }; | |
563 | + await getApp().request.promiseGet(url_ch_more_act, { data: req_data_m }).then(async function (res) { | |
564 | + if (res.data.code == 0 && res.data.data && res.data.data.length) { | |
565 | + //-- 先看一下有没有组合购 -- | |
566 | + var zh_fd=res.data.data.filter(function (e) { | |
567 | + return e.prom_type==7; | |
568 | + }) | |
569 | + if(zh_fd && zh_fd.length){ | |
570 | + c_prom_type=zh_fd[0].prom_type; | |
571 | + c_prom_id=zh_fd[0].act_id; | |
572 | + } | |
573 | + | |
574 | + //-- 先看一下有没有搭配购 -- | |
575 | + var dp_fd=res.data.data.filter(function (e) { | |
576 | + return e.prom_type==5; | |
577 | + }) | |
578 | + if(dp_fd && dp_fd.length){ | |
579 | + c_prom_type=dp_fd[0].prom_type; | |
580 | + c_prom_id=dp_fd[0].act_id; | |
581 | + } | |
582 | + | |
583 | + //-- 先看一下有没有指定优惠促销 -- | |
584 | + var yh_fd=res.data.data.filter(function (e) { | |
585 | + return e.prom_type==3 && e.good_object==1; | |
586 | + }) | |
587 | + if(yh_fd && yh_fd.length){ | |
588 | + c_prom_type=yh_fd[0].prom_type; | |
589 | + c_prom_id=yh_fd[0].act_id; | |
590 | + } | |
591 | + | |
592 | + //-- 先看一下有没有指定阶梯促销 -- | |
593 | + var jt_fd=res.data.data.filter(function (e) { | |
594 | + return e.prom_type==10 && e.good_object==1; | |
595 | + }) | |
596 | + if(jt_fd && jt_fd.length){ | |
597 | + c_prom_type=jt_fd[0].prom_type; | |
598 | + c_prom_id=jt_fd[0].act_id; | |
599 | + } | |
600 | + | |
601 | + } | |
602 | + }) | |
603 | + | |
604 | + if(c_prom_type && (c_prom_type!=item.prom_type || c_prom_id!=item.prom_id )){ | |
605 | + item.prom_type=c_prom_type; | |
606 | + item.prom_id=c_prom_id; | |
607 | + //-- 购物车更新 -- | |
608 | + var updata1 = { | |
609 | + id: item.id, | |
610 | + prom_type: c_prom_type, | |
611 | + prom_id:c_prom_id, | |
612 | + store_id: os.stoid, | |
613 | + user_id: getApp().globalData.userInfo.user_id | |
614 | + }; | |
615 | + getApp().request.put("/api/weshop/cart/update", { | |
616 | + data: updata1, | |
617 | + }) | |
618 | + } | |
619 | + | |
620 | + } | |
621 | + | |
552 | 622 | //判断如果是普通商品,后面参加活动了,变成失效商品 |
553 | 623 | if (item.prom_type == 0 ) { |
554 | 624 | ... | ... |