diff --git a/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js b/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js index 958c92d..61a160b 100644 --- a/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js +++ b/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js @@ -495,7 +495,7 @@ Page({ }); }, //---------计算立即购买---------- - calculatePrice2: function () { + calculatePrice2: async function () { console.log('calculatePrice2'); var th = this, good = this.data.bn_goods; @@ -506,12 +506,14 @@ Page({ th.setData({ [txt]: allpice, }); - console.log(th.data.formData); - - to.getwuliuprice(async function (rs) { + wx.showLoading({ + title: "处理中.", + mask:true + }) + //to.getwuliuprice(async function (rs) { - var o_shipping_price = 0, + var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; var out_of_weight = null; //超出多少重量 @@ -539,8 +541,7 @@ Page({ let item = gd_arr_list[i]; if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { - - + if (goods_weight < 0) goods_weight = 0; if (item['exp_sum_type'] == 2) { goods_weight += item['weight'] * item['buynum']; cut_good_weight += item['weight'] * item['buynum']; @@ -581,9 +582,36 @@ Page({ else out_of_weight = -back_data.weight_free * 1000; var code = th.data.wu_arr[th.data.index].code; - var shipping_price = - ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, - goods_piece, th.data.user_addr, back_data,rs); + var shipping_price =0; + // ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, + // goods_piece, th.data.user_addr, back_data,rs); + + var w_data={ + store_id:os.stoid, code:code, + o_shipping_price:o_shipping_price, + goods_weight:goods_weight, + out_of_weight:out_of_weight,goods_piece:goods_piece, + user_addr_province:th.data.user_addr.province, + 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, + } + + var is_ok=0; + await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', {data:w_data,is_json:1}).then(res=>{ + if(res.data.code==0){ + shipping_price=res.data.data; is_ok=1; + } + }) + if(!is_ok){ + wx.showToast({ + title: "计算物流错误", icon: 'none',duration: 2000 + }) + th.setData({ show_submit:0 }); + wx.hideLoading(); + } + shipping_price = parseFloat(shipping_price).toFixed(2); var wl_txt = "formData.shipping_price"; @@ -616,24 +644,27 @@ Page({ if (parseFloat(th.data.yuer) > total_m) { th.setData({ [txt]: total_m, - [txt2]: 0 + [txt2]: 0, + is_show_sub:1 }) } else { order_m = parseFloat(order_m) - parseFloat(th.data.yuer); order_m = order_m.toFixed(2); th.setData({ [txt]: th.data.yuer, - [txt2]: order_m + [txt2]: order_m, + is_show_sub:1 }) } } else { th.setData({ [txt]: 0, - [txt2]: order_m + [txt2]: order_m, + is_show_sub:1 }) } - - }); + wx.hideLoading(); + //}); }, diff --git a/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.wxml b/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.wxml index d8ac4ac..de02a90 100644 --- a/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.wxml +++ b/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.wxml @@ -154,7 +154,7 @@ - + 应付金额:¥{{formData.order_amount}} diff --git a/packageC/pages/presell/cart/cart.js b/packageC/pages/presell/cart/cart.js index 7fc3c63..addd47c 100644 --- a/packageC/pages/presell/cart/cart.js +++ b/packageC/pages/presell/cart/cart.js @@ -1716,9 +1716,9 @@ Page({ //----计算物流的钱---- - calculate_wuliu() { + async calculate_wuliu() { var to = getApp(), th = this; - to.getwuliuprice(async function (rs) { + //to.getwuliuprice(async function (rs) { var o_shipping_price = 0, goods_weight = -1, goods_piece = -1, @@ -1823,6 +1823,7 @@ Page({ let item = gd_arr_list[i]; if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { + if (goods_weight < 0) goods_weight = 0; if (item['exp_sum_type'] == 2) { goods_weight += item['weight'] * item['buynum']; cut_good_weight += item['weight'] * item['buynum']; @@ -1867,8 +1868,36 @@ Page({ th.data.is_no_by[th.data.bn_pick] = 0; //--------------开始计算物流------------------ - var shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, - goods_piece, th.data.user_addr, back_data, rs); + var shipping_price =0; + + //ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, + //goods_piece, th.data.user_addr, back_data, rs); + var w_data={ + store_id:os.stoid, code:code, + o_shipping_price:o_shipping_price, + goods_weight:goods_weight, + out_of_weight:out_of_weight,goods_piece:goods_piece, + user_addr_province:th.data.user_addr.province, + 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, + } + + var is_ok=0; + await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', {data:w_data,is_json:1}).then(res=>{ + if(res.data.code==0){ + shipping_price=res.data.data; is_ok=1; + } + }) + if(!is_ok){ + wx.showToast({ + title: "计算物流错误", icon: 'none',duration: 2000 + }) + th.setData({ show_submit:0 }); + wx.hideLoading(); + return false; + } exp_price = parseFloat(shipping_price).toFixed(2); } @@ -1876,7 +1905,7 @@ Page({ } else { th.wuliu_next(allpice, quan_price, exp_price); } - }); + //}); }, //相同的东西统一在一起 wuliu_next(allpice, quan_price, exp_price) { diff --git a/packageC/pages/presell/cart/cart.wxml b/packageC/pages/presell/cart/cart.wxml index fcea355..5789681 100644 --- a/packageC/pages/presell/cart/cart.wxml +++ b/packageC/pages/presell/cart/cart.wxml @@ -346,6 +346,9 @@ + + + 尾款时间{{filters.format_time(act.pay_begindate,1)}} - @@ -363,7 +366,7 @@ - + @@ -371,14 +374,13 @@ 取消订单 - 立即付款 + + 删除订单 - - @@ -401,6 +403,8 @@ + + diff --git a/packageC/pages/presell/cart/cart2.js b/packageC/pages/presell/cart/cart2.js index d513611..bdf859f 100644 --- a/packageC/pages/presell/cart/cart2.js +++ b/packageC/pages/presell/cart/cart2.js @@ -571,7 +571,7 @@ Page({ //---------计算立即购买---------- - calculatePrice2: function () { + calculatePrice2: async function () { var th = this, good = this.data.bn_goods; if (!good) return false; @@ -582,7 +582,7 @@ Page({ } wx.showLoading({ - title: "处理中." + title: "处理中.",mask:true }) //-----------计算商品总价-------------- var allpice = good.shop_price * good.buynum; @@ -609,8 +609,8 @@ Page({ } - to.getConfig2(function (ee) { - to.getwuliuprice(async function (rs) { + // to.getConfig2(function (ee) { + // to.getwuliuprice(async function (rs) { var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; var out_of_weight = null; //超出多少重量 @@ -699,6 +699,7 @@ Page({ let item = gd_arr_list[i]; if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { + if (goods_weight < 0) goods_weight = 0; if (item['exp_sum_type'] == 2) { cut_good_weight += item['weight'] * item['buynum']; goods_weight += item['weight'] * item['buynum']; @@ -744,9 +745,35 @@ Page({ if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code; //--------------开始计算物流------------------ - var shipping_price = - ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, - goods_piece, th.data.user_addr, back_data, rs); + var shipping_price =0; + // ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, + // goods_piece, th.data.user_addr, back_data, rs); + var w_data={ + store_id:os.stoid, code:code, + o_shipping_price:o_shipping_price, + goods_weight:goods_weight, + out_of_weight:out_of_weight,goods_piece:goods_piece, + user_addr_province:th.data.user_addr.province, + 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, + } + + var is_ok=0; + await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', {data:w_data,is_json:1}).then(res=>{ + if(res.data.code==0){ + shipping_price=res.data.data; is_ok=1; + } + }) + if(!is_ok){ + wx.showToast({ + title: "计算物流错误", icon: 'none',duration: 2000 + }) + th.setData({ show_submit:0 }); + wx.hideLoading(); + return false; + } if (shipping_price <= 0) { @@ -915,8 +942,8 @@ Page({ wx.hideLoading(); - }); - }); + // }); + // }); }, //--------------------提交订单----------------------- diff --git a/pages/cart/cart/cart.js b/pages/cart/cart/cart.js index fcd9bc3..f67c2a8 100644 --- a/pages/cart/cart/cart.js +++ b/pages/cart/cart/cart.js @@ -1731,7 +1731,7 @@ Page({ function normal_check(store_count, goodsinfo, wareIds) { //--- 看一下是不是线下库存 --- - if (th.data.sales_rules == 2 && goodsinfo.prom_type != 7) { + if (th.data.sales_rules == 2 && goodsinfo.prom_type != 7 && !goodsinfo.whsle_id) { th.check_down_line(t, pitem, item, wareIds); } else { if (t.goods_num > store_count) { @@ -2491,7 +2491,7 @@ Page({ ab = 1; //--普通商品,如果有开启线下库存的功能,要调用线下库存进行计算,赠品不要进行调用线下库存--- if ((i_arr[j].prom_type == 0 || i_arr[j].prom_type == 3 || i_arr[j].prom_type == 5 || - i_arr[j].need_downlow_num) && th.data.sales_rules == 2 && i_arr[j].is_gift != 1) { + i_arr[j].need_downlow_num) && th.data.sales_rules == 2 && i_arr[j].is_gift != 1 && !i_arr[j].whsle_id) { //--获取商品的线下商品ID-- var gd = null; await getApp().request.promiseGet("/api/weshop/goods/get/" + oo.stoid + "/" + i_arr[j].goods_id, {}).then(res => { diff --git a/pages/cart/cart2/cart2.js b/pages/cart/cart2/cart2.js index ae38c3b..47c3850 100644 --- a/pages/cart/cart2/cart2.js +++ b/pages/cart/cart2/cart2.js @@ -882,6 +882,11 @@ Page({ gd.prom_type = gg.prom_type ? gg.prom_type : 0; gd.prom_id = gg.prom_id ? gg.prom_id : 0; + if(gd.whsle_id>0){ + gd.prom_type =gg.prom_type=0; + gd.prom_id =gg.prom_id=0; + } + switch (gd.prom_type) { case 0: case 3: @@ -1458,15 +1463,14 @@ Page({ }, //-------------------计算订单价格------------------- - calculatePrice: function (t, s) { + calculatePrice:async function (t, s) { var th = this; wx.showLoading({ title: "处理中.", mask:true }) - - to.getwuliuprice(async function (rs) { + //-- to.getwuliuprice(async function (rs) { -- //是不是区域包邮 th.data.is_area_by = 0; @@ -1759,8 +1763,8 @@ 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)) { - + if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item[j].goods_id) == -1)) { + if (goods_weight < 0) goods_weight = 0; if (item[j]['exp_sum_type'] == 2) { cut_good_weight += item[j]['weight'] * item[j]['goods_num']; goods_weight += item[j]['weight'] * item[j]['goods_num']; @@ -1805,8 +1809,38 @@ Page({ var code = ""; if (th.data.wu_arr && th.data.wu_arr[cart_item.wind]) code = th.data.wu_arr[cart_item.wind].code; - cart_item.shipping_price = - ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,goods_piece, th.data.user_addr, back_data, rs); + + // 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 w_data={ + store_id:os.stoid, code:code, + o_shipping_price:o_shipping_price, + goods_weight:goods_weight, + out_of_weight:out_of_weight,goods_piece:goods_piece, + user_addr_province:th.data.user_addr.province, + 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, + } + + var is_ok=1; + await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', {data:w_data,is_json:1}).then(res=>{ + if(res.data.code==0){ + cart_item.shipping_price=res.data.data; + }else{ + is_ok=0; + } + }) + + if(!is_ok){ + wx.showToast({ + title: "计算物流错误", icon: 'none',duration: 2000 + }) + th.setData({ show_submit:0 }); + wx.hideLoading(); + } if (!th.data.using_quan[pickid] || th.data.using_quan[pickid].isby != 1) { if (cart_item.shipping_price == 0) th.data.is_by[pickid] = 1; //已经全场包邮,就不要选择券了 @@ -1960,7 +1994,7 @@ Page({ th.set_can_num(); wx.hideLoading(); - }); + //}); }, set_can_num: function () { @@ -1994,7 +2028,7 @@ Page({ //---------计算立即购买---------- - calculatePrice2: function () { + calculatePrice2: async function () { var th = this, good = this.data.bn_goods; if (!good) return false; @@ -2033,7 +2067,7 @@ Page({ allpice = good.offline_price * good.buynum; } - to.getwuliuprice(async function (rs) { + //to.getwuliuprice(async function (rs) { var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; var out_of_weight = null; //超出多少重量 @@ -2163,6 +2197,7 @@ Page({ if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { + if (goods_weight < 0) goods_weight = 0; if (item['exp_sum_type'] == 2) { goods_weight += item['weight'] * item['buynum']; cut_good_weight += item['weight'] * item['buynum']; @@ -2209,8 +2244,37 @@ Page({ th.data.is_by[th.data.bn_pick] = 0; //--------------开始计算物流------------------ - shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, - goods_piece, th.data.user_addr, back_data, rs); + // shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, + // goods_piece, th.data.user_addr, back_data, rs); + + var w_data={ + store_id:os.stoid, code:code, + o_shipping_price:o_shipping_price, + goods_weight:goods_weight, + out_of_weight:out_of_weight,goods_piece:goods_piece, + user_addr_province:th.data.user_addr.province, + 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, + } + + var is_ok=1; + await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', {data:w_data,is_json:1}).then(res=>{ + if(res.data.code==0){ + shipping_price=res.data.data; + }else{ + is_ok=0; + } + }) + + if(!is_ok){ + wx.showToast({ + title: "计算物流错误", icon: 'none',duration: 2000 + }) + th.setData({ show_submit:0 }); + wx.hideLoading(); + } if (shipping_price <= 0) { th.data.is_by[th.data.bn_pick] = 1; //已经是包邮了,就不要选择包邮券 @@ -2408,7 +2472,7 @@ Page({ wx.hideLoading(); - }); + //}); }, @@ -2606,7 +2670,7 @@ Page({ if (gg.is_pd_normal) goods.is_pd_normal = 1; //如果不立即购买或者秒杀,如果是线下库存购买的时候 - if (goods.prom_type != 1 && goods.prom_type != 6 && goods.prom_type != 2 && th.data.sales_rules == 2) { + if (goods.prom_type != 1 && goods.prom_type != 6 && goods.prom_type != 2 && th.data.sales_rules == 2 && !th.data.bn_goods.whsle_id) { var isok = 1; await th.check_store_num(goods.goods_id, th.data.bn_pick, gg.goods_num, function (res) { isok = res; @@ -2850,121 +2914,125 @@ Page({ } //代发商品的集合 - var df_goods=[]; - var df_price=0; - var df_room_ids=""; - //-------------让商品添加到商品列表-------------------- - for (var k = 0; k < t_item.goods.length; k++) { - var g_item = t_item.goods[k]; - if (g_item.goods_num <= 0) continue; - var goods = { - 'goods_id': g_item.goods_id, - 'goods_name': g_item.goods_name, - 'goods_sn': g_item.goods_sn, - 'goods_num': g_item.goods_num, - 'market_price': g_item.market_price, - 'goods_price': g_item.goods_price, - 'member_goods_price': g_item.goods_price, - 'store_id': oo.stoid, - }; + var df_goods = []; + var df_price = 0; + var df_room_ids = ""; + + //多个商品才运算 + if( t_item.goods.length>1) { + //-------------让商品添加到商品列表-------------------- + for (var k = 0; k < t_item.goods.length; k++) { + var g_item = t_item.goods[k]; + if (g_item.goods_num <= 0) continue; + var goods = { + 'goods_id': g_item.goods_id, + 'goods_name': g_item.goods_name, + 'goods_sn': g_item.goods_sn, + 'goods_num': g_item.goods_num, + 'market_price': g_item.market_price, + 'goods_price': g_item.goods_price, + 'member_goods_price': g_item.goods_price, + 'store_id': oo.stoid, + }; - if (getApp().globalData.skinface_id) { - goods.skinface_id = getApp().globalData.skinface_id; - } + if (getApp().globalData.skinface_id) { + goods.skinface_id = getApp().globalData.skinface_id; + } - //-- 线下取价也要写入,组合购的商品不能去线下价格 -- - if (g_item.offline_price && t_item.is_offline == 1 && g_item.prom_type != 7) { - goods.goods_price = g_item.offline_price; - goods.member_goods_price = g_item.offline_price; - goods.offline_cut = (g_item.goods_price - g_item.offline_price).toFixed(2); - goods.pricing_type = g_item.pricing_type; - } - if (g_item.quan_num) { - goods.quan_num = g_item.quan_num; - goods.quan_no = g_item.quan_no; - } - //--判断活动的类型-- - switch (g_item.prom_type) { - case 1: - case 2: - case 10: - goods.prom_type = g_item.prom_type; - goods.prom_id = g_item.prom_id; - break; - case 3: - goods.prom_type = 3; - goods.prom_id = g_item.prom_id; - if (g_item.is_gift) { - goods.is_gift = g_item.is_gift; - goods.gift_id = g_item.gift_id; - } - break; - case 5: - goods.prom_type = 5; - goods.prom_id = g_item.prom_id; - if (g_item.is_collocation) { - goods.is_collocation = g_item.is_collocation; - } - break - case 7: - goods.prom_type = 7; - goods.prom_id = g_item.prom_id; - break - default: - goods.prom_type = 0; - goods.prom_id = 0; - } + //-- 线下取价也要写入,组合购的商品不能去线下价格 -- + if (g_item.offline_price && t_item.is_offline == 1 && g_item.prom_type != 7) { + goods.goods_price = g_item.offline_price; + goods.member_goods_price = g_item.offline_price; + goods.offline_cut = (g_item.goods_price - g_item.offline_price).toFixed(2); + goods.pricing_type = g_item.pricing_type; + } + if (g_item.quan_num) { + goods.quan_num = g_item.quan_num; + goods.quan_no = g_item.quan_no; + } + //--判断活动的类型-- + switch (g_item.prom_type) { + case 1: + case 2: + case 10: + goods.prom_type = g_item.prom_type; + goods.prom_id = g_item.prom_id; + break; + case 3: + goods.prom_type = 3; + goods.prom_id = g_item.prom_id; + if (g_item.is_gift) { + goods.is_gift = g_item.is_gift; + goods.gift_id = g_item.gift_id; + } + break; + case 5: + goods.prom_type = 5; + goods.prom_id = g_item.prom_id; + if (g_item.is_collocation) { + goods.is_collocation = g_item.is_collocation; + } + break + case 7: + goods.prom_type = 7; + goods.prom_id = g_item.prom_id; + break + default: + goods.prom_type = 0; + goods.prom_id = 0; + } - //如果不立即购买或者秒杀,如果是线下库存购买的时候 - if (goods.prom_type == 0 && th.data.sales_rules == 2) { - var isok = 1; - await th.check_store_num(goods.goods_id, t_item.pickup_id, goods.goods_num, function (res) { - isok = res; - }); - if (!isok) { - getApp().confirmBox(goods.goods_name + "的门店库存不足"); - th.data.is_summit_ing = 0; - return false; + //如果不立即购买或者秒杀,如果是线下库存购买的时候 + if (goods.prom_type == 0 && th.data.sales_rules == 2) { + var isok = 1; + await th.check_store_num(goods.goods_id, t_item.pickup_id, goods.goods_num, function (res) { + isok = res; + }); + if (!isok) { + getApp().confirmBox(goods.goods_name + "的门店库存不足"); + th.data.is_summit_ing = 0; + return false; + } } - } - //把优惠的平摊结果写进去 - if (g_item.account >= 0 || (g_item.account_yu != 0 && g_item.account != undefined)) { - if (g_item.account >= 0) goods.account = g_item.account; - if (g_item.account_yu != 0) goods.account_yu = g_item.account_yu; - item.is_discount_amount = 1; - } + //把优惠的平摊结果写进去 + if (g_item.account >= 0 || (g_item.account_yu != 0 && g_item.account != undefined)) { + if (g_item.account >= 0) goods.account = g_item.account; + if (g_item.account_yu != 0) goods.account_yu = g_item.account_yu; + item.is_discount_amount = 1; + } - //导购ID - if (g_item.guide_id) { - goods.guide_id = g_item.guide_id; - goods.guide_type = g_item.guide_type; - //调用接口判断是不是会员 - await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + g_item.guide_id, {}).then(res => { - if (res.data.code == 0) { - goods.guide_name = res.data.data.salesman; - goods.guide_sn = res.data.data.salesman_no; - } - }) - } + //导购ID + if (g_item.guide_id) { + goods.guide_id = g_item.guide_id; + goods.guide_type = g_item.guide_type; + //调用接口判断是不是会员 + await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + g_item.guide_id, {}).then(res => { + if (res.data.code == 0) { + goods.guide_name = res.data.data.salesman; + goods.guide_sn = res.data.data.salesman_no; + } + }) + } - //如果有阶梯促销 - if (g_item.ladder_list_id) { - goods.ladder_list_id = g_item.ladder_list_id; - } + //如果有阶梯促销 + if (g_item.ladder_list_id) { + goods.ladder_list_id = g_item.ladder_list_id; + } - //-- 如果有代发商品,就要开始拆单 -- - if(g_item.whsle_id){ - df_price+= parseFloat(g_item.goods_num*g_item.goods_price); - goods.is_whsle_goods=1; - df_goods.push(goods); - df_room_ids+= g_item.room_id + ","; - }else{ - item.order_goods.push(goods); - //如果房间号不为空的时候 - if (g_item.room_id) { - goods.room_id = g_item.room_id; - room_ids += g_item.room_id + ","; + //-- 如果有代发商品,就要开始拆单 -- + if (g_item.whsle_id) { + df_price += parseFloat(g_item.goods_num * g_item.goods_price); + goods.is_whsle_goods = 1; + df_goods.push(goods); + df_room_ids += g_item.room_id + ","; + } else { + item.order_goods.push(goods); + //如果房间号不为空的时候 + if (g_item.room_id) { + goods.room_id = g_item.room_id; + room_ids += g_item.room_id + ","; + } } } } diff --git a/pages/cart/cart2_inte/cart2_inte.js b/pages/cart/cart2_inte/cart2_inte.js index f9dcd6f..fe42052 100644 --- a/pages/cart/cart2_inte/cart2_inte.js +++ b/pages/cart/cart2_inte/cart2_inte.js @@ -407,9 +407,9 @@ Page({ //---------计算立即购买---------- - calculatePrice2: function () { + calculatePrice2:async function () { var th = this, good = this.data.bn_goods; - wx.showLoading({ title: "处理中.", }) + wx.showLoading({ title: "处理中.", mask:true }) //-----------计算商品总价-------------- var allpice = good.shop_price * good.buynum; var all_integral = good.integral * good.buynum; @@ -426,7 +426,7 @@ Page({ th.setData({ [c_txt]: cut_price, }); } - to.getwuliuprice(async function (rs) { + //to.getwuliuprice(async function (rs) { var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; var out_of_weight = null; //超出多少重量 @@ -453,6 +453,7 @@ Page({ let item = gd_arr_list[i]; if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1) ) { + if (goods_weight < 0) goods_weight = 0; if (item['exp_sum_type'] == 2) { goods_weight += item['weight'] * item['buynum']; cut_good_weight += item['weight'] * item['buynum']; @@ -495,8 +496,38 @@ 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 shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, - goods_piece, th.data.user_addr, back_data, rs); + var shipping_price=0; + // var shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, + // goods_piece, th.data.user_addr, back_data, rs); + + var w_data={ + store_id:os.stoid, code:code, + o_shipping_price:o_shipping_price, + goods_weight:goods_weight, + out_of_weight:out_of_weight,goods_piece:goods_piece, + user_addr_province:th.data.user_addr.province, + 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, + } + + var is_ok=0; + await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', {data:w_data,is_json:1}).then(res=>{ + if(res.data.code==0){ + shipping_price=res.data.data; is_ok=1; + } + }) + if(!is_ok){ + wx.showToast({ + title: "计算物流错误", icon: 'none',duration: 2000 + }) + th.setData({ show_submit:0 }); + wx.hideLoading(); + return false; + } + + if (shipping_price <= 0) { th.data.is_by[th.data.bn_pick] = 1; //已经是包邮了,就不要选择包邮券 } @@ -547,7 +578,7 @@ Page({ wx.hideLoading(); - }); + //}); }, diff --git a/pages/cart/cart2_pt/cart2_pt.js b/pages/cart/cart2_pt/cart2_pt.js index 1f39299..db2038f 100644 --- a/pages/cart/cart2_pt/cart2_pt.js +++ b/pages/cart/cart2_pt/cart2_pt.js @@ -394,7 +394,7 @@ Page({ }); }, //---------计算立即购买---------- - calculatePrice2: function () { + calculatePrice2:async function () { wx.showLoading({ title: "处理中.", @@ -408,9 +408,10 @@ Page({ var txt = "formData.all_price"; th.setData({ [txt]: allpice, }); - to.getwuliuprice(async function (rs) { + //to.getwuliuprice(async function (rs) { console.log('calculatePrice2222'); - console.log(rs); + //console.log(rs); + var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; var out_of_weight = null; //超出多少重量 @@ -436,7 +437,8 @@ Page({ let item = gd_arr_list[i]; if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { - if (item['exp_sum_type'] == 2) { + if (goods_weight < 0) goods_weight = 0; + if (item['exp_sum_type'] == 2) { cut_good_weight += item['weight'] * item['buynum']; goods_weight += item['weight'] * item['buynum']; } @@ -479,8 +481,36 @@ Page({ var code = th.data.wu_arr[th.data.index].code; //--------------开始计算物流------------------ - var shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, - goods_piece, th.data.user_addr, back_data, rs); + var shipping_price=0; + // var shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, + // goods_piece, th.data.user_addr, back_data, rs); + + var w_data={ + store_id:os.stoid, code:code, + o_shipping_price:o_shipping_price, + goods_weight:goods_weight, + out_of_weight:out_of_weight,goods_piece:goods_piece, + user_addr_province:th.data.user_addr.province, + 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, + } + + var is_ok=0; + await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', {data:w_data,is_json:1}).then(res=>{ + if(res.data.code==0){ + shipping_price=res.data.data; is_ok=1; + } + }) + if(!is_ok){ + wx.showToast({ + title: "计算物流错误", icon: 'none',duration: 2000 + }) + th.setData({ show_submit:0 }); + wx.hideLoading(); + return false; + } shipping_price = parseFloat(shipping_price).toFixed(2); var wl_txt = "formData.shipping_price"; @@ -515,7 +545,7 @@ Page({ wx.hideLoading(); - }); + //}); }, //--------------------提交订单----------------------- diff --git a/pages/cart/cart_wk/cart_wk.js b/pages/cart/cart_wk/cart_wk.js index 7e613c2..6dc8685 100644 --- a/pages/cart/cart_wk/cart_wk.js +++ b/pages/cart/cart_wk/cart_wk.js @@ -473,9 +473,9 @@ Page({ }, //----计算物流的钱---- - calculate_wuliu() { + async calculate_wuliu() { var to = getApp(), th = this; - to.getwuliuprice(async function (rs) { + //to.getwuliuprice(async function (rs) { var o_shipping_price = 0, goods_weight = -1, goods_piece = -1, good = th.data.goods; var out_of_weight = null; //超出多少重量 @@ -505,7 +505,8 @@ Page({ let item = gd_arr_list[i]; if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { - if (item['exp_sum_type'] == 2) { + if (goods_weight < 0) goods_weight = 0; + if (item['exp_sum_type'] == 2) { goods_weight += item['weight'] * item['buynum']; cut_good_weight += item['weight'] * item['buynum']; } @@ -547,8 +548,36 @@ Page({ var code = th.data.wu_arr[th.data.index].code; //--------------开始计算物流------------------ - var shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, - goods_piece, th.data.user_addr, back_data, rs); + var shipping_price =0; + // ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, + // goods_piece, th.data.user_addr, back_data, rs); + + var w_data={ + store_id:os.stoid, code:code, + o_shipping_price:o_shipping_price, + goods_weight:goods_weight, + out_of_weight:out_of_weight,goods_piece:goods_piece, + user_addr_province:th.data.user_addr.province, + 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, + } + + var is_ok=0; + await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', {data:w_data,is_json:1}).then(res=>{ + if(res.data.code==0){ + shipping_price=res.data.data; is_ok=1; + } + }) + if(!is_ok){ + wx.showToast({ + title: "计算物流错误", icon: 'none',duration: 2000 + }) + th.setData({ show_submit:0 }); + wx.hideLoading(); + return false; + } var exp_price = parseFloat(shipping_price).toFixed(2); allpice = parseFloat(exp_price) + parseFloat(allpice); @@ -561,7 +590,7 @@ Page({ allpice = allpice.toFixed(2); th.setData({ exp_price: 0, allpice: allpice }) } - }); + //}); }, diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index cc996e0..9e23f2c 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -561,7 +561,7 @@ Page({ var that = this, th = this; getApp().getConfig2(function (e) { var sales_rules = e.sales_rules; - if (sales_rules == 2 && [1,2,4,6,8,9].indexOf(th.data.prom_type)==-1 ) { + if (sales_rules == 2 && [1,2,4,6,8,9].indexOf(th.data.prom_type)==-1 && !th.data.sele_g.whsle_id ) { getApp().waitfor2(that, "wait_for_user_store", "fir_goods", function () { var lock = 0, plist = null; var gd = that.data.fir_goods; @@ -1676,7 +1676,7 @@ Page({ } //---如果是线下门店销售的时候--- - if (th.data.sales_rules == 2) { + if (th.data.sales_rules == 2 && !th.data.sele_g.whsle_id ) { var pick = th.get_pick_from_list(th.data.sto_sele_id) //---通过接口获取门店的线下库存信息-- getApp().request.get("/api/weshop/goods/getWareStorages", { @@ -2348,7 +2348,7 @@ Page({ check_is_prom_goods: function (callback) { var th = this; var usr = getApp().globalData.userInfo; - if (this.data.sele_g.prom_type != 0 && this.data.sele_g.prom_type != 3) { + if (this.data.sele_g.prom_type != 0 && this.data.sele_g.prom_type != 3 && !this.data.sele_g.whsle_id) { callback(); } else { //-- 判断有没有优惠活动 -- @@ -2862,7 +2862,7 @@ Page({ if(!item.whsle_id) that.check_is_youhui(gid, that.data.is_normal); //默认门店要拿下门店库存 - if (that.data.sales_rules == 2 && that.data.def_pick_store) { + if (that.data.sales_rules == 2 && that.data.def_pick_store && !that.data.sele_g.whsle_id ) { var lock = 0, plist = null; //先读取门店的lock,采用链式写法,少用await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { @@ -3089,7 +3089,7 @@ Page({ th.setData({all_pick_list: e.data.data.pageData}); //--获取线下库存,而且不是新的门店规则, 同时是普通购买的时候,或者同时不能是活动,秒杀,拼团,积分购-- - if (th.data.sales_rules == 2 && !th.data.is_newsales_rules && ((th.data.prom_type != 1 && th.data.prom_type != 6 && th.data.prom_type != 4) || is_normal == 1)) { + if (th.data.sales_rules == 2 && !th.data.is_newsales_rules && !th.data.sele_g.whsle_id && ((th.data.prom_type != 1 && th.data.prom_type != 6 && th.data.prom_type != 4) || is_normal == 1)) { setTimeout(function () { th.deal_pickup_dline(e); }, 800) @@ -5993,7 +5993,7 @@ Page({ var lock = 0; //---如果是活动的时候,同时不是普通购买--- - if ((th.data.prom_type == 1 || th.data.prom_type == 6 || th.data.prom_type == 4) && !th.data.is_normal) { + if (th.data.sele_g.whsle_id || (th.data.prom_type == 1 || th.data.prom_type == 6 || th.data.prom_type == 4) && !th.data.is_normal) { func(); return false; } diff --git a/pages/goods/goodsInfo/goodsInfo.wxml b/pages/goods/goodsInfo/goodsInfo.wxml index 77164b7..49eff38 100644 --- a/pages/goods/goodsInfo/goodsInfo.wxml +++ b/pages/goods/goodsInfo/goodsInfo.wxml @@ -649,7 +649,7 @@ (配送不匹配) - + (库存不足) @@ -1254,7 +1254,7 @@ (库存不足) (配送不匹配) - + (库存不足) @@ -1326,7 +1326,7 @@ - + 库存不足 diff --git a/pages/user/order_detail/order_detail.js b/pages/user/order_detail/order_detail.js index 9d71b60..1237861 100644 --- a/pages/user/order_detail/order_detail.js +++ b/pages/user/order_detail/order_detail.js @@ -629,7 +629,7 @@ Page({ } //--如果是线下库存的时候-- - if(th.data.conf.sales_rules==2){ + if(th.data.conf.sales_rules==2 && !gg.whsle_id){ var ob={}; await th.check_down_line_next(gg,good.goods_num,order.pickup_id,function(obj){ ob=obj; @@ -1239,7 +1239,7 @@ Page({ //判断是不是线下库存的购买, 是不是秒杀活动 - if(th.data.sales_rules==2 && !prom){ + if(th.data.sales_rules==2 && !prom && !good.whsle_id){ //-- 看一下购物车上有多少商品 -- var cart_num=0; diff --git a/pages/user/order_list/order_list.js b/pages/user/order_list/order_list.js index ea2a2cc..fa416f3 100644 --- a/pages/user/order_list/order_list.js +++ b/pages/user/order_list/order_list.js @@ -881,7 +881,7 @@ Page({ } //--如果是线下库存的时候-- - if (th.data.conf.sales_rules == 2) { + if (th.data.conf.sales_rules == 2 && !gg.whsle_id) { var ob = {}; await th.check_down_line_next(gg, good.goods_num, order.pickup_id, function (obj) { ob = obj; @@ -1482,7 +1482,7 @@ Page({ //判断是不是线下库存的购买, 是不是秒杀活动 - if(th.data.sales_rules==2 && !prom){ + if(th.data.sales_rules==2 && !prom && !good.whsle_id){ //-- 看一下购物车上有多少商品 -- var cart_num=0;