Commit ef1f42faea76a2a19095c7191ddb6f4599d2390a

Authored by WXD-SEASON\season
2 parents c5589e3c 028e1d98

合并订单促销

packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js
... ... @@ -80,6 +80,13 @@ Page({
80 80 bconfig: null,
81 81 showFold:true,
82 82 template_id:[],
  83 +
  84 + //-- 订单促销判断积累 ---2024-2-20
  85 + order_prom_map_ck: {},
  86 + //能不能使用订单促销
  87 + can_use_ord_prom:{},
  88 + //存储订单促销的取价,按照门店进行索引
  89 + show_ord_prom:{},
83 90 },
84 91  
85 92  
... ... @@ -513,6 +520,7 @@ Page({
513 520 }
514 521  
515 522  
  523 + t.data.data.shop_price_y = t.data.data.shop_price;
516 524 t.data.data.shop_price = gg.goods_price;
517 525 //--如果是普通购买的时候--
518 526 if (gg.is_normal == 1) {
... ... @@ -569,7 +577,10 @@ Page({
569 577 }
570 578  
571 579  
  580 + t.data.data.goods_price=th.data.param.goods_price;
572 581  
  582 + //用深拷贝把商品缓存起来,方便后面使用
  583 + th.data.old_bn_goods=ut.deep_cp(t.data.data);
573 584  
574 585 th.setData({
575 586 bn_goods: t.data.data,
... ... @@ -642,6 +653,9 @@ Page({
642 653  
643 654 }
644 655  
  656 + t.data.data.goods_price=th.data.param.goods_price;
  657 + //用深拷贝把商品缓存起来,方便后面使用
  658 + th.data.old_bn_goods=ut.deep_cp(t.data.data);
645 659  
646 660 th.setData({
647 661 bn_goods: t.data.data,
... ... @@ -651,7 +665,6 @@ Page({
651 665 bn_exp_type: et
652 666 });
653 667  
654   -
655 668 //计算价格
656 669 th.calculatePrice2();
657 670 }
... ... @@ -842,7 +855,9 @@ Page({
842 855 //-----------计算商品总价--------------
843 856 //var allpice = th.data.param.goods_price;
844 857 var allpice = (th.data.act.group_price/100).toFixed(2);
845   -
  858 + if(th.data.can_use_ord_prom[th.data.bn_pick]){
  859 + allpice=th.data.param.goods_price*th.data.bn_goods.buynum;
  860 + }
846 861  
847 862 allpice = parseFloat(allpice).toFixed(2);
848 863 var txt = "formData.all_price";
... ... @@ -868,14 +883,18 @@ Page({
868 883 var ord_prom=null;
869 884 var o_condition=allpice;
870 885 if(th.data.act.is_order_yh){
  886 + // await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", {
  887 + // data: { store_id: os.stoid, orderAmount: o_condition, user_id: getApp().globalData.user_id }
  888 + // }).then(res => {
  889 + // if (res.data.code == 0) {
  890 + // ord_prom = res.data.data;
  891 + // }
  892 + // })
  893 +
  894 + th.set_by_now_ord_prom(th.data.bn_goods);
  895 + th.data.order_prom_map_ck[th.data.bn_pick].goods_price_all=o_condition;
  896 + ord_prom=await th.get_cur_ord_prom(th.data.bn_pick);
871 897  
872   - await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", {
873   - data: { store_id: os.stoid, orderAmount: o_condition, user_id: getApp().globalData.user_id }
874   - }).then(res => {
875   - if (res.data.code == 0) {
876   - ord_prom = res.data.data;
877   - }
878   - })
879 898 }
880 899  
881 900  
... ... @@ -964,7 +983,7 @@ Page({
964 983 title: "物流配置未启用物流公司", icon: 'none', duration: 2000
965 984 })
966 985 //th.setData({ show_submit:0, });
967   - th.setData({show_submit:1, submit: 0,same_ok:0 })
  986 + th.setData({show_submit:1, submit: 0,same_ok:0,sub:0 })
968 987 return false;
969 988 }
970 989  
... ... @@ -996,7 +1015,7 @@ Page({
996 1015 wx.showToast({
997 1016 title: "计算物流错误", icon: 'none', duration: 2000
998 1017 })
999   - th.setData({show_submit:1, submit: 0,same_ok:0 })
  1018 + th.setData({show_submit:1, submit: 0,same_ok:0,sub:0 })
1000 1019 return false;
1001 1020 }
1002 1021  
... ... @@ -1289,7 +1308,7 @@ Page({
1289 1308 // 提交订单前弹出确认对话框
1290 1309 submitConfirm(e) {
1291 1310 // is_show为0不显示温馨提示,为1显示温馨提示
1292   - if (this.data.param.is_show == 1) {
  1311 + if (this.data.param.is_show == 1 && !this.data.can_use_ord_prom[this.data.bn_pick]) {
1293 1312 wx.showModal({
1294 1313 title: '温馨提示',
1295 1314 content: this.data.param.alert,
... ... @@ -1451,6 +1470,34 @@ Page({
1451 1470 'prom_id': th.data.param.group_id, //促销活动id
1452 1471 };
1453 1472  
  1473 +
  1474 + if(th.data.bn_goods.discount_field){
  1475 + goods.discount_field=th.data.bn_goods.discount_field;
  1476 + }
  1477 +
  1478 + //如果有参与非实收的订单促销,那么就相当于是普通购买
  1479 + if(th.data.can_use_ord_prom[th.data.bn_pick]){
  1480 + goods.is_integral_normal=1;
  1481 + goods.prom_type=0;
  1482 + goods.prom_id=0;
  1483 +
  1484 + //如果是指定门店,就要判断
  1485 + if (th.data.bn_goods.pick_group_ids) {
  1486 + var idx0 = th.data.bn_goods.pick_up_lists.findIndex(function (e) {
  1487 + return e.pickup_id == th.data.bn_pick;
  1488 + })
  1489 + if (idx0 < 0) {
  1490 + getApp().my_warnning(th.data.bn_goods.goods_name + "的门店不可售", 0, th);
  1491 + th.data.is_summit_ing = 0;
  1492 + th.setData({
  1493 + submit: 0
  1494 + })
  1495 + return false;
  1496 + }
  1497 + }
  1498 +
  1499 + }
  1500 +
1454 1501 if (getApp().globalData.skinface_id) {
1455 1502 goods.skinface_id = getApp().globalData.skinface_id;
1456 1503 }
... ... @@ -2085,9 +2132,149 @@ Page({
2085 2132 th.calculatePrice2();
2086 2133 },
2087 2134  
  2135 + //-- 获取订单促销的判断结构 --
  2136 + set_by_now_ord_prom(item){
  2137 + let pickid=this.data.bn_pick;
  2138 + let order_prom_map_ck= this.data.order_prom_map_ck;
  2139 + order_prom_map_ck[pickid]={
  2140 + shop_price_all:0, //手店价的累计
  2141 + market_price_all:0, //市场价的累计
  2142 + goods_price_all:0, //实收价的累计
  2143 + no_ord_price:0, //要累计上不参与订单促销的金额
  2144 + goodsList:[],
  2145 + }
  2146 +
  2147 + let pk_ord_map=order_prom_map_ck[pickid];
  2148 + pk_ord_map.shop_price_all += item.shop_price_y * item.buynum;
  2149 + pk_ord_map.market_price_all += item.goods_market_price * item.buynum;
  2150 +
  2151 + },
  2152 +
  2153 + //获取当前进行中订单促销,同时带入相应的金额判断订单促销是不是运行,同时订单促销的条件不是实收价判断的话,默认的时候,订单促销是不参与运算的
  2154 + async get_cur_ord_prom(pickid) {
  2155 + let ord_prom = null;
  2156 + let order_prom_map_ck = this.data.order_prom_map_ck[pickid];
  2157 + if(!order_prom_map_ck) return null;
  2158 +
  2159 + //获取当前进行中的优惠促销
  2160 + await getApp().request.promiseGet("/api/weshop/promorder/getPromOrder", {
  2161 + data: {
  2162 + store_id: os.stoid,
  2163 + orderAmount: -1, //-1为不判断金额条件
  2164 + user_id: getApp().globalData.user_id
  2165 + }
  2166 + }).then(res => {
  2167 + if (res.data.code == 0) {
  2168 + ord_prom = res.data.data;
  2169 + }
  2170 + })
2088 2171  
  2172 + if (!ord_prom) return null;
  2173 + //用于计算订单促销的金额
  2174 + let calculate_price=0;
2089 2175  
  2176 + let txt1='show_ord_prom['+pickid+']';
  2177 + //-- 此时判断活动的金额满足与否 --
  2178 + switch (ord_prom.discount_field) {
  2179 + //实收价的时候
  2180 + case 0:
  2181 + //要先还原
  2182 + this.setData({
  2183 + [txt1]: 0
  2184 + });
  2185 +
  2186 + if (ord_prom.money > order_prom_map_ck.goods_price_all){
  2187 + return null;
  2188 + }
  2189 + break;
  2190 + //手店价的时候
  2191 + case 1:
  2192 + if (ord_prom.money > order_prom_map_ck.shop_price_all){
  2193 + //要先还原
  2194 + this.setData({
  2195 + [txt1]: 0
  2196 + });
  2197 + return null;
  2198 + }
  2199 + //要显示订单促销使用的按钮
  2200 + this.setData({
  2201 + [txt1]: 1
  2202 + });
  2203 + break;
  2204 + //市场价的时候
  2205 + case 2:
  2206 + if (ord_prom.money > order_prom_map_ck.market_price_all){
  2207 + //要先还原
  2208 + this.setData({
  2209 + [txt1]: 0
  2210 + });
  2211 + return null;
  2212 + }
  2213 + //要显示订单促销使用的按钮
  2214 + this.setData({
  2215 + [txt1]: 2
  2216 + });
  2217 + break;
  2218 + }
  2219 + //如果订单促销是不参与订单促销的,那么就直接返回null(订单促销不是实收价的时候)
  2220 + if(ord_prom.discount_field>0 && !this.data.can_use_ord_prom[pickid]){
  2221 + return null;
  2222 + }
  2223 + return ord_prom;
  2224 + },
  2225 +
  2226 + //立即购买的时候,点击订单促销的参与
  2227 + set_can_use_ord_prom_now:function (e){
  2228 +
  2229 + if(this.data.sub) return false;
  2230 + this.setData({ sub: 1,same_ok:1 });
  2231 +
  2232 + let pickid=this.data.bn_pick;
  2233 + let txt = 'can_use_ord_prom[' + pickid + ']';
  2234 + let can_use = this.data.can_use_ord_prom[pickid] ? this.data.can_use_ord_prom[pickid] : 0;
  2235 + this.setData({
  2236 + [txt]: !can_use
  2237 + })
  2238 +
  2239 + let th=this;
  2240 + let good=th.data.bn_goods;
  2241 + let param=th.data.param;
  2242 +
  2243 + //如果有要参与订单促销的按钮点击后,要修改商品的价格
  2244 + if(th.data.can_use_ord_prom[pickid]){
  2245 + let discount_field=th.data.show_ord_prom[pickid];
  2246 + switch (discount_field){
  2247 + case 1:
  2248 + good.shop_price=good.shop_price_y;
  2249 + param.goods_price=good.shop_price_y;
  2250 + break;
  2251 + case 2:
  2252 + good.shop_price=good.market_price;
  2253 + param.goods_price=good.market_price;
  2254 + break;
  2255 + }
  2256 + //-- 转成普通商品 ---
  2257 + good.prom_type=0;
  2258 + good.prom_id=0;
  2259 + good.discount_field=discount_field;
  2260 +
  2261 +
  2262 + }else{
  2263 + good=ut.deep_cp(th.data.old_bn_goods);
  2264 + param.goods_price=good.goods_price;
  2265 + }
  2266 +
  2267 + th.setData({
  2268 + bn_goods:good,
  2269 + param
  2270 + })
  2271 + wx.showLoading({
  2272 + title: "处理中.",
  2273 + mark:true
  2274 + })
  2275 + th.calculatePrice2()
2090 2276  
  2277 + }
2091 2278  
2092 2279  
2093 2280 });
... ...
packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.wxml
... ... @@ -100,6 +100,14 @@
100 100 <icon color="#f23030" size="16" type="info"></icon>{{order.store_prom}}
101 101 </view>
102 102  
  103 + <!-- 订单促销取价规则的优化 -->
  104 + <view class="set-mes" wx:if="{{show_ord_prom[bn_pick]}}">
  105 + <view class="use-item" >
  106 + <icon bindtap='set_can_use_ord_prom_now' color="{{can_use_ord_prom[bn_pick]?'red':'gray'}}" size="16" type="success"></icon>
  107 + <view bindtap='set_can_use_ord_prom_now' class="yu_er">参与订单促销</view>
  108 + </view>
  109 + </view>
  110 +
103 111 <!--阶梯团是不显示的-->
104 112 <block wx:if="{{bn_exp_type==0 && !is_default_logistics}}">
105 113 <view class="use-item flex-space-between" wx:if="{{kt_type!=3 || is_normal==1}}">
... ...
packageC/pages/presell/cart/cart.js
... ... @@ -2198,6 +2198,9 @@ Page({
2198 2198 }).then(res => {
2199 2199 if (res.data.code == 0) {
2200 2200 prom_ord = res.data.data;
  2201 +
  2202 + //如果订单促销的取价不是实收,清空订单促销
  2203 + if(prom_ord && prom_ord.discount_field>0) prom_ord=null;
2201 2204 }
2202 2205  
2203 2206 })
... ...
packageC/pages/presell/cart/cart2.js
... ... @@ -134,7 +134,14 @@ Page({
134 134 bconfig:null,
135 135 showFold:true,
136 136  
137   - is_fwk:0 //-- 判断是不是服务卡项订单 --
  137 + is_fwk:0, //-- 判断是不是服务卡项订单 --
  138 +
  139 + //-- 订单促销判断积累 ---2024-2-20
  140 + order_prom_map_ck: {},
  141 + //能不能使用订单促销
  142 + can_use_ord_prom:{},
  143 + //存储订单促销的取价,按照门店进行索引
  144 + show_ord_prom:{},
138 145 },
139 146  
140 147  
... ... @@ -595,7 +602,7 @@ Page({
595 602 });
596 603 },
597 604  
598   - //-- 获取到服务卡项的详情 --
  605 + //-- 获取到商品的详情 --
599 606 get_goods_detail(act, prelist,gg){
600 607 var th = this;
601 608 //--------如果goods_id一样,就是要立即购买-----
... ... @@ -728,7 +735,10 @@ Page({
728 735 }
729 736  
730 737 //这个位置要拿活动的预售价
  738 + t.data.data.shop_price_y = t.data.data.shop_price;
731 739 t.data.data.shop_price = prelist.presell_money;
  740 + th.data.old_bn_goods=ut.deep_cp(t.data.data);
  741 +
732 742 th.setData({
733 743 bn_goods: t.data.data,
734 744 bn_pickname: gg.pick_name,
... ... @@ -832,6 +842,7 @@ Page({
832 842 // }
833 843  
834 844 th.setData({dis_btn:1})
  845 + this.data.submit=0;
835 846  
836 847 wx.showLoading({
837 848 title: "处理中.",mask:true
... ... @@ -901,14 +912,18 @@ Page({
901 912 //-- 判断订单优惠的叠加 --
902 913 var ord_prom=null;
903 914 var o_condition=allpice;
904   - if (o_condition > 0 && th.data.act.is_useorderyh) {
905   - await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", {
906   - data: { store_id: os.stoid, orderAmount: o_condition, user_id: getApp().globalData.user_id }
907   - }).then(res => {
908   - if (res.data.code == 0) {
909   - ord_prom = res.data.data;
910   - }
911   - })
  915 + if (th.data.act.is_useorderyh) {
  916 + // await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", {
  917 + // data: { store_id: os.stoid, orderAmount: o_condition, user_id: getApp().globalData.user_id }
  918 + // }).then(res => {
  919 + // if (res.data.code == 0) {
  920 + // ord_prom = res.data.data;
  921 + // }
  922 + // })
  923 +
  924 + th.set_by_now_ord_prom(th.data.bn_goods);
  925 + th.data.order_prom_map_ck[bn_pick].goods_price_all=o_condition;
  926 + ord_prom=await th.get_cur_ord_prom(bn_pick);
912 927 }
913 928  
914 929 //-----------当地址不为空,且是物流时,计算物流费用,并同时商品不是优惠活动的包邮,同时商品购买时候,服务卡项购买不计算运费----------
... ... @@ -1568,6 +1583,33 @@ Page({
1568 1583 'prom_id': th.data.bn_goods.prom_id, //促销活动id
1569 1584 };
1570 1585  
  1586 + if(th.data.bn_goods.discount_field){
  1587 + goods.discount_field=th.data.bn_goods.discount_field;
  1588 + }
  1589 +
  1590 + //如果有参与非实收的订单促销,那么就相当于是普通购买
  1591 + if(th.data.can_use_ord_prom[th.data.bn_pick]){
  1592 + goods.is_integral_normal=1;
  1593 + //如果是指定门店,就要判断
  1594 + if (th.data.bn_goods.pick_group_ids) {
  1595 + var idx0 = th.data.bn_goods.pick_up_lists.findIndex(function (e) {
  1596 + return e.pickup_id == th.data.bn_pick;
  1597 + })
  1598 + if (idx0 < 0) {
  1599 + getApp().my_warnning(th.data.bn_goods.goods_name + "的门店不可售", 0, th);
  1600 + th.data.is_summit_ing = 0;
  1601 + th.setData({
  1602 + submit: 0
  1603 + })
  1604 + return false;
  1605 + }
  1606 + }
  1607 +
  1608 +
  1609 + }
  1610 +
  1611 +
  1612 +
1571 1613 if(getApp().globalData.skinface_id){
1572 1614 goods.skinface_id=getApp().globalData.skinface_id;
1573 1615 }
... ... @@ -3179,8 +3221,158 @@ Page({
3179 3221 url= "/pages/goods/goodsInfo/goodsInfo?goods_id="+gid;
3180 3222 }
3181 3223 getApp().goto(url);
  3224 + },
  3225 +
  3226 +
  3227 + //-- 获取订单促销的判断结构 --
  3228 + set_by_now_ord_prom(item){
  3229 + let pickid=this.data.bn_pick;
  3230 + let order_prom_map_ck= this.data.order_prom_map_ck;
  3231 + order_prom_map_ck[pickid]={
  3232 + shop_price_all:0, //手店价的累计
  3233 + market_price_all:0, //市场价的累计
  3234 + goods_price_all:0, //实收价的累计
  3235 + no_ord_price:0, //要累计上不参与订单促销的金额
  3236 + goodsList:[],
  3237 + }
  3238 +
  3239 + let pk_ord_map=order_prom_map_ck[pickid];
  3240 + pk_ord_map.shop_price_all += item.shop_price_y * item.buynum;
  3241 + pk_ord_map.market_price_all += item.goods_market_price * item.buynum;
  3242 +
  3243 + },
  3244 +
  3245 + //获取当前进行中订单促销,同时带入相应的金额判断订单促销是不是运行,同时订单促销的条件不是实收价判断的话,默认的时候,订单促销是不参与运算的
  3246 + async get_cur_ord_prom(pickid) {
  3247 + let ord_prom = null;
  3248 + let order_prom_map_ck = this.data.order_prom_map_ck[pickid];
  3249 + if(!order_prom_map_ck) return null;
  3250 +
  3251 + //获取当前进行中的优惠促销
  3252 + await getApp().request.promiseGet("/api/weshop/promorder/getPromOrder", {
  3253 + data: {
  3254 + store_id: os.stoid,
  3255 + orderAmount: -1, //-1为不判断金额条件
  3256 + user_id: getApp().globalData.user_id
  3257 + }
  3258 + }).then(res => {
  3259 + if (res.data.code == 0) {
  3260 + ord_prom = res.data.data;
  3261 + }
  3262 + })
  3263 +
  3264 + if (!ord_prom) return null;
  3265 + //用于计算订单促销的金额
  3266 + let calculate_price=0;
  3267 +
  3268 + let txt1='show_ord_prom['+pickid+']';
  3269 + //-- 此时判断活动的金额满足与否 --
  3270 + switch (ord_prom.discount_field) {
  3271 + //实收价的时候
  3272 + case 0:
  3273 + //要先还原
  3274 + this.setData({
  3275 + [txt1]: 0
  3276 + });
  3277 +
  3278 + if (ord_prom.money > order_prom_map_ck.goods_price_all){
  3279 + return null;
  3280 + }
  3281 + break;
  3282 + //手店价的时候
  3283 + case 1:
  3284 + if (ord_prom.money > order_prom_map_ck.shop_price_all){
  3285 + //要先还原
  3286 + this.setData({
  3287 + [txt1]: 0
  3288 + });
  3289 + return null;
  3290 + }
  3291 + //要显示订单促销使用的按钮
  3292 + this.setData({
  3293 + [txt1]: 1
  3294 + });
  3295 + break;
  3296 + //市场价的时候
  3297 + case 2:
  3298 + if (ord_prom.money > order_prom_map_ck.market_price_all){
  3299 + //要先还原
  3300 + this.setData({
  3301 + [txt1]: 0
  3302 + });
  3303 + return null;
  3304 + }
  3305 + //要显示订单促销使用的按钮
  3306 + this.setData({
  3307 + [txt1]: 2
  3308 + });
  3309 + break;
  3310 + }
  3311 + //如果订单促销是不参与订单促销的,那么就直接返回null(订单促销不是实收价的时候)
  3312 + if(ord_prom.discount_field>0 && !this.data.can_use_ord_prom[pickid]){
  3313 + return null;
  3314 + }
  3315 + return ord_prom;
  3316 + },
  3317 +
  3318 + //立即购买的时候,点击订单促销的参与
  3319 + set_can_use_ord_prom_now:function (e){
  3320 +
  3321 + if(this.data.submit || this.data.dis_btn) return false;
  3322 + this.data.submit=1;
  3323 +
  3324 + let pickid=this.data.bn_pick;
  3325 + let txt = 'can_use_ord_prom[' + pickid + ']';
  3326 + let can_use = this.data.can_use_ord_prom[pickid] ? this.data.can_use_ord_prom[pickid] : 0;
  3327 + this.setData({
  3328 + [txt]: !can_use
  3329 + })
  3330 +
  3331 + let th=this;
  3332 + let good=th.data.bn_goods;
  3333 +
  3334 + //如果有要参与订单促销的按钮点击后,要修改商品的价格
  3335 + if(th.data.can_use_ord_prom[pickid]){
  3336 + let discount_field=th.data.show_ord_prom[pickid];
  3337 + switch (discount_field){
  3338 + case 1:
  3339 + good.shop_price=good.shop_price_y;
  3340 + break;
  3341 + case 2:
  3342 + good.shop_price=good.market_price;
  3343 + break;
  3344 + }
  3345 + //-- 转成普通商品 ---
  3346 + good.prom_type=0;
  3347 + good.prom_id=0;
  3348 + good.integral=0;
  3349 + good.discount_field=discount_field;
  3350 +
  3351 + //把优惠券的使用还原
  3352 + th.setData({
  3353 + selected_quan_list: null,
  3354 + using_quan: {}
  3355 + })
  3356 +
  3357 + }else{
  3358 + good=ut.deep_cp(th.data.old_bn_goods);
  3359 + }
  3360 +
  3361 + th.setData({
  3362 + bn_goods:good
  3363 + })
  3364 + wx.showLoading({
  3365 + title: "处理中.",
  3366 + mark:true
  3367 + })
  3368 + th.calculatePrice2()
  3369 +
  3370 + if(!th.data.can_use_ord_prom[pickid]){
  3371 + th.get_buy_now_quan();
  3372 + }
3182 3373 }
3183 3374  
3184 3375  
3185 3376  
  3377 +
3186 3378 });
... ...
packageC/pages/presell/cart/cart2.wxml
... ... @@ -150,6 +150,15 @@
150 150 <icon color="#f23030" size="16" type="info"></icon>{{order.store_prom}}
151 151 </view>
152 152  
  153 + <!-- 订单促销取价规则的优化 -->
  154 + <view class="set-mes" wx:if="{{show_ord_prom[bn_pick]}}">
  155 + <view class="use-item" >
  156 + <icon bindtap='set_can_use_ord_prom_now' color="{{can_use_ord_prom[bn_pick]?'red':'gray'}}" size="16" type="success"></icon>
  157 + <view bindtap='set_can_use_ord_prom_now' class="yu_er">参与订单促销</view>
  158 + </view>
  159 + </view>
  160 +
  161 +
153 162 <view class="xc-coupon-frame flex-center" data-bn="1" bindtap="open_coupon_list" data-pickid="{{bn_pick}}" hidden="{{is_fwk}}"
154 163 wx:if="{{(selected_quan_list && selected_quan_list.length>0) || get_by_quan_list!=null}}">
155 164 <view class="work-frame flex-space-between">
... ...
packageE/pages/cart/cart2/cart2.js
... ... @@ -178,7 +178,15 @@ Page({
178 178 yhcx_act_map: {},
179 179  
180 180 //优惠促销购买次数
181   - yhcx_buy_map:{}
  181 + yhcx_buy_map:{},
  182 +
  183 + //-- 订单促销判断积累 ---2024-2-20
  184 + order_prom_map_ck: {},
  185 + //能不能使用订单促销
  186 + can_use_ord_prom:{},
  187 + //存储订单促销的取价,按照门店进行索引
  188 + show_ord_prom:{},
  189 +
182 190 },
183 191  
184 192  
... ... @@ -944,7 +952,8 @@ Page({
944 952 // }
945 953 // })
946 954  
947   - th.data.cartlist_y =JSON.parse(JSON.stringify(carr)); //存储原始购物车列表
  955 + th.data.cartlist_y =JSON.parse(JSON.stringify(carr)); //存储原始购物车列表,这个数据还会收到污染
  956 + th.data.cartlist_old =JSON.parse(JSON.stringify(carr)); //存储原始购物车列表
948 957 wx.showLoading();
949 958  
950 959 th.get_cart_next(carr);
... ... @@ -1028,33 +1037,35 @@ Page({
1028 1037 var no_zh_num={};
1029 1038 //-- 多促销活动调用接口需要的参数,和商品的购买数量和活动的购买数量的请求参数 --
1030 1039  
1031   - if(!is_change){
  1040 + if(!is_change) {
  1041 + //-- 多促销活动调用接口需要的参数,和商品的购买数量和活动的购买数量的请求参数 --
1032 1042 var dug_cx_arr = [];
1033 1043 //获取 限购 和 多活动的促销---2024-2-1
1034   - for (var i = 0; i < carr.length; i++) {
  1044 + for (var iv = 0; iv < carr.length; iv++) {
1035 1045  
1036   - let item1 = carr[i];
  1046 + let item1 = carr[iv];
1037 1047 //如果不是活动的时候,不是代发商品的时候,不是赠品的时候,不是阶梯商品拆分的,不是组合购拆分的
1038   - if([1, 2, 4, 6, 8, 9].indexOf(item1.prom_type)== -1 && !item1.whsle_id
1039   - && !item1.is_gift && !item1.is_ld_split && !item1.is_zh_split ){
  1048 + if ([1, 2, 4, 6, 8, 9].indexOf(item1.prom_type) == -1 && !item1.whsle_id
  1049 + && !item1.is_gift && !item1.is_ld_split && !item1.is_zh_split) {
1040 1050 //-- 快速查找,组装查询多活动的列表 --
1041   - let f_idx=dug_cx_arr.findIndex(function (ele) {
  1051 + let f_idx = dug_cx_arr.findIndex(function (ele) {
1042 1052 return ele.goods_id == item1.goods_id
1043 1053 });
1044   - if(f_idx==-1) {
1045   - let gd_ite={
1046   - goods_id:carr[i].goods_id,
1047   - goods_num:1,
1048   - is_limit_show:1,
1049   - is_state:0
  1054 + if (f_idx == -1) {
  1055 + let gd_ite = {
  1056 + goods_id: carr[iv].goods_id,
  1057 + goods_num: 1,
  1058 + is_limit_show: 1,
  1059 + is_state: 0
1050 1060 }
1051 1061 dug_cx_arr.push(gd_ite);
1052 1062 }
1053 1063  
1054 1064 }
1055 1065  
1056   - if(is_change){
1057   - carr[i].collocationList=null;
  1066 +
  1067 + if (is_change) {
  1068 + carr[iv].collocationList = null;
1058 1069 }
1059 1070 }
1060 1071 //-- 对商品的多促销进行判断 ---2024-2-1--
... ... @@ -1062,11 +1073,45 @@ Page({
1062 1073 await th.buy_pro_group(dug_cx_arr,carr);
1063 1074 }
1064 1075 }
1065   -
1066   -
1067 1076 //在分组的时候,就不要再调用接口,await
1068 1077 for (var i = 0; i < carr.length; i++) {
1069 1078 var item = carr[i];
  1079 +
  1080 + //如果有户有点击参与订单促销的话,那么可以参与订单促销的商品的活动都要清理成0,订单促销在使用过程中的重要方法
  1081 + if (this.data.can_use_ord_prom[item.pick_id]) {
  1082 + //从订单促销的order_prom_map_ck数据结构中获取到可以参与的商品列表
  1083 + let gdlist = this.data.order_prom_map_ck[item.pick_id] ? this.data.order_prom_map_ck[item.pick_id].goodsList : null;
  1084 + if (gdlist && gdlist.length) {
  1085 + //查找商品item1有没有在gdlist中,就要把商品的prom_type清理0
  1086 + let f_idx = gdlist.findIndex(function (ele) {
  1087 + return ele.id == item.id
  1088 + });
  1089 + if (f_idx != -1) {
  1090 + //开始变换商品的价格显示
  1091 + switch (th.data.show_ord_prom[item.pick_id]) {
  1092 + case 1:
  1093 + carr[i].goods_price = item.shop_price;
  1094 + break;
  1095 + case 2:
  1096 + carr[i].goods_price = item.goods_market_price;
  1097 + break;
  1098 + }
  1099 +
  1100 + if(!carr[i].prom_type) carr[i].prom_type=0;
  1101 + switch (parseInt(carr[i].prom_type)){
  1102 + case 4:
  1103 + carr[i].is_integral_normal = 1;
  1104 + break;
  1105 + default:
  1106 + carr[i].is_pd_normal = 1;
  1107 + break;
  1108 + }
  1109 + carr[i].prom_type = 0;
  1110 + carr[i].discount_field = th.data.show_ord_prom[item.pick_id];
  1111 + }
  1112 + }
  1113 + }
  1114 +
1070 1115 //-- 如果是等级会员注册返回 --
1071 1116 if (is_card_back) {
1072 1117 th.data.card_name = th.data.userinfo.card_field;
... ... @@ -1290,11 +1335,8 @@ Page({
1290 1335 if (ie.exp_type == 0 || ie.exp_type == 2) is_a_zt= 0;
1291 1336 }
1292 1337 th.setData({ is_all_zt: is_a_zt});
1293   -
1294 1338 }
1295 1339  
1296   -
1297   -
1298 1340 var cart_commission = 0;
1299 1341 //-- 循环计算一下线下取价 --
1300 1342 for (var k = 0; k < arr.length; k++) {
... ... @@ -1344,6 +1386,26 @@ Page({
1344 1386 //-- 如果初始活动在计算的时候,是不满足的时候,就要把活动清理掉 --
1345 1387 var is_no_ok=arr[k].show_can_cx[key_o].cur_act.is_no_ok;
1346 1388 if(is_no_ok==1){
  1389 +
  1390 + let temp_id=arr[k].show_can_cx[key_o].cur_act.prom_id;
  1391 + switch (parseInt(arr[k].show_can_cx[key_o].cur_act.prom_type+'')){
  1392 + case 3:
  1393 + var yhcx_act_map=th.data.yhcx_act_map?th.data.yhcx_act_map[temp_id]:null;
  1394 + if(yhcx_act_map && !yhcx_act_map.is_order_yh){
  1395 + item1.is_no_order_yh=1;
  1396 + }
  1397 + break;
  1398 + case 7:
  1399 + var zhhe_act=th.data.zhhe_act_map?th.data.zhhe_act_map[temp_id]:null;
  1400 + if(zhhe_act && !zhhe_act.is_orderyh){
  1401 + item1.is_no_order_yh=1;
  1402 + }
  1403 + break;
  1404 + }
  1405 +
  1406 + debugger;
  1407 +
  1408 +
1347 1409 item1.prom_id = 0;
1348 1410 item1.prom_type = 0;
1349 1411  
... ... @@ -1352,6 +1414,16 @@ Page({
1352 1414 item1.is_act_last=1; //这个是要在前端显示按钮切换的
1353 1415 }
1354 1416  
  1417 + }else{
  1418 +
  1419 + let obj=arr[k].show_can_cx[key_o];
  1420 + //不是优惠促销的不参与 不是订单促销参与(订单促销不是实收价的时候)
  1421 + let ck1=obj.no_cj_prom && obj.cur_act.prom_type==3;
  1422 + let ck2=th.data.can_use_ord_prom[arr[k].pickup_id];
  1423 + if( !ck1 && !ck2){
  1424 + item1.prom_id = arr[k].show_can_cx[key_o].cur_act.prom_id;
  1425 + item1.prom_type = arr[k].show_can_cx[key_o].cur_act.prom_type;
  1426 + }
1355 1427 }
1356 1428 }
1357 1429 }
... ... @@ -1463,8 +1535,6 @@ Page({
1463 1535  
1464 1536  
1465 1537 } else {
1466   -
1467   -
1468 1538 item1.act = th.data.zhhe_act_map[item1.prom_id];
1469 1539 }
1470 1540 }
... ... @@ -1609,7 +1679,6 @@ Page({
1609 1679 prom_type: item[c].prom_type,
1610 1680 prom_id: item[c].prom_id,
1611 1681 }
1612   - //单个就不调用了
1613 1682 // let req_d1 = {
1614 1683 // user_id: getApp().globalData.user_id, goods_ids: [hr], store_id: os.stoid
1615 1684 // }
... ... @@ -2094,6 +2163,8 @@ Page({
2094 2163 success: async function (tt) {
2095 2164 if (tt.data.code == 0) {
2096 2165 //t.data.data.shop_price = tt.data.data.prom_price;
  2166 +
  2167 + gd.shop_price_y=gd.shop_price;
2097 2168 gd.shop_price=t.data.data.shop_price = tt.data.data.prom_user_price;
2098 2169 th.data.ckeck_quan_price = 0;
2099 2170  
... ... @@ -2142,6 +2213,9 @@ Page({
2142 2213 }
2143 2214  
2144 2215  
  2216 + //用深拷贝把商品缓存起来,方便后面使用
  2217 + th.data.old_bn_goods=ut.deep_cp(gd);
  2218 +
2145 2219 th.setData({
2146 2220 bn_goods: gd,
2147 2221 bn_pickname: gg.pick_name,
... ... @@ -2170,6 +2244,7 @@ Page({
2170 2244 ut.get_active_info(2,gd.prom_id,os.stoid,function(e){
2171 2245  
2172 2246 //t.data.data.shop_price = tt.data.data.prom_price;
  2247 + gd.shop_price_y=gd.shop_price;
2173 2248 gd.shop_price=t.data.data.shop_price = tt.data.data.price;
2174 2249  
2175 2250 t.data.data.fir_rate = tt.data.data.fir_rate;
... ... @@ -2209,6 +2284,10 @@ Page({
2209 2284 gd.is_xz_yh = 1;
2210 2285 }
2211 2286  
  2287 +
  2288 + //用深拷贝把商品缓存起来,方便后面使用
  2289 + th.data.old_bn_goods=ut.deep_cp(gd);
  2290 +
2212 2291 th.setData({
2213 2292 bn_goods: gd,
2214 2293 bn_pickname: gg.pick_name,
... ... @@ -2980,6 +3059,9 @@ Page({
2980 3059 }
2981 3060 }
2982 3061  
  3062 + //重置订单促销判断累计
  3063 + this.re_set_order_prom_map_ck();
  3064 +
2983 3065 for (var i in c_arr) {
2984 3066 var cart_item = c_arr[i];
2985 3067 cart_item.prom_pt_json=[];
... ... @@ -2996,6 +3078,7 @@ Page({
2996 3078  
2997 3079 }
2998 3080  
  3081 +
2999 3082 //调用函数计算每件商品的单价
3000 3083 await th.calc_per(c_arr);
3001 3084  
... ... @@ -3009,7 +3092,7 @@ Page({
3009 3092  
3010 3093 //-- 经纬度不循环调用接口 --
3011 3094 var lon = 0; var lat = 0;
3012   - //---循环购物车---
  3095 + //---循环购物车,按照门店订单进行循环---
3013 3096 for (var i in c_arr) {
3014 3097 //因为搭配购买也是再这里计算,搭配购的is_b_now==1
3015 3098 if (th.data.is_b_now == 0) {
... ... @@ -3047,15 +3130,15 @@ Page({
3047 3130  
3048 3131 var no_order_yh = 0; //-- 有些活动不能和订单优惠叠加的金额 --
3049 3132 var no_post_temp = 0; //-- 有些活动不能和包邮模板的金额 --
  3133 + var no_post_temp_shop_price = 0; //-- 有些活动不能和包邮模板的金额 --因为订单促销有手店价取价
  3134 + var no_post_temp_market_price = 0; //-- 有些活动不能和包邮模板的金额 --因为订单促销有市场价取价
3050 3135  
3051 3136 if (th.data.using_quan[pickid] != null && th.data.using_quan[pickid] != undefined)
3052 3137 quan_no = th.data.using_quan[pickid].coupon_no;
3053 3138  
3054 3139 //普通券的时候
3055 3140 if (quan_no && th.data.using_quan[pickid].isby != 1) {
3056   -
3057 3141 var IsUserWare=1;
3058   -
3059 3142 //---获取优惠券优惠---
3060 3143 await getApp().request.promiseGet("/api/weshop/couponList/getUseCouponPrice", {
3061 3144 data: {
... ... @@ -3076,13 +3159,10 @@ Page({
3076 3159 quan_price=0;
3077 3160 break;
3078 3161 }
3079   -
3080 3162 }
3081   -
3082 3163 }
3083 3164 })
3084 3165  
3085   -
3086 3166 if(!IsUserWare){
3087 3167  
3088 3168 wx.showToast({
... ... @@ -3112,6 +3192,11 @@ Page({
3112 3192  
3113 3193 //--------循环计算总价-----------
3114 3194 for (var jc = 0; jc < item.length; jc++) {
  3195 + //如果item的prom_type==0,没有如果活动的时候,如果是优惠促销和组合促销不满足的时候
  3196 + //或者是组合购和阶梯购多出来的商品
  3197 + if (item[jc].prom_type == 0 && !item[jc].whsle_id && !item[jc].is_no_order_yh) {
  3198 + th.get_order_prom_map_ck(item[jc],pickid);
  3199 + }
3115 3200  
3116 3201 if (item[jc].whsle_id > 0) {
3117 3202 whsle_goods_price += item[jc].goods_price * item[jc].goods_num;
... ... @@ -3124,11 +3209,13 @@ Page({
3124 3209 if (item[jc].prom_type == 7 && th.data.zhhe_act_map && th.data.zhhe_act_map[item[jc].prom_id]
3125 3210 && th.data.zhhe_act_map[item[jc].prom_id].is_orderyh) {
3126 3211 is_no_zh = 1;
  3212 + th.get_order_prom_map_ck(item[jc],pickid); //有订单优惠叠加的时候,就要构建数据解救
3127 3213 }
3128 3214 //阶梯购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加,就要累积阶梯促销的金额
3129 3215 if (item[jc].prom_type == 10 && ladder_prom_goods && ladder_prom_goods[item[jc].prom_id]
3130 3216 && th.data.ladder_map[item[jc].prom_id].is_useorderyh) {
3131 3217 is_no_zh = 1;
  3218 + th.get_order_prom_map_ck(item[jc],pickid); //有订单优惠叠加的时候,就要构建数据解救
3132 3219 }
3133 3220  
3134 3221 if (is_no_zh) {
... ... @@ -3144,20 +3231,28 @@ Page({
3144 3231 var gd_price=item[jc].goods_price;
3145 3232 if(item[jc].account_fir) gd_price=item[jc].account_fir;
3146 3233  
3147   -
3148   - //组合购和阶梯购是订单优惠是另外算的
  3234 + //组合购和阶梯购是订单优惠是另外算的,不参与订单促销的时候
3149 3235 if(!item[jc].is_order_yh && !item[jc].whsle_id && item[jc].prom_type!=7 && item[jc].prom_type!=10){
3150 3236 no_order_yh+=gd_price * item[jc].goods_num;
3151 3237 if(item[jc].quan_num) no_order_yh-=item[jc].quan_num; //券要把他补回去
3152   -
3153 3238 }
  3239 + //参与订单促销的时候
  3240 + if(item[jc].is_order_yh && !item[jc].whsle_id && item[jc].prom_type!=7 && item[jc].prom_type!=10){
  3241 + th.get_order_prom_map_ck(item[jc],pickid); //有订单优惠叠加的时候,就要构建数据解救
  3242 + }
  3243 +
3154 3244 if(!item[jc].is_post_temp){
3155 3245 no_post_temp+=gd_price * item[jc].goods_num;
  3246 + no_post_temp_shop_price+=item[jc].shop_price * item[jc].goods_num;
  3247 + no_post_temp_market_price+=item[jc].goods_market_price * item[jc].goods_num;
3156 3248 if(item[jc].quan_num) no_post_temp-=item[jc].quan_num; //券要把他补回去
3157 3249 }
3158 3250 }
  3251 +
3159 3252 }
3160 3253  
  3254 +
  3255 +
3161 3256 //判断是不是有组合购的金额
3162 3257 var f_o_price = o_price;
3163 3258 //如果又优惠的钱,就要减价
... ... @@ -3236,21 +3331,33 @@ Page({
3236 3331 ord_prom_condition=o_price - quan_price - whsle_goods_price - no_order_yh;
3237 3332 }
3238 3333  
3239   - //---判断是不是有订单优惠---
3240   - await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", {
3241   - data: { store_id: os.stoid, orderAmount: parseFloat(ord_prom_condition).toFixed(2), user_id: getApp().globalData.user_id }
3242   - }).then(res => {
3243   - if (res.data.code == 0) {
3244   - ord_prom = res.data.data;
  3334 + //判断订单促销的实收价的累计
  3335 + if(!this.data.order_prom_map_ck[pickid]){
  3336 + this.data.order_prom_map_ck[pickid]={
  3337 + shop_price_all:0, //手店价的累计
  3338 + market_price_all:0, //市场价的累计
  3339 + goods_price_all:0, //实收价的累计
  3340 + no_ord_price:0, //要累计上不参与订单促销的金额
  3341 + goodsList:[],
3245 3342 }
3246   - })
  3343 + }
  3344 + this.data.order_prom_map_ck[pickid].goods_price_all=ord_prom_condition;
  3345 + //---判断是不是有订单优惠---
  3346 + // await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", {
  3347 + // data: { store_id: os.stoid, orderAmount: parseFloat(ord_prom_condition).toFixed(2), user_id: getApp().globalData.user_id }
  3348 + // }).then(res => {
  3349 + // if (res.data.code == 0) {
  3350 + // ord_prom = res.data.data;
  3351 + // }
  3352 + // })
  3353 + //获取当前时间段的进行中的订单促销
  3354 + ord_prom=await th.get_cur_ord_prom(pickid);
3247 3355  
3248 3356 //如果有使用优惠券,如何订单促销有控制使用优惠券不参与此活动的话
3249 3357 if(quan_price>0 && ord_prom && ord_prom.is_xz_yh ){
3250 3358 ord_prom=null;
3251 3359 }
3252 3360  
3253   -
3254 3361 //--如果是物流,且选择了地址,就要开始显示包邮券,且包邮券也已经优惠了优惠活动的金额--
3255 3362 if (cart_item.exp_type == 0 && th.data.user_addr != null && !cart_item.is_xz_yh) {
3256 3363  
... ... @@ -3300,10 +3407,23 @@ Page({
3300 3407  
3301 3408 //-- 如果没有订单优惠,或者订单优惠中有勾选包邮模板 --
3302 3409 if (!ord_prom || ord_prom.is_post_temp) {
3303   - var user_addr = th.data.user_addr;
  3410 +
  3411 + let user_addr = th.data.user_addr;
  3412 + let c_wuliu=parseFloat(o_price - quan_price - whsle_goods_price - no_post_temp).toFixed(2);
  3413 +
  3414 + //-- 因为订单促销的取价规则,所以要判断一下各种情况 --
  3415 + switch (ord_prom && ord_prom.discount_field){
  3416 + case 1:
  3417 + c_wuliu=parseFloat(ord_prom.real_condition_price - whsle_shop_price - no_post_temp_shop_price).toFixed(2);
  3418 + break;
  3419 + case 2:
  3420 + c_wuliu=parseFloat(ord_prom.real_condition_price - whsle_market_price - no_post_temp_market_price).toFixed(2);
  3421 + break;
  3422 + }
  3423 +
3304 3424 var req_d = {
3305 3425 province: user_addr.province, city: user_addr.city, district: user_addr.district,
3306   - wuliu: parseFloat(o_price - quan_price - whsle_goods_price - no_post_temp).toFixed(2), store_id: os.stoid
  3426 + wuliu: c_wuliu, store_id: os.stoid
3307 3427 }
3308 3428 await getApp().request.promisePost("/api/weshop/order/areaFreight", {
3309 3429 is_json: 1, data: req_d
... ... @@ -3313,7 +3433,6 @@ Page({
3313 3433 }
3314 3434 }
3315 3435  
3316   -
3317 3436 //如果是包邮券的时候,要看看券的情况
3318 3437 if (quan_no && th.data.using_quan[pickid].isby == 1) {
3319 3438 var quan = th.data.using_quan[pickid];
... ... @@ -3504,24 +3623,25 @@ Page({
3504 3623 }
3505 3624  
3506 3625 var order_m = 0;
3507   -
3508 3626 //么有使用券,或者活动没有限制使用优惠券
3509 3627 if (ord_prom && (quan_price <= 0 || !ord_prom.is_xz_yh)) {
3510   - order_prom_id = ord_prom['id'];
3511   - switch (ord_prom['type']) {
3512   - case 0:
3513   - order_m = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折
3514   - order_prom_amount = (o_condition - order_m).toFixed(2);
3515   - break;
3516   - case 1:
3517   - //order_m = o_condition - ord_prom['expression'];//满额优惠金额
3518   - var bs = 1;
3519   - if (ord_prom.is_bz) {
3520   - bs = Math.floor(o_condition / ord_prom.money);
3521   - }
3522   - order_prom_amount = ord_prom['expression'];
3523   - break;
3524   - }
  3628 + order_prom_id = ord_prom['id'];
  3629 + //-- 订单促销是按照实收价格进行计算的时候 --
  3630 + switch (ord_prom['type']) {
  3631 + case 0:
  3632 + order_m = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折
  3633 + order_prom_amount = (o_condition - order_m).toFixed(2);
  3634 + break;
  3635 + case 1:
  3636 + //order_m = o_condition - ord_prom['expression'];//满额优惠金额
  3637 + var bs = 1;
  3638 + if (ord_prom.is_bz) {
  3639 + bs = Math.floor(o_condition / ord_prom.money);
  3640 + }
  3641 + order_prom_amount = ord_prom['expression'];
  3642 + break;
  3643 + }
  3644 +
3525 3645 }
3526 3646  
3527 3647 cart_item.order_prom_amount = 0;
... ... @@ -3930,7 +4050,7 @@ Page({
3930 4050 //---如果有选择优惠券的情况下---
3931 4051 var quan_price = 0, bn_pick = th.data.bn_pick;
3932 4052 var quan_no = null;
3933   - if (th.data.using_quan[bn_pick] != null && th.data.using_quan[bn_pick] != undefined)
  4053 + if (th.data.using_quan && th.data.using_quan[bn_pick] != null && th.data.using_quan[bn_pick] != undefined)
3934 4054 quan_no = th.data.using_quan[bn_pick].coupon_no;
3935 4055  
3936 4056 if (quan_no) {
... ... @@ -3964,15 +4084,22 @@ Page({
3964 4084 var ord_prom = null;
3965 4085 var is_ord_prom_post = 0;
3966 4086  
3967   - if (condition > 0 && th.data.bn_is_order_yh && !th.data.bn_goods.whsle_id) {
3968   - await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", {
3969   - data: { store_id: os.stoid, orderAmount: condition, user_id: getApp().globalData.user_id }
3970   - }).then(res => {
3971   - if (res.data.code == 0) {
3972   - var data = res.data.data;
3973   - ord_prom = data;
3974   - }
3975   - })
  4087 + //一件代发商品不参与订单优惠, 本身商品的活动也有要不要参与优惠促销的设置bn_is_order_yh
  4088 + if (th.data.bn_is_order_yh && !th.data.bn_goods.whsle_id) {
  4089 +
  4090 + th.set_by_now_ord_prom(th.data.bn_goods);
  4091 + th.data.order_prom_map_ck[bn_pick].goods_price_all=condition;
  4092 +
  4093 + // await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", {
  4094 + // data: { store_id: os.stoid, orderAmount: condition, user_id: getApp().globalData.user_id }
  4095 + // }).then(res => {
  4096 + // if (res.data.code == 0) {
  4097 + // var data = res.data.data;
  4098 + // ord_prom = data;
  4099 + // }
  4100 + // })
  4101 + ord_prom=await th.get_cur_ord_prom(bn_pick);
  4102 +
3976 4103 if (ord_prom && ord_prom.is_post_temp) {
3977 4104 is_ord_prom_post = 1;
3978 4105 }
... ... @@ -4717,6 +4844,9 @@ Page({
4717 4844 if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) {
4718 4845 getApp().my_warnning("读取物流失败", 0, th);
4719 4846 th.data.is_summit_ing = 0;
  4847 + th.setData({
  4848 + submit: 0
  4849 + })
4720 4850 return false;
4721 4851 }
4722 4852  
... ... @@ -4853,6 +4983,29 @@ Page({
4853 4983 'prom_id': th.data.bn_goods.prom_id, //促销活动id
4854 4984 };
4855 4985  
  4986 + //如果有参与非实收的订单促销,那么就相当于是普通购买
  4987 + if (th.data.can_use_ord_prom[th.data.bn_pick]) {
  4988 + goods.is_pd_normal = 1;
  4989 + goods.discount_field = th.data.show_ord_prom[th.data.bn_pick];
  4990 +
  4991 + //如果是指定门店,就要判断
  4992 + if (th.data.bn_goods.pick_group_ids) {
  4993 + var idx0 = th.data.bn_goods.pick_up_lists.findIndex(function (e) {
  4994 + return e.pickup_id == th.data.bn_pick;
  4995 + })
  4996 + if (idx0 < 0) {
  4997 + getApp().my_warnning(th.data.bn_goods.goods_name + "的门店不可售", 0, th);
  4998 + th.data.is_summit_ing = 0;
  4999 + th.setData({
  5000 + submit: 0
  5001 + })
  5002 + return false;
  5003 + }
  5004 + }
  5005 + }
  5006 +
  5007 +
  5008 +
4856 5009 if (th.data.bn_goods.whsle_id) {
4857 5010 item.is_whsle = 1;
4858 5011 item.whsle_id = th.data.bn_goods.whsle_id;
... ... @@ -4903,11 +5056,17 @@ Page({
4903 5056 if(mo_num>goods.goods_num){
4904 5057 getApp().confirmBox(goods.goods_name + "的未达到起订数量");
4905 5058 th.data.is_summit_ing = 0;
  5059 + th.setData({
  5060 + submit: 0
  5061 + })
4906 5062 return false;
4907 5063 }
4908 5064 if(steep>1 && (goods.goods_num-mo_num)%steep!=0 ){
4909 5065 getApp().confirmBox(goods.goods_name + "的购买的数量不是起订量的倍数");
4910 5066 th.data.is_summit_ing = 0;
  5067 + th.setData({
  5068 + submit: 0
  5069 + })
4911 5070 return false;
4912 5071 }
4913 5072 }
... ... @@ -4922,6 +5081,9 @@ Page({
4922 5081 if (!isok) {
4923 5082 getApp().confirmBox("商品的门店库存不足");
4924 5083 th.data.is_summit_ing = 0;
  5084 + th.setData({
  5085 + submit: 0
  5086 + })
4925 5087 return false;
4926 5088 }
4927 5089 }
... ... @@ -5040,6 +5202,9 @@ Page({
5040 5202 if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) {
5041 5203 th.data.is_summit_ing = 0;
5042 5204 getApp().confirmBox("读取物流失败");
  5205 + th.setData({
  5206 + submit: 0
  5207 + })
5043 5208 return false;
5044 5209 }
5045 5210 }
... ... @@ -5246,6 +5411,26 @@ Page({
5246 5411 'store_id': oo.stoid,
5247 5412 };
5248 5413  
  5414 + //订单促销取价规则使用
  5415 + if (g_item.discount_field) {
  5416 + goods.discount_field =g_item.discount_field;
  5417 + //此时要判断商品的门店是不是匹配
  5418 + if(g_item.prom_type==0 && g_item.pick_group_ids){
  5419 + var idx0 = g_item.pick_up_lists.findIndex(function (e) {
  5420 + return e.pickup_id == item.pickup_id;
  5421 + })
  5422 + if (idx0 < 0) {
  5423 + getApp().my_warnning(g_item.goods_name + "的门店不可售", 0, th);
  5424 + th.data.is_summit_ing = 0;
  5425 + th.setData({
  5426 + submit: 0
  5427 + })
  5428 + return false;
  5429 + }
  5430 + }
  5431 +
  5432 + }
  5433 +
5249 5434 if (g_item.is_pd_normal) {
5250 5435 goods.is_pd_normal = 1;
5251 5436 }
... ... @@ -6531,6 +6716,7 @@ Page({
6531 6716 get_cart_quan: async function (order_prom_list_cart) {
6532 6717 var th = this;
6533 6718 var user_id = getApp().globalData.user_id;
  6719 +
6534 6720 //等待值的出现
6535 6721 //getApp().waitfor2(this,"g_cart_q_time","order_prom_list_cart",async function () {
6536 6722 //var arr=th.data.order_prom_list_cart;
... ... @@ -6542,6 +6728,12 @@ Page({
6542 6728 //------------开始计算使用优惠券相关------------
6543 6729 for (var ind in arr) {
6544 6730 var ep = arr[ind];
  6731 +
  6732 + //如果门店订单使用订单促销(此订单促销取价规则不是实收价的时候)
  6733 + if(th.data.can_use_ord_prom[ep.pickup_id]){
  6734 + continue;
  6735 + }
  6736 +
6545 6737 var goodlist = ep.goods;
6546 6738 var pickup_id = ep.pickup_id;
6547 6739 //--更优惠券抵用有关,立即购买的,如果是购物车,如果有等级价还有考虑等级价的东西
... ... @@ -8423,10 +8615,13 @@ Page({
8423 8615  
8424 8616 var cx_prom_group=this.data.cartlist[idx].show_can_cx[gd_key].act_arr;
8425 8617  
  8618 + //-- 切换活动的时候,让订单促销参与不选中 --
  8619 + let tt_wd="can_use_ord_prom["+pk+"]";
8426 8620 th.setData({
8427 8621 send_lb:{},
8428 8622 month_lb:{},
8429   - send_gf:{}
  8623 + send_gf:{},
  8624 + [tt_wd]:0
8430 8625 })
8431 8626  
8432 8627 th.data.prom_goods_map={};
... ... @@ -8635,6 +8830,9 @@ Page({
8635 8830  
8636 8831 //--- 不参与优惠促销的开关 ---
8637 8832 no_cj_prom: function (e) {
  8833 + //避免重复点击
  8834 + if(this.data.submit) return false;
  8835 + this.setData({ submit: 1,same_ok:1 });
8638 8836  
8639 8837 //重新调用cart_next,进行下一步计算
8640 8838 wx.showLoading({
... ... @@ -8719,16 +8917,245 @@ Page({
8719 8917 if(!goods[ig].is_gift){
8720 8918 n_goods.push(goods[ig]);
8721 8919 }
8722   - }
  8920 + }
  8921 +
8723 8922 //原始数据要有深拷贝不能有地址的牵连
8724 8923 th.data.cartlist_y = JSON.parse(JSON.stringify(n_goods))
  8924 + //重新调用cart_next,进行下一步计算
  8925 + wx.showLoading({
  8926 + title: "处理中.",
  8927 + })
  8928 + this.get_cart_next(null, 1, {prom_type: 0, prom_id: 0});
  8929 +
  8930 + },
  8931 +
  8932 + //---订单促销累计的数据结构的构建,购物车计算流程的那一部分
  8933 + get_order_prom_map_ck(item,pickid) {
8725 8934  
  8935 + //赠品不计算
  8936 + if(item.is_gift) return false;
8726 8937  
  8938 + var order_prom_map_ck= this.data.order_prom_map_ck;
  8939 + if(!order_prom_map_ck[pickid]){
  8940 + order_prom_map_ck[pickid]={
  8941 + shop_price_all:0, //手店价的累计
  8942 + market_price_all:0, //市场价的累计
  8943 + goods_price_all:0, //实收价的累计
  8944 + no_ord_price:0, //要累计上不参与订单促销的金额
  8945 + goodsList:[],
  8946 + }
  8947 + }
  8948 +
  8949 + let pk_ord_map=order_prom_map_ck[pickid];
  8950 + pk_ord_map.shop_price_all += item.shop_price * item.goods_num;
  8951 + pk_ord_map.market_price_all += item.goods_market_price * item.goods_num;
  8952 +
  8953 + let ite = {
  8954 + id: item.id,
  8955 + goods_id: item.goods_id,
  8956 + goods_num: item.goods_num,
  8957 + prom_type: item.prom_type
  8958 + }
  8959 + pk_ord_map.goodsList.push(ite);
  8960 + },
  8961 +
  8962 +
  8963 + //-- 秒杀和团购使用 --
  8964 + set_by_now_ord_prom(item){
  8965 + let pickid=this.data.bn_pick;
  8966 + let order_prom_map_ck= this.data.order_prom_map_ck;
  8967 + order_prom_map_ck[pickid]={
  8968 + shop_price_all:0, //手店价的累计
  8969 + market_price_all:0, //市场价的累计
  8970 + goods_price_all:0, //实收价的累计
  8971 + no_ord_price:0, //要累计上不参与订单促销的金额
  8972 + goodsList:[],
  8973 + }
8727 8974  
  8975 + let pk_ord_map=order_prom_map_ck[pickid];
  8976 + pk_ord_map.shop_price_all += item.shop_price_y * item.buynum;
  8977 + pk_ord_map.market_price_all += item.goods_market_price * item.buynum;
  8978 +
  8979 + },
  8980 +
  8981 + //重置订单促销判断累计
  8982 + re_set_order_prom_map_ck() {
  8983 + this.data.order_prom_map_ck = {}
  8984 + },
  8985 +
  8986 + //获取当前进行中订单促销,同时带入相应的金额判断订单促销是不是运行,同时订单促销的条件不是实收价判断的话,默认的时候,订单促销是不参与运算的
  8987 + async get_cur_ord_prom(pickid) {
  8988 + let ord_prom = null;
  8989 + let order_prom_map_ck = this.data.order_prom_map_ck[pickid];
  8990 + if(!order_prom_map_ck) return null;
  8991 +
  8992 + //获取当前进行中的优惠促销
  8993 + await getApp().request.promiseGet("/api/weshop/promorder/getPromOrder", {
  8994 + data: {
  8995 + store_id: os.stoid,
  8996 + orderAmount: -1, //-1为不判断金额条件
  8997 + user_id: getApp().globalData.user_id
  8998 + }
  8999 + }).then(res => {
  9000 + if (res.data.code == 0) {
  9001 + ord_prom = res.data.data;
  9002 + }
  9003 + })
  9004 +
  9005 + if (!ord_prom) return null;
  9006 + //用于计算订单促销的金额
  9007 + let calculate_price=0;
  9008 +
  9009 + let txt1='show_ord_prom['+pickid+']';
  9010 + //-- 此时判断活动的金额满足与否 --
  9011 + switch (ord_prom.discount_field) {
  9012 + //实收价的时候
  9013 + case 0:
  9014 + //要先还原
  9015 + this.setData({
  9016 + [txt1]: 0
  9017 + });
  9018 +
  9019 + if (ord_prom.money > order_prom_map_ck.goods_price_all){
  9020 + return null;
  9021 + }
  9022 + break;
  9023 + //手店价的时候
  9024 + case 1:
  9025 + if (ord_prom.money > order_prom_map_ck.shop_price_all){
  9026 + //要先还原
  9027 + this.setData({
  9028 + [txt1]: 0
  9029 + });
  9030 + return null;
  9031 + }
  9032 + //要显示订单促销使用的按钮
  9033 + this.setData({
  9034 + [txt1]: 1
  9035 + });
  9036 + break;
  9037 + //市场价的时候
  9038 + case 2:
  9039 + if (ord_prom.money > order_prom_map_ck.market_price_all){
  9040 + //要先还原
  9041 + this.setData({
  9042 + [txt1]: 0
  9043 + });
  9044 + return null;
  9045 + }
  9046 + //要显示订单促销使用的按钮
  9047 + this.setData({
  9048 + [txt1]: 2
  9049 + });
  9050 + break;
  9051 + }
  9052 + //如果订单促销是不参与订单促销的,那么就直接返回null(订单促销不是实收价的时候)
  9053 + if(ord_prom.discount_field>0 && !this.data.can_use_ord_prom[pickid]){
  9054 + return null;
  9055 + }
  9056 + return ord_prom;
  9057 + },
  9058 +
  9059 + //设置能够参与订单促销
  9060 + set_can_use_ord_prom: function (e) {
  9061 +
  9062 + if(this.data.submit) return false;
  9063 + this.setData({ submit: 1,same_ok:1 });
  9064 +
  9065 + let pickid = e.currentTarget.dataset.pd;
  9066 + let txt = 'can_use_ord_prom[' + pickid + ']';
  9067 + let can_use = this.data.can_use_ord_prom[pickid] ? this.data.can_use_ord_prom[pickid] : 0;
  9068 + this.setData({
  9069 + [txt]: !can_use
  9070 + })
  9071 +
  9072 + //购物车进行还原,一下数据的清理的必须的
  9073 + this.setData({
  9074 + send_lb: {},
  9075 + month_lb: {},
  9076 + send_gf: {}
  9077 + })
  9078 + //清空优惠促销的内容
  9079 + this.data.prom_goods_map = {};
  9080 +
  9081 + //处理一下商品
  9082 + let goods0 = JSON.parse(JSON.stringify(this.data.cartlist_y));
  9083 + let goods = [];
  9084 + for (var ik = 0; ik < goods0.length; ik++) {
  9085 + var item_c = goods0[ik];
  9086 + if(item_c.pick_id == pickid && item_c.is_collocation) continue;
  9087 + if(item_c.is_gift) continue
  9088 + goods.push(item_c);
  9089 + }
  9090 +
  9091 + //原始数据要有深拷贝不能有地址的牵连
  9092 + this.data.cartlist_y = JSON.parse(JSON.stringify(goods))
  9093 + //重新调用cart_next,进行下一步计算
  9094 + wx.showLoading({
  9095 + title: "处理中.",
  9096 + mark:true
  9097 + })
  9098 + //-- 重新计算一下价格 --
  9099 +>>>>>>> dev_oa_fuordercx
8728 9100 this.get_cart_next(null, 1, {prom_type: 0, prom_id: 0});
  9101 + },
  9102 +
  9103 + //立即购买的时候,点击订单促销的参与
  9104 + set_can_use_ord_prom_now:function (e){
8729 9105  
  9106 + if(this.data.submit) return false;
  9107 + this.setData({ submit: 1,same_ok:1 });
  9108 +
  9109 + let pickid=this.data.bn_pick;
  9110 + let txt = 'can_use_ord_prom[' + pickid + ']';
  9111 + let can_use = this.data.can_use_ord_prom[pickid] ? this.data.can_use_ord_prom[pickid] : 0;
  9112 + this.setData({
  9113 + [txt]: !can_use
  9114 + })
  9115 +
  9116 + let th=this;
  9117 + let good=th.data.bn_goods;
  9118 +
  9119 + //如果有要参与订单促销的按钮点击后,要修改商品的价格
  9120 + if(th.data.can_use_ord_prom[pickid]){
  9121 + let discount_field=th.data.show_ord_prom[pickid];
  9122 + switch (discount_field){
  9123 + case 1:
  9124 + good.shop_price=good.shop_price_y;
  9125 + break;
  9126 + case 2:
  9127 + good.shop_price=good.market_price;
  9128 + break;
  9129 + }
  9130 +
  9131 + //-- 转成普通商品 ---
  9132 + good.prom_type=0;
  9133 + good.prom_id=0;
  9134 +
  9135 + th.setData({
  9136 + selected_quan_list: null,
  9137 + using_quan:{}
  9138 + })
  9139 +
  9140 + }else{
  9141 + good=ut.deep_cp(th.data.old_bn_goods);
  9142 + }
8730 9143  
  9144 + th.setData({
  9145 + bn_goods:good
  9146 + })
  9147 + wx.showLoading({
  9148 + title: "处理中.",
  9149 + mark:true
  9150 + })
  9151 + th.calculatePrice2()
  9152 +
  9153 + if(!th.data.can_use_ord_prom[pickid]){
  9154 + th.get_buy_now_quan();
  9155 + }
8731 9156 }
8732 9157  
8733 9158  
  9159 +
  9160 +
8734 9161 });
... ...
packageE/pages/cart/cart2/cart2.wxml
... ... @@ -104,9 +104,9 @@
104 104 <block><text>{{filters.show_gui_ge(items.goods_spec,items.goods_color)}}</text></block>
105 105 </view>
106 106 </view>
107   -
108 107 <!-----商品名称规格------>
109 108 <view class="order-num flex-space-between">
  109 + <!-- 动态显示商品的价格 -->
110 110 <view wx:if="{{items.prom_type==10}}" class="co-red">¥<text class="fs36">{{filters.toFix(items.goods_price,2)}}</text><text>({{items.discount}}折)</text></view>
111 111 <view wx:else class="co-red">¥<text class="fs36">{{filters.toFix(items.goods_price,2)}}</text></view>
112 112 <view style="color: red;" wx:if="{{items.use_commission && items.use_commission*1>0}}">佣金:{{filters.toFix(items.use_commission/items.goods_num,2)}}*{{items.goods_num}}</view>
... ... @@ -171,8 +171,10 @@
171 171 </block>
172 172 </block>
173 173  
174   - <block wx:if="{{!items.is_gift}}">
175   - <view class="set-mes" wx:if="{{items.prom_type==3 || (items.prom_type==0 && item.show_can_cx[items.goods_id].no_cj_prom && item.show_can_cx[items.goods_id].sele_prom_type==3) }}">
  174 + <block wx:if="{{!items.is_gift}}">
  175 + <!-- 如果不是点击使用订单促销的话 -->
  176 + <block wx:if="{{!can_use_ord_prom[item.pickup_id]}}">
  177 + <view class="set-mes" wx:if="{{items.prom_type==3 || (items.prom_type==0 && item.show_can_cx[items.goods_id].no_cj_prom && item.show_can_cx[items.goods_id].sele_prom_type==3) }}">
176 178 <view class="use-item" data-pidx="{{pidx}}" data-can_cx_idx="{{items.goods_id}}" bindtap='no_cj_prom'>
177 179 <icon color="{{!item.show_can_cx[items.goods_id].no_cj_prom?'red':'gray'}}" size="16" type="success"></icon>
178 180 <view class="yu_er">参与优惠活动</view>
... ... @@ -234,12 +236,15 @@
234 236 </block>
235 237  
236 238  
237   - <view class="set-mes" wx:if="{{pitem.is_duo_gd && pitem.sele_prom_type==3 && util.check_is_last(index,items.goods_id) && !items.is_gift }}">
238   - <view class="use-item" data-pidx="{{pidx}}" data-can_cx_idx="{{index}}" bindtap='no_cj_prom'>
239   - <icon color="{{!pitem.no_cj_prom?'red':'gray'}}" size="16" type="success"></icon>
240   - <view class="yu_er">参与优惠活动</view>
  239 +
  240 + <block wx:if="{{!can_use_ord_prom[item.pickup_id]}}">
  241 + <view class="set-mes" wx:if="{{pitem.is_duo_gd && pitem.sele_prom_type==3 && util.check_is_last(index,items.goods_id) }}">
  242 + <view class="use-item" data-pidx="{{pidx}}" data-can_cx_idx="{{index}}" bindtap='no_cj_prom'>
  243 + <icon color="{{!pitem.no_cj_prom?'red':'gray'}}" size="16" type="success"></icon>
  244 + <view class="yu_er">参与优惠活动</view>
  245 + </view>
241 246 </view>
242   - </view>
  247 + </block>
243 248  
244 249 </block>
245 250 </block>
... ... @@ -348,6 +353,14 @@
348 353 </block>
349 354 </view>
350 355  
  356 + <!-- 订单促销取价规则的优化 -->
  357 + <view class="set-mes" wx:if="{{show_ord_prom[item.pickup_id]}}">
  358 + <view class="use-item" >
  359 + <icon data-pd="{{item.pickup_id}}" bindtap='set_can_use_ord_prom' color="{{can_use_ord_prom[item.pickup_id]?'red':'gray'}}" size="16" type="success"></icon>
  360 + <view data-pd="{{item.pickup_id}}" bindtap='set_can_use_ord_prom' class="yu_er">参与订单促销</view>
  361 + </view>
  362 + </view>
  363 +
351 364 <!-----使用优惠券------>
352 365 <view class="xc-coupon-frame flex-center" data-bn="0" bindtap="open_coupon_list" wx:if="{{!(yh_is_xz_yh[item.pickup_id]) && ((item.quan_list && item.quan_list.length>0 ) || get_by_quan_list_cart[item.pickup_id]!=null && item.can_num>0)}}" data-cind="{{pidx}}" data-pickid="{{item.pickup_id}}">
353 366 <view class="work-frame flex-space-between">
... ... @@ -679,6 +692,14 @@
679 692 <icon color="#f23030" size="16" type="info"></icon>{{order.store_prom}}
680 693 </view>
681 694  
  695 + <!-- 订单促销取价规则的优化 -->
  696 + <view class="set-mes" wx:if="{{show_ord_prom[bn_pick]}}">
  697 + <view class="use-item" >
  698 + <icon bindtap='set_can_use_ord_prom_now' color="{{can_use_ord_prom[bn_pick]?'red':'gray'}}" size="16" type="success"></icon>
  699 + <view bindtap='set_can_use_ord_prom_now' class="yu_er">参与订单促销</view>
  700 + </view>
  701 + </view>
  702 +
682 703 <view class="xc-coupon-frame flex-center" data-bn="1" bindtap="open_coupon_list" data-pickid="{{bn_pick}}" hidden="{{(selected_quan_list?selected_quan_list.length:0)+ (get_by_quan_list && bn_exp_type==0?get_by_quan_list.length:0)<=0}}" wx:if="{{is_coupon > 0 && ((selected_quan_list && selected_quan_list.length>0) || get_by_quan_list!=null)}}">
683 704 <view class="work-frame flex-space-between">
684 705 <view class="work">
... ... @@ -1096,7 +1117,7 @@
1096 1117 </view>
1097 1118 <view class="count">
1098 1119 <view bindtap="{{items.goods_num <= 1 ? '':'subNum'}}" class="sub fs28 {{items.goods_num <= 1 ? 'active':''}}" data-pitems="{{pidx}}" data-item="{{idx}}">一</view>
1099   - <input class="goodadd" bindblur="valueToNum" data-item="{{idx}}" bindinput="refresh_input" data-item="{{idx}}" type="number" value="{{items.goods_num}}"></input>
  1120 + <input class="goodadd" bindblur="valueToNum" data-item="{{idx}}" bindinput="refresh_input" type="number" value="{{items.goods_num}}"></input>
1100 1121 <view class="add" bindtap="addNum" data-item="{{idx}}">+</view>
1101 1122 </view>
1102 1123 </view>
... ...
packageE/pages/cart/cart2/filter.wxs
... ... @@ -49,14 +49,11 @@ function check_is_last(index,goods_id){
49 49 return true;
50 50 }
51 51 return false;
52   -
53 52 }
54 53  
55   -
56   -
57 54 module.exports = {
58 55 format: format,
59 56 is_more_act:is_more_act,
60 57 check_show:check_show,
61   - check_is_last:check_is_last
  58 + check_is_last:check_is_last,
62 59 }
... ...
packageE/pages/cart/cart2/ladder_calculate.js
... ... @@ -115,6 +115,11 @@ module.exports = {
115 115 })
116 116 //goods[idx].goods_num -= num;
117 117 let new_g = JSON.parse(JSON.stringify(goods[idx]));
  118 +
  119 + //多余的商品如果活动不参与订单促销,那么变成普通商品的也不能参与订单促销,2024-2-26
  120 + if(!ladder_map.is_useorderyh){
  121 + new_g.is_no_order_yh=1;
  122 + }
118 123 new_g.goods_num = num;
119 124 new_g.prom_type = 0;
120 125 new_g.prom_id = 0;
... ...
packageE/pages/cart/cart2/zh_calculate.js
... ... @@ -270,6 +270,11 @@ module.exports = {
270 270 let new_g = JSON.parse(JSON.stringify(goods[idx]));
271 271  
272 272 if(new_g.more_cx) delete new_g.more_cx;
  273 +
  274 + //多余的商品如果活动不参与订单促销,那么变成普通商品的也不能参与订单促销,2024-2-26
  275 + if(!act.is_orderyh){
  276 + new_g.is_no_order_yh=1;
  277 + }
273 278 new_g.goods_num = num;
274 279 new_g.prom_type = 0;
275 280 new_g.prom_id = 0;
... ... @@ -331,6 +336,11 @@ module.exports = {
331 336 offline_price += item.goods_price - item.offline_price;
332 337 offline_num += 1;
333 338 }
  339 +
  340 + //多余的商品如果活动不参与订单促销,那么变成普通商品的也不能参与订单促销,2024-2-26
  341 + if(!act.is_orderyh){
  342 + item.is_no_order_yh=1;
  343 + }
334 344 item.prom_type = 0;
335 345 item.prom_id = 0;
336 346 }
... ...
packageE/pages/cart/cart2_inte/cart2_inte.js
... ... @@ -85,7 +85,14 @@ Page({
85 85 same_ok:1, //同城配送的控制,默认ok
86 86 bconfig: null,
87 87 showFold:true,
88   - template_id:[]
  88 + template_id:[],
  89 +
  90 + //-- 订单促销判断积累 ---2024-2-20
  91 + order_prom_map_ck: {},
  92 + //能不能使用订单促销
  93 + can_use_ord_prom:{},
  94 + //存储订单促销的取价,按照门店进行索引
  95 + show_ord_prom:{},
89 96 },
90 97  
91 98  
... ... @@ -632,6 +639,8 @@ Page({
632 639 success: async function (tt) {
633 640 if (tt.data.code == 0 && tt.data.data && tt.data.data.pageData) {
634 641 var inte_data = tt.data.data.pageData[0];
  642 +
  643 + gd.shop_price_y=gd.shop_price;
635 644 t.data.data.shop_price = inte_data.addmoney;
636 645 t.data.data.integral = inte_data.integral;
637 646  
... ... @@ -658,6 +667,9 @@ Page({
658 667  
659 668  
660 669  
  670 + //用深拷贝把商品缓存起来,方便后面使用
  671 + th.data.old_bn_goods=ut.deep_cp(t.data.data);
  672 +
661 673 th.setData({
662 674 bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et, index: m_wind,
663 675 bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et,inv_is_post:inte_data.is_post
... ... @@ -742,16 +754,23 @@ Page({
742 754 var condition = parseFloat(allpice-cut_price).toFixed(2);
743 755 var ord_prom = null;
744 756 var is_ord_prom_post = 0;
  757 + //---如果有选择优惠券的情况下---
  758 + var quan_price = 0, bn_pick = th.data.bn_pick;
  759 +
  760 + if (th.data.bn_is_order_yh && !th.data.bn_goods.whsle_id) {
  761 + // await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", {
  762 + // data: { store_id: os.stoid, orderAmount: condition, user_id: getApp().globalData.user_id }
  763 + // }).then(res => {
  764 + // if (res.data.code == 0) {
  765 + // var data = res.data.data;
  766 + // ord_prom = data;
  767 + // }
  768 + // })
  769 +
  770 + th.set_by_now_ord_prom(th.data.bn_goods);
  771 + th.data.order_prom_map_ck[bn_pick].goods_price_all=condition;
  772 + ord_prom=await th.get_cur_ord_prom(bn_pick);
745 773  
746   - if (condition > 0 && th.data.bn_is_order_yh && !th.data.bn_goods.whsle_id) {
747   - await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", {
748   - data: { store_id: os.stoid, orderAmount: condition, user_id: getApp().globalData.user_id }
749   - }).then(res => {
750   - if (res.data.code == 0) {
751   - var data = res.data.data;
752   - ord_prom = data;
753   - }
754   - })
755 774 if (ord_prom && ord_prom.is_post_temp) {
756 775 is_ord_prom_post = 1;
757 776 }
... ... @@ -894,8 +913,7 @@ Page({
894 913 var wl_txt = "formData.shipping_price";
895 914 th.setData({ [wl_txt]: 0, })
896 915 }
897   - //---如果有选择优惠券的情况下---
898   - var quan_price = 0, bn_pick = th.data.bn_pick;
  916 +
899 917  
900 918 //-----------------支付价,优惠券不减物流-----------------
901 919 var total_m = (parseFloat(allpice)).toFixed(2);
... ... @@ -1281,7 +1299,6 @@ Page({
1281 1299 item.samecity_order_amount=th.data.bn_samecity_order_amount;
1282 1300 }
1283 1301  
1284   -
1285 1302 //获取立即购买的商品的信息
1286 1303 var gg = to.get_b_now();
1287 1304 //--商品的房间号--
... ... @@ -1319,6 +1336,31 @@ Page({
1319 1336 'prom_id': th.data.bn_goods.prom_id, //促销活动id
1320 1337 };
1321 1338  
  1339 + if(th.data.bn_goods.discount_field){
  1340 + goods.discount_field=th.data.bn_goods.discount_field;
  1341 + }
  1342 +
  1343 + //如果有参与非实收的订单促销,那么就相当于是普通购买
  1344 + if(th.data.can_use_ord_prom[th.data.bn_pick]){
  1345 + goods.is_integral_normal=1;
  1346 +
  1347 + //如果是指定门店,就要判断
  1348 + if (th.data.bn_goods.pick_group_ids) {
  1349 + var idx0 = th.data.bn_goods.pick_up_lists.findIndex(function (e) {
  1350 + return e.pickup_id == th.data.bn_pick;
  1351 + })
  1352 + if (idx0 < 0) {
  1353 + getApp().my_warnning(th.data.bn_goods.goods_name + "的门店不可售", 0, th);
  1354 + th.data.is_summit_ing = 0;
  1355 + th.setData({
  1356 + submit: 0
  1357 + })
  1358 + return false;
  1359 + }
  1360 + }
  1361 +
  1362 + }
  1363 +
1322 1364 if(getApp().globalData.skinface_id){
1323 1365 goods.skinface_id=getApp().globalData.skinface_id;
1324 1366 }
... ... @@ -1757,7 +1799,146 @@ Page({
1757 1799 var th = this;
1758 1800 th.setData({bn_use_commission: !th.data.bn_use_commission});
1759 1801 th.calculatePrice2();
  1802 + },
  1803 +
  1804 + //-- 获取订单促销的判断结构 --
  1805 + set_by_now_ord_prom(item){
  1806 + let pickid=this.data.bn_pick;
  1807 + let order_prom_map_ck= this.data.order_prom_map_ck;
  1808 + order_prom_map_ck[pickid]={
  1809 + shop_price_all:0, //手店价的累计
  1810 + market_price_all:0, //市场价的累计
  1811 + goods_price_all:0, //实收价的累计
  1812 + no_ord_price:0, //要累计上不参与订单促销的金额
  1813 + goodsList:[],
  1814 + }
  1815 +
  1816 + let pk_ord_map=order_prom_map_ck[pickid];
  1817 + pk_ord_map.shop_price_all += item.shop_price_y * item.buynum;
  1818 + pk_ord_map.market_price_all += item.goods_market_price * item.buynum;
  1819 +
  1820 + },
  1821 +
  1822 + //获取当前进行中订单促销,同时带入相应的金额判断订单促销是不是运行,同时订单促销的条件不是实收价判断的话,默认的时候,订单促销是不参与运算的
  1823 + async get_cur_ord_prom(pickid) {
  1824 + let ord_prom = null;
  1825 + let order_prom_map_ck = this.data.order_prom_map_ck[pickid];
  1826 + if(!order_prom_map_ck) return null;
  1827 +
  1828 + //获取当前进行中的优惠促销
  1829 + await getApp().request.promiseGet("/api/weshop/promorder/getPromOrder", {
  1830 + data: {
  1831 + store_id: os.stoid,
  1832 + orderAmount: -1, //-1为不判断金额条件
  1833 + user_id: getApp().globalData.user_id
  1834 + }
  1835 + }).then(res => {
  1836 + if (res.data.code == 0) {
  1837 + ord_prom = res.data.data;
  1838 + }
  1839 + })
  1840 +
  1841 + if (!ord_prom) return null;
  1842 + //用于计算订单促销的金额
  1843 + let calculate_price=0;
  1844 +
  1845 + let txt1='show_ord_prom['+pickid+']';
  1846 + //-- 此时判断活动的金额满足与否 --
  1847 + switch (ord_prom.discount_field) {
  1848 + //实收价的时候
  1849 + case 0:
  1850 + //要先还原
  1851 + this.setData({
  1852 + [txt1]: 0
  1853 + });
  1854 +
  1855 + if (ord_prom.money > order_prom_map_ck.goods_price_all){
  1856 + return null;
  1857 + }
  1858 + break;
  1859 + //手店价的时候
  1860 + case 1:
  1861 + if (ord_prom.money > order_prom_map_ck.shop_price_all){
  1862 + //要先还原
  1863 + this.setData({
  1864 + [txt1]: 0
  1865 + });
  1866 + return null;
  1867 + }
  1868 + //要显示订单促销使用的按钮
  1869 + this.setData({
  1870 + [txt1]: 1
  1871 + });
  1872 + break;
  1873 + //市场价的时候
  1874 + case 2:
  1875 + if (ord_prom.money > order_prom_map_ck.market_price_all){
  1876 + //要先还原
  1877 + this.setData({
  1878 + [txt1]: 0
  1879 + });
  1880 + return null;
  1881 + }
  1882 + //要显示订单促销使用的按钮
  1883 + this.setData({
  1884 + [txt1]: 2
  1885 + });
  1886 + break;
  1887 + }
  1888 + //如果订单促销是不参与订单促销的,那么就直接返回null(订单促销不是实收价的时候)
  1889 + if(ord_prom.discount_field>0 && !this.data.can_use_ord_prom[pickid]){
  1890 + return null;
  1891 + }
  1892 + return ord_prom;
  1893 + },
  1894 +
  1895 + //立即购买的时候,点击订单促销的参与
  1896 + set_can_use_ord_prom_now:function (e){
  1897 +
  1898 + if(this.data.submit) return false;
  1899 + this.setData({ submit: 1,same_ok:1 });
  1900 +
  1901 + let pickid=this.data.bn_pick;
  1902 + let txt = 'can_use_ord_prom[' + pickid + ']';
  1903 + let can_use = this.data.can_use_ord_prom[pickid] ? this.data.can_use_ord_prom[pickid] : 0;
  1904 + this.setData({
  1905 + [txt]: !can_use
  1906 + })
  1907 +
  1908 + let th=this;
  1909 + let good=th.data.bn_goods;
  1910 +
  1911 + //如果有要参与订单促销的按钮点击后,要修改商品的价格
  1912 + if(th.data.can_use_ord_prom[pickid]){
  1913 + let discount_field=th.data.show_ord_prom[pickid];
  1914 + switch (discount_field){
  1915 + case 1:
  1916 + good.shop_price=good.shop_price_y;
  1917 + break;
  1918 + case 2:
  1919 + good.shop_price=good.market_price;
  1920 + break;
  1921 + }
  1922 + //-- 转成普通商品 ---
  1923 + good.prom_type=0;
  1924 + good.prom_id=0;
  1925 + good.integral=0;
  1926 + good.discount_field=discount_field;
  1927 +
  1928 + }else{
  1929 + good=ut.deep_cp(th.data.old_bn_goods);
  1930 + }
  1931 +
  1932 + th.setData({
  1933 + bn_goods:good
  1934 + })
  1935 + wx.showLoading({
  1936 + title: "处理中.",
  1937 + mark:true
  1938 + })
  1939 + th.calculatePrice2()
1760 1940 }
1761 1941  
1762 1942  
  1943 +
1763 1944 });
... ...
packageE/pages/cart/cart2_inte/cart2_inte.wxml
... ... @@ -94,6 +94,14 @@
94 94 <icon color="#f23030" size="16" type="info"></icon>{{order.store_prom}}
95 95 </view>
96 96  
  97 + <!-- 订单促销取价规则的优化 -->
  98 + <view class="set-mes" wx:if="{{show_ord_prom[bn_pick]}}">
  99 + <view class="use-item" >
  100 + <icon bindtap='set_can_use_ord_prom_now' color="{{can_use_ord_prom[bn_pick]?'red':'gray'}}" size="16" type="success"></icon>
  101 + <view bindtap='set_can_use_ord_prom_now' class="yu_er">参与订单促销</view>
  102 + </view>
  103 + </view>
  104 +
97 105 <view class="xc-coupon-frame flex-center" data-bn="1" bindtap="open_coupon_list" data-pickid="{{bn_pick}}" wx:if="{{(selected_quan_list && selected_quan_list.length>0) || get_by_quan_list!=null}}">
98 106 <view class="work-frame flex-space-between">
99 107 <view class="work">
... ...
packageE/pages/cart/cart2_pt/cart2_pt.js
... ... @@ -90,6 +90,13 @@ Page({
90 90 is_no_by: {},
91 91 is_by: {},
92 92 is_quan_by: {},
  93 +
  94 + //-- 订单促销判断积累 ---2024-2-20
  95 + order_prom_map_ck: {},
  96 + //能不能使用订单促销
  97 + can_use_ord_prom:{},
  98 + //存储订单促销的取价,按照门店进行索引
  99 + show_ord_prom:{},
93 100 },
94 101  
95 102  
... ... @@ -444,7 +451,9 @@ Page({
444 451 et = 2;
445 452 }
446 453  
  454 + t.data.data.shop_price_y=t.data.data.shop_price
447 455 t.data.data.shop_price = gg.goods_price;
  456 +
448 457 //--如果是普通购买的时候--
449 458 if (gg.is_normal == 1) {
450 459 t.data.data.prom_id = 0;
... ... @@ -485,6 +494,8 @@ Page({
485 494  
486 495 }
487 496  
  497 + //用深拷贝把商品缓存起来,方便后面使用
  498 + th.data.old_bn_goods=ut.deep_cp(t.data.data);
488 499  
489 500 th.setData({
490 501 bn_goods: t.data.data, bn_pickname: gg.pick_name,
... ... @@ -568,7 +579,6 @@ Page({
568 579 et = th.data.bn_exp_type;
569 580 }
570 581  
571   -
572 582 //-- 计算获得佣金的金额 --
573 583 if (getApp().globalData.userInfo.is_distribut
574 584 && th.data.dis_config && th.data.dis_config.is_yongjin_dk) {
... ... @@ -591,6 +601,8 @@ Page({
591 601  
592 602 }
593 603  
  604 + //用深拷贝把商品缓存起来,方便后面使用
  605 + th.data.old_bn_goods=ut.deep_cp(t.data.data);
594 606  
595 607 th.setData({
596 608 bn_goods: t.data.data, bn_pickname: gg.pick_name,
... ... @@ -834,13 +846,17 @@ Page({
834 846  
835 847 if(th.data.bn_is_order_yh && th.data.kt_type != 3 ){
836 848  
837   - await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", {
838   - data: { store_id: os.stoid, orderAmount: o_condition, user_id: getApp().globalData.user_id }
839   - }).then(res => {
840   - if (res.data.code == 0) {
841   - ord_prom = res.data.data;
842   - }
843   - })
  849 + // await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", {
  850 + // data: { store_id: os.stoid, orderAmount: o_condition, user_id: getApp().globalData.user_id }
  851 + // }).then(res => {
  852 + // if (res.data.code == 0) {
  853 + // ord_prom = res.data.data;
  854 + // }
  855 + // })
  856 +
  857 + th.set_by_now_ord_prom(th.data.bn_goods);
  858 + th.data.order_prom_map_ck[bn_pick].goods_price_all=o_condition;
  859 + ord_prom=await th.get_cur_ord_prom(bn_pick);
844 860 }
845 861  
846 862  
... ... @@ -1468,6 +1484,31 @@ Page({
1468 1484 'prom_id': th.data.bn_goods.prom_id, //促销活动id
1469 1485 };
1470 1486  
  1487 + if(th.data.bn_goods.discount_field){
  1488 + goods.discount_field=th.data.bn_goods.discount_field;
  1489 + }
  1490 +
  1491 + //如果有参与非实收的订单促销,那么就相当于是普通购买
  1492 + if(th.data.can_use_ord_prom[th.data.bn_pick]){
  1493 + goods.is_integral_normal=1;
  1494 +
  1495 + //如果是指定门店,就要判断
  1496 + if (th.data.bn_goods.pick_group_ids) {
  1497 + var idx0 = th.data.bn_goods.pick_up_lists.findIndex(function (e) {
  1498 + return e.pickup_id == th.data.bn_pick;
  1499 + })
  1500 + if (idx0 < 0) {
  1501 + getApp().my_warnning(th.data.bn_goods.goods_name + "的门店不可售", 0, th);
  1502 + th.data.is_summit_ing = 0;
  1503 + th.setData({
  1504 + submit: 0
  1505 + })
  1506 + return false;
  1507 + }
  1508 + }
  1509 +
  1510 + }
  1511 +
1471 1512 if (getApp().globalData.skinface_id) {
1472 1513 goods.skinface_id = getApp().globalData.skinface_id;
1473 1514 }
... ... @@ -2260,6 +2301,152 @@ Page({
2260 2301 th.setData({ open_quan: 0 });
2261 2302 },
2262 2303  
  2304 + //-- 获取订单促销的判断结构 --
  2305 + set_by_now_ord_prom(item){
  2306 + let pickid=this.data.bn_pick;
  2307 + let order_prom_map_ck= this.data.order_prom_map_ck;
  2308 + order_prom_map_ck[pickid]={
  2309 + shop_price_all:0, //手店价的累计
  2310 + market_price_all:0, //市场价的累计
  2311 + goods_price_all:0, //实收价的累计
  2312 + no_ord_price:0, //要累计上不参与订单促销的金额
  2313 + goodsList:[],
  2314 + }
  2315 +
  2316 + let pk_ord_map=order_prom_map_ck[pickid];
  2317 + pk_ord_map.shop_price_all += item.shop_price_y * item.buynum;
  2318 + pk_ord_map.market_price_all += item.goods_market_price * item.buynum;
  2319 +
  2320 + },
  2321 +
  2322 + //获取当前进行中订单促销,同时带入相应的金额判断订单促销是不是运行,同时订单促销的条件不是实收价判断的话,默认的时候,订单促销是不参与运算的
  2323 + async get_cur_ord_prom(pickid) {
  2324 + let ord_prom = null;
  2325 + let order_prom_map_ck = this.data.order_prom_map_ck[pickid];
  2326 + if(!order_prom_map_ck) return null;
  2327 +
  2328 + //获取当前进行中的优惠促销
  2329 + await getApp().request.promiseGet("/api/weshop/promorder/getPromOrder", {
  2330 + data: {
  2331 + store_id: os.stoid,
  2332 + orderAmount: -1, //-1为不判断金额条件
  2333 + user_id: getApp().globalData.user_id
  2334 + }
  2335 + }).then(res => {
  2336 + if (res.data.code == 0) {
  2337 + ord_prom = res.data.data;
  2338 + }
  2339 + })
  2340 +
  2341 + if (!ord_prom) return null;
  2342 + //用于计算订单促销的金额
  2343 + let calculate_price=0;
  2344 +
  2345 + let txt1='show_ord_prom['+pickid+']';
  2346 + //-- 此时判断活动的金额满足与否 --
  2347 + switch (ord_prom.discount_field) {
  2348 + //实收价的时候
  2349 + case 0:
  2350 + //要先还原
  2351 + this.setData({
  2352 + [txt1]: 0
  2353 + });
  2354 +
  2355 + if (ord_prom.money > order_prom_map_ck.goods_price_all){
  2356 + return null;
  2357 + }
  2358 + break;
  2359 + //手店价的时候
  2360 + case 1:
  2361 + if (ord_prom.money > order_prom_map_ck.shop_price_all){
  2362 + //要先还原
  2363 + this.setData({
  2364 + [txt1]: 0
  2365 + });
  2366 + return null;
  2367 + }
  2368 + //要显示订单促销使用的按钮
  2369 + this.setData({
  2370 + [txt1]: 1
  2371 + });
  2372 + break;
  2373 + //市场价的时候
  2374 + case 2:
  2375 + if (ord_prom.money > order_prom_map_ck.market_price_all){
  2376 + //要先还原
  2377 + this.setData({
  2378 + [txt1]: 0
  2379 + });
  2380 + return null;
  2381 + }
  2382 + //要显示订单促销使用的按钮
  2383 + this.setData({
  2384 + [txt1]: 2
  2385 + });
  2386 + break;
  2387 + }
  2388 + //如果订单促销是不参与订单促销的,那么就直接返回null(订单促销不是实收价的时候)
  2389 + if(ord_prom.discount_field>0 && !this.data.can_use_ord_prom[pickid]){
  2390 + return null;
  2391 + }
  2392 + return ord_prom;
  2393 + },
  2394 +
  2395 + //立即购买的时候,点击订单促销的参与
  2396 + set_can_use_ord_prom_now:function (e){
  2397 +
  2398 + if(this.data.submit) return false;
  2399 + this.setData({ submit: 1,same_ok:1 });
  2400 +
  2401 + let pickid=this.data.bn_pick;
  2402 + let txt = 'can_use_ord_prom[' + pickid + ']';
  2403 + let can_use = this.data.can_use_ord_prom[pickid] ? this.data.can_use_ord_prom[pickid] : 0;
  2404 + this.setData({
  2405 + [txt]: !can_use
  2406 + })
  2407 +
  2408 + let th=this;
  2409 + let good=th.data.bn_goods;
  2410 +
  2411 + //如果有要参与订单促销的按钮点击后,要修改商品的价格
  2412 + if(th.data.can_use_ord_prom[pickid]){
  2413 + let discount_field=th.data.show_ord_prom[pickid];
  2414 + switch (discount_field){
  2415 + case 1:
  2416 + good.shop_price=good.shop_price_y;
  2417 + break;
  2418 + case 2:
  2419 + good.shop_price=good.market_price;
  2420 + break;
  2421 + }
  2422 + //-- 转成普通商品 ---
  2423 + good.prom_type=0;
  2424 + good.prom_id=0;
  2425 + good.discount_field=discount_field;
  2426 +
  2427 + //把优惠券的使用还原
  2428 + th.setData({
  2429 + selected_quan_list: null,
  2430 + using_quan: {}
  2431 + })
  2432 + }else{
  2433 + good=ut.deep_cp(th.data.old_bn_goods);
  2434 + }
  2435 +
  2436 + th.setData({
  2437 + bn_goods:good
  2438 + })
  2439 + wx.showLoading({
  2440 + title: "处理中.",
  2441 + mark:true
  2442 + })
  2443 + th.calculatePrice2()
  2444 +
  2445 + if(!th.data.can_use_ord_prom[pickid]){
  2446 + th.get_buy_now_quan();
  2447 + }
  2448 + }
  2449 +
2263 2450  
2264 2451  
2265 2452  
... ...
packageE/pages/cart/cart2_pt/cart2_pt.wxml
... ... @@ -102,6 +102,13 @@
102 102 <icon color="#f23030" size="16" type="info"></icon>{{order.store_prom}}
103 103 </view>
104 104  
  105 + <!-- 订单促销取价规则的优化 -->
  106 + <view class="set-mes" wx:if="{{show_ord_prom[bn_pick]}}">
  107 + <view class="use-item" >
  108 + <icon bindtap='set_can_use_ord_prom_now' color="{{can_use_ord_prom[bn_pick]?'red':'gray'}}" size="16" type="success"></icon>
  109 + <view bindtap='set_can_use_ord_prom_now' class="yu_er">参与订单促销</view>
  110 + </view>
  111 + </view>
105 112  
106 113 <view class="xc-coupon-frame flex-center" data-bn="1" bindtap="open_coupon_list" data-pickid="{{bn_pick}}" hidden="{{(selected_quan_list?selected_quan_list.length:0)+ (get_by_quan_list && bn_exp_type==0?get_by_quan_list.length:0)<=0}}" wx:if="{{(selected_quan_list && selected_quan_list.length>0) || get_by_quan_list!=null}}">
107 114 <view class="work-frame flex-space-between">
... ...
packageE/pages/cart/cart_wk/cart_wk.js
... ... @@ -539,6 +539,9 @@ Page({
539 539 }).then(res => {
540 540 if (res.data.code == 0) {
541 541 ord_prom = res.data.data;
  542 +
  543 + //如果订单促销的取价不是实收,清空订单促销
  544 + if(ord_prom && ord_prom.discount_field>0) ord_prom=null;
542 545 }
543 546 })
544 547 }
... ...
packageG/pages/user/order_detail/order_detail.js
... ... @@ -1157,13 +1157,39 @@ Page({
1157 1157 //-- 优惠促销的时候控制取价规则 --
1158 1158 // gg.prom_type!=3 && gg.prom_type!=10 同时商品不是普通购买的时候,又参与优惠促销,阶梯促销
1159 1159 if((gg.prom_type!=3 && gg.prom_type!=10) || gg.discount_field==undefined || gg.discount_field==0 ) {
1160   - if (card_field && gg[card_field] > 0) {
1161   - if (good.goods_price != gg[card_field] && good.offline_cut <= 0) isok = 0;
1162   - if (good.goods_price > gg[card_field] && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过
1163 1160  
1164   - } else {
1165   - if (good.goods_price != gg.shop_price && good.offline_cut <= 0) isok = 0;
1166   - if (good.goods_price > gg.shop_price && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过
  1161 +
  1162 + //判断一下活动是不是有参与订单促销,并且订单促销的活动是不是实收取价,2024-2-23
  1163 + let ordprom_price_type=0;
  1164 + if(order.order_prom_id && good.prom_type==0){
  1165 + let p_rs= await getApp().request.promiseGet("/api/weshop/promorder/get/"+os.stoid+"/"+order.order_prom_id, {});
  1166 + if(p_rs && p_rs.data.code==0 && p_rs.data.data){
  1167 + let ord_p=p_rs.data.data;
  1168 + if(ord_p && ord_p.discount_field>0){
  1169 + ordprom_price_type=ord_p.discount_field
  1170 + }
  1171 + }
  1172 + }
  1173 + if(ordprom_price_type>0){
  1174 + //-- 看一下订单促销的取价规则 --
  1175 + switch (ordprom_price_type){
  1176 + case 1:
  1177 + if (good.goods_price != gg.shop_price) isok = 0;
  1178 + break;
  1179 + case 2:
  1180 + if (good.goods_price != gg.market_price) isok = 0;
  1181 + break;
  1182 + }
  1183 +
  1184 + }else {
  1185 + if (card_field && gg[card_field] > 0) {
  1186 + if (good.goods_price != gg[card_field] && good.offline_cut <= 0) isok = 0;
  1187 + if (good.goods_price > gg[card_field] && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过
  1188 +
  1189 + } else {
  1190 + if (good.goods_price != gg.shop_price && good.offline_cut <= 0) isok = 0;
  1191 + if (good.goods_price > gg.shop_price && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过
  1192 + }
1167 1193 }
1168 1194 }else{
1169 1195 if(good.prom_type==3 && good.prom_type==10){
... ...
pages/cart/cart/cart.js
... ... @@ -1192,10 +1192,10 @@ Page({
1192 1192 // if (this.data.btn_click) {
1193 1193 // return false;
1194 1194 // }
  1195 +
1195 1196 setTimeout(() => {
1196 1197 if (this.data.up_dating == 1) return false;
1197 1198 this.data.up_dating=1
1198   -
1199 1199 this.data.btn_click = 1;
1200 1200 var a = t.currentTarget.dataset.item;
1201 1201 var b = t.currentTarget.dataset.pitems;
... ...
pages/user/order_list/order_list.js
... ... @@ -1446,14 +1446,43 @@ Page({
1446 1446 //-- 优惠促销的时候控制取价规则 --
1447 1447 // gg.prom_type!=3 && gg.prom_type!=10 同时商品不是普通购买的时候,又参与优惠促销,阶梯促销
1448 1448 if((gg.prom_type!=3 && gg.prom_type!=10) || gg.discount_field==undefined || gg.discount_field==0 ){
1449   - if (card_field && gg[card_field] > 0) {
1450   - if (good.goods_price != gg[card_field] && good.offline_cut <= 0) isok = 0;
1451   - if (good.goods_price > gg[card_field] && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过
1452 1449  
1453   - } else {
1454   - if (good.goods_price != gg.shop_price && good.offline_cut <= 0) isok = 0;
1455   - if (good.goods_price > gg.shop_price && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过
  1450 + //判断一下活动是不是有参与订单促销,并且订单促销的活动是不是实收取价,2024-2-23
  1451 + let ordprom_price_type=0;
  1452 + if(order.order_prom_id && good.prom_type==0){
  1453 + let p_rs= await getApp().request.promiseGet("/api/weshop/promorder/get/"+os.stoid+"/"+order.order_prom_id, {});
  1454 + if(p_rs && p_rs.data.code==0 && p_rs.data.data){
  1455 + let ord_p=p_rs.data.data;
  1456 + if(ord_p && ord_p.discount_field>0){
  1457 + ordprom_price_type=ord_p.discount_field
  1458 + }
  1459 + }
  1460 + }
  1461 + if(ordprom_price_type>0){
  1462 + //-- 看一下订单促销的取价规则 --
  1463 + switch (ordprom_price_type){
  1464 + case 1:
  1465 + if (good.goods_price != gg.shop_price) isok = 0;
  1466 + break;
  1467 + case 2:
  1468 + if (good.goods_price != gg.market_price) isok = 0;
  1469 + break;
  1470 + }
  1471 +
  1472 + }else{
  1473 + if (card_field && gg[card_field] > 0) {
  1474 + if (good.goods_price != gg[card_field] && good.offline_cut <= 0) isok = 0;
  1475 + if (good.goods_price > gg[card_field] && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过
  1476 +
  1477 + } else {
  1478 + if (good.goods_price != gg.shop_price && good.offline_cut <= 0) isok = 0;
  1479 + if (good.goods_price > gg.shop_price && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过
  1480 + }
1456 1481 }
  1482 +
  1483 +
  1484 +
  1485 +
1457 1486 }else{
1458 1487  
1459 1488 if(good.prom_type==3 || good.prom_type==10 ){
... ...
utils/more_cx.js
... ... @@ -36,6 +36,7 @@ module.exports = {
36 36 }
37 37 return 0;
38 38 }
  39 +
39 40 var goods =gdlist;
40 41 var all_num=0;
41 42 var need_to_buy=0;
... ...