Commit ab4fb495d8beb172d30bcbdfcb3dd5df154aa433

Authored by yvan.ni
1 parent 5ea73552

运费的计算

packageE/pages/cart/cart2/cart2.js
... ... @@ -718,8 +718,12 @@ Page({
718 718 //如果有购买活动
719 719 item1.promgoodsbuynum = promgoodsbuynum;
720 720  
  721 + //默认是包邮和优惠的
  722 + item1.is_order_yh=1;
  723 + item1.is_post_temp=1;
  724 +
721 725 //如果是秒杀,团购的时候
722   - if([1,2].indexOf(item1.prom_type)>-1){
  726 + if([1,2,6].indexOf(item1.prom_type)>-1){
723 727 var url= "/api/weshop/activitylist/getSJGoodsPriceNew/" + os.stoid
724 728 + "/" + item1.goods_id + "/"+item1.prom_type+"/" + item1.prom_id + "/" + app.globalData.user_id;
725 729 await app.request.promiseGet(url,{}).then(res=>{
... ... @@ -2075,7 +2079,6 @@ Page({
2075 2079 var no_order_yh = 0; //-- 有些活动不能和订单优惠叠加的金额 --
2076 2080 var no_post_temp = 0; //-- 有些活动不能和包邮模板的金额 --
2077 2081  
2078   -
2079 2082 if (th.data.using_quan[pickid] != null && th.data.using_quan[pickid] != undefined)
2080 2083 quan_no = th.data.using_quan[pickid].coupon_no;
2081 2084  
... ... @@ -2103,40 +2106,42 @@ Page({
2103 2106  
2104 2107 var whsle_goods_price = 0;
2105 2108 //--------循环计算总价-----------
2106   - for (var j = 0; j < item.length; j++) {
  2109 + for (var jc = 0; jc < item.length; jc++) {
2107 2110  
2108   - if (item[j].whsle_id > 0) {
2109   - whsle_goods_price += item[j].goods_price * item[j].goods_num;
  2111 + if (item[jc].whsle_id > 0) {
  2112 + whsle_goods_price += item[jc].goods_price * item[jc].goods_num;
2110 2113 }
2111 2114  
2112 2115 var is_no_zh = 0;
2113   - if (item[j].prom_type != 7 && item[j].prom_type != 10) is_no_zh = 1;
  2116 + if (item[jc].prom_type != 7 && item[jc].prom_type != 10) is_no_zh = 1;
2114 2117  
2115 2118 //组合购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加
2116   - if (item[j].prom_type == 7 && th.data.zhhe_act_map && th.data.zhhe_act_map[item[j].prom_id]
2117   - && th.data.zhhe_act_map[item[j].prom_id].is_orderyh) {
  2119 + if (item[jc].prom_type == 7 && th.data.zhhe_act_map && th.data.zhhe_act_map[item[jc].prom_id]
  2120 + && th.data.zhhe_act_map[item[jc].prom_id].is_orderyh) {
2118 2121 is_no_zh = 1;
2119 2122 }
2120 2123 //阶梯购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加
2121   - if (item[j].prom_type == 10 && ladder_prom_goods && ladder_prom_goods[item[j].prom_id]
2122   - && th.data.ladder_map[item[j].prom_id].is_useorderyh) {
  2124 + if (item[jc].prom_type == 10 && ladder_prom_goods && ladder_prom_goods[item[jc].prom_id]
  2125 + && th.data.ladder_map[item[jc].prom_id].is_useorderyh) {
2123 2126 is_no_zh = 1;
2124 2127 }
2125 2128  
2126 2129 if (is_no_zh) {
2127   - o_price_no_zh += item[j].goods_price * item[j].goods_num;
  2130 + o_price_no_zh += item[jc].goods_price * item[jc].goods_num;
2128 2131 }
2129   - o_price += item[j].goods_price * item[j].goods_num;
2130   -
  2132 + o_price += item[jc].goods_price * item[jc].goods_num;
2131 2133  
2132   - //-- 秒杀, 团购的时候,判断有没有订单优惠和包邮模板的叠加 --
2133   - if( [1,2].indexOf(item[j].prom_type)>-1){
2134   - if(!item[j].is_order_yh)
2135   - no_order_yh+=item[j].goods_price * item[j].goods_num;
2136   - if(!item[j].is_post_temp)
2137   - no_post_temp+=item[j].goods_price * item[j].goods_num;
  2134 + //--- 秒杀, 团购的时候,判断有没有订单优惠和包邮模板的叠加 ---
  2135 + if( [1,2,6].indexOf(item[jc].prom_type)>-1){
  2136 + if(!item[jc].is_order_yh){
  2137 + no_order_yh+=item[jc].goods_price * item[jc].goods_num;
  2138 + }
  2139 + if(!item[jc].is_post_temp){
  2140 + no_post_temp+=item[jc].goods_price * item[jc].goods_num;
  2141 + }
2138 2142 }
2139 2143 }
  2144 +
2140 2145 //判断是不是有组合购的金额
2141 2146 var f_o_price = o_price;
2142 2147 //如果又优惠的钱,就要减价
... ... @@ -2259,8 +2264,6 @@ Page({
2259 2264 if (rs.data.code == 0) back_data = rs.data.data;
2260 2265 });
2261 2266 }
2262   -
2263   -
2264 2267 }
2265 2268  
2266 2269  
... ... @@ -2315,7 +2318,9 @@ Page({
2315 2318 continue;
2316 2319 }
2317 2320  
2318   - if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item[j].goods_id) == -1)) {
  2321 + debugger;
  2322 + if (back_data && back_data['is_by_all'] && item[j].is_post_temp
  2323 + && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item[j].goods_id) == -1)) {
2319 2324  
2320 2325 if (item[j]['exp_sum_type'] == 2 && back_data.weight_free > 0) {
2321 2326 if (goods_weight < 0) goods_weight = 0;
... ... @@ -2355,7 +2360,7 @@ Page({
2355 2360  
2356 2361 }
2357 2362  
2358   - //如果是正值的时候
  2363 + //如果是正值的时候,多少重量内免运费
2359 2364 if (out_of_weight >= 0) out_of_weight = -cut_good_weight;
2360 2365 else out_of_weight = -back_data.weight_free * 1000;
2361 2366  
... ... @@ -2366,6 +2371,9 @@ Page({
2366 2371 // cart_item.shipping_price =
2367 2372 // ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,goods_piece, th.data.user_addr, back_data, rs);
2368 2373  
  2374 + var no_free=back_data && back_data.no_free_goods && back_data.no_free_goods.length > 0 ? 1 : 0
  2375 +
  2376 +
2369 2377 var w_data = {
2370 2378 store_id: os.stoid, code: code,
2371 2379 o_shipping_price: o_shipping_price,
... ... @@ -2375,7 +2383,7 @@ Page({
2375 2383 user_addr_city: th.data.user_addr.city,
2376 2384 user_addr_district: th.data.user_addr.district,
2377 2385 is_by_all: back_data && back_data.is_by_all ? 1 : 0,
2378   - no_free_goods: back_data && back_data.no_free_goods && back_data.no_free_goods.length > 0 ? 1 : 0,
  2386 + no_free_goods: no_post_temp>0 || no_free?1:0 ,
2379 2387 }
2380 2388  
2381 2389 var is_ok = 1;
... ...