From b29b5dd8c6148728369853717228408f75de8330 Mon Sep 17 00:00:00 2001 From: abson Date: Thu, 13 Jan 2022 09:54:53 +0800 Subject: [PATCH] 物流 --- packageC/pages/presell/cart/cart.js | 23 +++++++++++++++++++---- packageC/pages/presell/cart/cart2.js | 7 ++++--- packageC/pages/presell/cart/cart2_pre.js | 31 ++++++++++++++++++++++++------- pages/cart/cart2/cart2.js | 32 ++++++++++++++++---------------- pages/cart/cart2_inte/cart2_inte.js | 26 +++++++++++++++++++++----- pages/cart/cart2_pt/cart2_pt.js | 29 +++++++++++++++++++++++------ pages/cart/cart_wk/cart_wk.js | 26 +++++++++++++++++++------- 7 files changed, 126 insertions(+), 48 deletions(-) diff --git a/packageC/pages/presell/cart/cart.js b/packageC/pages/presell/cart/cart.js index 9374ed6..38be4f7 100644 --- a/packageC/pages/presell/cart/cart.js +++ b/packageC/pages/presell/cart/cart.js @@ -852,12 +852,12 @@ Page({ th.calculatePrice2(); }, //-------------------计算物流--------------- - calculatewuliu: function (code, o_shipping_price, goods_weight, + calculatewuliu: function (code, o_shipping_price, goods_weight,out_of_weight, goods_piece, user_addr, freight_free, o_price, rs) { var price = 0, th = this; price += parseFloat(o_shipping_price); //如果是包邮 - if (freight_free > 0 && o_price >= freight_free) { + if (freight_free > 0 && o_price >= freight_free && out_of_weight>=0) { return 0; } if (user_addr == null) { @@ -875,7 +875,7 @@ Page({ item = item.config; if (item == null) return o_shipping_price; //------按重量---------- - if (goods_weight >= 0 && item['money']) { + if (goods_weight >= 0 && item['money'] && out_of_weight >= 0) { fw_price = parseFloat(item['money']); if (goods_weight > item['first_weight']) { var fw = goods_weight - item['first_weight']; @@ -883,6 +883,16 @@ Page({ fw_price = fw_price + n * parseFloat(item['add_money']); } } + //------超出重量---------- + if(out_of_weight < 0){ + fw_price = parseFloat(item['money']); + var out_of_weight = Math.abs(out_of_weight); + if (out_of_weight > item['first_weight']) { + var fw = out_of_weight - item['first_weight']; + var n = Math.ceil(fw / item['second_weight']) + fw_price = fw_price + n * parseFloat(item['add_money']); + } + } //------按件数---------- if (goods_piece > 0 && item['piecemoney']) { fp_price = parseFloat(item['piecemoney']); @@ -1713,6 +1723,9 @@ Page({ var quan_no = null; var bn_pick=th.data.pickup.pickup_id; var allpice =th.data.all_price; + var out_of_weight=null; //超出多少重量 + var freight_free = ee.freight_free; //全场满多少包邮 + var weight_free = ee.weight_free; //多少kg内包邮 if (th.data.using_quan[bn_pick] != null && th.data.using_quan[bn_pick] != undefined) quan_no = th.data.using_quan[bn_pick].coupon_no; @@ -1793,6 +1806,9 @@ Page({ if (goods_weight < 0) goods_weight = 0; //累积商品重量 每种商品的重量 * 数量 goods_weight += good['weight'] * th.data.order.order_goods['goods_num']; + if(weight_free > 0){ + out_of_weight = (weight_free * 1000 ) - goods_weight; + } break; case 3: if (goods_piece < 0) goods_piece = 0; @@ -1802,7 +1818,6 @@ Page({ } var code = th.data.wu_arr[th.data.index].code; - var freight_free = ee.freight_free; //全场满多少包邮 var shipping_price = th.calculatewuliu(code, o_shipping_price, goods_weight, goods_piece, th.data.user_addr, freight_free, allpice, rs); diff --git a/packageC/pages/presell/cart/cart2.js b/packageC/pages/presell/cart/cart2.js index 8cba3d4..68ce70d 100644 --- a/packageC/pages/presell/cart/cart2.js +++ b/packageC/pages/presell/cart/cart2.js @@ -734,7 +734,7 @@ Page({ //如果有赠品的时候,也要计算赠品的物流费用 if (th.data.buy_now_gift_goods) { - shipping_price = th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free,gift_weight_free, + shipping_price = th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free,out_of_weight,gift_weight_free, parseFloat(allpice) - cut_price - quan_price, rs, shipping_price, no_by_data, goods_weight, goods_piece); } @@ -2540,7 +2540,7 @@ Page({ }, //计算立即购买赠品的物流费用 - get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free,gift_weight_free, allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1) { + get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free,gift_weight_free,out_of_weight,allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1) { var good = this.data.buy_now_gift_goods; var goods_weight = -1, goods_piece = -1; var gift_shipping_price = 0; @@ -2556,8 +2556,9 @@ Page({ //累积商品重量 每种商品的重量 * 数量 goods_weight += good['weight'] * good['buynum']; if (goods_weight1 > 0) { + out_of_weight = gift_weight_free - goods_weight; + //不能调换位置 下面goods_weight会变大 goods_weight += goods_weight1; - out_of_weight = (gift_weight_free*1000) - goods_weight; } break; case 3: diff --git a/packageC/pages/presell/cart/cart2_pre.js b/packageC/pages/presell/cart/cart2_pre.js index 39a3410..249683d 100644 --- a/packageC/pages/presell/cart/cart2_pre.js +++ b/packageC/pages/presell/cart/cart2_pre.js @@ -342,7 +342,11 @@ Page({ app.getConfig2(function (ee) { app.getwuliuprice(function (rs) { - var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; + var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; + var out_of_weight=null; //超出多少重量 + var freight_free = ee.freight_free; //全场满多少包邮 + var weight_free = ee.weight_free; //多少kg内包邮 + var no_ex_id = ee.no_ex_id; //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格---------- if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && (th.data.kt_type!=3 || th.data.bn_goods.is_normal==1) ){ @@ -353,7 +357,11 @@ Page({ case 2: if (goods_weight < 0) goods_weight = 0; //累积商品重量 每种商品的重量 * 数量 - goods_weight += good['weight'] * good['buynum'];break; + goods_weight += good['weight'] * good['buynum']; + if(weight_free > 0){ + out_of_weight = (weight_free * 1000 ) - goods_weight; + } + break; case 3: if (goods_piece < 0) goods_piece = 0; //累积商品数量 @@ -361,9 +369,8 @@ Page({ } var code = th.data.wu_arr[th.data.index].code; - var freight_free = ee.freight_free; //全场满多少包邮 var shipping_price= - th.calculatewuliu(code, o_shipping_price, goods_weight, + th.calculatewuliu(code, o_shipping_price, goods_weight,out_of_weight, goods_piece, th.data.user_addr, freight_free, allpice, rs); shipping_price = parseFloat(shipping_price).toFixed(2); @@ -701,12 +708,12 @@ Page({ }, //-------------------计算物流--------------- - calculatewuliu:function(code, o_shipping_price, goods_weight, + calculatewuliu:function(code, o_shipping_price, goods_weight,out_of_weight, goods_piece,user_addr, freight_free, o_price, rs){ var price =0,th=this; price +=parseFloat(o_shipping_price); //如果是包邮 - if (freight_free > 0 && o_price >= freight_free){ return 0;} + if (freight_free > 0 && o_price >= freight_free && out_of_weight>=0){ return 0;} if (user_addr==null) { return 0; } //计算物流的config item; var item=null; @@ -720,7 +727,7 @@ Page({ item=item.config; if (item == null) return o_shipping_price; //------按重量---------- - if (goods_weight>0) { + if (goods_weight >= 0 && item['money'] && out_of_weight >= 0) { fw_price =parseFloat(item['money']); if (goods_weight > item['first_weight']){ var fw = goods_weight - item['first_weight']; @@ -728,6 +735,16 @@ Page({ fw_price = fw_price + n * parseFloat(item['add_money']); } } + //------超出重量---------- + if(out_of_weight < 0){ + fw_price = parseFloat(item['money']); + var out_of_weight = Math.abs(out_of_weight); + if (out_of_weight > item['first_weight']) { + var fw = out_of_weight - item['first_weight']; + var n = Math.ceil(fw / item['second_weight']) + fw_price = fw_price + n * parseFloat(item['add_money']); + } + } //------按件数---------- if (goods_piece > 0) { fp_price = parseFloat(item['piecemoney']); diff --git a/pages/cart/cart2/cart2.js b/pages/cart/cart2/cart2.js index 6c161ed..28293a9 100644 --- a/pages/cart/cart2/cart2.js +++ b/pages/cart/cart2/cart2.js @@ -1484,13 +1484,11 @@ Page({ o_price += item[j].goods_price * item[j].goods_num; //判断是否有设置限制重量包邮,先看商品有没有包邮 - if(item[j]['is_past']!==1 && weight_free){ - if( item[j]['exp_sum_type']==2 ){ - if (goods_weight < 0) goods_weight = 0; - //累积商品重量 每种商品的重量 * 数量 - goods_weight += item[j]['weight'] * item[j]['goods_num']; - out_of_weight = (weight_free*1000) - goods_weight; - } + if(item[j]['is_past']!==1 && item[j]['exp_sum_type']==2 && weight_free>0){ + if (goods_weight < 0) goods_weight = 0; + //累积商品重量 每种商品的重量 * 数量 + goods_weight += item[j]['weight'] * item[j]['goods_num']; + out_of_weight = (weight_free*1000) - goods_weight; } } //判断是不是有组合购的金额 @@ -1666,7 +1664,7 @@ Page({ o_shipping_price += item[j]['uniform_exp_sum']; break; // case 2: //1464行已计算 不必重复计算 注释为:判断是否有设置限制重量包邮 - // +'' + // +'' // if (goods_weight < 0) goods_weight = 0; // //累积商品重量 每种商品的重量 * 数量 // goods_weight += item[j]['weight'] * item[j]['goods_num']; @@ -1679,12 +1677,14 @@ Page({ break; } } - }else{ - if(goods_weight && out_of_weight !==0){ - goods_weight=-1; - out_of_weight=0; + if(item[j]['exp_sum_type']==2){ + if(out_of_weight !==0){ + goods_weight=-1; + out_of_weight=0; + } } + } } @@ -1999,7 +1999,9 @@ Page({ //dw //累积商品重量 每种商品的重量 * 数量 goods_weight += good['weight'] * good['buynum']; - out_of_weight = (weight_free * 1000 ) - goods_weight; + if(weight_free > 0){ + out_of_weight = (weight_free * 1000 ) - goods_weight; + } break; case 3: if (goods_piece < 0) goods_piece = 0; @@ -3067,8 +3069,6 @@ Page({ if(out_of_weight < 0){ fw_price = parseFloat(item['money']); var out_of_weight = Math.abs(out_of_weight); - // var n = Math.ceil(out_of_weight / item['second_weight']) - // fw_price = fw_price + n * parseFloat(item['add_money']); if (out_of_weight > item['first_weight']) { var fw = out_of_weight - item['first_weight']; var n = Math.ceil(fw / item['second_weight']) @@ -3985,7 +3985,7 @@ Page({ }, //计算立即购买赠品的物流费用 - get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free,gift_weight_free, allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1) { + get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free,out_of_weight, allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1) { var good = this.data.buy_now_gift_goods; var goods_weight = -1, goods_piece = -1; var gift_shipping_price = 0; diff --git a/pages/cart/cart2_inte/cart2_inte.js b/pages/cart/cart2_inte/cart2_inte.js index 0f2a7f6..d5358b2 100644 --- a/pages/cart/cart2_inte/cart2_inte.js +++ b/pages/cart/cart2_inte/cart2_inte.js @@ -442,6 +442,9 @@ Page({ to.getwuliuprice(async function (rs) { var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; + var out_of_weight=null; //超出多少重量 + var freight_free = ee.freight_free; //全场满多少包邮 + var weight_free = ee.weight_free; //多少kg内包邮 //-----------当地址不为空,且是物流时,计算物流费用,并同时商品不是优惠活动的包邮---------- if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && good.is_past!=1 ){ @@ -452,7 +455,11 @@ Page({ case 2: if (goods_weight < 0) goods_weight = 0; //累积商品重量 每种商品的重量 * 数量 - goods_weight += good['weight'] * good['buynum'];break; + goods_weight += good['weight'] * good['buynum']; + if(weight_free > 0){ + out_of_weight = (weight_free * 1000 ) - goods_weight; + } + break; case 3: if (goods_piece < 0) goods_piece = 0; //累积商品数量 @@ -461,8 +468,7 @@ Page({ var code =""; if(th.data.wu_arr && th.data.wu_arr[th.data.index]) code=th.data.wu_arr[th.data.index].code; - var freight_free = ee.freight_free; //全场满多少包邮 - var no_ex_id=ee.no_ex_id; + var no_ex_id=ee.no_ex_id; th.data.is_no_by[th.data.bn_pick]=0; var no_by_data=null; @@ -924,7 +930,7 @@ Page({ var price =0,th=this; price +=parseFloat(o_shipping_price); //如果是包邮 - if (freight_free > 0 && o_price >= freight_free){ return 0;} + if (freight_free > 0 && o_price >= freight_free && out_of_weight>=0){ return 0;} if (user_addr==null) { return 0; } //计算物流的config item; var item=null; @@ -938,7 +944,7 @@ Page({ item=item.config; if (item == null) return o_shipping_price; //------按重量---------- - if (goods_weight>=0 && item['money']) { + if (goods_weight >= 0 && item['money'] && out_of_weight >= 0) { fw_price =parseFloat(item['money']); if (goods_weight > item['first_weight']){ var fw = goods_weight - item['first_weight']; @@ -946,6 +952,16 @@ Page({ fw_price = fw_price + n * parseFloat(item['add_money']); } } + //------超出重量---------- + if(out_of_weight < 0){ + fw_price = parseFloat(item['money']); + var out_of_weight = Math.abs(out_of_weight); + if (out_of_weight > item['first_weight']) { + var fw = out_of_weight - item['first_weight']; + var n = Math.ceil(fw / item['second_weight']) + fw_price = fw_price + n * parseFloat(item['add_money']); + } + } //------按件数---------- if (goods_piece > 0 && item['piecemoney']) { fp_price = parseFloat(item['piecemoney']); diff --git a/pages/cart/cart2_pt/cart2_pt.js b/pages/cart/cart2_pt/cart2_pt.js index 377b76f..f80416d 100644 --- a/pages/cart/cart2_pt/cart2_pt.js +++ b/pages/cart/cart2_pt/cart2_pt.js @@ -395,7 +395,6 @@ Page({ }, //---------计算立即购买---------- calculatePrice2: function () { - console.log('calculatePrice2'); var th = this, good = this.data.bn_goods; //-----------计算商品总价-------------- var allpice = good.shop_price * good.buynum; @@ -408,7 +407,10 @@ Page({ to.getwuliuprice(function (rs) { console.log('calculatePrice2222'); console.log(rs); - var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; + var o_shipping_price = 0,goods_weight = -1,goods_piece = -1; + var out_of_weight=null; //超出多少重量 + var freight_free = ee.freight_free; //全场满多少包邮 + var weight_free = ee.weight_free; //多少kg内包邮 //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格---------- if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && (th.data.kt_type!=3 || th.data.bn_goods.is_normal==1) ){ switch (good['exp_sum_type']) { @@ -418,7 +420,12 @@ Page({ case 2: if (goods_weight < 0) goods_weight = 0; //累积商品重量 每种商品的重量 * 数量 - goods_weight += good['weight'] * good['buynum'];break; + goods_weight += good['weight'] * good['buynum']; + if(weight_free > 0){ + out_of_weight = (weight_free * 1000 ) - goods_weight; + } + break; + // goods_weight += good['weight'] * good['buynum'];break; case 3: if (goods_piece < 0) goods_piece = 0; //累积商品数量 @@ -430,7 +437,7 @@ Page({ var code = th.data.wu_arr[th.data.index].code; var freight_free = ee.freight_free; //全场满多少包邮 var shipping_price= - th.calculatewuliu(code, o_shipping_price, goods_weight, + th.calculatewuliu(code, o_shipping_price, goods_weight,out_of_weight, goods_piece, th.data.user_addr, freight_free, allpice, rs); shipping_price = parseFloat(shipping_price).toFixed(2); @@ -779,7 +786,7 @@ Page({ var price =0,th=this; price +=parseFloat(o_shipping_price); //如果是包邮 - if (freight_free > 0 && o_price >= freight_free){ return 0;} + if (freight_free > 0 && o_price >= freight_free && out_of_weight>=0){ return 0;} if (user_addr==null) { return 0; } //计算物流的config item; var item=null; @@ -793,7 +800,7 @@ Page({ item=item.config; if (item == null) return o_shipping_price; //------按重量---------- - if (goods_weight>=0) { + if (goods_weight >= 0 && item['money'] && out_of_weight >= 0) { fw_price =parseFloat(item['money']); if (goods_weight > item['first_weight']){ var fw = goods_weight - item['first_weight']; @@ -801,6 +808,16 @@ Page({ fw_price = fw_price + n * parseFloat(item['add_money']); } } + //------超出重量---------- + if(out_of_weight < 0){ + fw_price = parseFloat(item['money']); + var out_of_weight = Math.abs(out_of_weight); + if (out_of_weight > item['first_weight']) { + var fw = out_of_weight - item['first_weight']; + var n = Math.ceil(fw / item['second_weight']) + fw_price = fw_price + n * parseFloat(item['add_money']); + } + } //------按件数---------- if (goods_piece > 0) { fp_price = parseFloat(item['piecemoney']); diff --git a/pages/cart/cart_wk/cart_wk.js b/pages/cart/cart_wk/cart_wk.js index f55f477..b34316d 100644 --- a/pages/cart/cart_wk/cart_wk.js +++ b/pages/cart/cart_wk/cart_wk.js @@ -420,10 +420,10 @@ Page({ var to = getApp(), th = this; to.getConfig2(function (ee) { to.getwuliuprice(function (rs) { - var o_shipping_price = 0, - goods_weight = -1, - goods_piece = -1, - good = th.data.goods; + var o_shipping_price = 0,goods_weight = -1,goods_piece = -1; + var out_of_weight=null; //超出多少重量 + var freight_free = ee.freight_free; //全场满多少包邮 + var weight_free = ee.weight_free; //多少kg内包邮 //-----------当地址不为空,且是物流时,计算物流费用---------- if (th.data.user_addr != null && th.data.exp_type == 0 && good.is_free_shipping == 0) { switch (good['exp_sum_type']) { @@ -435,6 +435,9 @@ Page({ if (goods_weight < 0) goods_weight = 0; //累积商品重量 每种商品的重量 * 数量 goods_weight += good['weight'] * th.data.order.order_goods['goods_num']; + if(weight_free > 0){ + out_of_weight = (weight_free * 1000 ) - goods_weight; + } break; case 3: if (goods_piece < 0) goods_piece = 0; @@ -443,7 +446,6 @@ Page({ break; } var code = th.data.wu_arr[th.data.index].code; - var freight_free = ee.freight_free; //全场满多少包邮 //--全部金额-- var allpice = th.data.order.order_amount + th.data.order.user_money + th.data.order.pt_tail_money; var shipping_price = @@ -470,7 +472,7 @@ Page({ var price = 0, th = this; price += parseFloat(o_shipping_price); //如果是包邮 - if (freight_free > 0 && o_price >= freight_free) { return 0; } + if (freight_free > 0 && o_price >= freight_free && out_of_weight>=0) { return 0; } if (user_addr == null) { return 0; } //计算物流的config item; var item = null; @@ -484,7 +486,7 @@ Page({ item = item.config; if (item == null) return o_shipping_price; //------按重量---------- - if (goods_weight > 0) { + if (goods_weight >= 0 && item['money'] && out_of_weight >= 0) { fw_price = parseFloat(item['money']); if (goods_weight > item['first_weight']) { var fw = goods_weight - item['first_weight']; @@ -492,6 +494,16 @@ Page({ fw_price = fw_price + n * parseFloat(item['add_money']); } } + //------超出重量---------- + if(out_of_weight < 0){ + fw_price = parseFloat(item['money']); + var out_of_weight = Math.abs(out_of_weight); + if (out_of_weight > item['first_weight']) { + var fw = out_of_weight - item['first_weight']; + var n = Math.ceil(fw / item['second_weight']) + fw_price = fw_price + n * parseFloat(item['add_money']); + } + } //------按件数---------- if (goods_piece > 0) { fp_price = parseFloat(item['piecemoney']); -- libgit2 0.21.4