From 6405bf360d0c274d32d20a7512712bac52a54272 Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Thu, 14 Dec 2023 15:28:30 +0800 Subject: [PATCH] 预存使用的优化 --- packageE/pages/cart/cart2/cart2.js | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 69 insertions(+), 8 deletions(-) diff --git a/packageE/pages/cart/cart2/cart2.js b/packageE/pages/cart/cart2/cart2.js index 75799a2..ef02b14 100644 --- a/packageE/pages/cart/cart2/cart2.js +++ b/packageE/pages/cart/cart2/cart2.js @@ -510,14 +510,75 @@ Page({ let goods = item.goods let keyid = item.sto.keyid let listform = [] - goods.map(ite => { - let obj = { - wareno: ite.goods_sn, - price: ite.goods_price, - qty: ite.goods_num + + //-- 如果有订单优惠的时候,就要进行第二次平摊,要用实收来判断满 -- + if (cartList.order_prom_amount > 0) { + let new_arr = []; + //--- 预存要以商品的实收为准, --- + goods.map(ite => { + //-- 不是赠品的时候 -- + if(!ite.is_gift){ + let obj = { + goods_sn:ite.goods_sn, + goods_id: ite.goods_id, + goods_price: ite.goods_price, //account是平摊后的实收价格 + goods_num: ite.goods_num, + sumgoods_price: ite.account_fir * ite.goods_num - ite.account_yu_fir-(ite.quan_num?ite.quan_num:0) //-- 优惠后的实收 -- + } + new_arr.push(obj); + } + + }) + + //-- 如果系统要平摊到单品 -- + var pt_data = { + 'prom_id': 1, + 'dis': cartList.order_prom_amount, + 'goods': new_arr } - listform.push(obj) - }) + var pt_res = null; + await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", { + is_json: 1, + data: pt_data + }).then(res => { + if (res.data.code == 0) { + pt_res = res.data.data; + } + }) + if (pt_res) { + for (let io = 0; io { + let obj = { + wareno: ite.goods_sn, + price: ite.account_yc, //account是平摊后的实收价格 + qty: ite.goods_num, + sumprice: parseFloat(ite.account_yc * ite.goods_num - ite.account_yc_yu).toFixed(2) + } + listform.push(obj) + }) + } + else{ + goods.map(ite => { + //-- 不是赠品的时候 -- + if(!ite.is_gift) { + let obj = { + wareno: ite.goods_sn, + price: ite.first_account, //account是平摊后的实收价格 + qty: ite.goods_num, + sumprice: parseFloat(ite.account_fir * ite.goods_num - ite.account_yu_fir-(ite.quan_num?ite.quan_num:0)).toFixed(2) + } + listform.push(obj) + } + }) + + } + + let arr = await this.getGoodsAdvancesum(keyid, listform, cartList) // } wx.hideLoading() @@ -6817,7 +6878,7 @@ Page({ switch (ob.discount_field){ case 0: f_price=item.goods_price;break; case 1: f_price=item.shop_price;break; - case 2: f_price=item.market_price;break; + case 2: f_price=item.goods_market_price;break; } } -- libgit2 0.21.4