Commit cf3cea80fc6865ce860849a4dea4c21e36c91735

Authored by 泉州测试
2 parents c740cde2 773836e4

Merge refs/remotes/origin/dev into refs/heads/dev

pages/cart/cart/cart.js
... ... @@ -356,7 +356,6 @@ Page({
356 356 })
357 357 }
358 358 }
359   -
360 359 //--判断优惠活动有没有过期,--
361 360 else if (item.prom_type == 3) {
362 361 var isok = 1,is_g_prom=0;
... ... @@ -436,8 +435,6 @@ Page({
436 435  
437 436 if (!isok) continue;
438 437  
439   -
440   -
441 438 }
442 439 else if (item.prom_type == 7) {
443 440 if(!th.data.zuhe_map[item.prom_id]){
... ... @@ -599,9 +596,79 @@ Page({
599 596 });
600 597 item.prom_type=3;
601 598 item.prom_id=r_data.promGoodsLists[0].prom_id;
  599 + }else if(r_data.ladderLists){
  600 + var url = '/api/weshop/cart/update';
  601 + getApp().request.put(url, {
  602 + data:{id:item.id,store_id:oo.stoid,prom_type:10,prom_id:r_data.ladderLists[0].form_id}
  603 + });
  604 + item.prom_type=10;
  605 + item.prom_id=r_data.ladderLists[0].form_id;
  606 +
602 607 }
603 608 }
604 609 })
  610 +
  611 + //如果是阶梯购的时候
  612 + if(item.prom_type==10){
  613 + if(!th.data.ladder_map[item.prom_id]){
  614 + //如果有阶梯购,要判断身份
  615 + var isok = 1;
  616 + var is_flag=1;
  617 + var act=null;
  618 + var url="/api/weshop/prom/ladderForm/getNew/"+os.stoid+"/"+user_id+"/"+item.prom_id;
  619 + await getApp().request.promiseGet(url, {}).then(res => {
  620 + console.log(res,1000);
  621 + if(res.data.code==0 && res.data.data){
  622 + if(res.data.data.isuse!=1){
  623 + isok=0;
  624 + }
  625 + //如果活动已经结束
  626 + if(res.data.data.is_end==1){
  627 + isok=0;
  628 + }
  629 + //已经结束
  630 + if(ut.gettimestamp()>res.data.data.end_time){
  631 + isok=0;
  632 + }
  633 + //还未开始
  634 + if(ut.gettimestamp()<res.data.data.start_time){
  635 + isok=0;
  636 + }
  637 + act=res.data.data;
  638 +
  639 + }else{
  640 + //未找到商品的活动
  641 + isok = 0;
  642 + }
  643 + })
  644 + if (!isok){
  645 + item.prom_type=0;
  646 + item.prom_id=0;
  647 + continue;
  648 +
  649 + }
  650 + th.data.ladder_map[item.prom_id]=act;
  651 + //-- 获取阶梯规则 --
  652 + var url1 = "/api/weshop/prom/ladderList/list";
  653 + var req_data = {
  654 + store_id: os.stoid,
  655 + form_id: item.prom_id,
  656 + }
  657 + await getApp().request.promiseGet(url1, {
  658 + data: req_data
  659 + }).then(rs1 => {
  660 + if (rs1.data.code==0 && rs1.data.data) {
  661 + var gdlist = rs1.data.data;
  662 + th.data.ladder_map[item.prom_id].ladder_list=gdlist;
  663 + }
  664 + })
  665 + }
  666 + //直接把活动赋值给元素
  667 + if(th.data.ladder_map[item.prom_id] && th.data.ladder_map[item.prom_id]!=-1 ){
  668 + item.act=th.data.ladder_map[item.prom_id];
  669 + }
  670 + }
  671 +
