Commit 6405bf360d0c274d32d20a7512712bac52a54272
1 parent
b02e37f4
预存使用的优化
Showing
1 changed file
with
69 additions
and
8 deletions
packageE/pages/cart/cart2/cart2.js
... | ... | @@ -510,14 +510,75 @@ Page({ |
510 | 510 | let goods = item.goods |
511 | 511 | let keyid = item.sto.keyid |
512 | 512 | let listform = [] |
513 | - goods.map(ite => { | |
514 | - let obj = { | |
515 | - wareno: ite.goods_sn, | |
516 | - price: ite.goods_price, | |
517 | - qty: ite.goods_num | |
513 | + | |
514 | + //-- 如果有订单优惠的时候,就要进行第二次平摊,要用实收来判断满 -- | |
515 | + if (cartList.order_prom_amount > 0) { | |
516 | + let new_arr = []; | |
517 | + //--- 预存要以商品的实收为准, --- | |
518 | + goods.map(ite => { | |
519 | + //-- 不是赠品的时候 -- | |
520 | + if(!ite.is_gift){ | |
521 | + let obj = { | |
522 | + goods_sn:ite.goods_sn, | |
523 | + goods_id: ite.goods_id, | |
524 | + goods_price: ite.goods_price, //account是平摊后的实收价格 | |
525 | + goods_num: ite.goods_num, | |
526 | + sumgoods_price: ite.account_fir * ite.goods_num - ite.account_yu_fir-(ite.quan_num?ite.quan_num:0) //-- 优惠后的实收 -- | |
527 | + } | |
528 | + new_arr.push(obj); | |
529 | + } | |
530 | + | |
531 | + }) | |
532 | + | |
533 | + //-- 如果系统要平摊到单品 -- | |
534 | + var pt_data = { | |
535 | + 'prom_id': 1, | |
536 | + 'dis': cartList.order_prom_amount, | |
537 | + 'goods': new_arr | |
518 | 538 | } |
519 | - listform.push(obj) | |
520 | - }) | |
539 | + var pt_res = null; | |
540 | + await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", { | |
541 | + is_json: 1, | |
542 | + data: pt_data | |
543 | + }).then(res => { | |
544 | + if (res.data.code == 0) { | |
545 | + pt_res = res.data.data; | |
546 | + } | |
547 | + }) | |
548 | + if (pt_res) { | |
549 | + for (let io = 0; io <new_arr.length ; io++) { | |
550 | + new_arr[io].account_yc = this.arr_get_goods(new_arr[io].goods_id, pt_res).fisrt_account; | |
551 | + new_arr[io].account_yc_yu = this.arr_get_goods(new_arr[io].goods_id, pt_res).fisrt_account_yu; | |
552 | + } | |
553 | + } | |
554 | + | |
555 | + new_arr.map(ite => { | |
556 | + let obj = { | |
557 | + wareno: ite.goods_sn, | |
558 | + price: ite.account_yc, //account是平摊后的实收价格 | |
559 | + qty: ite.goods_num, | |
560 | + sumprice: parseFloat(ite.account_yc * ite.goods_num - ite.account_yc_yu).toFixed(2) | |
561 | + } | |
562 | + listform.push(obj) | |
563 | + }) | |
564 | + } | |
565 | + else{ | |
566 | + goods.map(ite => { | |
567 | + //-- 不是赠品的时候 -- | |
568 | + if(!ite.is_gift) { | |
569 | + let obj = { | |
570 | + wareno: ite.goods_sn, | |
571 | + price: ite.first_account, //account是平摊后的实收价格 | |
572 | + qty: ite.goods_num, | |
573 | + sumprice: parseFloat(ite.account_fir * ite.goods_num - ite.account_yu_fir-(ite.quan_num?ite.quan_num:0)).toFixed(2) | |
574 | + } | |
575 | + listform.push(obj) | |
576 | + } | |
577 | + }) | |
578 | + | |
579 | + } | |
580 | + | |
581 | + | |
521 | 582 | let arr = await this.getGoodsAdvancesum(keyid, listform, cartList) |
522 | 583 | // } |
523 | 584 | wx.hideLoading() |
... | ... | @@ -6817,7 +6878,7 @@ Page({ |
6817 | 6878 | switch (ob.discount_field){ |
6818 | 6879 | case 0: f_price=item.goods_price;break; |
6819 | 6880 | case 1: f_price=item.shop_price;break; |
6820 | - case 2: f_price=item.market_price;break; | |
6881 | + case 2: f_price=item.goods_market_price;break; | |
6821 | 6882 | } |
6822 | 6883 | } |
6823 | 6884 | ... | ... |