From ab4fb495d8beb172d30bcbdfcb3dd5df154aa433 Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Fri, 3 Feb 2023 17:12:19 +0800 Subject: [PATCH] 运费的计算 --- packageE/pages/cart/cart2/cart2.js | 56 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/packageE/pages/cart/cart2/cart2.js b/packageE/pages/cart/cart2/cart2.js index b64a633..c313e79 100644 --- a/packageE/pages/cart/cart2/cart2.js +++ b/packageE/pages/cart/cart2/cart2.js @@ -718,8 +718,12 @@ Page({ //如果有购买活动 item1.promgoodsbuynum = promgoodsbuynum; + //默认是包邮和优惠的 + item1.is_order_yh=1; + item1.is_post_temp=1; + //如果是秒杀,团购的时候 - if([1,2].indexOf(item1.prom_type)>-1){ + if([1,2,6].indexOf(item1.prom_type)>-1){ var url= "/api/weshop/activitylist/getSJGoodsPriceNew/" + os.stoid + "/" + item1.goods_id + "/"+item1.prom_type+"/" + item1.prom_id + "/" + app.globalData.user_id; await app.request.promiseGet(url,{}).then(res=>{ @@ -2075,7 +2079,6 @@ Page({ var no_order_yh = 0; //-- 有些活动不能和订单优惠叠加的金额 -- var no_post_temp = 0; //-- 有些活动不能和包邮模板的金额 -- - if (th.data.using_quan[pickid] != null && th.data.using_quan[pickid] != undefined) quan_no = th.data.using_quan[pickid].coupon_no; @@ -2103,40 +2106,42 @@ Page({ var whsle_goods_price = 0; //--------循环计算总价----------- - for (var j = 0; j < item.length; j++) { + for (var jc = 0; jc < item.length; jc++) { - if (item[j].whsle_id > 0) { - whsle_goods_price += item[j].goods_price * item[j].goods_num; + if (item[jc].whsle_id > 0) { + whsle_goods_price += item[jc].goods_price * item[jc].goods_num; } var is_no_zh = 0; - if (item[j].prom_type != 7 && item[j].prom_type != 10) is_no_zh = 1; + if (item[jc].prom_type != 7 && item[jc].prom_type != 10) is_no_zh = 1; //组合购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加 - if (item[j].prom_type == 7 && th.data.zhhe_act_map && th.data.zhhe_act_map[item[j].prom_id] - && th.data.zhhe_act_map[item[j].prom_id].is_orderyh) { + if (item[jc].prom_type == 7 && th.data.zhhe_act_map && th.data.zhhe_act_map[item[jc].prom_id] + && th.data.zhhe_act_map[item[jc].prom_id].is_orderyh) { is_no_zh = 1; } //阶梯购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加 - if (item[j].prom_type == 10 && ladder_prom_goods && ladder_prom_goods[item[j].prom_id] - && th.data.ladder_map[item[j].prom_id].is_useorderyh) { + if (item[jc].prom_type == 10 && ladder_prom_goods && ladder_prom_goods[item[jc].prom_id] + && th.data.ladder_map[item[jc].prom_id].is_useorderyh) { is_no_zh = 1; } if (is_no_zh) { - o_price_no_zh += item[j].goods_price * item[j].goods_num; + o_price_no_zh += item[jc].goods_price * item[jc].goods_num; } - o_price += item[j].goods_price * item[j].goods_num; - + o_price += item[jc].goods_price * item[jc].goods_num; - //-- 秒杀, 团购的时候,判断有没有订单优惠和包邮模板的叠加 -- - if( [1,2].indexOf(item[j].prom_type)>-1){ - if(!item[j].is_order_yh) - no_order_yh+=item[j].goods_price * item[j].goods_num; - if(!item[j].is_post_temp) - no_post_temp+=item[j].goods_price * item[j].goods_num; + //--- 秒杀, 团购的时候,判断有没有订单优惠和包邮模板的叠加 --- + if( [1,2,6].indexOf(item[jc].prom_type)>-1){ + if(!item[jc].is_order_yh){ + no_order_yh+=item[jc].goods_price * item[jc].goods_num; + } + if(!item[jc].is_post_temp){ + no_post_temp+=item[jc].goods_price * item[jc].goods_num; + } } } + //判断是不是有组合购的金额 var f_o_price = o_price; //如果又优惠的钱,就要减价 @@ -2259,8 +2264,6 @@ Page({ if (rs.data.code == 0) back_data = rs.data.data; }); } - - } @@ -2315,7 +2318,9 @@ Page({ continue; } - if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item[j].goods_id) == -1)) { + debugger; + if (back_data && back_data['is_by_all'] && item[j].is_post_temp + && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item[j].goods_id) == -1)) { if (item[j]['exp_sum_type'] == 2 && back_data.weight_free > 0) { if (goods_weight < 0) goods_weight = 0; @@ -2355,7 +2360,7 @@ Page({ } - //如果是正值的时候 + //如果是正值的时候,多少重量内免运费 if (out_of_weight >= 0) out_of_weight = -cut_good_weight; else out_of_weight = -back_data.weight_free * 1000; @@ -2366,6 +2371,9 @@ Page({ // cart_item.shipping_price = // ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,goods_piece, th.data.user_addr, back_data, rs); + var no_free=back_data && back_data.no_free_goods && back_data.no_free_goods.length > 0 ? 1 : 0 + + var w_data = { store_id: os.stoid, code: code, o_shipping_price: o_shipping_price, @@ -2375,7 +2383,7 @@ Page({ user_addr_city: th.data.user_addr.city, user_addr_district: th.data.user_addr.district, is_by_all: back_data && back_data.is_by_all ? 1 : 0, - no_free_goods: back_data && back_data.no_free_goods && back_data.no_free_goods.length > 0 ? 1 : 0, + no_free_goods: no_post_temp>0 || no_free?1:0 , } var is_ok = 1; -- libgit2 0.21.4