605 672 }
606 673  
607 674 all_num += item.goods_num;
... ... @@ -1442,8 +1509,7 @@ Page({
1442 1509 if(car && car.length>0){
1443 1510 th.data.in_zhact_gdmap={};
1444 1511 for (var a = 0; a < car.length; a++) {
1445   - var item = car[a].goods,
1446   - is_s_sele = 1;
  1512 + var item = car[a].goods,is_s_sele = 1;
1447 1513 var offline_price=0;
1448 1514 var offline_num=0;
1449 1515 for (var c = 0; c < item.length; c++) {
... ...
pages/cart/cart2/cart2.js
... ... @@ -631,6 +631,7 @@ Page({
631 631 }
632 632 arr[j].exp_type = e_t;
633 633 if (e_t == 0) th.setData({is_all_zt: 0});
  634 + else if(e_t==1) th.setData({is_all_zt: 1});
634 635 //}
635 636  
636 637 //-- 把等级卡会优惠多少钱装进去 --
... ... @@ -2543,6 +2544,15 @@ Page({
2543 2544  
2544 2545 //房间号的ids
2545 2546 var room_ids = "";
  2547 +
  2548 + //-- 把券的钱,写入从表 ---
  2549 + if (t_item.quan_youhui_list && t_item.coupon_price) {
  2550 + for (var kk in t_item.quan_youhui_list) {
  2551 + var you_item = t_item.quan_youhui_list[kk];
  2552 + //-- 对券的价格进行平摊 --
  2553 + await th.split_set_goods_quanprice(you_item,t_item);
  2554 + }
  2555 + }
2546 2556 //-------------让商品添加到商品列表--------------------
2547 2557 for (var k = 0; k < t_item.goods.length; k++) {
2548 2558 var g_item = t_item.goods[k];
... ... @@ -2566,17 +2576,6 @@ Page({
2566 2576 goods.pricing_type = g_item.pricing_type;
2567 2577 }
2568 2578  
2569   - //--把券的钱,写入从表---
2570   - if (t_item.quan_youhui_list && t_item.coupon_price) {
2571   - for (var kk in t_item.quan_youhui_list) {
2572   - var you_item = t_item.quan_youhui_list[kk];
2573   - if (g_item.prom_type!=7 && g_item.erpwareid == you_item.WareId) {
2574   - goods.quan_num = you_item.WareCashSum;
2575   - goods.quan_no = you_item.CashRepNo;
2576   - }
2577   - }
2578   - }
2579   -
2580 2579 //--判断活动的类型--
2581 2580 switch (g_item.prom_type) {
2582 2581 case 1:
... ... @@ -4039,6 +4038,73 @@ Page({
4039 4038 go_url:function (e) {
4040 4039 var url = e.currentTarget.dataset.url;
4041 4040 getApp().goto(url);
  4041 + },
  4042 +
  4043 + //进行对商品的平摊g_item是单个商品,you_item是这个商品分多少优惠券的钱,goods是商品列表
  4044 + split_set_goods_quanprice:async function (you_item,t_item) {
  4045 + var coupon_price=t_item.coupon_price;
  4046 + var goods=t_item.goods;
  4047 + var arr=[];
  4048 + //判断是不是有goods_id重复
  4049 + for(var i=0;i<goods.length;i++){
  4050 + if(goods[i].prom_type!=7 && goods[i].erpwareid==you_item.WareId){
  4051 + var gg_ite={
  4052 + goods_id:goods[i].goods_id,
  4053 + goods_num:goods[i].goods_num,
  4054 + goods_price:goods[i].goods_price,
  4055 + };
  4056 + if(goods[i].account) gg_ite.goods_price=goods[i].account;
  4057 + gg_ite.idx=i;arr.push(gg_ite);
  4058 + }
  4059 + }
  4060 +
  4061 + if(arr.length<=0) return false;
  4062 + if(arr.length==1){
  4063 + var idx=arr[0].idx;
  4064 + t_item.goods[idx].quan_num =Math.floor(coupon_price* 100) / 100;
  4065 + t_item.goods[idx].quan_no=t_item.quan_no;
  4066 + return false;
  4067 + }
  4068 +
  4069 + var pt_data = {
  4070 + 'dis': parseFloat(coupon_price),
  4071 + 'goods': arr,
  4072 + }
  4073 +
  4074 + var pt_res = null;
  4075 + await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", {
  4076 + is_json: 1,
  4077 + data: pt_data
  4078 + }).then(res => {
  4079 + if (res.data.code == 0) {
  4080 + pt_res = res.data.data;
  4081 + }
  4082 + })
  4083 + if (pt_res) {
  4084 + var q_s_num = 0;
  4085 + for (var i in pt_res) {
  4086 + var idx = pt_res[i].idx;
  4087 + //有account的实收价,就要用account实收价
  4088 + var price=(t_item.goods[idx].account?t_item.goods[idx].account:t_item.goods[idx].goods_price);
  4089 + price=(price - pt_res[i].fisrt_account)* t_item.goods[idx].goods_num;
  4090 + t_item.goods[idx].quan_num =price;
  4091 +
  4092 + t_item.goods[idx].quan_num =Math.floor(t_item.goods[idx].quan_num * 100) / 100;
  4093 + t_item.goods[idx].quan_no=t_item.quan_no;
  4094 + q_s_num += t_item.goods[idx].quan_num;
  4095 + }
  4096 +
  4097 + if (q_s_num > parseFloat(coupon_price) || q_s_num < parseFloat(coupon_price)){
  4098 + for (var ik in arr) {
  4099 + if (arr[ik].goods_num == 1) {
  4100 + var id = arr[ik].idx;
  4101 + var pri=Math.floor(coupon_price*100)/100-Math.floor(q_s_num*100)/100
  4102 + t_item.goods[id].quan_num+=pri;
  4103 + break;
  4104 + }
  4105 + }
  4106 + }
  4107 + }
4042 4108 }
4043 4109  
4044 4110  
... ...
pages/cart/cart2/ladder_calculate.js
... ... @@ -67,7 +67,8 @@ module.exports = {
67 67 //-- 单个文件新增 --
68 68 let new_g = JSON.parse(JSON.stringify(end.item));
69 69 new_g.goods_num = 1;
70   - new_g.account = account.toFixed(2);
  70 + //如果有平摊到单品的时候,account要显示
  71 + if(!th.data.ispt_goods) new_g.account = account.toFixed(2);
71 72 new_g.discount = item_j.discount;
72 73 new_g.goods_price =new_price;
73 74 new_g.ladder_list_id =item_j.id;
... ... @@ -184,7 +185,7 @@ module.exports = {
184 185 return dest;
185 186 },
186 187  
187   - //-- 平摊组合购的价格 --
  188 + //-- 组装阶梯购的价格 --
188 189 calc_split_price: async function (c_arr, th) {
189 190 //-- 循环处理 --
190 191 for (var k in c_arr) {
... ...
pages/goods/goodsInfo/goodsInfo.js
... ... @@ -5734,6 +5734,32 @@ Page({
5734 5734 success: function (res) {
5735 5735 if (res.data.code == 0) {
5736 5736 var r_data = res.data.data;
  5737 +
  5738 + if(r_data.ladderLists){
  5739 + var act_id=r_data.ladderLists[0].form_id;
  5740 + //-- 判断会员能不能参与阶梯促销 --
  5741 + getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid+"/"+user_id + "/"+act_id, {
  5742 + }).then(res=>{
  5743 + if(res.data.code==0 && res.data.data){
  5744 + var prom_content="";
  5745 + for(let jj in r_data.ladderLists){
  5746 + if(r_data.ladderLists[jj].discount==10){
  5747 + prom_content+="第"+(parseInt(jj)+1)+"件原价,";
  5748 + }else{
  5749 + prom_content+="第"+(parseInt(jj)+1)+"件"+r_data.ladderLists[jj].discount+"折,";
  5750 + }
  5751 + }
  5752 + prom_content=ut.sub_last(prom_content);
  5753 + th.data.prom_type=10;
  5754 + th.data.prom_id=act_id;
  5755 + th.setData({
  5756 + jieti_prom:prom_content,
  5757 + ladder_act_id:act_id
  5758 + })
  5759 + }
  5760 + })
  5761 + }
  5762 +
5737 5763 th.setData({
5738 5764 prom_goods: r_data.promGoodsLists,
5739 5765 })
... ...
pages/goods/goodsList/goodsList.js
... ... @@ -69,7 +69,13 @@ Page({
69 69  
70 70 if (0 != t.is_new && t.is_new != undefined) { url += "&is_new=" + t.is_new; }
71 71 if (0 != t.is_hot && t.is_hot != undefined) { url += "&is_hot=" + t.is_hot; }
72   - if (0 != t.ladder_id && t.ladder_id != undefined) { url += "&ladder_id=" + t.ladder_id; }
  72 + if (0 != t.ladder_id && t.ladder_id != undefined) {
  73 + url += "&ladder_id=" + t.ladder_id;
  74 + this.setData({
  75 + ladder_id:t.ladder_id,
  76 + baseUrl:url,
  77 + })
  78 + }
73 79  
74 80 var user_id=getApp().globalData.user_id;
75 81 if(!user_id) user_id=0;
... ...
pages/goods/goodsList/goodsList.wxml
... ... @@ -19,7 +19,7 @@
19 19 <view class="pd20 flex ai-center jc_sb">
20 20 <!-- 搜索框 -->
21 21 <view class="search-box f1">
22   - <navigator hover-class="none" url="/pages/goods/search/search"><text class="iconfont icon-sousuo pdr10"></text>搜索店铺商品</navigator>
  22 + <navigator hover-class="none" url="/pages/goods/search/search?ladder_id={{ladder_id}}"><text class="iconfont icon-sousuo pdr10"></text>搜索店铺商品</navigator>
23 23 </view>
24 24 <!-- 单列/双列 显示切换 -->
25 25 <text class="iconfont {{isToggle ? 'icon-fenxiang':'icon-fenlie'}} pdl30 fs36" bindtap="bindToggleDisplay"></text>
... ...
pages/goods/search/search.js
... ... @@ -108,7 +108,13 @@ Page({
108 108 if (0 != t.brand_id && t.brand_id!=undefined){ url += "&brand_id=" + t.brand_id;}
109 109 if (0 != t.nation_id && t.nation_id!=undefined) { url += "&nation_id=" + t.nation_id;}
110 110 if (0 != t.max_price && t.max_price!=undefined) { url += "&min_pirce=" + t.min_pirce + "&max_price=" + t.max_price;}
111   -
  111 + if (0 != t.ladder_id && t.ladder_id != undefined) {
  112 + url += "&ladder_id=" + t.ladder_id;
  113 + this.setData({
  114 + baseUrl:url,
  115 +
  116 + })
  117 + }
112 118 if (url != this.data.baseUrl) return this.requestSearch(url);
113 119 this.openSearchModal();
114 120 // 获取历史搜索记录
... ... @@ -200,23 +206,43 @@ Page({
200 206 break
201 207 }
202 208 if(url!=null && url!=''){
203   - await getApp().request.promiseGet(url, {}).then(res => {
  209 + await getApp().request.promiseGet(url, {}).then(async res => {
204 210 var prom =null;
205   - if(res && res.data) prom=res.data.data;
206   - if (prom != null && prom.is_end==0 && prom.end_time>now && (prom.start_time<now || (prom.show_time && prom.show_time<now)) ) {
207   - item.prom_price = res.data.data.price;
208   - if(res.data.data.user_price) item.prom_price=res.data.data.user_price;
209   - var vNum=res.data.data.virtual_num?res.data.data.virtual_num:0;
210   - var vNum1=res.data.data.virtualNum?res.data.data.virtualNum:0;
211   - var vNum2=res.data.data.virtual?res.data.data.virtual:0;
212   - item.sales_sum=res.data.data.buy_num+(vNum+vNum1+vNum2);
213   - }else{
214   - item.prom_type=0;
215   - item.prom_id=0;
216   - item.prom_price=null;
  211 + var flag=null;
  212 + if(res.data.code==0 && res.data.data){
  213 + prom=res.data.data;
  214 + await getApp().request.promiseGet("/api/weshop/teamlist/pageteam/1",{
  215 + data:{
  216 + store_id: oo.stoid,
  217 + is_end: 0,
  218 + is_show: 1,
  219 + user_id: getApp().globalData.user_id,
  220 + pageSize:1000
  221 + }
  222 + }).then(pd=>{
  223 + let pd_list=pd.data.data.pageData;
  224 + if(res.data.code==0 && pd_list.length>0){
  225 + flag =pd_list.some(pd=>{
  226 + return pd.goods_id==item.goods_id
  227 + })
  228 + }
  229 + if (prom != null && prom.is_end==0 && prom.end_time>now && flag && (prom.start_time<now || (prom.show_time && prom.show_time<now)) ) {
  230 + item.prom_price = res.data.data.price;
  231 + if(res.data.data.user_price) item.prom_price=res.data.data.user_price;
  232 + var vNum=prom.virtual_num?prom.virtual_num:0;
  233 + var vNum1=prom.virtualNum?prom.virtualNum:0;
  234 + var vNum2=prom.virtual?prom.virtual:0;
  235 + item.sales_sum=prom.buy_num+(vNum+vNum1+vNum2);
  236 + }else{
  237 + item.prom_type=0;
  238 + item.prom_id=0;
  239 + item.prom_price=null;
  240 + }
  241 + })
217 242 }
218 243 })
219 244 }
  245 + if(!th.data.requestData) th.data.requestData=[];
220 246 th.data.requestData.push(item);
221 247 e.setData({requestData: e.data.requestData});
222 248 }
... ...
pages/user/order_detail/order_detail.js
... ... @@ -101,7 +101,25 @@ Page({
101 101 r.order_status_detail = "组团中";
102 102  
103 103  
104   - r['is_all_return'] = 0;
  104 + r['is_all_return'] = 0;
  105 +
  106 + var discount_price=r['discount_amount'];
  107 + var dis_json=r['prom_pt_json'];
  108 +
  109 + if(dis_json && discount_price){
  110 + var prom_pt_json=JSON.parse(dis_json);
  111 + var ladder_amount=0;
  112 + for (var ll_item of prom_pt_json) {
  113 + if(ll_item['ladder_prom_id']){
  114 + ladder_amount += ll_item['dis'];
  115 + }
  116 + }
  117 + r['ladder_amount']=ladder_amount;
  118 + r['discount_amount']=Math.floor((discount_price-ladder_amount)*100)/100;
  119 + }
  120 +
  121 +
  122 +
105 123  
106 124 //------获取订单商品-------
107 125 rq.get("/api/weshop/ordergoods/list",{
... ...
pages/user/order_detail/order_detail.wxml
... ... @@ -120,7 +120,12 @@
120 120  
121 121 <view class="item pnew" wx:if="{{order.discount_amount>0}}">
122 122 <view>优惠活动</view>
123   - <view>¥ {{order.discount_amount}}元</view>
  123 + <view>¥ {{filters.toFix(order.discount_amount,2)}}元</view>
  124 + </view>
  125 +
  126 + <view class="item pnew" wx:if="{{order.ladder_amount>0}}">
  127 + <view>阶梯优惠活动</view>
  128 + <view>¥ {{filters.toFix(order.ladder_amount,2)}}元</view>
124 129 </view>
125 130  
126 131 <view class="item pnew" wx:if="{{order.order_prom_amount>0}}">
... ...