Commit 40727adf27f2064c8d044d5be1fc796079172940
1 parent
267d4c48
多促销优化支付的功能
Showing
2 changed files
with
680 additions
and
407 deletions
pages/user/order_detail/order_detail.js
| ... | ... | @@ -350,101 +350,140 @@ Page({ |
| 350 | 350 | url: "/pages/team/team_confirm/team_confirm?orderSn=" + this.data.order.order_sn + "&orderPay=true" |
| 351 | 351 | }) |
| 352 | 352 | var order=this.data.order; |
| 353 | + | |
| 353 | 354 | var order_goods=order.order_goods; |
| 354 | 355 | var user_id=order.user_id; |
| 355 | - | |
| 356 | - var wlist=""; | |
| 357 | - for(var i in order_goods){ | |
| 358 | - var good=order_goods[i]; | |
| 359 | - //线下取价功能已经关闭或者过期 | |
| 360 | - if(!th.data.is_open_offline && good.offline_cut>0){ | |
| 361 | - wx.showModal({ | |
| 362 | - title: '提示', | |
| 363 | - content: '线下取价功能已经关闭或者过期!' | |
| 364 | - }); | |
| 365 | - th.setData({paying:0}); | |
| 366 | - return false; | |
| 367 | - } | |
| 368 | - | |
| 369 | - //要每件每件的商品进行检查,看有么有超出库存,超出限购 | |
| 370 | - var good= order_goods[i],goodsbuynum=0,promgoodsbuynum=0,gg=null; | |
| 371 | - //获取单品的现在的活动状态 | |
| 372 | - await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + good.goods_id, { | |
| 373 | - }).then(res=>{ | |
| 374 | - gg=res.data.data; | |
| 375 | - }) | |
| 376 | - var limit = gg.viplimited; | |
| 377 | - var store_count = gg.store_count; | |
| 378 | - good.erpwareid=gg.erpwareid; | |
| 379 | - | |
| 380 | - //---要获得商品,该用户买了多少件,同步应用--- | |
| 381 | - await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", { | |
| 382 | - data: { | |
| 383 | - store_id: os.stoid, | |
| 384 | - user_id: getApp().globalData.user_id, | |
| 385 | - goods_id: good.goods_id, | |
| 386 | - prom_type: good.prom_type, | |
| 387 | - prom_id: good.prom_id | |
| 388 | - }, | |
| 389 | - }).then(res => { | |
| 390 | - var buy_num_data = res.data.data; | |
| 391 | - if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum; | |
| 392 | - goodsbuynum = buy_num_data.goodsbuynum; | |
| 393 | - }) | |
| 394 | - | |
| 395 | - var buyed_mum2=goodsbuynum+good.goods_num; | |
| 396 | - if (buyed_mum2 > limit && limit > 0) { | |
| 397 | - | |
| 398 | - var content=gg.goods_name+'购买数量超出商品限购,请取消订单'; | |
| 399 | - th.toast(content); | |
| 400 | - th.setData({paying:0}); | |
| 401 | - return false; | |
| 402 | - } | |
| 356 | + | |
| 357 | + | |
| 358 | + //如果使用预存的话,要重新效验下预存金额是否足够 | |
| 359 | + if(order.pre_cut && order.pre_json){ | |
| 360 | + let pickup_id=order.pickup_id | |
| 361 | + let res = await r.promiseGet('/api/weshop/pickup/get/' + os.stoid + '/' + pickup_id, {}) | |
| 362 | + let keyid = res.data.data.keyid | |
| 363 | + let resdata = await th.vipadvancesum(keyid,order.pre_cut,order.pre_json) | |
| 364 | + if(resdata.code !=0){ | |
| 365 | + let msg=resdata.msg || "预存金额不足" | |
| 366 | + getApp().confirmBox(msg); | |
| 367 | + th.setData({ paying: 0 }); | |
| 368 | + return false; | |
| 369 | + } | |
| 370 | + } | |
| 371 | + // 幸运购检查库存量 api/weshop/activitylist/getActLen/{store_id}/{prom_type}/{prom_id} | |
| 372 | + if (parseInt(order_goods['0']['prom_type']) == 9) { | |
| 373 | + var aid = order_goods['0']['prom_id']; | |
| 374 | + var knum = 0; | |
| 375 | + await r.promiseGet('/api/weshop/activitylist/getActLen/' + os.stoid + '/9/' + aid, { | |
| 376 | + }).then(res => { | |
| 377 | + if (res.data.code == 0) { | |
| 378 | + knum = res.data.data; | |
| 379 | + } | |
| 380 | + }); | |
| 381 | + | |
| 382 | + if (knum <= 0) { | |
| 383 | + getApp().confirmBox("库存为0,支付失败"); | |
| 384 | + th.setData({ paying: 0 }); | |
| 385 | + return false; | |
| 386 | + } | |
| 387 | + | |
| 388 | + } | |
| 389 | + | |
| 390 | + var wlist = ""; | |
| 391 | + for (var i in order_goods) { | |
| 392 | + var good = order_goods[i]; | |
| 393 | + | |
| 394 | + | |
| 395 | + //线下取价功能已经关闭或者过期 | |
| 396 | + if (!th.data.is_open_offline && good.offline_cut > 0) { | |
| 397 | + wx.showModal({ | |
| 398 | + title: '提示', | |
| 399 | + content: '线下取价功能已经关闭或者过期!' | |
| 400 | + }); | |
| 401 | + th.setData({ paying: 0 }); | |
| 402 | + return false; | |
| 403 | + } | |
| 404 | + | |
| 405 | + //要每件每件的商品进行检查,看有么有超出库存,超出限购 | |
| 406 | + var good = order_goods[i], goodsbuynum = 0, promgoodsbuynum = 0, gg = null, presellList = null; | |
| 407 | + | |
| 408 | + //获取单品的现在的活动状态 | |
| 409 | + await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + good.goods_id, {}).then(res => { | |
| 410 | + gg = res.data.data; | |
| 411 | + }) | |
| 412 | + | |
| 413 | + var limit = gg.viplimited; | |
| 414 | + var store_count = gg.store_count; | |
| 415 | + good.erpwareid = gg.erpwareid; | |
| 416 | + | |
| 417 | + //---要获得商品,该用户买了多少件,同步应用--- | |
| 418 | + await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", { | |
| 419 | + data: { | |
| 420 | + store_id: os.stoid, | |
| 421 | + user_id: user_id, | |
| 422 | + goods_id: good.goods_id, | |
| 423 | + prom_type: good.prom_type, | |
| 424 | + prom_id: good.prom_id | |
| 425 | + }, | |
| 426 | + }).then(res => { | |
| 427 | + var buy_num_data = res.data.data; | |
| 428 | + if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum; | |
| 429 | + goodsbuynum = buy_num_data.goodsbuynum; | |
| 430 | + }) | |
| 431 | + | |
| 432 | + var buyed_mum2 = goodsbuynum + good.goods_num; | |
| 433 | + if (buyed_mum2 > limit && limit > 0) { | |
| 434 | + var content = gg.goods_name + '购买数量超出商品限购,请取消订单'; | |
| 435 | + th.toast(content); | |
| 436 | + th.setData({ paying: 0 }); | |
| 437 | + return false; | |
| 438 | + } | |
| 439 | + | |
| 403 | 440 | //当是组合优惠的时候 |
| 404 | - if(good.prom_type==7){ | |
| 441 | + if (good.prom_type == 7) { | |
| 405 | 442 | //如果有组合购 |
| 406 | 443 | var isok = 1; |
| 444 | + var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + good.prom_id + "/" + getApp().globalData.userInfo.user_id; | |
| 407 | 445 | let zh_buy_info=null |
| 408 | - var url="/api/weshop/prom/zhbuy/get/"+os.stoid+"/"+good.prom_id+"/"+getApp().globalData.userInfo.user_id; | |
| 409 | 446 | await getApp().request.promiseGet(url, {}).then(res => { |
| 410 | - if(res.data.code==0 && res.data.data){ | |
| 411 | - zh_buy_info = res.data.data | |
| 412 | - if(res.data.data.is_show!=1){ | |
| 413 | - isok=0; | |
| 447 | + if (res.data.code == 0 && res.data.data) { | |
| 448 | + zh_buy_info = res.data.data | |
| 449 | + if (res.data.data.is_show != 1) { | |
| 450 | + isok = 0; | |
| 414 | 451 | } |
| 415 | 452 | //如果活动已经结束 |
| 416 | - if(res.data.data.is_end==1){ | |
| 417 | - isok=0; | |
| 453 | + if (res.data.data.is_end == 1) { | |
| 454 | + isok = 0; | |
| 418 | 455 | } |
| 419 | 456 | //已经结束 |
| 420 | - if(ut.gettimestamp()>res.data.data.end_time){ | |
| 421 | - isok=0; | |
| 457 | + if (ut.gettimestamp() > res.data.data.end_time) { | |
| 458 | + isok = 0; | |
| 422 | 459 | } |
| 423 | 460 | //还未开始 |
| 424 | - if(ut.gettimestamp()<res.data.data.start_time){ | |
| 425 | - isok=0; | |
| 461 | + if (ut.gettimestamp() < res.data.data.start_time) { | |
| 462 | + isok = 0; | |
| 426 | 463 | } |
| 427 | 464 | |
| 428 | - }else{ | |
| 465 | + | |
| 466 | + } else { | |
| 429 | 467 | //未找到商品的活动 |
| 430 | 468 | isok = 0; |
| 431 | 469 | } |
| 432 | 470 | |
| 433 | 471 | }) |
| 434 | - if (!isok){ | |
| 435 | - var content=gg.goods_name+'活动已经结束,请取消订单'; | |
| 472 | + if (!isok) { | |
| 473 | + var content = gg.goods_name + '活动已经结束,请取消订单'; | |
| 436 | 474 | th.toast(content); |
| 437 | - th.setData({paying:0}); | |
| 438 | - return false; | |
| 475 | + th.setData({ paying: 0 }); | |
| 476 | + return false; | |
| 439 | 477 | } |
| 440 | 478 | |
| 441 | 479 | //增加组合购次数判断 |
| 442 | - let userbuynum = await th.getUserBuyPromNum(good.prom_id) | |
| 480 | + let userbuynum = await th.getUserBuyPromNum(good.prom_id,1) | |
| 481 | + | |
| 443 | 482 | if (zh_buy_info.buy_limit !=0 && zh_buy_info && userbuynum >= zh_buy_info.buy_limit) { |
| 444 | - var content = gg.goods_name + '超出组合购限购次数,请取消订单'; | |
| 445 | - th.toast(content); | |
| 446 | - th.setData({ paying: 0 }); | |
| 447 | - return false; | |
| 483 | + var content = gg.goods_name + '超出组合购限购次数,请取消订单'; | |
| 484 | + th.toast(content); | |
| 485 | + th.setData({ paying: 0 }); | |
| 486 | + return false; | |
| 448 | 487 | } |
| 449 | 488 | |
| 450 | 489 | var url1 = "/api/weshop/prom/zhbuyGoods/page"; |
| ... | ... | @@ -453,380 +492,611 @@ Page({ |
| 453 | 492 | pageSize: 1, |
| 454 | 493 | store_id: os.stoid, |
| 455 | 494 | zh_id: good.prom_id, |
| 456 | - goods_id:good.goods_id | |
| 495 | + goods_id: good.goods_id | |
| 457 | 496 | } |
| 458 | 497 | await getApp().request.promiseGet(url1, { |
| 459 | 498 | data: req_data |
| 460 | 499 | }).then(res => { |
| 461 | 500 | if (ut.ajax_ok(res)) { |
| 462 | 501 | var gdlist = res.data.data.pageData[0]; |
| 463 | - good.buyqty=gdlist.buyqty; | |
| 502 | + good.buyqty = gdlist.buyqty; | |
| 464 | 503 | } |
| 465 | 504 | }) |
| 466 | 505 | |
| 467 | - var num=good['buyqty']; | |
| 468 | - console.log(1111); | |
| 469 | - console.log(num); | |
| 506 | + var num = good['buyqty']; | |
| 470 | 507 | //---- 要计算商品的限购 ----- |
| 471 | - if(good['buyqty']>0){ | |
| 472 | - if(good.goods_num+promgoodsbuynum>good['buyqty']){ | |
| 508 | + if (good['buyqty'] > 0) { | |
| 509 | + if (good.goods_num + promgoodsbuynum > good['buyqty']) { | |
| 510 | + var content = good['goods_name'] + "超出活动限购\n"; | |
| 511 | + th.toast(content); | |
| 512 | + th.setData({ paying: 0 }); | |
| 513 | + return false; | |
| 514 | + } | |
| 515 | + } | |
| 516 | + } | |
| 517 | + //如果是预售的时候, | |
| 518 | + if (good.prom_type == 8) { | |
| 519 | + await getApp().request.promiseGet("/api/weshop/order/orderPresell/countBuyGoodsSum", { | |
| 520 | + data: { store_id: os.stoid, user_id: user_id, goods_id: good.goods_id, prom_id: good.prom_id }, | |
| 521 | + }).then(e => { | |
| 522 | + if (e.data.code == 0) { | |
| 523 | + promgoodsbuynum = e.data.data.sumgoodsnum; | |
| 524 | + } | |
| 525 | + }) | |
| 526 | + | |
| 527 | + var presell_id = good.prom_id; | |
| 528 | + var url = "/api/weshop/marketing/marketingPresellList/list" | |
| 529 | + var rd = { | |
| 530 | + store_id: os.stoid, | |
| 531 | + presell_id: presell_id, | |
| 532 | + goods_id: good.goods_id | |
| 533 | + } | |
| 534 | + //------获取预售从表---------- | |
| 535 | + await getApp().request.promiseGet(url, { | |
| 536 | + data: rd | |
| 537 | + }).then(res => { | |
| 538 | + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { | |
| 539 | + var arr = res.data.data[0]; | |
| 540 | + presellList = arr | |
| 541 | + } | |
| 542 | + }) | |
| 473 | 543 | |
| 474 | - var content= good['goods_name']+"超出活动限购\n"; | |
| 544 | + if (presellList) { | |
| 545 | + | |
| 546 | + if (good.goods_num > presellList.presell_sumqty - presellList.buy_goodnum) { | |
| 547 | + var content = good.goods_name + '购买数量超出商品库存,请取消订单'; | |
| 548 | + th.toast(content); | |
| 549 | + th.setData({ paying: 0 }); | |
| 550 | + return false; | |
| 551 | + } | |
| 552 | + var buyed_mum3 = promgoodsbuynum + good.goods_num; | |
| 553 | + if (buyed_mum3 > presellList.vip_butyqty && presellList.vip_butyqty > 0) { | |
| 554 | + var content = good.goods_name + '购买数量超出商品限购,请取消订单'; | |
| 475 | 555 | th.toast(content); |
| 476 | - th.setData({paying:0}); | |
| 556 | + th.setData({ paying: 0 }); | |
| 477 | 557 | return false; |
| 478 | 558 | } |
| 559 | + | |
| 479 | 560 | } |
| 480 | 561 | } |
| 481 | 562 | |
| 482 | 563 | //如果优惠促销和搭配购的时候 |
| 483 | - if((good.prom_type==3 || good.prom_type==5) && good.is_collocation!=1 && good.is_gift!=1){ | |
| 484 | - var p_ok = 1,is_g_prom=0; | |
| 485 | - //因为有全场优惠活动,商品参加的活动还未开始 | |
| 486 | - var url="/api/weshop/activitylist/getGoodActInfo"; | |
| 487 | - var req_data={ | |
| 488 | - store_id:os.stoid,goodsidlist:good.goods_id,is_detail:1,user_id:user_id | |
| 489 | - }; | |
| 490 | - await getApp().request.promiseGet(url, {data:req_data}).then(async function (res) { | |
| 491 | - if(res.data.code==0 && res.data.data && res.data.data.length){ | |
| 492 | - for(let i in res.data.data){ | |
| 493 | - let item=res.data.data[i]; | |
| 494 | - if(item.prom_type==3 || item.prom_type==5) { | |
| 495 | - is_g_prom=1; break; | |
| 496 | - } | |
| 564 | + if ((good.prom_type == 3 || good.prom_type == 5 || good.prom_type == 10) && good.is_gift != 1 && good.is_collocation != 1) { | |
| 565 | + var p_ok = 1, is_g_prom = 0; | |
| 566 | + //只读优化促销和阶梯促销 | |
| 567 | + await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromListNew1/" + os.stoid + "/" + good.goods_id+"/0/"+user_id, {}).then(res => { | |
| 568 | + if (res.data.code == 0) { | |
| 569 | + var r_data = res.data.data; | |
| 570 | + if (!r_data.collocationPromList && good.prom_type == 5) { | |
| 571 | + var content = good.goods_name + '未找到活动,请取消订单重新购买'; | |
| 572 | + th.toast(content) | |
| 573 | + p_ok = 0; | |
| 497 | 574 | } |
| 575 | + if (!r_data.promGoodsLists && good.prom_type == 3) { | |
| 576 | + var content = good.goods_name + '未找到活动,请取消订单重新购买'; | |
| 577 | + th.toast(content); | |
| 578 | + p_ok = 0; | |
| 579 | + } | |
| 580 | + if (!r_data.ladderLists && good.prom_type == 10) { | |
| 581 | + var content = good.goods_name + '未找到活动,请取消订单重新购买'; | |
| 582 | + th.toast(content); | |
| 583 | + p_ok = 0; | |
| 584 | + } | |
| 585 | + } else { | |
| 586 | + | |
| 587 | + var content = good.goods_name + '未找到活动,请取消订单重新购买' | |
| 588 | + th.toast(content); | |
| 589 | + p_ok = 0; | |
| 498 | 590 | } |
| 499 | 591 | }) |
| 500 | - if(is_g_prom){ | |
| 501 | - await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + good.goods_id + "/0"+"/"+getApp().globalData.user_id, {}).then(res => { | |
| 502 | - if (res.data.code == 0) { | |
| 503 | - var r_data = res.data.data; | |
| 504 | - if (!r_data.collocationPromList && good.prom_type == 5) { | |
| 505 | - | |
| 506 | - var content = good.goods_name + '未找到活动,请取消订单重新购买'; | |
| 507 | - th.toast(content) | |
| 508 | - p_ok = 0; | |
| 509 | - } | |
| 510 | - if (!r_data.promGoodsLists && good.prom_type == 3) { | |
| 592 | + if (!p_ok) { | |
| 593 | + th.setData({ paying: 0 }); | |
| 594 | + return false; | |
| 595 | + } | |
| 596 | + } | |
| 511 | 597 | |
| 512 | - var content = good.goods_name + '未找到活动,请取消订单重新购买'; | |
| 513 | - th.toast(content); | |
| 514 | - p_ok = 0; | |
| 515 | - } | |
| 516 | - } else { | |
| 598 | + //-- 商品的普通购买 ,不要进行判断 -- | |
| 599 | + if ((good.prom_type == 1 || good.prom_type == 2 || good.prom_type == 6 || good.prom_type == 4 || good.prom_type == 8 || good.prom_type == 9) | |
| 600 | + && !good.is_gift && !good.is_collocation && !good.is_integral_normal && !good.is_pd_normal) { | |
| 517 | 601 | |
| 518 | - var content = good.goods_name + '未找到活动,请取消订单重新购买' | |
| 519 | - th.toast(content); | |
| 520 | - th.setData({paying:0}); | |
| 521 | - p_ok = 0; | |
| 602 | + } else { | |
| 603 | + | |
| 604 | + //因为商品的prom_type=0,所以商品的实际活动要重新获取 | |
| 605 | + var url = '/api/weshop/activitylist/listGoodActInfo2New'; | |
| 606 | + var req_d = { | |
| 607 | + "store_id": os.stoid, | |
| 608 | + "goods_id": good.goods_id, | |
| 609 | + "user_id": user_id, | |
| 610 | + } | |
| 611 | + await getApp().request.promiseGet(url, { | |
| 612 | + data: req_d | |
| 613 | + }).then(res => { | |
| 614 | + if (res.data.code == 0 && res.data.data) { | |
| 615 | + var arr = res.data.data; | |
| 616 | + //-- 预热也要计算 -- | |
| 617 | + var arr2 = arr.filter(function (e) { | |
| 618 | + return e.s_time < ut.gettimestamp() || (e.warm_uptime && e.warm_uptime < ut.gettimestamp()) | |
| 619 | + }) | |
| 620 | + if (arr2.length == 1) { | |
| 621 | + gg.prom_type=arr2[0].prom_type; | |
| 622 | + gg.prom_id=arr2[0].act_id; | |
| 522 | 623 | } |
| 523 | - }) | |
| 524 | - }else{ | |
| 525 | - await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromNormal/" + os.stoid + "/" + good.goods_id, {}).then(res => { | |
| 526 | - if (res.data.code == 0) { | |
| 527 | - var r_data = res.data.data; | |
| 528 | - if (!r_data.collocationPromList && good.prom_type == 5) { | |
| 624 | + } | |
| 625 | + }) | |
| 529 | 626 | |
| 530 | - var content = good.goods_name + '未找到活动,请取消订单重新购买'; | |
| 531 | - th.toast(content) | |
| 532 | 627 | |
| 533 | - p_ok = 0; | |
| 628 | + if ((gg.prom_type == 1 || gg.prom_type == 2 || gg.prom_type == 4 || gg.prom_type == 6 || gg.prom_type == 8 || gg.prom_type == 9) | |
| 629 | + && !good.is_collocation && !good.is_gift && !good.is_integral_normal && !good.is_pd_normal) { | |
| 630 | + var prom = null; | |
| 631 | + //---如果是活动的时候--- | |
| 632 | + var prom = null, th = this; | |
| 633 | + if (gg.prom_type == 1) { | |
| 634 | + await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + gg.prom_id, {}).then(res => { | |
| 635 | + if (res.data.code == 0) { | |
| 636 | + prom = res.data.data; | |
| 637 | + prom.price = prom.user_price; | |
| 534 | 638 | } |
| 535 | - if (!r_data.promGoodsLists && good.prom_type == 3) { | |
| 536 | - | |
| 537 | - var content = good.goods_name + '未找到活动,请取消订单重新购买'; | |
| 538 | - th.toast(content); | |
| 539 | - p_ok = 0; | |
| 639 | + }) | |
| 640 | + } | |
| 641 | + if (gg.prom_type == 2) { | |
| 642 | + await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + gg.goods_id + "/" + gg.prom_id, {}).then(res => { | |
| 643 | + if (res.data.code == 0) { | |
| 644 | + prom = res.data.data; | |
| 645 | + prom.price = prom.price; | |
| 646 | + } | |
| 647 | + }) | |
| 648 | + } | |
| 649 | + if (gg.prom_type == 6) { | |
| 650 | + await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + gg.prom_id, {}).then(res => { | |
| 651 | + if (res.data.code == 0) { | |
| 652 | + prom = res.data.data; | |
| 653 | + } | |
| 654 | + }) | |
| 655 | + } | |
| 656 | + if (gg.prom_type == 4) { | |
| 657 | + await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1&timetype=2", { | |
| 658 | + data: { store_id: os.stoid, goods_id: gg.goods_id,user_id: getApp().globalData.user_id, } | |
| 659 | + }).then(res => { | |
| 660 | + if (res.data.code == 0 && res.data.data && res.data.data.pageData) { | |
| 661 | + prom = res.data.data.pageData[0]; | |
| 540 | 662 | } |
| 541 | - } else { | |
| 663 | + }) | |
| 664 | + } | |
| 665 | + if (prom) { | |
| 666 | + var t_now = ut.gettimestamp(); | |
| 667 | + if (prom.is_end == 0 && prom.start_time < t_now && prom.end_time > t_now) { | |
| 542 | 668 | |
| 543 | - var content = good.goods_name + '未找到活动,请取消订单重新购买' | |
| 669 | + var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买'; | |
| 544 | 670 | th.toast(content); |
| 545 | - p_ok = 0; | |
| 671 | + th.setData({ paying: 0 }); | |
| 672 | + return false; | |
| 546 | 673 | } |
| 674 | + } | |
| 675 | + | |
| 676 | + //-- 幸运购的时候 -- | |
| 677 | + if(gg.prom_type==8 || gg.prom_type==9){ | |
| 678 | + var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买'; | |
| 679 | + th.toast(content); | |
| 680 | + th.setData({ paying: 0 }); | |
| 681 | + return false; | |
| 682 | + } | |
| 683 | + | |
| 684 | + } | |
| 685 | + else { | |
| 686 | + var t_ok = 1; | |
| 687 | + //-- 如果是普通购买的时候,此时计算的一定是商品的prom_type==0了, (组合购在普通购买的时候,就不判断了,因为组合购本身就可以普通购买)--- | |
| 688 | + if(!good.is_collocation && !good.is_gift && good.is_pd_normal!=2 && gg.prom_type!=7 ){ | |
| 689 | + | |
| 690 | + var promgoodsbuynum0=0; | |
| 691 | + //---要获得商品,该用户买了多少件,同步应用--- | |
| 692 | + await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", { | |
| 693 | + data: { | |
| 694 | + store_id: os.stoid, | |
| 695 | + user_id: user_id, | |
| 696 | + goods_id: good.goods_id, | |
| 697 | + prom_type: gg.prom_type, | |
| 698 | + prom_id: gg.prom_id | |
| 699 | + }, | |
| 700 | + }).then(res => { | |
| 701 | + var buy_num_data = res.data.data; | |
| 702 | + if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum; | |
| 703 | + }) | |
| 704 | + | |
| 705 | + | |
| 706 | + if(good.prom_type != gg.prom_type && good.prom_id != gg.prom_id){ | |
| 707 | + //如果商品有单独的活动的是偶 | |
| 708 | + switch (gg.prom_type){ | |
| 709 | + case 5: | |
| 710 | + case 10: | |
| 711 | + var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买'; | |
| 712 | + th.toast(content); | |
| 713 | + t_ok = 0; | |
| 714 | + break; | |
| 715 | + //-- 优惠促销是有限购的 -- | |
| 716 | + case 3: | |
| 717 | + var prom=null; | |
| 718 | + var yh_check=1; | |
| 719 | + await getApp().request.promiseGet("/api/weshop/promgoods/get/" + os.stoid + "/" + gg.prom_id, {}).then(res => { | |
| 720 | + if (res.data.code == 0) { prom = res.data.data; } | |
| 721 | + }) | |
| 722 | + if (prom && prom.limit_num) { | |
| 723 | + var limit_num = prom.limit_num; | |
| 724 | + var user_pre_buynum = await this.getUserBuyPromNum_pre(prom.id) | |
| 725 | + if (limit_num>0 && user_pre_buynum >= limit_num) { | |
| 726 | + yh_check=0; | |
| 727 | + } | |
| 728 | + } | |
| 729 | + //-- 优惠促销活动没有超出限购的话 -- | |
| 730 | + if(yh_check){ | |
| 731 | + var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买'; | |
| 732 | + th.toast(content); | |
| 733 | + t_ok = 0; | |
| 734 | + break; | |
| 735 | + } | |
| 736 | + | |
| 737 | + break | |
| 738 | + case 7: | |
| 739 | + //获取组合购活动 | |
| 740 | + var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + gg.prom_id + "/" + getApp().globalData.userInfo.user_id; | |
| 741 | + let zh_buy_info=null | |
| 742 | + await getApp().request.promiseGet(url, {}).then(res => { | |
| 743 | + if (res.data.code == 0 && res.data.data) { | |
| 744 | + zh_buy_info = res.data.data | |
| 745 | + } | |
| 746 | + }) | |
| 747 | + //判断活动超出限购 | |
| 748 | + var is_act_ok=1; | |
| 749 | + let userbuynum = await th.getUserBuyPromNum(gg.prom_id) | |
| 750 | + if (zh_buy_info.buy_limit !=0 && zh_buy_info && userbuynum >= zh_buy_info.buy_limit) { | |
| 751 | + is_act_ok=0; | |
| 752 | + } | |
| 753 | + | |
| 754 | + //判断活动商品超出限购,在从表 | |
| 755 | + var url1 = "/api/weshop/prom/zhbuyGoods/page"; | |
| 756 | + var req_data = { | |
| 757 | + page: 1, | |
| 758 | + pageSize: 1, | |
| 759 | + store_id: os.stoid, | |
| 760 | + zh_id: gg.prom_id, | |
| 761 | + goods_id: gg.goods_id | |
| 762 | + } | |
| 763 | + await getApp().request.promiseGet(url1, { | |
| 764 | + data: req_data | |
| 765 | + }).then(res => { | |
| 766 | + if (ut.ajax_ok(res)) { | |
| 767 | + var gdlist = res.data.data.pageData[0]; | |
| 768 | + gg.buyqty = gdlist.buyqty; | |
| 769 | + } | |
| 770 | + }) | |
| 771 | + var num = gg['buyqty']; | |
| 772 | + //---- 要计算商品的限购 ----- | |
| 773 | + if (gg['buyqty'] > 0) { | |
| 774 | + if (gg.goods_num + promgoodsbuynum0 > gg['buyqty']) { | |
| 775 | + is_act_ok=0; | |
| 776 | + } | |
| 777 | + } | |
| 778 | + if(is_act_ok){ | |
| 779 | + var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买'; | |
| 780 | + th.toast(content); | |
| 781 | + t_ok = 0; | |
| 782 | + break; | |
| 783 | + } | |
| 784 | + } | |
| 785 | + } | |
| 786 | + } | |
| 787 | + //-- 判断活动是不是OK -- | |
| 788 | + if (!t_ok) { | |
| 789 | + th.setData({ paying: 0 }); return false; | |
| 790 | + } | |
| 791 | + | |
| 792 | + // if (!good.is_gift && good.prom_type != 3) { | |
| 793 | + // var t_ok = 1; | |
| 794 | + // await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + good.goods_id + "/0" + "/" + getApp().globalData.user_id, {}).then(res => { | |
| 795 | + // if (res.data.code == 0) { | |
| 796 | + // var r_data = res.data.data; | |
| 797 | + // //-- 参加了全局的优惠活动 -- | |
| 798 | + // if (r_data.promGoodsLists) { | |
| 799 | + // var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买'; | |
| 800 | + // th.toast(content); | |
| 801 | + // t_ok = 0; | |
| 802 | + // } | |
| 803 | + // } | |
| 804 | + // }) | |
| 805 | + // if (!t_ok) { | |
| 806 | + // th.setData({ paying: 0 }); return false; | |
| 807 | + // } | |
| 808 | + // } | |
| 809 | + //-- 如果有参加线下取价 -- | |
| 810 | + if (good.offline_cut > 0) wlist += encodeURIComponent(gg.erpwareid) + ","; | |
| 811 | + } | |
| 812 | + //赠品和搭配购不判断商品金额 | |
| 813 | + var isok = 1; | |
| 814 | + var card_field = th.data.card_field; | |
| 815 | + | |
| 816 | + //-- 如果会员是等级会员,商品有等级价,且不是活动商品,同时线下取价的要放在最后来判断 -- | |
| 817 | + if (!good.is_gift && !good.is_collocation && gg.prom_type != 9) { | |
| 818 | + if (card_field && gg[card_field] > 0) { | |
| 819 | + if (good.goods_price != gg[card_field] && good.offline_cut <= 0) isok = 0; | |
| 820 | + if (good.goods_price > gg[card_field] && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过 | |
| 821 | + | |
| 822 | + } else { | |
| 823 | + if (good.goods_price != gg.shop_price && good.offline_cut <= 0) isok = 0; | |
| 824 | + if (good.goods_price > gg.shop_price && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过 | |
| 825 | + } | |
| 826 | + var is_h = 0; | |
| 827 | + if (!isok) { | |
| 828 | + | |
| 829 | + var content = gg.goods_name + '商品的价格发生了变化,请取消订单重新购买1' | |
| 830 | + th.toast(content); | |
| 831 | + th.setData({ paying: 0 }); | |
| 832 | + return false; | |
| 833 | + } | |
| 834 | + } | |
| 835 | + | |
| 836 | + //--如果是线下库存的时候-- | |
| 837 | + if (th.data.conf.sales_rules >= 2 && !gg.whsle_id) { | |
| 838 | + var ob = {}; | |
| 839 | + await th.check_down_line_next(gg, good.goods_num, order.pickup_id, function (obj) { | |
| 840 | + ob = obj; | |
| 547 | 841 | }) |
| 842 | + if (ob.code == -1) { | |
| 843 | + var content = gg.goods_name + '门店库存不足,请取消订单'; | |
| 844 | + th.toast(content); | |
| 845 | + th.setData({ paying: 0 }); | |
| 846 | + return false; | |
| 847 | + } | |
| 848 | + | |
| 849 | + } else { | |
| 850 | + if (good.goods_num > store_count) { | |
| 851 | + | |
| 852 | + var content = gg.goods_name + '商品的库存不足,请取消订单'; | |
| 853 | + th.toast(content); | |
| 854 | + th.setData({ paying: 0 }); | |
| 855 | + return false; | |
| 856 | + } | |
| 548 | 857 | |
| 549 | 858 | } |
| 550 | - if (!p_ok){ | |
| 551 | - th.setData({paying:0});return false; | |
| 859 | + } | |
| 860 | + | |
| 861 | + //---如果是活动的时候--- | |
| 862 | + var prom = null, goodsinfo = good, th = this; | |
| 863 | + if (goodsinfo.prom_type == 1) { | |
| 864 | + await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + goodsinfo.prom_id, {}).then(res => { | |
| 865 | + if (res.data.code == 0) { | |
| 866 | + prom = res.data.data; | |
| 867 | + prom.price = prom.user_price; | |
| 868 | + } | |
| 869 | + }) | |
| 870 | + } | |
| 871 | + if (goodsinfo.prom_type == 2) { | |
| 872 | + await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + good.goods_id + "/" + goodsinfo.prom_id, {}).then(res => { | |
| 873 | + if (res.data.code == 0) { | |
| 874 | + prom = res.data.data; | |
| 875 | + prom.price = prom.price; | |
| 876 | + } | |
| 877 | + }) | |
| 878 | + } | |
| 879 | + | |
| 880 | + if (goodsinfo.prom_type == 6 && !good.is_pd_normal) { | |
| 881 | + await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + goodsinfo.prom_id, {}).then(res => { | |
| 882 | + if (res.data.code == 0) { | |
| 883 | + prom = res.data.data; | |
| 884 | + } | |
| 885 | + }) | |
| 886 | + } | |
| 887 | + | |
| 888 | + if (goodsinfo.prom_type == 4 && !good.is_integral_normal) { | |
| 889 | + await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1&timetype=2", { | |
| 890 | + data: { store_id: os.stoid, goods_id: goodsinfo.goods_id,user_id: getApp().globalData.user_id, } | |
| 891 | + }).then(res => { | |
| 892 | + if (res.data.code == 0 && res.data.data && res.data.data.pageData) { | |
| 893 | + prom = res.data.data.pageData[0]; | |
| 894 | + } | |
| 895 | + }) | |
| 896 | + } | |
| 897 | + //----------如果有活动,并且在进行中,就不计算线下库存--------------- | |
| 898 | + if (prom) { | |
| 899 | + var now = ut.gettimestamp(); | |
| 900 | + if (prom.is_end == 1 && prom.end_time < now) { | |
| 901 | + var content = goodsinfo.goods_name + '商品的活动已经结束,请取消订单' | |
| 902 | + th.toast(content); | |
| 903 | + th.setData({ paying: 0 }); | |
| 904 | + return false; | |
| 552 | 905 | } |
| 553 | - } | |
| 554 | 906 | |
| 907 | + buyed_mum2 = promgoodsbuynum + good.goods_num; | |
| 908 | + if (buyed_mum2 > prom.buy_limit && prom.buy_limit > 0) { | |
| 555 | 909 | |
| 556 | - //商品的普通购买 ,不要进行判断 | |
| 557 | - if((good.prom_type==1 || good.prom_type==2 || good.prom_type==6 || good.prom_type==4) && !good.is_gift && !good.is_collocation && !good.is_integral_normal && !good.is_pd_normal){ | |
| 910 | + var content = goodsinfo.goods_name + '购买数量超出商品活动限购,请取消订单' | |
| 911 | + th.toast(content); | |
| 912 | + th.setData({ paying: 0 }); | |
| 913 | + return false; | |
| 914 | + } | |
| 558 | 915 | |
| 559 | - }else{ | |
| 560 | - if((gg.prom_type==1 || gg.prom_type==3 || gg.prom_type==5 || gg.prom_type==6 || gg.prom_type==4) | |
| 561 | - && !good.is_collocation && !good.is_gift && !good.is_integral_normal && !good.is_pd_normal) { | |
| 562 | - var prom=null; | |
| 563 | - //---如果是活动的时候--- | |
| 564 | - var prom=null,th=this; | |
| 565 | - if(gg.prom_type==1){ | |
| 566 | - await getApp().request.promiseGet("/api/ms/flash_sale/getNew/"+os.stoid+"/"+user_id+"/"+gg.prom_id,{ | |
| 567 | - }).then(res=>{ | |
| 568 | - if(res.data.code==0){ | |
| 569 | - prom=res.data.data; | |
| 570 | - prom.price=prom.user_price; | |
| 571 | - } | |
| 572 | - }) | |
| 573 | - } | |
| 574 | - | |
| 575 | - if (gg.prom_type == 2) { | |
| 576 | - await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/"+ gg.goods_id + "/" + gg.prom_id, {}).then(res => { | |
| 577 | - if (res.data.code == 0) { | |
| 578 | - prom = res.data.data; | |
| 579 | - prom.price=prom.price; | |
| 580 | - } | |
| 581 | - }) | |
| 582 | - } | |
| 583 | - | |
| 584 | - | |
| 585 | - if(gg.prom_type==6){ | |
| 586 | - await getApp().request.promiseGet("/api/weshop/teamlist/get/"+os.stoid+"/"+gg.prom_id,{ | |
| 587 | - }).then(res=>{ | |
| 588 | - if(res.data.code==0){ | |
| 589 | - prom=res.data.data; | |
| 590 | - } | |
| 591 | - }) | |
| 592 | - } | |
| 593 | - | |
| 594 | - if(gg.prom_type==4){ | |
| 595 | - await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1&timetype=2",{ | |
| 596 | - data:{store_id:os.stoid,goods_id:gg.goods_id,user_id: getApp().globalData.user_id,} | |
| 597 | - }).then(res=>{ | |
| 598 | - if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length){ | |
| 599 | - prom=res.data.data.pageData[0]; | |
| 600 | - } | |
| 601 | - }) | |
| 602 | - } | |
| 603 | - | |
| 604 | - if(prom){ | |
| 605 | - var t_now=ut.gettimestamp(); | |
| 606 | - if(prom.is_end==0 && prom.start_time<t_now && prom.end_time>t_now){ | |
| 607 | - | |
| 608 | - var content=gg.goods_name+'商品的活动发生了变化,请取消订单重新购买'; | |
| 609 | - th.toast(content); | |
| 610 | - th.setData({paying:0}); | |
| 611 | - return false; | |
| 612 | - } | |
| 613 | - } | |
| 614 | - }else{ | |
| 615 | - //不是赠品的时候 | |
| 616 | - if(!good.is_gift && good.prom_type!=3 && !good.is_collocation ){ | |
| 617 | - var t_ok=1; | |
| 618 | - await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+good.goods_id+"/0"+"/"+getApp().globalData.user_id, {}).then(res => { | |
| 619 | - if(res.data.code==0){ | |
| 620 | - var r_data=res.data.data; | |
| 621 | - //-- 参加了全局的优惠活动 -- | |
| 622 | - if(r_data.promGoodsLists){ | |
| 623 | - | |
| 624 | - var content=gg.goods_name+'商品的活动发生了变化,请取消订单重新购买'; | |
| 625 | - th.toast(content); | |
| 626 | - t_ok=0; | |
| 627 | - } | |
| 628 | - } | |
| 629 | - }) | |
| 630 | - if(!t_ok) { | |
| 631 | - th.setData({paying:0});return false; | |
| 632 | - } | |
| 633 | - } | |
| 916 | + // --看一下会员的秒杀价格是不是发生了变化,因为会员的身份发生了变化 | |
| 917 | + if (goodsinfo.prom_type == 1 && goodsinfo.goods_price != prom.price) { | |
| 918 | + var content = goodsinfo.goods_name + '秒杀活动的价格发生了变化'; | |
| 919 | + th.toast(content); | |
| 920 | + th.setData({ paying: 0 }); | |
| 921 | + return false; | |
| 922 | + } | |
| 634 | 923 | |
| 635 | - //-- 如果有参加线下取价 -- | |
| 636 | - if(good.offline_cut>0) wlist+=encodeURIComponent(gg.erpwareid)+","; | |
| 637 | - } | |
| 638 | - //赠品和搭配购不判断商品金额 | |
| 639 | - var isok=1; | |
| 640 | - var card_field=th.data.card_field; // 会员等级 | |
| 641 | - //如果会员是等级会员,商品有等级价,且不是活动商品 | |
| 642 | - if(!good.is_gift && !good.is_collocation) { | |
| 643 | - if (card_field && gg[card_field] > 0) { | |
| 644 | - if (good.goods_price != gg[card_field] && good.offline_cut<=0) isok = 0; | |
| 645 | - if (good.goods_price >gg[card_field] && good.offline_cut>0) isok = 0; //如果线下价格比较贵,则不通过 | |
| 646 | - | |
| 647 | - } else { | |
| 648 | - if (good.goods_price != gg.shop_price && good.offline_cut<=0) isok = 0; | |
| 649 | - if (good.goods_price> gg.shop_price && good.offline_cut>0) isok = 0; //如果线下价格比较贵,则不通过 | |
| 650 | - } | |
| 651 | - var is_h=0; | |
| 652 | - if (!isok) { | |
| 653 | - | |
| 654 | - var content=gg.goods_name + '商品的价格发生了变化,请取消订单重新购买22'; | |
| 655 | - th.toast(content); | |
| 656 | - th.setData({paying:0}); | |
| 657 | - return false; | |
| 658 | - } | |
| 659 | - } | |
| 660 | - | |
| 661 | - //--如果是线下库存的时候-- | |
| 662 | - if(th.data.conf.sales_rules>=2 && !gg.whsle_id){ | |
| 663 | - var ob={}; | |
| 664 | - await th.check_down_line_next(gg,good.goods_num,order.pickup_id,function(obj){ | |
| 665 | - ob=obj; | |
| 666 | - }) | |
| 667 | - if(ob.code==-1){ | |
| 668 | - var content=gg.goods_name+'门店库存不足,请取消订单'; | |
| 669 | - th.toast(content); | |
| 670 | - th.setData({paying:0}); | |
| 671 | - return false; | |
| 672 | - } | |
| 673 | - | |
| 674 | - }else{ | |
| 675 | - if(good.goods_num>store_count){ | |
| 676 | - | |
| 677 | - var content=gg.goods_name+'商品的库存不足,请取消订单'; | |
| 678 | - th.toast(content); | |
| 679 | - th.setData({paying:0}); | |
| 680 | - return false; | |
| 681 | - } | |
| 682 | - | |
| 683 | - } | |
| 684 | - } | |
| 685 | - | |
| 686 | - console.log("------------------------------------"); | |
| 687 | - //---如果是活动的时候--- | |
| 688 | - var prom=null,goodsinfo=good,th=this; | |
| 689 | - if(goodsinfo.prom_type==1){ | |
| 690 | - await getApp().request.promiseGet("/api/ms/flash_sale/getNew/"+os.stoid+"/"+user_id+"/"+goodsinfo.prom_id,{ | |
| 691 | - }).then(res=>{ | |
| 692 | - if(res.data.code==0){ | |
| 693 | - prom=res.data.data; | |
| 694 | - prom.price=prom.user_price; | |
| 695 | - } | |
| 696 | - }) | |
| 697 | - } | |
| 698 | - | |
| 699 | - if (goodsinfo.prom_type == 2) { | |
| 700 | - await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/"+ good.goods_id + "/" + goodsinfo.prom_id, {}).then(res => { | |
| 701 | - if (res.data.code == 0) { | |
| 702 | - prom = res.data.data; | |
| 703 | - prom.price=prom.price; | |
| 704 | - } | |
| 705 | - }) | |
| 706 | - } | |
| 707 | - | |
| 708 | - | |
| 709 | - if(goodsinfo.prom_type==6 && !good.is_pd_normal){ | |
| 710 | - await getApp().request.promiseGet("/api/weshop/teamlist/get/"+os.stoid+"/"+goodsinfo.prom_id,{ | |
| 711 | - }).then(res=>{ | |
| 712 | - if(res.data.code==0){ | |
| 713 | - prom=res.data.data; | |
| 714 | - } | |
| 715 | - }) | |
| 716 | - } | |
| 717 | - | |
| 718 | - if(goodsinfo.prom_type==4 && !good.is_integral_normal){ | |
| 719 | - await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1&timetype=2",{ | |
| 720 | - data:{store_id:os.stoid,goods_id:goodsinfo.goods_id,user_id: getApp().globalData.user_id,} | |
| 721 | - }).then(res=>{ | |
| 722 | - if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length){ | |
| 723 | - prom=res.data.data.pageData[0]; | |
| 724 | - } | |
| 725 | - }) | |
| 726 | - } | |
| 727 | - | |
| 728 | - //----------如果有活动,并且在进行中,就不计算线下库存--------------- | |
| 729 | - if(prom){ | |
| 730 | - var now=ut.gettimestamp(); | |
| 731 | - if(prom.is_end==1 && prom.end_time<now){ | |
| 732 | - | |
| 733 | - var content=goodsinfo.goods_name+'商品的活动已经结束,请取消订单重新购买'; | |
| 734 | - th.toast(content); | |
| 735 | - th.setData({paying:0}); | |
| 736 | - return false; | |
| 737 | - } | |
| 738 | - | |
| 739 | - buyed_mum2=promgoodsbuynum+good.goods_num; | |
| 740 | - if (buyed_mum2 > prom.buy_limit && prom.buy_limit > 0) { | |
| 741 | - var content=goodsinfo.goods_name+'购买数量超出商品活动限购,请取消订单重新购买'; | |
| 742 | - th.toast(content); | |
| 743 | - th.setData({paying:0}); | |
| 744 | - return false; | |
| 745 | - } | |
| 746 | - //看一下会员的秒杀价格是不是发生了变化 | |
| 747 | - if(goodsinfo.prom_type==1 && goodsinfo.goods_price!=prom.price){ | |
| 748 | - var content=goodsinfo.goods_name+'秒杀活动的价格发生了变化'; | |
| 749 | - th.toast(content); | |
| 750 | - th.setData({paying:0}); | |
| 751 | - return false; | |
| 752 | - } | |
| 753 | - | |
| 754 | - //看一下会员的团购价格是不是发生了变化 | |
| 755 | - if(goodsinfo.prom_type==2 && goodsinfo.goods_price!=prom.price){ | |
| 756 | - var content=goodsinfo.goods_name+'秒杀活动的价格发生了变化'; | |
| 757 | - th.toast(content); | |
| 758 | - th.setData({paying:0}); | |
| 759 | - return false; | |
| 760 | - } | |
| 924 | + // --看一下会员的团购价格是不是发生了变化 | |
| 925 | + if (goodsinfo.prom_type == 2 && goodsinfo.goods_price != prom.price) { | |
| 926 | + var content = goodsinfo.goods_name + '秒杀活动的价格发生了变化'; | |
| 927 | + th.toast(content); | |
| 928 | + th.setData({ paying: 0 }); | |
| 929 | + return false; | |
| 930 | + } | |
| 931 | + | |
| 932 | + if (goodsinfo.prom_type == 4) { | |
| 933 | + if (good.goods_num > prom.limitqty - prom.buy_num) { | |
| 934 | + | |
| 935 | + var content = goodsinfo.goods_name + '购买数量超出商品活动库存,请取消订单' | |
| 936 | + th.toast(content); | |
| 937 | + th.setData({ paying: 0 }); | |
| 938 | + return false; | |
| 939 | + } | |
| 940 | + } else if (goodsinfo.prom_type == 1 || goodsinfo.prom_type == 2 || goodsinfo.prom_type == 6) { | |
| 941 | + if (order.add_time + 5 * 60 < ut.gettimestamp()) { | |
| 942 | + var content = gg.goods_name + '该订单已经超时无法支付,请取消订单'; | |
| 943 | + th.toast(content); | |
| 944 | + th.setData({ paying: 0 }); | |
| 945 | + return false; | |
| 946 | + } | |
| 947 | + } | |
| 761 | 948 | |
| 762 | - if(goodsinfo.prom_type==4){ | |
| 763 | - if (good.goods_num > prom.limitqty-prom.buy_num) { | |
| 764 | - | |
| 765 | - var content=goodsinfo.goods_name+'购买数量超出商品活动库存,请取消订单'; | |
| 766 | - th.toast(content); | |
| 767 | - th.setData({paying:0}); | |
| 768 | - return false; | |
| 769 | - } | |
| 770 | - }else if(goodsinfo.prom_type == 1 || goodsinfo.prom_type == 2 || goodsinfo.prom_type == 6 ) { | |
| 771 | - if(order.add_time+5*60<ut.gettimestamp()) { | |
| 772 | - var content = gg.goods_name + '该订单已经超时无法支付,请取消订单'; | |
| 773 | - th.toast(content); | |
| 774 | - th.setData({paying:0}); | |
| 775 | - return false; | |
| 776 | - } | |
| 777 | - } | |
| 778 | - | |
| 779 | - } | |
| 780 | - | |
| 781 | - } | |
| 782 | - | |
| 783 | - //-- 要判断一下线下取价价格是不是发生改变 -- | |
| 784 | - if(wlist!="" && th.data.is_open_offline && th.data.is_open_offline>0){ | |
| 785 | - wlist=ut.sub_last(wlist); | |
| 786 | - var keyid=order.pickup_id; | |
| 787 | - var user_info=getApp().globalData.userInfo; | |
| 788 | - if(!keyid) { | |
| 789 | - th.setData({paying:0});return false; | |
| 790 | 949 | } |
| 791 | - var offarr=null; | |
| 792 | - await getApp().request.promiseGet("/api/weshop/goods/listWarePrice", { | |
| 793 | - data:{ | |
| 794 | - VIPId:encodeURIComponent(user_info.erpvipid), | |
| 795 | - store_id:os.stoid, | |
| 796 | - PickupId:keyid, | |
| 797 | - WareIds:wlist}, | |
| 798 | - }, | |
| 799 | - ).then(res=>{ | |
| 800 | - if(res.data.code==0 && res.data.data && res.data.data.length>0){ | |
| 801 | - offarr=res.data.data; | |
| 802 | - } | |
| 803 | - }) | |
| 804 | - if(!offarr && offarr.length<=0 ){ | |
| 805 | - wx.showModal({ title: '获取线下取价失败',}); | |
| 806 | - } | |
| 807 | - var newarr=ut.convert_arr_key(offarr,'WareId'); | |
| 808 | - //-- 循环判断线下的价格 -- | |
| 809 | - for(var k in order_goods){ | |
| 810 | - var good=order_goods[k]; | |
| 811 | - //判断线下取价是不是一样 | |
| 812 | - if(newarr[good.erpwareid] && | |
| 813 | - parseFloat(newarr[good.erpwareid].WarePrice)!=parseFloat(good.goods_price)){ | |
| 814 | - | |
| 815 | - var content=good.goods_name + '商品的价格发生了变化,请取消订单重新购买'; | |
| 816 | - th.toast(content); | |
| 817 | - th.setData({paying:0}); | |
| 818 | - return false; | |
| 819 | - } | |
| 820 | - } | |
| 821 | - | |
| 822 | - } | |
| 823 | 950 | |
| 824 | - /*--- | |
| 825 | - o.jumpToCart4({ | |
| 826 | - order_sn: this.data.order.order_sn, | |
| 827 | - order_amount: this.data.order.order_amount, | |
| 828 | - type: 1 //正常单 | |
| 829 | - }, 1);--*/ | |
| 951 | + //-- 预售和幸运购要单独计算 -- | |
| 952 | + if (goodsinfo.prom_type == 8) { | |
| 953 | + var presell_id= goodsinfo.prom_id; | |
| 954 | + //------获取预售主表,判断预售活动是不是到期不可以使用了---------- | |
| 955 | + var res= await getApp().request.promiseGet(`/api/weshop/marketing/marketingPresellForm/get/${os.stoid}/${presell_id}`, {}) | |
| 956 | + if (res.data.code == 0 && res.data.data) { | |
| 957 | + var act_data = res.data.data; | |
| 958 | + if (act_data.is_end) { | |
| 959 | + wx.showToast({ title: "活动已经结束", icon: 'none', duration: 3000 }); | |
| 960 | + return false; | |
| 961 | + } | |
| 962 | + if (act_data.isuse == 0) { | |
| 963 | + wx.showToast({ title: "活动未启用", icon: 'none', duration: 3000 }); | |
| 964 | + return false; | |
| 965 | + } | |
| 966 | + | |
| 967 | + var err_txt = "活动定金时间已经结束"; | |
| 968 | + var end_time = act_data.end_time; | |
| 969 | + if (act_data.presell_type == 1) { | |
| 970 | + err_txt = "活动时间已经结束"; | |
| 971 | + } | |
| 972 | + if (end_time < ut.gettimestamp()) { | |
| 973 | + wx.showToast({ title: err_txt, icon: 'none', duration: 3000 }); | |
| 974 | + return false; | |
| 975 | + } | |
| 976 | + | |
| 977 | + if (act_data.presell_type == 0) { | |
| 978 | + end_time = act_data.pay_enddate; | |
| 979 | + err_txt = "活动尾款时间已经结束"; | |
| 980 | + } | |
| 981 | + if (end_time < ut.gettimestamp()) { | |
| 982 | + wx.showToast({ title: err_txt, icon: 'none', duration: 3000 }); | |
| 983 | + return false; | |
| 984 | + } | |
| 985 | + } | |
| 986 | + | |
| 987 | + var all_pre_goods=null; | |
| 988 | + var userInfo = getApp().globalData.userInfo; | |
| 989 | + var pre_data = { store_id: os.stoid, is_end: 0, timetype: 1, isuse: 1, goods_id: goodsinfo.goods_id }; | |
| 990 | + if (userInfo) { | |
| 991 | + pre_data.user_id = userInfo.user_id; | |
| 992 | + } | |
| 993 | + var rs_pre= await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/page", { | |
| 994 | + data: pre_data, | |
| 995 | + }) | |
| 996 | + if (rs_pre.data.code == 0 && rs_pre.data.data.pageData && rs_pre.data.data.pageData.length > 0) { | |
| 997 | + all_pre_goods = rs_pre.data.data.pageData; | |
| 998 | + } | |
| 999 | + | |
| 1000 | + if(!all_pre_goods){ | |
| 1001 | + wx.showToast({ title: "未找到活动商品", icon: 'none', duration: 3000 }); | |
| 1002 | + return false; | |
| 1003 | + } | |
| 1004 | + var idx = all_pre_goods.findIndex(function (ele) { | |
| 1005 | + return ele.goods_id == goodsinfo.goods_id; | |
| 1006 | + }) | |
| 1007 | + | |
| 1008 | + if(idx==-1){ | |
| 1009 | + wx.showToast({ title: "未找到活动商品", icon: 'none', duration: 3000 }); | |
| 1010 | + return false; | |
| 1011 | + } | |
| 1012 | + var pre_arr = all_pre_goods[idx]; | |
| 1013 | + var prom_buy_limit = pre_arr.vip_butyqty; | |
| 1014 | + | |
| 1015 | + if (goods.goods_num > th.data.pre_arr.presell_sumqty - th.data.pre_arr.buy_goodnum) { | |
| 1016 | + wx.showToast({ title: "超出活动商品库存", icon: 'none', duration: 3000 }); | |
| 1017 | + return false; | |
| 1018 | + } | |
| 1019 | + //--判断商品是否超出活动限购-- | |
| 1020 | + if (promgoodsbuynum0 && prom_buy_limit > 0) { | |
| 1021 | + wx.showToast({ title: "超出活动商品库存", icon: 'none', duration: 3000 }); | |
| 1022 | + return false; | |
| 1023 | + } | |
| 1024 | + | |
| 1025 | + } | |
| 1026 | + //幸运购的时候 | |
| 1027 | + if (goodsinfo.prom_type == 9 && !good.is_pt_normal) { | |
| 1028 | + | |
| 1029 | + var lk_act=null; | |
| 1030 | + //获取单个活动成团信息 | |
| 1031 | + var lk_rs= await getApp().request.promiseGet('/api/weshop/prom/luckyActivity/page', { | |
| 1032 | + data: { | |
| 1033 | + store_id: os.stoid, | |
| 1034 | + is_end: 0, | |
| 1035 | + timetype: 1, | |
| 1036 | + id: goodsinfo.prom_id, | |
| 1037 | + } | |
| 1038 | + }); | |
| 1039 | + | |
| 1040 | + if(lk_rs && ut.ajax_ok(lk_rs)){ | |
| 1041 | + lk_act= lk_rs.data.data.pageData[0]; | |
| 1042 | + } | |
| 1043 | + if(!lk_act){ | |
| 1044 | + wx.showToast({ title: "未找到活动,或者活动已结束", icon: 'none', duration: 3000 }); | |
| 1045 | + th.setData({ paying: 0 }); | |
| 1046 | + return false; | |
| 1047 | + } | |
| 1048 | + // 检查幸运购活动商品库存 | |
| 1049 | + var lk_redis=await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/9/" + goodsinfo.prom_id,{}); | |
| 1050 | + if(!lk_redis || lk_redis<goodsinfo.goods_num ){ | |
| 1051 | + wx.showToast({ title: "活动商品库存不足", icon: 'none', duration: 3000 }); | |
| 1052 | + th.setData({ paying: 0 }); | |
| 1053 | + return false; | |
| 1054 | + } | |
| 1055 | + } | |
| 1056 | + | |
| 1057 | + } | |
| 1058 | + | |
| 1059 | + //-- 要判断一下线下取价价格是不是发生改变 -- | |
| 1060 | + if (wlist != "" && th.data.is_open_offline && th.data.is_open_offline > 0) { | |
| 1061 | + wlist = ut.sub_last(wlist); | |
| 1062 | + var keyid = order.pickup_id; | |
| 1063 | + var user_info = getApp().globalData.userInfo; | |
| 1064 | + if (!keyid) { | |
| 1065 | + th.setData({ paying: 0 }); return false; | |
| 1066 | + } | |
| 1067 | + var offarr = null; | |
| 1068 | + await getApp().request.promiseGet("/api/weshop/goods/listWarePrice", { | |
| 1069 | + data: { | |
| 1070 | + VIPId: encodeURIComponent(user_info.erpvipid), | |
| 1071 | + store_id: os.stoid, | |
| 1072 | + PickupId: keyid, | |
| 1073 | + WareIds: wlist | |
| 1074 | + }, | |
| 1075 | + }, | |
| 1076 | + ).then(res => { | |
| 1077 | + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { | |
| 1078 | + offarr = res.data.data; | |
| 1079 | + } | |
| 1080 | + }) | |
| 1081 | + if (!offarr && offarr.length <= 0) { | |
| 1082 | + th.toast('获取线下取价失败'); | |
| 1083 | + } | |
| 1084 | + var newarr = ut.convert_arr_key(offarr, 'WareId'); | |
| 1085 | + //-- 循环判断线下的价格 -- | |
| 1086 | + for (var k in order_goods) { | |
| 1087 | + var good = order_goods[k]; | |
| 1088 | + //判断线下取价是不是一样 | |
| 1089 | + if (newarr[good.erpwareid] && | |
| 1090 | + parseFloat(newarr[good.erpwareid].WarePrice) != parseFloat(good.goods_price)) { | |
| 1091 | + | |
| 1092 | + var content = good.goods_name + '商品的价格发生了变化,请取消订单重新购买'; | |
| 1093 | + th.toast(content); | |
| 1094 | + th.setData({ paying: 0 }); | |
| 1095 | + return false; | |
| 1096 | + } | |
| 1097 | + } | |
| 1098 | + } | |
| 1099 | + | |
| 830 | 1100 | |
| 831 | 1101 | py.pay(this.data.order.order_sn, function() { |
| 832 | 1102 | th.setData({paying:0}); |
| ... | ... | @@ -836,8 +1106,10 @@ Page({ |
| 836 | 1106 | th.setData({paying:0}); |
| 837 | 1107 | },os.stoid,1); |
| 838 | 1108 | |
| 839 | - | |
| 840 | 1109 | }, |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 841 | 1113 | checkTeam: function() { |
| 842 | 1114 | wx.navigateTo({ |
| 843 | 1115 | url: "/pages/team/team_detail/team_detail?foundId=" + this.data.order.orderTeamFound.found_id | ... | ... |
pages/user/order_list/order_list.js
| ... | ... | @@ -611,7 +611,8 @@ Page({ |
| 611 | 611 | } |
| 612 | 612 | }); |
| 613 | 613 | }, |
| 614 | - //预存款判断 | |
| 614 | + | |
| 615 | + //-- 预存款判断 -- | |
| 615 | 616 | async vipadvancesum(keyid,pre_cut,pre_json){ |
| 616 | 617 | let pre=JSON.parse(pre_json) |
| 617 | 618 | let listform=[] |
| ... | ... | @@ -676,7 +677,6 @@ Page({ |
| 676 | 677 | if (res.data.code == 0) { |
| 677 | 678 | knum = res.data.data; |
| 678 | 679 | } |
| 679 | - | |
| 680 | 680 | }); |
| 681 | 681 | |
| 682 | 682 | if (knum <= 0) { |
| ... | ... | @@ -983,7 +983,7 @@ Page({ |
| 983 | 983 | |
| 984 | 984 | } |
| 985 | 985 | else { |
| 986 | - | |
| 986 | + var t_ok = 1; | |
| 987 | 987 | //-- 如果是普通购买的时候,此时计算的一定是商品的prom_type==0了, (组合购在普通购买的时候,就不判断了,因为组合购本身就可以普通购买)--- |
| 988 | 988 | if(!good.is_collocation && !good.is_gift && good.is_pd_normal!=2 && gg.prom_type!=7 ){ |
| 989 | 989 | |
| ... | ... | @@ -1002,7 +1002,7 @@ Page({ |
| 1002 | 1002 | if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum; |
| 1003 | 1003 | }) |
| 1004 | 1004 | |
| 1005 | - var t_ok = 1; | |
| 1005 | + | |
| 1006 | 1006 | if(good.prom_type != gg.prom_type && good.prom_id != gg.prom_id){ |
| 1007 | 1007 | //如果商品有单独的活动的是偶 |
| 1008 | 1008 | switch (gg.prom_type){ |
| ... | ... | @@ -1396,6 +1396,7 @@ Page({ |
| 1396 | 1396 | } |
| 1397 | 1397 | } |
| 1398 | 1398 | } |
| 1399 | + | |
| 1399 | 1400 | th.pay_next(e, o_index); |
| 1400 | 1401 | }, |
| 1401 | 1402 | ... | ... |