Commit 1df16535a9ab6e3b10a308bd8ca9979128f0c22d
1 parent
ad07eacb
购物购买速度优化, 和提交订单优化
Showing
2 changed files
with
221 additions
and
201 deletions
packageE/pages/cart/cart2/cart2.js
| ... | ... | @@ -1026,6 +1026,7 @@ Page({ |
| 1026 | 1026 | //-----------循环查找门店------------- |
| 1027 | 1027 | if (arr.length > 0) { |
| 1028 | 1028 | for (var j = 0; j < arr.length; j++) { |
| 1029 | + | |
| 1029 | 1030 | if (arr[j].pickup_id == pcid) { |
| 1030 | 1031 | if (item.is_gift != 1) { |
| 1031 | 1032 | //确定配送方式 |
| ... | ... | @@ -1044,15 +1045,22 @@ Page({ |
| 1044 | 1045 | } |
| 1045 | 1046 | switch (dis_t) { |
| 1046 | 1047 | case 0: |
| 1047 | - e_t = 1; | |
| 1048 | - //-- 系统后台有设置要默认的 -- | |
| 1049 | - if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) e_t = 0; | |
| 1048 | + if(!arr[j].exp_sure){ | |
| 1049 | + e_t = 1; | |
| 1050 | + //-- 系统后台有设置要默认的 -- | |
| 1051 | + if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) e_t = 0; | |
| 1052 | + arr[j].exp_type=e_t | |
| 1053 | + } | |
| 1050 | 1054 | break; |
| 1051 | 1055 | case 1: |
| 1052 | 1056 | e_t = 1; |
| 1057 | + arr[j].exp_sure=1 | |
| 1058 | + arr[j].exp_type=1 | |
| 1053 | 1059 | break; |
| 1054 | 1060 | case 2: |
| 1055 | 1061 | e_t = 0; |
| 1062 | + arr[j].exp_sure=1 | |
| 1063 | + arr[j].exp_type=0 | |
| 1056 | 1064 | break; |
| 1057 | 1065 | } |
| 1058 | 1066 | //如果是物流的话,全部自提的控制要弄成0 |
| ... | ... | @@ -1115,6 +1123,9 @@ Page({ |
| 1115 | 1123 | } else { |
| 1116 | 1124 | dis_t = item.distr_type; |
| 1117 | 1125 | } |
| 1126 | + | |
| 1127 | + let exp_sure=0; | |
| 1128 | + | |
| 1118 | 1129 | switch (dis_t) { |
| 1119 | 1130 | case 0: |
| 1120 | 1131 | e_t = 1; |
| ... | ... | @@ -1123,9 +1134,11 @@ Page({ |
| 1123 | 1134 | break; |
| 1124 | 1135 | case 1: |
| 1125 | 1136 | e_t = 1; |
| 1137 | + exp_sure=1; | |
| 1126 | 1138 | break; |
| 1127 | 1139 | case 2: |
| 1128 | 1140 | e_t = 0; |
| 1141 | + exp_sure=1; | |
| 1129 | 1142 | break; |
| 1130 | 1143 | } |
| 1131 | 1144 | //如果是物流的话,全部自提的控制要弄成0 |
| ... | ... | @@ -1147,7 +1160,7 @@ Page({ |
| 1147 | 1160 | } |
| 1148 | 1161 | |
| 1149 | 1162 | |
| 1150 | - if (back_data && parseFloat(back_data)) { | |
| 1163 | + if (back_data && parseFloat(back_data)) { | |
| 1151 | 1164 | c_item.can_usecommise = parseFloat(parseFloat(back_data).toFixed(2)); |
| 1152 | 1165 | cart_commission += c_item.can_usecommise; |
| 1153 | 1166 | } |
| ... | ... | @@ -1166,7 +1179,8 @@ Page({ |
| 1166 | 1179 | total_amount: 0, |
| 1167 | 1180 | order_amount: 0, |
| 1168 | 1181 | user_note: "", |
| 1169 | - sto: sto | |
| 1182 | + sto: sto, | |
| 1183 | + exp_sure:1 | |
| 1170 | 1184 | }; |
| 1171 | 1185 | |
| 1172 | 1186 | //-- 把等级卡会优惠多少钱装进去 -- |
| ... | ... | @@ -1209,199 +1223,197 @@ Page({ |
| 1209 | 1223 | //-- 循环计算一下线下取价 -- |
| 1210 | 1224 | for (var k = 0; k < arr.length; k++) { |
| 1211 | 1225 | var c_item = arr[k]; |
| 1212 | - if(!is_change){ | |
| 1226 | + if (!is_change) { | |
| 1213 | 1227 | //-- 要进行归类一下活动 -- |
| 1214 | - await m_cx.cart_cx_group(th,arr[k].goods,c_item,0,0,(show_can_cx)=>{ | |
| 1228 | + await m_cx.cart_cx_group(th, arr[k].goods, c_item, 0, 0, (show_can_cx) => { | |
| 1215 | 1229 | |
| 1216 | - arr[k].show_can_cx=show_can_cx; | |
| 1230 | + arr[k].show_can_cx = show_can_cx; | |
| 1217 | 1231 | }) |
| 1218 | - }else{ | |
| 1219 | - var show_can_cx=this.data.cartlist[k].show_can_cx; | |
| 1220 | - //-- 多促销活动的优化 -- | |
| 1221 | - if(show_can_cx){ | |
| 1222 | - arr[k].show_can_cx=show_can_cx; | |
| 1223 | - } | |
| 1232 | + } else { | |
| 1233 | + var show_can_cx = this.data.cartlist[k].show_can_cx; | |
| 1234 | + //-- 多促销活动的优化 -- | |
| 1235 | + if (show_can_cx) { | |
| 1236 | + arr[k].show_can_cx = show_can_cx; | |
| 1237 | + } | |
| 1224 | 1238 | } |
| 1225 | 1239 | |
| 1226 | 1240 | //要在多活动确定之后,在来计算 |
| 1227 | - for(var jh=0;jh<arr[k].goods.length;jh++){ | |
| 1228 | - var item1=arr[k].goods[jh] | |
| 1229 | - //要把优惠活动加入,prom_goods_map中,赠品不要运算,代发商品不算优惠 | |
| 1230 | - if (item1.prom_type == 3 && item1.is_gift != 1 && !item1.whsle_id) { | |
| 1231 | - // th.check_is_youhui(item1.goods_id, item1.pick_id); | |
| 1232 | - //增加优惠活动次数限制 | |
| 1233 | - let limit_num= await th.getprom(item1) //活动限制次数 | |
| 1234 | - | |
| 1235 | - if(!limit_num){ | |
| 1241 | + for (var jh = 0; jh < arr[k].goods.length; jh++) { | |
| 1242 | + var item1 = arr[k].goods[jh] | |
| 1243 | + //要把优惠活动加入,prom_goods_map中,赠品不要运算,代发商品不算优惠 | |
| 1244 | + if (item1.prom_type == 3 && item1.is_gift != 1 && !item1.whsle_id) { | |
| 1245 | + // th.check_is_youhui(item1.goods_id, item1.pick_id); | |
| 1246 | + //增加优惠活动次数限制 | |
| 1247 | + let limit_num = await th.getprom(item1) //活动限制次数 | |
| 1248 | + | |
| 1249 | + if (!limit_num) { | |
| 1250 | + await th.add_prom_goods_map(item1); | |
| 1251 | + // item1.prom_id='' | |
| 1252 | + // item1.prom_type='' | |
| 1253 | + } else { | |
| 1254 | + let user_pre_buynum = await th.getUserBuyPromNum_pre(item1.prom_id) //用户已经参与次数 | |
| 1255 | + if (user_pre_buynum < limit_num) { | |
| 1236 | 1256 | await th.add_prom_goods_map(item1); |
| 1237 | - // item1.prom_id='' | |
| 1238 | - // item1.prom_type='' | |
| 1239 | - }else{ | |
| 1240 | - let user_pre_buynum = await th.getUserBuyPromNum_pre(item1.prom_id) //用户已经参与次数 | |
| 1241 | - if(user_pre_buynum<limit_num){ | |
| 1242 | - await th.add_prom_goods_map(item1); | |
| 1243 | - }else{ | |
| 1244 | - // await th.add_prom_goods_map(item1); | |
| 1245 | - item1.prom_id='' | |
| 1246 | - item1.prom_type='' | |
| 1247 | - } | |
| 1257 | + } else { | |
| 1258 | + // await th.add_prom_goods_map(item1); | |
| 1259 | + item1.prom_id = '' | |
| 1260 | + item1.prom_type = '' | |
| 1248 | 1261 | } |
| 1249 | 1262 | } |
| 1250 | - //-- 如果组合购的总数量不足的处理 -- | |
| 1251 | - // if(no_zh_num[item1.prom_id] && item1.prom_type == 7){ | |
| 1252 | - // item1.prom_type = 0; | |
| 1253 | - // item1.prom_type1 = 0; | |
| 1254 | - // item1.prom_id = 0; | |
| 1255 | - // item1.prom_id1 = 0 | |
| 1256 | - // } | |
| 1257 | - | |
| 1258 | - //要把组合购的东西拿出来算一下,同时组合购的总数量要有存在 | |
| 1259 | - if (item1.prom_type == 7) { | |
| 1260 | - if (!th.data.zuhe_map_good[item1.prom_id]) { | |
| 1261 | - var isok = 1; | |
| 1262 | - var is_flag = 1; | |
| 1263 | - var store_count_ok=1; | |
| 1264 | - //如果有组合购 | |
| 1265 | - var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + item1.prom_id + '/' + getApp().globalData.userInfo.user_id; | |
| 1266 | - await getApp().request.promiseGet(url, {}).then(res => { | |
| 1267 | - if (res.data.code == 0 && res.data.data) { | |
| 1268 | - //如果活动已经结束 | |
| 1269 | - if (res.data.data.is_end == 1) { | |
| 1270 | - isok = 0; | |
| 1271 | - } | |
| 1272 | - if (ut.gettimestamp() > res.data.data.end_time) { | |
| 1273 | - isok = 0; | |
| 1274 | - } | |
| 1275 | - item1.act = res.data.data; | |
| 1276 | - | |
| 1277 | - //-- 在这里要判断一下活动的组合购总数量 -- | |
| 1278 | - if(item1.act.zh_num>0 && item1.act.zh_buy_num>=item1.act.zh_num){ | |
| 1279 | - store_count_ok = 0; | |
| 1280 | - no_zh_num[item1.prom_id]=1; | |
| 1281 | - //-- 清理一下活动的状态 -- | |
| 1282 | - // item1.prom_type = 0; | |
| 1283 | - // item1.prom_type1 = 0; | |
| 1284 | - // item1.prom_id = 0; | |
| 1285 | - // item1.prom_id1 = 0 | |
| 1286 | - | |
| 1287 | - }else{ | |
| 1288 | - th.data.zhhe_act_map[item1.prom_id] = res.data.data; | |
| 1289 | - } | |
| 1263 | + } | |
| 1264 | + //-- 如果组合购的总数量不足的处理 -- | |
| 1265 | + // if(no_zh_num[item1.prom_id] && item1.prom_type == 7){ | |
| 1266 | + // item1.prom_type = 0; | |
| 1267 | + // item1.prom_type1 = 0; | |
| 1268 | + // item1.prom_id = 0; | |
| 1269 | + // item1.prom_id1 = 0 | |
| 1270 | + // } | |
| 1290 | 1271 | |
| 1291 | - } else { | |
| 1292 | - //未找到商品的活动 | |
| 1293 | - is_flag = 0; | |
| 1272 | + //要把组合购的东西拿出来算一下,同时组合购的总数量要有存在 | |
| 1273 | + if (item1.prom_type == 7) { | |
| 1274 | + if (!th.data.zuhe_map_good[item1.prom_id]) { | |
| 1275 | + var isok = 1; | |
| 1276 | + var is_flag = 1; | |
| 1277 | + var store_count_ok = 1; | |
| 1278 | + //如果有组合购 | |
| 1279 | + var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + item1.prom_id + '/' + getApp().globalData.userInfo.user_id; | |
| 1280 | + await getApp().request.promiseGet(url, {}).then(res => { | |
| 1281 | + if (res.data.code == 0 && res.data.data) { | |
| 1282 | + //如果活动已经结束 | |
| 1283 | + if (res.data.data.is_end == 1) { | |
| 1284 | + isok = 0; | |
| 1294 | 1285 | } |
| 1295 | - }) | |
| 1296 | - | |
| 1297 | - if (!isok) { | |
| 1298 | - getApp().my_warnning("组合购的活动已经过期", 0, th); | |
| 1299 | - return false; | |
| 1300 | - } | |
| 1301 | - | |
| 1302 | - //------ 先增组合活动的总数量的时候 ------- | |
| 1303 | - if(store_count_ok) { | |
| 1304 | - var url1 = "/api/weshop/prom/zhbuyGoods/page"; | |
| 1305 | - var req_data = { | |
| 1306 | - page: 1, | |
| 1307 | - pageSize: 2000, | |
| 1308 | - store_id: os.stoid, | |
| 1309 | - zh_id: item1.prom_id, | |
| 1286 | + if (ut.gettimestamp() > res.data.data.end_time) { | |
| 1287 | + isok = 0; | |
| 1310 | 1288 | } |
| 1311 | - await getApp().request.promiseGet(url1, { | |
| 1312 | - data: req_data | |
| 1313 | - }).then(res => { | |
| 1314 | - if (ut.ajax_ok(res)) { | |
| 1315 | - var gdlist = res.data.data.pageData; | |
| 1316 | - gdlist.forEach(i => { | |
| 1317 | - if (item1.goods_id == i.goods_id && !is_flag) { | |
| 1318 | - item1.prom_type = 0; | |
| 1319 | - item1.prom_type1 = 0; | |
| 1320 | - item1.prom_id = 0; | |
| 1321 | - item1.prom_id1 = 0 | |
| 1322 | - } | |
| 1323 | - }) | |
| 1324 | - th.data.zuhe_map_good[item1.prom_id] = gdlist; | |
| 1325 | - } | |
| 1326 | - }) | |
| 1327 | - } | |
| 1328 | - | |
| 1329 | - | |
| 1330 | - | |
| 1331 | - } | |
| 1332 | - else { | |
| 1333 | - item1.act = th.data.zhhe_act_map[item1.prom_id]; | |
| 1334 | - } | |
| 1335 | - } | |
| 1336 | - if (item1.prom_type == 10) { | |
| 1337 | - if (!th.data.ladder_map[item1.prom_id]) { | |
| 1338 | - //如果有预售 | |
| 1339 | - var isok = 1; | |
| 1340 | - var is_flag = 1; | |
| 1341 | - var act = null; | |
| 1342 | - var url = "/api/weshop/prom/ladderForm/get/" + os.stoid + "/" + item1.prom_id; | |
| 1343 | - await getApp().request.promiseGet(url, {}).then(res => { | |
| 1344 | - console.log(res, 1000); | |
| 1345 | - if (res.data.code == 0 && res.data.data) { | |
| 1346 | - if (res.data.data.isuse != 1) { | |
| 1347 | - isok = 0; | |
| 1348 | - } | |
| 1349 | - //如果活动已经结束 | |
| 1350 | - if (res.data.data.is_end == 1) { | |
| 1351 | - isok = 0; | |
| 1352 | - } | |
| 1353 | - //已经结束 | |
| 1354 | - if (ut.gettimestamp() > res.data.data.end_time) { | |
| 1355 | - isok = 0; | |
| 1356 | - } | |
| 1357 | - //还未开始 | |
| 1358 | - if (ut.gettimestamp() < res.data.data.start_time) { | |
| 1359 | - isok = 0; | |
| 1360 | - } | |
| 1361 | - act = res.data.data; | |
| 1289 | + item1.act = res.data.data; | |
| 1290 | + | |
| 1291 | + //-- 在这里要判断一下活动的组合购总数量 -- | |
| 1292 | + if (item1.act.zh_num > 0 && item1.act.zh_buy_num >= item1.act.zh_num) { | |
| 1293 | + store_count_ok = 0; | |
| 1294 | + no_zh_num[item1.prom_id] = 1; | |
| 1295 | + //-- 清理一下活动的状态 -- | |
| 1296 | + // item1.prom_type = 0; | |
| 1297 | + // item1.prom_type1 = 0; | |
| 1298 | + // item1.prom_id = 0; | |
| 1299 | + // item1.prom_id1 = 0 | |
| 1362 | 1300 | |
| 1363 | 1301 | } else { |
| 1364 | - //未找到商品的活动 | |
| 1365 | - is_flag = 0; | |
| 1302 | + th.data.zhhe_act_map[item1.prom_id] = res.data.data; | |
| 1366 | 1303 | } |
| 1367 | - }) | |
| 1368 | - if (!isok) { | |
| 1369 | - var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item1.id; | |
| 1370 | - getApp().request.delete(url, {}); | |
| 1371 | - th.data.ladder_map[item1.prom_id] = -1; | |
| 1372 | - continue; | |
| 1304 | + | |
| 1305 | + } else { | |
| 1306 | + //未找到商品的活动 | |
| 1307 | + is_flag = 0; | |
| 1373 | 1308 | } |
| 1374 | - th.data.ladder_map[item1.prom_id] = act; | |
| 1309 | + }) | |
| 1310 | + | |
| 1311 | + if (!isok) { | |
| 1312 | + getApp().my_warnning("组合购的活动已经过期", 0, th); | |
| 1313 | + return false; | |
| 1314 | + } | |
| 1375 | 1315 | |
| 1376 | - //-- 获取阶梯规则 -- | |
| 1377 | - var url1 = "/api/weshop/prom/ladderList/list"; | |
| 1316 | + //------ 先增组合活动的总数量的时候 ------- | |
| 1317 | + if (store_count_ok) { | |
| 1318 | + var url1 = "/api/weshop/prom/zhbuyGoods/page"; | |
| 1378 | 1319 | var req_data = { |
| 1320 | + page: 1, | |
| 1321 | + pageSize: 2000, | |
| 1379 | 1322 | store_id: os.stoid, |
| 1380 | - form_id: item1.prom_id, | |
| 1323 | + zh_id: item1.prom_id, | |
| 1381 | 1324 | } |
| 1382 | 1325 | await getApp().request.promiseGet(url1, { |
| 1383 | 1326 | data: req_data |
| 1384 | - }).then(rs1 => { | |
| 1385 | - if (rs1.data.code == 0 && rs1.data.data) { | |
| 1386 | - var gdlist = rs1.data.data; | |
| 1387 | - th.data.ladder_map[item1.prom_id].ladder_list = gdlist; | |
| 1327 | + }).then(res => { | |
| 1328 | + if (ut.ajax_ok(res)) { | |
| 1329 | + var gdlist = res.data.data.pageData; | |
| 1330 | + gdlist.forEach(i => { | |
| 1331 | + if (item1.goods_id == i.goods_id && !is_flag) { | |
| 1332 | + item1.prom_type = 0; | |
| 1333 | + item1.prom_type1 = 0; | |
| 1334 | + item1.prom_id = 0; | |
| 1335 | + item1.prom_id1 = 0 | |
| 1336 | + } | |
| 1337 | + }) | |
| 1338 | + th.data.zuhe_map_good[item1.prom_id] = gdlist; | |
| 1388 | 1339 | } |
| 1389 | 1340 | }) |
| 1390 | 1341 | } |
| 1391 | - } | |
| 1392 | 1342 | |
| 1393 | - //-- 判断一下,获取搭配购的消息,只有prom_type==5才会判断优惠活动 -- | |
| 1394 | - if ( item1.prom_type == 5 && (!item1.collocationList || !item1.collocationList.length)) { | |
| 1395 | - await th.set_collection(item1, arr[k].goods, jh); | |
| 1343 | + | |
| 1344 | + } else { | |
| 1345 | + item1.act = th.data.zhhe_act_map[item1.prom_id]; | |
| 1396 | 1346 | } |
| 1347 | + } | |
| 1348 | + if (item1.prom_type == 10) { | |
| 1349 | + if (!th.data.ladder_map[item1.prom_id]) { | |
| 1350 | + //如果有预售 | |
| 1351 | + var isok = 1; | |
| 1352 | + var is_flag = 1; | |
| 1353 | + var act = null; | |
| 1354 | + var url = "/api/weshop/prom/ladderForm/get/" + os.stoid + "/" + item1.prom_id; | |
| 1355 | + await getApp().request.promiseGet(url, {}).then(res => { | |
| 1356 | + console.log(res, 1000); | |
| 1357 | + if (res.data.code == 0 && res.data.data) { | |
| 1358 | + if (res.data.data.isuse != 1) { | |
| 1359 | + isok = 0; | |
| 1360 | + } | |
| 1361 | + //如果活动已经结束 | |
| 1362 | + if (res.data.data.is_end == 1) { | |
| 1363 | + isok = 0; | |
| 1364 | + } | |
| 1365 | + //已经结束 | |
| 1366 | + if (ut.gettimestamp() > res.data.data.end_time) { | |
| 1367 | + isok = 0; | |
| 1368 | + } | |
| 1369 | + //还未开始 | |
| 1370 | + if (ut.gettimestamp() < res.data.data.start_time) { | |
| 1371 | + isok = 0; | |
| 1372 | + } | |
| 1373 | + act = res.data.data; | |
| 1397 | 1374 | |
| 1398 | - if (item1.collocationList) { | |
| 1399 | - if (!arr[k].collocationList) arr[k].collocationList = item1.collocationList; | |
| 1400 | - else { | |
| 1401 | - var arr_new = [...arr[k].collocationList, ...item1.collocationList]; | |
| 1402 | - arr[k].collocationList = arr_new; | |
| 1375 | + } else { | |
| 1376 | + //未找到商品的活动 | |
| 1377 | + is_flag = 0; | |
| 1378 | + } | |
| 1379 | + }) | |
| 1380 | + if (!isok) { | |
| 1381 | + var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item1.id; | |
| 1382 | + getApp().request.delete(url, {}); | |
| 1383 | + th.data.ladder_map[item1.prom_id] = -1; | |
| 1384 | + continue; | |
| 1385 | + } | |
| 1386 | + th.data.ladder_map[item1.prom_id] = act; | |
| 1387 | + | |
| 1388 | + //-- 获取阶梯规则 -- | |
| 1389 | + var url1 = "/api/weshop/prom/ladderList/list"; | |
| 1390 | + var req_data = { | |
| 1391 | + store_id: os.stoid, | |
| 1392 | + form_id: item1.prom_id, | |
| 1403 | 1393 | } |
| 1394 | + await getApp().request.promiseGet(url1, { | |
| 1395 | + data: req_data | |
| 1396 | + }).then(rs1 => { | |
| 1397 | + if (rs1.data.code == 0 && rs1.data.data) { | |
| 1398 | + var gdlist = rs1.data.data; | |
| 1399 | + th.data.ladder_map[item1.prom_id].ladder_list = gdlist; | |
| 1400 | + } | |
| 1401 | + }) | |
| 1402 | + } | |
| 1403 | + } | |
| 1404 | + | |
| 1405 | + //-- 判断一下,获取搭配购的消息,只有prom_type==5才会判断优惠活动 -- | |
| 1406 | + if (item1.prom_type == 5 && (!item1.collocationList || !item1.collocationList.length)) { | |
| 1407 | + await th.set_collection(item1, arr[k].goods, jh); | |
| 1408 | + } | |
| 1409 | + | |
| 1410 | + if (item1.collocationList) { | |
| 1411 | + if (!arr[k].collocationList) arr[k].collocationList = item1.collocationList; | |
| 1412 | + else { | |
| 1413 | + var arr_new = [...arr[k].collocationList, ...item1.collocationList]; | |
| 1414 | + arr[k].collocationList = arr_new; | |
| 1404 | 1415 | } |
| 1416 | + } | |
| 1405 | 1417 | |
| 1406 | 1418 | } |
| 1407 | 1419 | |
| ... | ... | @@ -1412,25 +1424,32 @@ Page({ |
| 1412 | 1424 | //计算佣金的商品 |
| 1413 | 1425 | var commission_gds = []; |
| 1414 | 1426 | for (var c = 0; c < item.length; c++) { |
| 1415 | - if (!item[c].is_gift) { | |
| 1416 | - var hr = { | |
| 1417 | - goods_id: item[c].goods_id, | |
| 1418 | - goods_num: item[c].goods_num, | |
| 1419 | - prom_type: item[c].prom_type, | |
| 1420 | - prom_id: item[c].prom_id, | |
| 1421 | 1427 | |
| 1422 | - } | |
| 1423 | - let req_d1 = { | |
| 1424 | - user_id: getApp().globalData.user_id, goods_ids: [hr], store_id: os.stoid | |
| 1425 | - } | |
| 1428 | + //-- 有开启佣金抵扣的时候 -- | |
| 1429 | + if (getApp().globalData.userInfo.is_distribut | |
| 1430 | + && th.data.dis_config && th.data.dis_config.is_yongjin_dk) { | |
| 1426 | 1431 | |
| 1427 | - await getApp().request.promisePost("/api/weshop/order/getrebateSum", { | |
| 1428 | - is_json: 1, data: req_d1 | |
| 1429 | - }).then(grs => { | |
| 1430 | - if (grs.data.code == 0) item[c].use_commission = grs.data.data; | |
| 1431 | - }); | |
| 1432 | - commission_gds.push(hr); | |
| 1432 | + if (!item[c].is_gift) { | |
| 1433 | + var hr = { | |
| 1434 | + goods_id: item[c].goods_id, | |
| 1435 | + goods_num: item[c].goods_num, | |
| 1436 | + prom_type: item[c].prom_type, | |
| 1437 | + prom_id: item[c].prom_id, | |
| 1438 | + | |
| 1439 | + } | |
| 1440 | + let req_d1 = { | |
| 1441 | + user_id: getApp().globalData.user_id, goods_ids: [hr], store_id: os.stoid | |
| 1442 | + } | |
| 1443 | + | |
| 1444 | + await getApp().request.promisePost("/api/weshop/order/getrebateSum", { | |
| 1445 | + is_json: 1, data: req_d1 | |
| 1446 | + }).then(grs => { | |
| 1447 | + if (grs.data.code == 0) item[c].use_commission = grs.data.data; | |
| 1448 | + }); | |
| 1449 | + commission_gds.push(hr); | |
| 1450 | + } | |
| 1433 | 1451 | } |
| 1452 | + | |
| 1434 | 1453 | if (th.data.sales_rules != 2) { |
| 1435 | 1454 | item[c].offline_price = 0; |
| 1436 | 1455 | } |
| ... | ... | @@ -1446,22 +1465,24 @@ Page({ |
| 1446 | 1465 | c_item.is_offline = 1; |
| 1447 | 1466 | } |
| 1448 | 1467 | |
| 1449 | - //获取购物车的佣金,此处要优化调用接口,获取佣金 | |
| 1450 | - var req_d = { | |
| 1451 | - user_id: getApp().globalData.user_id, goods_ids: commission_gds, store_id: os.stoid | |
| 1452 | - } | |
| 1453 | - var back_data = null; | |
| 1454 | - await getApp().request.promisePost("/api/weshop/order/getrebateSum", { | |
| 1455 | - is_json: 1, data: req_d | |
| 1456 | - }).then(rs => { | |
| 1457 | - if (rs.data.code == 0) back_data = rs.data.data; | |
| 1458 | - }); | |
| 1468 | + //-- 如果有佣金抵扣的时候 -- | |
| 1469 | + if (commission_gds.length) { | |
| 1470 | + //获取购物车的佣金,此处要优化调用接口,获取佣金 | |
| 1471 | + var req_d = { | |
| 1472 | + user_id: getApp().globalData.user_id, goods_ids: commission_gds, store_id: os.stoid | |
| 1473 | + } | |
| 1474 | + var back_data = null; | |
| 1475 | + await getApp().request.promisePost("/api/weshop/order/getrebateSum", { | |
| 1476 | + is_json: 1, data: req_d | |
| 1477 | + }).then(rs => { | |
| 1478 | + if (rs.data.code == 0) back_data = rs.data.data; | |
| 1479 | + }); | |
| 1459 | 1480 | |
| 1460 | - if (back_data && parseFloat(back_data)) { | |
| 1461 | - c_item.can_usecommise = parseFloat(back_data); | |
| 1462 | - cart_commission += c_item.can_usecommise; | |
| 1481 | + if (back_data && parseFloat(back_data)) { | |
| 1482 | + c_item.can_usecommise = parseFloat(back_data); | |
| 1483 | + cart_commission += c_item.can_usecommise; | |
| 1484 | + } | |
| 1463 | 1485 | } |
| 1464 | - | |
| 1465 | 1486 | } |
| 1466 | 1487 | |
| 1467 | 1488 | if (cart_commission) { | ... | ... |
pages/cart/cart/cart.js
| ... | ... | @@ -570,15 +570,14 @@ Page({ |
| 570 | 570 | // } |
| 571 | 571 | // }) |
| 572 | 572 | |
| 573 | - | |
| 574 | 573 | for (let ir = 0; ir < g_arr.length; ir++) { |
| 575 | 574 | let gg_it=g_arr[ir]; |
| 576 | 575 | await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", { |
| 577 | 576 | data: { |
| 578 | 577 | store_id: oo.stoid, |
| 579 | 578 | user_id: user_id, |
| 580 | - goods_ids: gg_it, | |
| 581 | - isnew:1 | |
| 579 | + goods_id: gg_it, | |
| 580 | + isnew:1 | |
| 582 | 581 | }, |
| 583 | 582 | }).then(tt => { |
| 584 | 583 | if (tt.data.code == 0) { | ... | ... |