From c6f6c79426eb76a0a06c1a6804e0ebe25c4bc8ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E7=A3=8A?= <45566618@qq.com> Date: Thu, 8 Aug 2024 17:17:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E9=94=80=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/OrdersServiceImpl.java | 1685 ++++++++--------- .../pay/controller/app/AliPayController.java | 726 +++---- .../pay/service/impl/WxServiceImpl.java | 726 +++---- 3 files changed, 1532 insertions(+), 1605 deletions(-) diff --git a/src/main/java/com/sqx/modules/artificer/service/impl/OrdersServiceImpl.java b/src/main/java/com/sqx/modules/artificer/service/impl/OrdersServiceImpl.java index 79f1a59..9652d30 100644 --- a/src/main/java/com/sqx/modules/artificer/service/impl/OrdersServiceImpl.java +++ b/src/main/java/com/sqx/modules/artificer/service/impl/OrdersServiceImpl.java @@ -1337,39 +1337,41 @@ public class OrdersServiceImpl extends ServiceImpl implements // } // ordersOld.setOneArtificerMoney(oneArtificerMoney); UserEntity user = userService.selectUserById(orders.getUserId()); + //经纪人分佣 + ordersOld.setJjrMoney(BigDecimal.ZERO); + ordersOld.setJjrArtificerDeductMoney(BigDecimal.ZERO); JjrConfig jc = jjrConfigService.getOne(new QueryWrapper()); - if(jc.getIsOpen().equals(1)){ + if(jc!=null && jc.getIsOpen().equals(1)){ UserEntity jjrUser = userService.queryByInvitationCode(user.getBlJjrCode()); - JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); - if(jjrApply.getStatus().equals(1)){ - if(jjrUser!=null && jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ - ordersOld.setJjrUserId(jjrUser.getUserId()); - ordersOld.setJjrUserName(jjrUser.getUserName()); - BigDecimal artificerRate = jc.getArtificerRate(); - BigDecimal agentRate = jc.getAgentRate(); - BigDecimal rate = BigDecimal.ZERO; - if(jc.getType().equals(1)){ - rate = jc.getRate(); - }else{ - int invitationCn = jjrApplyService.getInvitationCn(user.getBlJjrCode()); - List list = jjrConfigServiceLevel.findList(null); - for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ - rate = jjrcl.getRate(); - break; + if(jjrUser!=null){ + JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); + if(jjrApply!=null && jjrApply.getStatus().equals(1)){ + if(jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ + ordersOld.setJjrUserId(jjrUser.getUserId()); + ordersOld.setJjrUserName(jjrUser.getUserName()); + BigDecimal artificerRate = jc.getArtificerRate(); + BigDecimal agentRate = jc.getAgentRate(); + BigDecimal rate = BigDecimal.ZERO; + if(jc.getType().equals(1)){ + rate = jc.getRate(); + }else{ + int invitationCn = jjrApplyService.getInvitationCn(user.getBlJjrCode()); + List list = jjrConfigServiceLevel.findList(null); + for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ + rate = jjrcl.getRate(); + break; + } } } + BigDecimal jjrMoney = subtract.multiply(rate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + ordersOld.setJjrMoney(jjrMoney); + BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + ordersOld.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); } - BigDecimal jjrMoney = subtract.multiply(rate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - ordersOld.setJjrMoney(jjrMoney); - BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - ordersOld.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); } } - }else{ - ordersOld.setJjrMoney(BigDecimal.ZERO); - ordersOld.setJjrArtificerDeductMoney(BigDecimal.ZERO); } UserEntity artificerUser = userService.selectUserById(artificer.getUserId()); BigDecimal shopMoney = BigDecimal.ZERO; @@ -1399,115 +1401,115 @@ public class OrdersServiceImpl extends ServiceImpl implements // ordersOld.setOneUserMoney(oneUserMoney); //分销商分佣 + ordersOld.setFxyOneMoney(BigDecimal.ZERO); + ordersOld.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); + ordersOld.setFxyTwoMoney(BigDecimal.ZERO); + ordersOld.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); FxyConfig fc = fxyConfigService.getOne(new QueryWrapper()); - if(fc.getIsOpen().equals(1)){ + if(fc!=null && fc.getIsOpen().equals(1)){ UserEntity fxyOneUser = userService.queryByInvitationCode(user.getBlFxyCode()); - FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); - if(faOne.getStatus().equals(1)){ - if(fxyOneUser!=null && fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ - boolean isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faOne.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy){ - ordersOld.setFxyOneUserId(fxyOneUser.getUserId()); - ordersOld.setFxyOneUserName(fxyOneUser.getUserName()); - BigDecimal fxyMoney = BigDecimal.ZERO; - if(fc.getType().equals(1)){ - fxyMoney = artificerPrice; - } - if(fc.getType().equals(2)){ - fxyMoney = subtract; - } - BigDecimal artificerRate = fc.getArtificerRate(); - BigDecimal mostRate = fc.getMostRate(); - BigDecimal oneRate = fc.getOneRate(); - BigDecimal oneRecommendRate = fc.getOneRecommendRate(); - BigDecimal fxyRate = BigDecimal.ZERO; - if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ - fxyRate = oneRecommendRate; - if(oneRecommendRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; + if(fxyOneUser!=null){ + FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); + if(faOne!=null && faOne.getStatus().equals(1)){ + if(fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ + boolean isCanFxyFy = false; + if(fc.getFxmLimit().equals(2)){ + int fxmLimitDays = fc.getFxmLimitDays(); + String approveTime = faOne.getApproveTime(); + Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(approveDate); + calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); + approveDate = calendar.getTime(); + Date current = new Date(); + if(approveDate.getTime() > current.getTime()){ + isCanFxyFy = true; } }else{ - fxyRate = oneRate; - if(oneRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; - } + isCanFxyFy = true; } - BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - ordersOld.setFxyOneMoney(fxyOneMoney); - BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - ordersOld.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); - if(fxyOneUser.getBlFxyLevel().equals(1)){ - UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); - FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); - if(faTwo.getStatus().equals(1)){ - if(fxyTwoUser!=null && fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ - isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faTwo.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy) { - ordersOld.setFxyTwoUserId(fxyTwoUser.getUserId()); - ordersOld.setFxyTwoUserName(fxyTwoUser.getUserName()); - BigDecimal twoRate = fc.getTwoRate(); - BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); - fxyRate = BigDecimal.ZERO; - if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { - fxyRate = twoRecommendRate; - if (twoRecommendRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; + if(isCanFxyFy){ + ordersOld.setFxyOneUserId(fxyOneUser.getUserId()); + ordersOld.setFxyOneUserName(fxyOneUser.getUserName()); + BigDecimal fxyMoney = BigDecimal.ZERO; + if(fc.getType().equals(1)){ + fxyMoney = artificerPrice; + } + if(fc.getType().equals(2)){ + fxyMoney = subtract; + } + BigDecimal artificerRate = fc.getArtificerRate(); + BigDecimal mostRate = fc.getMostRate(); + BigDecimal oneRate = fc.getOneRate(); + BigDecimal oneRecommendRate = fc.getOneRecommendRate(); + BigDecimal fxyRate = BigDecimal.ZERO; + if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ + fxyRate = oneRecommendRate; + if(oneRecommendRate.compareTo(mostRate)> 0){ + fxyRate = mostRate; + } + }else{ + fxyRate = oneRate; + if(oneRate.compareTo(mostRate)> 0){ + fxyRate = mostRate; + } + } + BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + ordersOld.setFxyOneMoney(fxyOneMoney); + BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + ordersOld.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); + if(fxyOneUser.getBlFxyLevel().equals(1)){ + UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); + if(fxyTwoUser!=null){ + FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); + if(faTwo!=null && faTwo.getStatus().equals(1)){ + if(fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ + isCanFxyFy = false; + if(fc.getFxmLimit().equals(2)){ + int fxmLimitDays = fc.getFxmLimitDays(); + String approveTime = faTwo.getApproveTime(); + Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(approveDate); + calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); + approveDate = calendar.getTime(); + Date current = new Date(); + if(approveDate.getTime() > current.getTime()){ + isCanFxyFy = true; + } + }else{ + isCanFxyFy = true; } - } else { - fxyRate = twoRate; - if (twoRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; + if(isCanFxyFy) { + ordersOld.setFxyTwoUserId(fxyTwoUser.getUserId()); + ordersOld.setFxyTwoUserName(fxyTwoUser.getUserName()); + BigDecimal twoRate = fc.getTwoRate(); + BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); + fxyRate = BigDecimal.ZERO; + if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { + fxyRate = twoRecommendRate; + if (twoRecommendRate.compareTo(mostRate) > 0) { + fxyRate = mostRate; + } + } else { + fxyRate = twoRate; + if (twoRate.compareTo(mostRate) > 0) { + fxyRate = mostRate; + } + } + BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); + ordersOld.setFxyTwoMoney(fxyTwoMoney); + BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); + ordersOld.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); } } - BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - ordersOld.setFxyTwoMoney(fxyTwoMoney); - BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - ordersOld.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); } } } - }else{ - ordersOld.setFxyTwoMoney(BigDecimal.ZERO); - ordersOld.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } } } } - }else{ - ordersOld.setFxyOneMoney(BigDecimal.ZERO); - ordersOld.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); - ordersOld.setFxyTwoMoney(BigDecimal.ZERO); - ordersOld.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } // artificerPrice = artificerPrice.subtract(oneArtificerMoney); @@ -1968,39 +1970,41 @@ public class OrdersServiceImpl extends ServiceImpl implements orders.setProjectBenefits(artificerPrice); } UserEntity user = userService.selectUserById(orders.getUserId()); + //经纪人分佣 + orders.setJjrMoney(BigDecimal.ZERO); + orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); JjrConfig jc = jjrConfigService.getOne(new QueryWrapper()); - if(jc.getIsOpen().equals(1)){ + if(jc!=null && jc.getIsOpen().equals(1)){ UserEntity jjrUser = userService.queryByInvitationCode(user.getBlJjrCode()); - JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); - if(jjrApply.getStatus().equals(1)){ - if(jjrUser!=null && jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ - orders.setJjrUserId(jjrUser.getUserId()); - orders.setJjrUserName(jjrUser.getUserName()); - BigDecimal artificerRate = jc.getArtificerRate(); - BigDecimal agentRate = jc.getAgentRate(); - BigDecimal rate = BigDecimal.ZERO; - if(jc.getType().equals(1)){ - rate = jc.getRate(); - }else{ - int invitationCn = jjrApplyService.getInvitationCn(user.getBlJjrCode()); - List list = jjrConfigServiceLevel.findList(null); - for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ - rate = jjrcl.getRate(); - break; + if(jjrUser!=null){ + JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); + if(jjrApply!=null && jjrApply.getStatus().equals(1)){ + if(jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ + orders.setJjrUserId(jjrUser.getUserId()); + orders.setJjrUserName(jjrUser.getUserName()); + BigDecimal artificerRate = jc.getArtificerRate(); + BigDecimal agentRate = jc.getAgentRate(); + BigDecimal rate = BigDecimal.ZERO; + if(jc.getType().equals(1)){ + rate = jc.getRate(); + }else{ + int invitationCn = jjrApplyService.getInvitationCn(user.getBlJjrCode()); + List list = jjrConfigServiceLevel.findList(null); + for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ + rate = jjrcl.getRate(); + break; + } } } + BigDecimal jjrMoney = subtract.multiply(rate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setJjrMoney(jjrMoney); + BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); } - BigDecimal jjrMoney = subtract.multiply(rate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setJjrMoney(jjrMoney); - BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); } } - }else{ - orders.setJjrMoney(BigDecimal.ZERO); - orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); } UserEntity artificerUser = userService.selectUserById(artificer.getUserId()); BigDecimal shopMoney = BigDecimal.ZERO; @@ -2030,115 +2034,115 @@ public class OrdersServiceImpl extends ServiceImpl implements // orders.setOneUserMoney(oneUserMoney); //分销商分佣 + orders.setFxyOneMoney(BigDecimal.ZERO); + orders.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); + orders.setFxyTwoMoney(BigDecimal.ZERO); + orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); FxyConfig fc = fxyConfigService.getOne(new QueryWrapper()); - if(fc.getIsOpen().equals(1)){ + if(fc!=null && fc.getIsOpen().equals(1)){ UserEntity fxyOneUser = userService.queryByInvitationCode(user.getBlFxyCode()); - FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); - if(faOne.getStatus().equals(1)){ - if(fxyOneUser!=null && fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ - boolean isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faOne.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy){ - orders.setFxyOneUserId(fxyOneUser.getUserId()); - orders.setFxyOneUserName(fxyOneUser.getUserName()); - BigDecimal fxyMoney = BigDecimal.ZERO; - if(fc.getType().equals(1)){ - fxyMoney = artificerPrice; - } - if(fc.getType().equals(2)){ - fxyMoney = subtract; - } - BigDecimal artificerRate = fc.getArtificerRate(); - BigDecimal mostRate = fc.getMostRate(); - BigDecimal oneRate = fc.getOneRate(); - BigDecimal oneRecommendRate = fc.getOneRecommendRate(); - BigDecimal fxyRate = BigDecimal.ZERO; - if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ - fxyRate = oneRecommendRate; - if(oneRecommendRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; + if(fxyOneUser!=null){ + FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); + if(faOne!=null && faOne.getStatus().equals(1)){ + if(fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ + boolean isCanFxyFy = false; + if(fc.getFxmLimit().equals(2)){ + int fxmLimitDays = fc.getFxmLimitDays(); + String approveTime = faOne.getApproveTime(); + Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(approveDate); + calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); + approveDate = calendar.getTime(); + Date current = new Date(); + if(approveDate.getTime() > current.getTime()){ + isCanFxyFy = true; } }else{ - fxyRate = oneRate; - if(oneRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; - } + isCanFxyFy = true; } - BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setFxyOneMoney(fxyOneMoney); - BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); - if(fxyOneUser.getBlFxyLevel().equals(1)){ - UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); - FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); - if(faTwo.getStatus().equals(1)){ - if(fxyTwoUser!=null && fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ - isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faTwo.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy) { - orders.setFxyTwoUserId(fxyTwoUser.getUserId()); - orders.setFxyTwoUserName(fxyTwoUser.getUserName()); - BigDecimal twoRate = fc.getTwoRate(); - BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); - fxyRate = BigDecimal.ZERO; - if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { - fxyRate = twoRecommendRate; - if (twoRecommendRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; + if(isCanFxyFy){ + orders.setFxyOneUserId(fxyOneUser.getUserId()); + orders.setFxyOneUserName(fxyOneUser.getUserName()); + BigDecimal fxyMoney = BigDecimal.ZERO; + if(fc.getType().equals(1)){ + fxyMoney = artificerPrice; + } + if(fc.getType().equals(2)){ + fxyMoney = subtract; + } + BigDecimal artificerRate = fc.getArtificerRate(); + BigDecimal mostRate = fc.getMostRate(); + BigDecimal oneRate = fc.getOneRate(); + BigDecimal oneRecommendRate = fc.getOneRecommendRate(); + BigDecimal fxyRate = BigDecimal.ZERO; + if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ + fxyRate = oneRecommendRate; + if(oneRecommendRate.compareTo(mostRate)> 0){ + fxyRate = mostRate; + } + }else{ + fxyRate = oneRate; + if(oneRate.compareTo(mostRate)> 0){ + fxyRate = mostRate; + } + } + BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setFxyOneMoney(fxyOneMoney); + BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); + if(fxyOneUser.getBlFxyLevel().equals(1)){ + UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); + if(fxyTwoUser!=null){ + FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); + if(faTwo!=null && faTwo.getStatus().equals(1)){ + if(fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ + isCanFxyFy = false; + if(fc.getFxmLimit().equals(2)){ + int fxmLimitDays = fc.getFxmLimitDays(); + String approveTime = faTwo.getApproveTime(); + Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(approveDate); + calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); + approveDate = calendar.getTime(); + Date current = new Date(); + if(approveDate.getTime() > current.getTime()){ + isCanFxyFy = true; + } + }else{ + isCanFxyFy = true; } - } else { - fxyRate = twoRate; - if (twoRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; + if(isCanFxyFy) { + orders.setFxyTwoUserId(fxyTwoUser.getUserId()); + orders.setFxyTwoUserName(fxyTwoUser.getUserName()); + BigDecimal twoRate = fc.getTwoRate(); + BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); + fxyRate = BigDecimal.ZERO; + if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { + fxyRate = twoRecommendRate; + if (twoRecommendRate.compareTo(mostRate) > 0) { + fxyRate = mostRate; + } + } else { + fxyRate = twoRate; + if (twoRate.compareTo(mostRate) > 0) { + fxyRate = mostRate; + } + } + BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); + orders.setFxyTwoMoney(fxyTwoMoney); + BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); + orders.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); } } - BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - orders.setFxyTwoMoney(fxyTwoMoney); - BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - orders.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); } } } - }else{ - orders.setFxyTwoMoney(BigDecimal.ZERO); - orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } } } } - }else{ - orders.setFxyOneMoney(BigDecimal.ZERO); - orders.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); - orders.setFxyTwoMoney(BigDecimal.ZERO); - orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } // artificerPrice = artificerPrice.subtract(oneArtificerMoney); @@ -2323,39 +2327,41 @@ public class OrdersServiceImpl extends ServiceImpl implements ordersOld.setProjectBenefits(oldArtificerPrice); } UserEntity user = userService.selectUserById(orders.getUserId()); + //经纪人分佣 + ordersOld.setJjrMoney(BigDecimal.ZERO); + ordersOld.setJjrArtificerDeductMoney(BigDecimal.ZERO); JjrConfig jc = jjrConfigService.getOne(new QueryWrapper()); - if(jc.getIsOpen().equals(1)){ + if(jc!=null && jc.getIsOpen().equals(1)){ UserEntity jjrUser = userService.queryByInvitationCode(user.getBlJjrCode()); - JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); - if(jjrApply.getStatus().equals(1)){ - if(jjrUser!=null && jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ - ordersOld.setJjrUserId(jjrUser.getUserId()); - ordersOld.setJjrUserName(jjrUser.getUserName()); - BigDecimal artificerRate = jc.getArtificerRate(); - BigDecimal agentRate = jc.getAgentRate(); - BigDecimal rate = BigDecimal.ZERO; - if(jc.getType().equals(1)){ - rate = jc.getRate(); - }else{ - int invitationCn = jjrApplyService.getInvitationCn(user.getBlJjrCode()); - List list = jjrConfigServiceLevel.findList(null); - for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ - rate = jjrcl.getRate(); - break; + if(jjrUser!=null){ + JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); + if(jjrApply!=null && jjrApply.getStatus().equals(1)){ + if(jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ + ordersOld.setJjrUserId(jjrUser.getUserId()); + ordersOld.setJjrUserName(jjrUser.getUserName()); + BigDecimal artificerRate = jc.getArtificerRate(); + BigDecimal agentRate = jc.getAgentRate(); + BigDecimal rate = BigDecimal.ZERO; + if(jc.getType().equals(1)){ + rate = jc.getRate(); + }else{ + int invitationCn = jjrApplyService.getInvitationCn(user.getBlJjrCode()); + List list = jjrConfigServiceLevel.findList(null); + for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ + rate = jjrcl.getRate(); + break; + } } } + BigDecimal jjrMoney = subtract.multiply(rate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + ordersOld.setJjrMoney(jjrMoney); + BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + ordersOld.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); } - BigDecimal jjrMoney = subtract.multiply(rate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - ordersOld.setJjrMoney(jjrMoney); - BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - ordersOld.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); } } - }else{ - ordersOld.setJjrMoney(BigDecimal.ZERO); - ordersOld.setJjrArtificerDeductMoney(BigDecimal.ZERO); } UserEntity artificerUser = userService.selectUserById(artificer.getUserId()); BigDecimal shopMoney = BigDecimal.ZERO; @@ -2385,115 +2391,115 @@ public class OrdersServiceImpl extends ServiceImpl implements // ordersOld.setOneUserMoney(oneUserMoney); //分销商分佣 + ordersOld.setFxyOneMoney(BigDecimal.ZERO); + ordersOld.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); + ordersOld.setFxyTwoMoney(BigDecimal.ZERO); + ordersOld.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); FxyConfig fc = fxyConfigService.getOne(new QueryWrapper()); - if(fc.getIsOpen().equals(1)){ + if(fc!=null && fc.getIsOpen().equals(1)){ UserEntity fxyOneUser = userService.queryByInvitationCode(user.getBlFxyCode()); - FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); - if(faOne.getStatus().equals(1)){ - if(fxyOneUser!=null && fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ - boolean isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faOne.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy){ - ordersOld.setFxyOneUserId(fxyOneUser.getUserId()); - ordersOld.setFxyOneUserName(fxyOneUser.getUserName()); - BigDecimal fxyMoney = BigDecimal.ZERO; - if(fc.getType().equals(1)){ - fxyMoney = artificerPrice; - } - if(fc.getType().equals(2)){ - fxyMoney = subtract; - } - BigDecimal artificerRate = fc.getArtificerRate(); - BigDecimal mostRate = fc.getMostRate(); - BigDecimal oneRate = fc.getOneRate(); - BigDecimal oneRecommendRate = fc.getOneRecommendRate(); - BigDecimal fxyRate = BigDecimal.ZERO; - if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ - fxyRate = oneRecommendRate; - if(oneRecommendRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; + if(fxyOneUser!=null){ + FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); + if(faOne!=null && faOne.getStatus().equals(1)){ + if(fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ + boolean isCanFxyFy = false; + if(fc.getFxmLimit().equals(2)){ + int fxmLimitDays = fc.getFxmLimitDays(); + String approveTime = faOne.getApproveTime(); + Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(approveDate); + calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); + approveDate = calendar.getTime(); + Date current = new Date(); + if(approveDate.getTime() > current.getTime()){ + isCanFxyFy = true; } }else{ - fxyRate = oneRate; - if(oneRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; - } + isCanFxyFy = true; } - BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - ordersOld.setFxyOneMoney(fxyOneMoney); - BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - ordersOld.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); - if(fxyOneUser.getBlFxyLevel().equals(1)){ - UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); - FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); - if(faTwo.getStatus().equals(1)){ - if(fxyTwoUser!=null && fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ - isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faTwo.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy) { - ordersOld.setFxyTwoUserId(fxyTwoUser.getUserId()); - ordersOld.setFxyTwoUserName(fxyTwoUser.getUserName()); - BigDecimal twoRate = fc.getTwoRate(); - BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); - fxyRate = BigDecimal.ZERO; - if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { - fxyRate = twoRecommendRate; - if (twoRecommendRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; + if(isCanFxyFy){ + ordersOld.setFxyOneUserId(fxyOneUser.getUserId()); + ordersOld.setFxyOneUserName(fxyOneUser.getUserName()); + BigDecimal fxyMoney = BigDecimal.ZERO; + if(fc.getType().equals(1)){ + fxyMoney = artificerPrice; + } + if(fc.getType().equals(2)){ + fxyMoney = subtract; + } + BigDecimal artificerRate = fc.getArtificerRate(); + BigDecimal mostRate = fc.getMostRate(); + BigDecimal oneRate = fc.getOneRate(); + BigDecimal oneRecommendRate = fc.getOneRecommendRate(); + BigDecimal fxyRate = BigDecimal.ZERO; + if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ + fxyRate = oneRecommendRate; + if(oneRecommendRate.compareTo(mostRate)> 0){ + fxyRate = mostRate; + } + }else{ + fxyRate = oneRate; + if(oneRate.compareTo(mostRate)> 0){ + fxyRate = mostRate; + } + } + BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + ordersOld.setFxyOneMoney(fxyOneMoney); + BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + ordersOld.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); + if(fxyOneUser.getBlFxyLevel().equals(1)){ + UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); + if(fxyTwoUser!=null){ + FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); + if(faTwo!=null && faTwo.getStatus().equals(1)){ + if(fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ + isCanFxyFy = false; + if(fc.getFxmLimit().equals(2)){ + int fxmLimitDays = fc.getFxmLimitDays(); + String approveTime = faTwo.getApproveTime(); + Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(approveDate); + calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); + approveDate = calendar.getTime(); + Date current = new Date(); + if(approveDate.getTime() > current.getTime()){ + isCanFxyFy = true; + } + }else{ + isCanFxyFy = true; } - } else { - fxyRate = twoRate; - if (twoRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; + if(isCanFxyFy) { + ordersOld.setFxyTwoUserId(fxyTwoUser.getUserId()); + ordersOld.setFxyTwoUserName(fxyTwoUser.getUserName()); + BigDecimal twoRate = fc.getTwoRate(); + BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); + fxyRate = BigDecimal.ZERO; + if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { + fxyRate = twoRecommendRate; + if (twoRecommendRate.compareTo(mostRate) > 0) { + fxyRate = mostRate; + } + } else { + fxyRate = twoRate; + if (twoRate.compareTo(mostRate) > 0) { + fxyRate = mostRate; + } + } + BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); + ordersOld.setFxyTwoMoney(fxyTwoMoney); + BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); + ordersOld.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); } } - BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - ordersOld.setFxyTwoMoney(fxyTwoMoney); - BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - ordersOld.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); } } } - }else{ - ordersOld.setFxyTwoMoney(BigDecimal.ZERO); - ordersOld.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } } } } - }else{ - ordersOld.setFxyOneMoney(BigDecimal.ZERO); - ordersOld.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); - ordersOld.setFxyTwoMoney(BigDecimal.ZERO); - ordersOld.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } // oldArtificerPrice = oldArtificerPrice.subtract(oneArtificerMoney); @@ -2861,39 +2867,41 @@ public class OrdersServiceImpl extends ServiceImpl implements orders.setPingTaxiMoney(pingTaxiMoney); UserEntity user = userService.selectUserById(orders.getUserId()); + //经纪人分佣 + orders.setJjrMoney(BigDecimal.ZERO); + orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); JjrConfig jc = jjrConfigService.getOne(new QueryWrapper()); - if(jc.getIsOpen().equals(1)){ + if(jc!=null && jc.getIsOpen().equals(1)){ UserEntity jjrUser = userService.queryByInvitationCode(user.getBlJjrCode()); - JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); - if(jjrApply.getStatus().equals(1)){ - if(jjrUser!=null && jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ - orders.setJjrUserId(jjrUser.getUserId()); - orders.setJjrUserName(jjrUser.getUserName()); - BigDecimal artificerRate = jc.getArtificerRate(); - BigDecimal agentRate = jc.getAgentRate(); - BigDecimal jjrRate = BigDecimal.ZERO; - if(jc.getType().equals(1)){ - jjrRate = jc.getRate(); - }else{ - int invitationCn = jjrApplyService.getInvitationCn(user.getBlJjrCode()); - List list = jjrConfigServiceLevel.findList(null); - for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ - jjrRate = jjrcl.getRate(); - break; + if(jjrUser!=null){ + JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); + if(jjrApply!=null && jjrApply.getStatus().equals(1)){ + if(jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ + orders.setJjrUserId(jjrUser.getUserId()); + orders.setJjrUserName(jjrUser.getUserName()); + BigDecimal artificerRate = jc.getArtificerRate(); + BigDecimal agentRate = jc.getAgentRate(); + BigDecimal jjrRate = BigDecimal.ZERO; + if(jc.getType().equals(1)){ + jjrRate = jc.getRate(); + }else{ + int invitationCn = jjrApplyService.getInvitationCn(user.getBlJjrCode()); + List list = jjrConfigServiceLevel.findList(null); + for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ + jjrRate = jjrcl.getRate(); + break; + } } } + BigDecimal jjrMoney = subtract.multiply(jjrRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setJjrMoney(jjrMoney); + BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); } - BigDecimal jjrMoney = subtract.multiply(jjrRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setJjrMoney(jjrMoney); - BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); } } - }else{ - orders.setJjrMoney(BigDecimal.ZERO); - orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); } UserEntity artificerUser = userService.selectUserById(artificer.getUserId()); BigDecimal shopMoney = BigDecimal.ZERO; @@ -2923,115 +2931,115 @@ public class OrdersServiceImpl extends ServiceImpl implements // orders.setOneUserMoney(oneUserMoney); //分销商分佣 + orders.setFxyOneMoney(BigDecimal.ZERO); + orders.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); + orders.setFxyTwoMoney(BigDecimal.ZERO); + orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); FxyConfig fc = fxyConfigService.getOne(new QueryWrapper()); - if(fc.getIsOpen().equals(1)){ + if(fc!=null && fc.getIsOpen().equals(1)){ UserEntity fxyOneUser = userService.queryByInvitationCode(user.getBlFxyCode()); - FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); - if(faOne.getStatus().equals(1)){ - if(fxyOneUser!=null && fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ - boolean isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faOne.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy){ - orders.setFxyOneUserId(fxyOneUser.getUserId()); - orders.setFxyOneUserName(fxyOneUser.getUserName()); - BigDecimal fxyMoney = BigDecimal.ZERO; - if(fc.getType().equals(1)){ - fxyMoney = artificerMoney; - } - if(fc.getType().equals(2)){ - fxyMoney = subtract; - } - BigDecimal artificerRate = fc.getArtificerRate(); - BigDecimal mostRate = fc.getMostRate(); - BigDecimal oneRate = fc.getOneRate(); - BigDecimal oneRecommendRate = fc.getOneRecommendRate(); - BigDecimal fxyRate = BigDecimal.ZERO; - if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ - fxyRate = oneRecommendRate; - if(oneRecommendRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; + if(fxyOneUser!=null){ + FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); + if(faOne!=null && faOne.getStatus().equals(1)){ + if(fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ + boolean isCanFxyFy = false; + if(fc.getFxmLimit().equals(2)){ + int fxmLimitDays = fc.getFxmLimitDays(); + String approveTime = faOne.getApproveTime(); + Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(approveDate); + calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); + approveDate = calendar.getTime(); + Date current = new Date(); + if(approveDate.getTime() > current.getTime()){ + isCanFxyFy = true; } }else{ - fxyRate = oneRate; - if(oneRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; - } + isCanFxyFy = true; } - BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setFxyOneMoney(fxyOneMoney); - BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); - if(fxyOneUser.getBlFxyLevel().equals(1)){ - UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); - FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); - if(faTwo.getStatus().equals(1)){ - if(fxyTwoUser!=null && fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ - isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faTwo.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy) { - orders.setFxyTwoUserId(fxyTwoUser.getUserId()); - orders.setFxyTwoUserName(fxyTwoUser.getUserName()); - BigDecimal twoRate = fc.getTwoRate(); - BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); - fxyRate = BigDecimal.ZERO; - if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { - fxyRate = twoRecommendRate; - if (twoRecommendRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; + if(isCanFxyFy){ + orders.setFxyOneUserId(fxyOneUser.getUserId()); + orders.setFxyOneUserName(fxyOneUser.getUserName()); + BigDecimal fxyMoney = BigDecimal.ZERO; + if(fc.getType().equals(1)){ + fxyMoney = artificerMoney; + } + if(fc.getType().equals(2)){ + fxyMoney = subtract; + } + BigDecimal artificerRate = fc.getArtificerRate(); + BigDecimal mostRate = fc.getMostRate(); + BigDecimal oneRate = fc.getOneRate(); + BigDecimal oneRecommendRate = fc.getOneRecommendRate(); + BigDecimal fxyRate = BigDecimal.ZERO; + if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ + fxyRate = oneRecommendRate; + if(oneRecommendRate.compareTo(mostRate)> 0){ + fxyRate = mostRate; + } + }else{ + fxyRate = oneRate; + if(oneRate.compareTo(mostRate)> 0){ + fxyRate = mostRate; + } + } + BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setFxyOneMoney(fxyOneMoney); + BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); + if(fxyOneUser.getBlFxyLevel().equals(1)){ + UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); + if(fxyTwoUser!=null){ + FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); + if(faTwo!=null && faTwo.getStatus().equals(1)){ + if(fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ + isCanFxyFy = false; + if(fc.getFxmLimit().equals(2)){ + int fxmLimitDays = fc.getFxmLimitDays(); + String approveTime = faTwo.getApproveTime(); + Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(approveDate); + calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); + approveDate = calendar.getTime(); + Date current = new Date(); + if(approveDate.getTime() > current.getTime()){ + isCanFxyFy = true; + } + }else{ + isCanFxyFy = true; } - } else { - fxyRate = twoRate; - if (twoRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; + if(isCanFxyFy) { + orders.setFxyTwoUserId(fxyTwoUser.getUserId()); + orders.setFxyTwoUserName(fxyTwoUser.getUserName()); + BigDecimal twoRate = fc.getTwoRate(); + BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); + fxyRate = BigDecimal.ZERO; + if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { + fxyRate = twoRecommendRate; + if (twoRecommendRate.compareTo(mostRate) > 0) { + fxyRate = mostRate; + } + } else { + fxyRate = twoRate; + if (twoRate.compareTo(mostRate) > 0) { + fxyRate = mostRate; + } + } + BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); + orders.setFxyTwoMoney(fxyTwoMoney); + BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); + orders.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); } } - BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - orders.setFxyTwoMoney(fxyTwoMoney); - BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - orders.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); } } } - }else{ - orders.setFxyTwoMoney(BigDecimal.ZERO); - orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } } } } - }else{ - orders.setFxyOneMoney(BigDecimal.ZERO); - orders.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); - orders.setFxyTwoMoney(BigDecimal.ZERO); - orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } // artificerMoney = artificerMoney.subtract(oneArtificerMoney); @@ -3435,21 +3443,23 @@ public class OrdersServiceImpl extends ServiceImpl implements orders.setPingTaxiMoney(pingTaxiMoney); UserEntity user = userService.selectUserById(orders.getUserId()); + //经纪人分佣 + orders.setJjrMoney(BigDecimal.ZERO); + orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); JjrConfig jc = jjrConfigService.getOne(new QueryWrapper()); - if(jc.getIsOpen().equals(1)){ + if(jc!=null && jc.getIsOpen().equals(1)){ UserEntity jjrUser = userService.queryByInvitationCode(user.getBlJjrCode()); - JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); - if(jjrApply.getStatus().equals(1)){ - if(jjrUser!=null && jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ - orders.setJjrUserId(jjrUser.getUserId()); - orders.setJjrUserName(jjrUser.getUserName()); - orders.setJjrMoney(BigDecimal.ZERO); - orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); + if(jjrUser!=null){ + JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); + if(jjrApply!=null && jjrApply.getStatus().equals(1)){ + if(jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ + orders.setJjrUserId(jjrUser.getUserId()); + orders.setJjrUserName(jjrUser.getUserName()); + orders.setJjrMoney(BigDecimal.ZERO); + orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); + } } } - }else{ - orders.setJjrMoney(BigDecimal.ZERO); - orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); } UserEntity artificerUser = userService.selectUserById(artificer.getUserId()); BigDecimal shopMoney = BigDecimal.ZERO; @@ -3467,74 +3477,74 @@ public class OrdersServiceImpl extends ServiceImpl implements orders.setShopMoney(shopMoney); //分销商分佣 + orders.setFxyOneMoney(BigDecimal.ZERO); + orders.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); + orders.setFxyTwoMoney(BigDecimal.ZERO); + orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); FxyConfig fc = fxyConfigService.getOne(new QueryWrapper()); - if(fc.getIsOpen().equals(1)){ + if(fc!=null && fc.getIsOpen().equals(1)){ UserEntity fxyOneUser = userService.queryByInvitationCode(user.getBlFxyCode()); - FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); - if(faOne.getStatus().equals(1)){ - if(fxyOneUser!=null && fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ - boolean isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faOne.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ + if(fxyOneUser!=null){ + FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); + if(faOne!=null && faOne.getStatus().equals(1)){ + if(fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ + boolean isCanFxyFy = false; + if(fc.getFxmLimit().equals(2)){ + int fxmLimitDays = fc.getFxmLimitDays(); + String approveTime = faOne.getApproveTime(); + Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(approveDate); + calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); + approveDate = calendar.getTime(); + Date current = new Date(); + if(approveDate.getTime() > current.getTime()){ + isCanFxyFy = true; + } + }else{ isCanFxyFy = true; } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy){ - orders.setFxyOneUserId(fxyOneUser.getUserId()); - orders.setFxyOneUserName(fxyOneUser.getUserName()); - orders.setFxyOneMoney(BigDecimal.ZERO); - orders.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); - if(fxyOneUser.getBlFxyLevel().equals(1)){ - UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); - FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); - if(faTwo.getStatus().equals(1)){ - if(fxyTwoUser!=null && fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ - isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faTwo.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; + if(isCanFxyFy){ + orders.setFxyOneUserId(fxyOneUser.getUserId()); + orders.setFxyOneUserName(fxyOneUser.getUserName()); + orders.setFxyOneMoney(BigDecimal.ZERO); + orders.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); + if(fxyOneUser.getBlFxyLevel().equals(1)){ + UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); + if(fxyTwoUser!=null){ + FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); + if(faTwo!=null && faTwo.getStatus().equals(1)){ + if(fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ + isCanFxyFy = false; + if(fc.getFxmLimit().equals(2)){ + int fxmLimitDays = fc.getFxmLimitDays(); + String approveTime = faTwo.getApproveTime(); + Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(approveDate); + calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); + approveDate = calendar.getTime(); + Date current = new Date(); + if(approveDate.getTime() > current.getTime()){ + isCanFxyFy = true; + } + }else{ + isCanFxyFy = true; + } + if(isCanFxyFy) { + orders.setFxyTwoUserId(fxyTwoUser.getUserId()); + orders.setFxyTwoUserName(fxyTwoUser.getUserName()); + orders.setFxyTwoMoney(BigDecimal.ZERO); + orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); + } } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy) { - orders.setFxyTwoUserId(fxyTwoUser.getUserId()); - orders.setFxyTwoUserName(fxyTwoUser.getUserName()); - orders.setFxyTwoMoney(BigDecimal.ZERO); - orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } } } - }else{ - orders.setFxyTwoMoney(BigDecimal.ZERO); - orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } } } } - }else{ - orders.setFxyOneMoney(BigDecimal.ZERO); - orders.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); - orders.setFxyTwoMoney(BigDecimal.ZERO); - orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } orders.setArtificerMoney(artificerTaxiMoney); @@ -5355,39 +5365,41 @@ public class OrdersServiceImpl extends ServiceImpl implements orders.setProjectBenefits(artificerPrice); UserEntity user = userService.selectUserById(orders.getUserId()); + //经纪人分佣 + orders.setJjrMoney(BigDecimal.ZERO); + orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); JjrConfig jc = jjrConfigService.getOne(new QueryWrapper()); - if(jc.getIsOpen().equals(1)){ + if(jc!=null && jc.getIsOpen().equals(1)){ UserEntity jjrUser = userService.queryByInvitationCode(user.getBlJjrCode()); - JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); - if(jjrApply.getStatus().equals(1)){ - if(jjrUser!=null && jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ - orders.setJjrUserId(jjrUser.getUserId()); - orders.setJjrUserName(jjrUser.getUserName()); - BigDecimal artificerRate = jc.getArtificerRate(); - BigDecimal agentRate = jc.getAgentRate(); - BigDecimal jjrRate = BigDecimal.ZERO; - if(jc.getType().equals(1)){ - jjrRate = jc.getRate(); - }else{ - int invitationCn = jjrApplyService.getInvitationCn(user.getBlJjrCode()); - List list = jjrConfigServiceLevel.findList(null); - for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ - jjrRate = jjrcl.getRate(); - break; + if(jjrUser!=null){ + JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); + if(jjrApply!=null && jjrApply.getStatus().equals(1)){ + if(jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ + orders.setJjrUserId(jjrUser.getUserId()); + orders.setJjrUserName(jjrUser.getUserName()); + BigDecimal artificerRate = jc.getArtificerRate(); + BigDecimal agentRate = jc.getAgentRate(); + BigDecimal jjrRate = BigDecimal.ZERO; + if(jc.getType().equals(1)){ + jjrRate = jc.getRate(); + }else{ + int invitationCn = jjrApplyService.getInvitationCn(user.getBlJjrCode()); + List list = jjrConfigServiceLevel.findList(null); + for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ + jjrRate = jjrcl.getRate(); + break; + } } } + BigDecimal jjrMoney = subtract.multiply(jjrRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setJjrMoney(jjrMoney); + BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); } - BigDecimal jjrMoney = subtract.multiply(jjrRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setJjrMoney(jjrMoney); - BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); } } - }else{ - orders.setJjrMoney(BigDecimal.ZERO); - orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); } UserEntity artificerUser = userService.selectUserById(artificer.getUserId()); BigDecimal shopMoney = BigDecimal.ZERO; @@ -5417,115 +5429,115 @@ public class OrdersServiceImpl extends ServiceImpl implements // orders.setOneUserMoney(oneUserMoney); //分销商分佣 + orders.setFxyOneMoney(BigDecimal.ZERO); + orders.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); + orders.setFxyTwoMoney(BigDecimal.ZERO); + orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); FxyConfig fc = fxyConfigService.getOne(new QueryWrapper()); - if(fc.getIsOpen().equals(1)){ + if(fc!=null && fc.getIsOpen().equals(1)){ UserEntity fxyOneUser = userService.queryByInvitationCode(user.getBlFxyCode()); - FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); - if(faOne.getStatus().equals(1)){ - if(fxyOneUser!=null && fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ - boolean isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faOne.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy){ - orders.setFxyOneUserId(fxyOneUser.getUserId()); - orders.setFxyOneUserName(fxyOneUser.getUserName()); - BigDecimal fxyMoney = BigDecimal.ZERO; - if(fc.getType().equals(1)){ - fxyMoney = artificerPrice; - } - if(fc.getType().equals(2)){ - fxyMoney = subtract; - } - BigDecimal artificerRate = fc.getArtificerRate(); - BigDecimal mostRate = fc.getMostRate(); - BigDecimal oneRate = fc.getOneRate(); - BigDecimal oneRecommendRate = fc.getOneRecommendRate(); - BigDecimal fxyRate = BigDecimal.ZERO; - if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ - fxyRate = oneRecommendRate; - if(oneRecommendRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; + if(fxyOneUser!=null){ + FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); + if(faOne!=null && faOne.getStatus().equals(1)){ + if(fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ + boolean isCanFxyFy = false; + if(fc.getFxmLimit().equals(2)){ + int fxmLimitDays = fc.getFxmLimitDays(); + String approveTime = faOne.getApproveTime(); + Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(approveDate); + calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); + approveDate = calendar.getTime(); + Date current = new Date(); + if(approveDate.getTime() > current.getTime()){ + isCanFxyFy = true; } }else{ - fxyRate = oneRate; - if(oneRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; - } + isCanFxyFy = true; } - BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setFxyOneMoney(fxyOneMoney); - BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); - if(fxyOneUser.getBlFxyLevel().equals(1)){ - UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); - FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); - if(faTwo.getStatus().equals(1)){ - if(fxyTwoUser!=null && fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ - isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faTwo.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy) { - orders.setFxyTwoUserId(fxyTwoUser.getUserId()); - orders.setFxyTwoUserName(fxyTwoUser.getUserName()); - BigDecimal twoRate = fc.getTwoRate(); - BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); - fxyRate = BigDecimal.ZERO; - if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { - fxyRate = twoRecommendRate; - if (twoRecommendRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; + if(isCanFxyFy){ + orders.setFxyOneUserId(fxyOneUser.getUserId()); + orders.setFxyOneUserName(fxyOneUser.getUserName()); + BigDecimal fxyMoney = BigDecimal.ZERO; + if(fc.getType().equals(1)){ + fxyMoney = artificerPrice; + } + if(fc.getType().equals(2)){ + fxyMoney = subtract; + } + BigDecimal artificerRate = fc.getArtificerRate(); + BigDecimal mostRate = fc.getMostRate(); + BigDecimal oneRate = fc.getOneRate(); + BigDecimal oneRecommendRate = fc.getOneRecommendRate(); + BigDecimal fxyRate = BigDecimal.ZERO; + if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ + fxyRate = oneRecommendRate; + if(oneRecommendRate.compareTo(mostRate)> 0){ + fxyRate = mostRate; + } + }else{ + fxyRate = oneRate; + if(oneRate.compareTo(mostRate)> 0){ + fxyRate = mostRate; + } + } + BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setFxyOneMoney(fxyOneMoney); + BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); + if(fxyOneUser.getBlFxyLevel().equals(1)){ + UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); + if(fxyTwoUser!=null){ + FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); + if(faTwo!=null && faTwo.getStatus().equals(1)){ + if(fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ + isCanFxyFy = false; + if(fc.getFxmLimit().equals(2)){ + int fxmLimitDays = fc.getFxmLimitDays(); + String approveTime = faTwo.getApproveTime(); + Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(approveDate); + calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); + approveDate = calendar.getTime(); + Date current = new Date(); + if(approveDate.getTime() > current.getTime()){ + isCanFxyFy = true; + } + }else{ + isCanFxyFy = true; } - } else { - fxyRate = twoRate; - if (twoRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; + if(isCanFxyFy) { + orders.setFxyTwoUserId(fxyTwoUser.getUserId()); + orders.setFxyTwoUserName(fxyTwoUser.getUserName()); + BigDecimal twoRate = fc.getTwoRate(); + BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); + fxyRate = BigDecimal.ZERO; + if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { + fxyRate = twoRecommendRate; + if (twoRecommendRate.compareTo(mostRate) > 0) { + fxyRate = mostRate; + } + } else { + fxyRate = twoRate; + if (twoRate.compareTo(mostRate) > 0) { + fxyRate = mostRate; + } + } + BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); + orders.setFxyTwoMoney(fxyTwoMoney); + BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); + orders.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); } } - BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - orders.setFxyTwoMoney(fxyTwoMoney); - BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - orders.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); } } } - }else{ - orders.setFxyTwoMoney(BigDecimal.ZERO); - orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } } } } - }else{ - orders.setFxyOneMoney(BigDecimal.ZERO); - orders.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); - orders.setFxyTwoMoney(BigDecimal.ZERO); - orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } // artificerPrice = artificerPrice.subtract(oneArtificerMoney); @@ -5891,39 +5903,41 @@ public class OrdersServiceImpl extends ServiceImpl implements orders.setProjectBenefits(artificerPrice); UserEntity user = userService.selectUserById(orders.getUserId()); + //经纪人分佣 + orders.setJjrMoney(BigDecimal.ZERO); + orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); JjrConfig jc = jjrConfigService.getOne(new QueryWrapper()); if(jc.getIsOpen().equals(1)){ UserEntity jjrUser = userService.queryByInvitationCode(user.getBlJjrCode()); - JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); - if(jjrApply.getStatus().equals(1)){ - if(jjrUser!=null && jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ - orders.setJjrUserId(jjrUser.getUserId()); - orders.setJjrUserName(jjrUser.getUserName()); - BigDecimal artificerRate = jc.getArtificerRate(); - BigDecimal agentRate = jc.getAgentRate(); - BigDecimal jjrRate = BigDecimal.ZERO; - if(jc.getType().equals(1)){ - jjrRate = jc.getRate(); - }else{ - int invitationCn = jjrApplyService.getInvitationCn(user.getBlJjrCode()); - List list = jjrConfigServiceLevel.findList(null); - for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ - jjrRate = jjrcl.getRate(); - break; + if(jjrUser!=null){ + JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); + if(jjrApply!=null && jjrApply.getStatus().equals(1)){ + if(jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ + orders.setJjrUserId(jjrUser.getUserId()); + orders.setJjrUserName(jjrUser.getUserName()); + BigDecimal artificerRate = jc.getArtificerRate(); + BigDecimal agentRate = jc.getAgentRate(); + BigDecimal jjrRate = BigDecimal.ZERO; + if(jc.getType().equals(1)){ + jjrRate = jc.getRate(); + }else{ + int invitationCn = jjrApplyService.getInvitationCn(user.getBlJjrCode()); + List list = jjrConfigServiceLevel.findList(null); + for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ + jjrRate = jjrcl.getRate(); + break; + } } } + BigDecimal jjrMoney = subtract.multiply(jjrRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setJjrMoney(jjrMoney); + BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); } - BigDecimal jjrMoney = subtract.multiply(jjrRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setJjrMoney(jjrMoney); - BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); } } - }else{ - orders.setJjrMoney(BigDecimal.ZERO); - orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); } UserEntity artificerUser = userService.selectUserById(artificer.getUserId()); BigDecimal shopMoney = BigDecimal.ZERO; @@ -5953,115 +5967,115 @@ public class OrdersServiceImpl extends ServiceImpl implements // orders.setOneUserMoney(oneUserMoney); //分销商分佣 + orders.setFxyOneMoney(BigDecimal.ZERO); + orders.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); + orders.setFxyTwoMoney(BigDecimal.ZERO); + orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); FxyConfig fc = fxyConfigService.getOne(new QueryWrapper()); - if(fc.getIsOpen().equals(1)){ + if(fc!=null && fc.getIsOpen().equals(1)){ UserEntity fxyOneUser = userService.queryByInvitationCode(user.getBlFxyCode()); - FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); - if(faOne.getStatus().equals(1)){ - if(fxyOneUser!=null && fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ - boolean isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faOne.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy){ - orders.setFxyOneUserId(fxyOneUser.getUserId()); - orders.setFxyOneUserName(fxyOneUser.getUserName()); - BigDecimal fxyMoney = BigDecimal.ZERO; - if(fc.getType().equals(1)){ - fxyMoney = artificerPrice; - } - if(fc.getType().equals(2)){ - fxyMoney = subtract; - } - BigDecimal artificerRate = fc.getArtificerRate(); - BigDecimal mostRate = fc.getMostRate(); - BigDecimal oneRate = fc.getOneRate(); - BigDecimal oneRecommendRate = fc.getOneRecommendRate(); - BigDecimal fxyRate = BigDecimal.ZERO; - if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ - fxyRate = oneRecommendRate; - if(oneRecommendRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; + if(fxyOneUser!=null){ + FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); + if(faOne!=null && faOne.getStatus().equals(1)){ + if(fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ + boolean isCanFxyFy = false; + if(fc.getFxmLimit().equals(2)){ + int fxmLimitDays = fc.getFxmLimitDays(); + String approveTime = faOne.getApproveTime(); + Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(approveDate); + calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); + approveDate = calendar.getTime(); + Date current = new Date(); + if(approveDate.getTime() > current.getTime()){ + isCanFxyFy = true; } }else{ - fxyRate = oneRate; - if(oneRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; - } + isCanFxyFy = true; } - BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setFxyOneMoney(fxyOneMoney); - BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); - if(fxyOneUser.getBlFxyLevel().equals(1)){ - UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); - FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); - if(faTwo.getStatus().equals(1)){ - if(fxyTwoUser!=null && fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ - isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faTwo.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy) { - orders.setFxyTwoUserId(fxyTwoUser.getUserId()); - orders.setFxyTwoUserName(fxyTwoUser.getUserName()); - BigDecimal twoRate = fc.getTwoRate(); - BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); - fxyRate = BigDecimal.ZERO; - if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { - fxyRate = twoRecommendRate; - if (twoRecommendRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; + if(isCanFxyFy){ + orders.setFxyOneUserId(fxyOneUser.getUserId()); + orders.setFxyOneUserName(fxyOneUser.getUserName()); + BigDecimal fxyMoney = BigDecimal.ZERO; + if(fc.getType().equals(1)){ + fxyMoney = artificerPrice; + } + if(fc.getType().equals(2)){ + fxyMoney = subtract; + } + BigDecimal artificerRate = fc.getArtificerRate(); + BigDecimal mostRate = fc.getMostRate(); + BigDecimal oneRate = fc.getOneRate(); + BigDecimal oneRecommendRate = fc.getOneRecommendRate(); + BigDecimal fxyRate = BigDecimal.ZERO; + if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ + fxyRate = oneRecommendRate; + if(oneRecommendRate.compareTo(mostRate)> 0){ + fxyRate = mostRate; + } + }else{ + fxyRate = oneRate; + if(oneRate.compareTo(mostRate)> 0){ + fxyRate = mostRate; + } + } + BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setFxyOneMoney(fxyOneMoney); + BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); + if(fxyOneUser.getBlFxyLevel().equals(1)){ + UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); + if(fxyTwoUser!=null){ + FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); + if(faTwo!=null && faTwo.getStatus().equals(1)){ + if(fxyTwoUser!=null && fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ + isCanFxyFy = false; + if(fc.getFxmLimit().equals(2)){ + int fxmLimitDays = fc.getFxmLimitDays(); + String approveTime = faTwo.getApproveTime(); + Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(approveDate); + calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); + approveDate = calendar.getTime(); + Date current = new Date(); + if(approveDate.getTime() > current.getTime()){ + isCanFxyFy = true; + } + }else{ + isCanFxyFy = true; } - } else { - fxyRate = twoRate; - if (twoRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; + if(isCanFxyFy) { + orders.setFxyTwoUserId(fxyTwoUser.getUserId()); + orders.setFxyTwoUserName(fxyTwoUser.getUserName()); + BigDecimal twoRate = fc.getTwoRate(); + BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); + fxyRate = BigDecimal.ZERO; + if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { + fxyRate = twoRecommendRate; + if (twoRecommendRate.compareTo(mostRate) > 0) { + fxyRate = mostRate; + } + } else { + fxyRate = twoRate; + if (twoRate.compareTo(mostRate) > 0) { + fxyRate = mostRate; + } + } + BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); + orders.setFxyTwoMoney(fxyTwoMoney); + BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); + orders.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); } } - BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - orders.setFxyTwoMoney(fxyTwoMoney); - BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - orders.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); } } } - }else{ - orders.setFxyTwoMoney(BigDecimal.ZERO); - orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } } } } - }else{ - orders.setFxyOneMoney(BigDecimal.ZERO); - orders.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); - orders.setFxyTwoMoney(BigDecimal.ZERO); - orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } // artificerPrice = artificerPrice.subtract(oneArtificerMoney); @@ -7731,103 +7745,4 @@ public class OrdersServiceImpl extends ServiceImpl implements return Result.success(map); } - public static void main(String[] args) { - - JjrConfig jc = new JjrConfig(); - jc.setIsOpen(1); - jc.setType(2); - jc.setRate(new BigDecimal(2.5)); - jc.setArtificerRate(new BigDecimal(10)); - jc.setAgentRate(new BigDecimal(10)); - - JjrApply jjrApply = new JjrApply(); - jjrApply.setUserId(625L); - jjrApply.setStatus(1); - - UserEntity jjrUser = new UserEntity(); - jjrUser.setUserId(625L); - jjrUser.setUserName("曹磊"); - jjrUser.setBlIsJjr(1); - - List list = new ArrayList<>(); - JjrConfigLevel jjrConfigLevel = new JjrConfigLevel(); - jjrConfigLevel.setLevel("A1"); - jjrConfigLevel.setMinNumber(0); - jjrConfigLevel.setMaxNumber(10); - jjrConfigLevel.setRate(new BigDecimal(5)); - list.add(jjrConfigLevel); - JjrConfigLevel jjrConfigLevel2 = new JjrConfigLevel(); - jjrConfigLevel2.setLevel("A2"); - jjrConfigLevel2.setMinNumber(0); - jjrConfigLevel2.setMaxNumber(10); - jjrConfigLevel2.setRate(new BigDecimal(5)); - list.add(jjrConfigLevel2); - JjrConfigLevel jjrConfigLevel3 = new JjrConfigLevel(); - jjrConfigLevel3.setLevel("A3"); - jjrConfigLevel3.setMinNumber(0); - jjrConfigLevel3.setMaxNumber(10); - jjrConfigLevel3.setRate(new BigDecimal(5)); - list.add(jjrConfigLevel3); - JjrConfigLevel jjrConfigLevel4 = new JjrConfigLevel(); - jjrConfigLevel4.setLevel("A4"); - jjrConfigLevel4.setMinNumber(0); - jjrConfigLevel4.setMaxNumber(10); - jjrConfigLevel4.setRate(new BigDecimal(5)); - list.add(jjrConfigLevel4); - JjrConfigLevel jjrConfigLevel5 = new JjrConfigLevel(); - jjrConfigLevel5.setLevel("A5"); - jjrConfigLevel5.setMinNumber(0); - jjrConfigLevel5.setMaxNumber(10); - jjrConfigLevel5.setRate(new BigDecimal(5)); - list.add(jjrConfigLevel5); - - Orders orders = new Orders(); - - BigDecimal subtract = new BigDecimal(200);//项目金额 - BigDecimal artificerPrice = new BigDecimal(150);//技师金额 - -// JjrConfig jc = jjrConfigService.getOne(new QueryWrapper()); - if(jc.getIsOpen().equals(1)){ -// UserEntity user = userService.selectUserById(orders.getUserId()); -// UserEntity jjrUser = userService.queryByInvitationCode(user.getBlJjrCode()); -// JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); - if(jjrApply.getStatus().equals(1)){ - if(jjrUser!=null && jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ - orders.setJjrUserId(jjrUser.getUserId()); - orders.setJjrUserName(jjrUser.getUserName()); - BigDecimal artificerRate = jc.getArtificerRate(); - BigDecimal agentRate = jc.getAgentRate(); - BigDecimal rate = BigDecimal.ZERO; - if(jc.getType().equals(1)){ - rate = jc.getRate(); - }else{ -// int invitationCn = jjrApplyService.getInvitationCn(user.getBlJjrCode()); - int invitationCn = 10; -// List list = jjrConfigServiceLevel.findList(null); - for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ - rate = jjrcl.getRate(); - break; - } - } - } - BigDecimal jjrMoney = subtract.multiply(rate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setJjrMoney(jjrMoney); - BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); - } - } - }else{ - orders.setJjrMoney(BigDecimal.ZERO); - orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); - } - artificerPrice = artificerPrice.subtract(orders.getJjrArtificerDeductMoney()); - - System.out.println(orders.getJjrMoney()); - System.out.println(orders.getJjrArtificerDeductMoney()); - System.out.println(artificerPrice); - - } - } \ No newline at end of file diff --git a/src/main/java/com/sqx/modules/pay/controller/app/AliPayController.java b/src/main/java/com/sqx/modules/pay/controller/app/AliPayController.java index 24eb4ae..1537eaf 100644 --- a/src/main/java/com/sqx/modules/pay/controller/app/AliPayController.java +++ b/src/main/java/com/sqx/modules/pay/controller/app/AliPayController.java @@ -654,39 +654,41 @@ public class AliPayController { orders.setProjectBenefits(artificerPrice); UserEntity user = userService.selectUserById(orders.getUserId()); + //经纪人分佣 + orders.setJjrMoney(BigDecimal.ZERO); + orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); JjrConfig jc = jjrConfigService.getOne(new QueryWrapper()); - if(jc.getIsOpen().equals(1)){ + if(jc!=null && jc.getIsOpen().equals(1)){ UserEntity jjrUser = userService.queryByInvitationCode(user.getBlJjrCode()); - JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); - if(jjrApply.getStatus().equals(1)){ - if(jjrUser!=null && jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ - orders.setJjrUserId(jjrUser.getUserId()); - orders.setJjrUserName(jjrUser.getUserName()); - BigDecimal artificerRate = jc.getArtificerRate(); - BigDecimal agentRate = jc.getAgentRate(); - BigDecimal jjrRate = BigDecimal.ZERO; - if(jc.getType().equals(1)){ - jjrRate = jc.getRate(); - }else{ - int invitationCn = jjrApplyService.getInvitationCn(user.getBlJjrCode()); - List list = jjrConfigServiceLevel.findList(null); - for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ - jjrRate = jjrcl.getRate(); - break; + if(jjrUser!=null){ + JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); + if(jjrApply!=null && jjrApply.getStatus().equals(1)){ + if(jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ + orders.setJjrUserId(jjrUser.getUserId()); + orders.setJjrUserName(jjrUser.getUserName()); + BigDecimal artificerRate = jc.getArtificerRate(); + BigDecimal agentRate = jc.getAgentRate(); + BigDecimal jjrRate = BigDecimal.ZERO; + if(jc.getType().equals(1)){ + jjrRate = jc.getRate(); + }else{ + int invitationCn = jjrApplyService.getInvitationCn(user.getBlJjrCode()); + List list = jjrConfigServiceLevel.findList(null); + for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ + jjrRate = jjrcl.getRate(); + break; + } } } + BigDecimal jjrMoney = subtract.multiply(jjrRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setJjrMoney(jjrMoney); + BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); } - BigDecimal jjrMoney = subtract.multiply(jjrRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setJjrMoney(jjrMoney); - BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); } } - }else{ - orders.setJjrMoney(BigDecimal.ZERO); - orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); } UserEntity artificerUser = userService.selectUserById(artificer.getUserId()); BigDecimal shopMoney = BigDecimal.ZERO; @@ -716,115 +718,115 @@ public class AliPayController { // orders.setOneUserMoney(oneUserMoney); //分销商分佣 + orders.setFxyOneMoney(BigDecimal.ZERO); + orders.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); + orders.setFxyTwoMoney(BigDecimal.ZERO); + orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); FxyConfig fc = fxyConfigService.getOne(new QueryWrapper()); - if(fc.getIsOpen().equals(1)){ + if(fc!=null && fc.getIsOpen().equals(1)){ UserEntity fxyOneUser = userService.queryByInvitationCode(user.getBlFxyCode()); - FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); - if(faOne.getStatus().equals(1)){ - if(fxyOneUser!=null && fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ - boolean isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faOne.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy){ - orders.setFxyOneUserId(fxyOneUser.getUserId()); - orders.setFxyOneUserName(fxyOneUser.getUserName()); - BigDecimal fxyMoney = BigDecimal.ZERO; - if(fc.getType().equals(1)){ - fxyMoney = artificerPrice; - } - if(fc.getType().equals(2)){ - fxyMoney = subtract; - } - BigDecimal artificerRate = fc.getArtificerRate(); - BigDecimal mostRate = fc.getMostRate(); - BigDecimal oneRate = fc.getOneRate(); - BigDecimal oneRecommendRate = fc.getOneRecommendRate(); - BigDecimal fxyRate = BigDecimal.ZERO; - if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ - fxyRate = oneRecommendRate; - if(oneRecommendRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; + if(fxyOneUser!=null){ + FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); + if(faOne!=null && faOne.getStatus().equals(1)){ + if(fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ + boolean isCanFxyFy = false; + if(fc.getFxmLimit().equals(2)){ + int fxmLimitDays = fc.getFxmLimitDays(); + String approveTime = faOne.getApproveTime(); + Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(approveDate); + calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); + approveDate = calendar.getTime(); + Date current = new Date(); + if(approveDate.getTime() > current.getTime()){ + isCanFxyFy = true; } }else{ - fxyRate = oneRate; - if(oneRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; - } + isCanFxyFy = true; } - BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setFxyOneMoney(fxyOneMoney); - BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); - if(fxyOneUser.getBlFxyLevel().equals(1)){ - UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); - FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); - if(faTwo.getStatus().equals(1)){ - if(fxyTwoUser!=null && fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ - isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faTwo.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy) { - orders.setFxyTwoUserId(fxyTwoUser.getUserId()); - orders.setFxyTwoUserName(fxyTwoUser.getUserName()); - BigDecimal twoRate = fc.getTwoRate(); - BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); - fxyRate = BigDecimal.ZERO; - if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { - fxyRate = twoRecommendRate; - if (twoRecommendRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; + if(isCanFxyFy){ + orders.setFxyOneUserId(fxyOneUser.getUserId()); + orders.setFxyOneUserName(fxyOneUser.getUserName()); + BigDecimal fxyMoney = BigDecimal.ZERO; + if(fc.getType().equals(1)){ + fxyMoney = artificerPrice; + } + if(fc.getType().equals(2)){ + fxyMoney = subtract; + } + BigDecimal artificerRate = fc.getArtificerRate(); + BigDecimal mostRate = fc.getMostRate(); + BigDecimal oneRate = fc.getOneRate(); + BigDecimal oneRecommendRate = fc.getOneRecommendRate(); + BigDecimal fxyRate = BigDecimal.ZERO; + if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ + fxyRate = oneRecommendRate; + if(oneRecommendRate.compareTo(mostRate)> 0){ + fxyRate = mostRate; + } + }else{ + fxyRate = oneRate; + if(oneRate.compareTo(mostRate)> 0){ + fxyRate = mostRate; + } + } + BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setFxyOneMoney(fxyOneMoney); + BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); + if(fxyOneUser.getBlFxyLevel().equals(1)){ + UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); + if(fxyTwoUser!=null){ + FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); + if(faTwo!=null && faTwo.getStatus().equals(1)){ + if(fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ + isCanFxyFy = false; + if(fc.getFxmLimit().equals(2)){ + int fxmLimitDays = fc.getFxmLimitDays(); + String approveTime = faTwo.getApproveTime(); + Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(approveDate); + calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); + approveDate = calendar.getTime(); + Date current = new Date(); + if(approveDate.getTime() > current.getTime()){ + isCanFxyFy = true; + } + }else{ + isCanFxyFy = true; } - } else { - fxyRate = twoRate; - if (twoRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; + if(isCanFxyFy) { + orders.setFxyTwoUserId(fxyTwoUser.getUserId()); + orders.setFxyTwoUserName(fxyTwoUser.getUserName()); + BigDecimal twoRate = fc.getTwoRate(); + BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); + fxyRate = BigDecimal.ZERO; + if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { + fxyRate = twoRecommendRate; + if (twoRecommendRate.compareTo(mostRate) > 0) { + fxyRate = mostRate; + } + } else { + fxyRate = twoRate; + if (twoRate.compareTo(mostRate) > 0) { + fxyRate = mostRate; + } + } + BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); + orders.setFxyTwoMoney(fxyTwoMoney); + BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); + orders.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); } } - BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - orders.setFxyTwoMoney(fxyTwoMoney); - BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - orders.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); } } } - }else{ - orders.setFxyTwoMoney(BigDecimal.ZERO); - orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } } } } - }else{ - orders.setFxyOneMoney(BigDecimal.ZERO); - orders.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); - orders.setFxyTwoMoney(BigDecimal.ZERO); - orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } // artificerPrice = artificerPrice.subtract(oneArtificerMoney); @@ -1759,39 +1761,41 @@ public class AliPayController { // orders.setOneArtificerMoney(oneArtificerMoney); UserEntity user = userService.selectUserById(orders.getUserId()); + //经纪人分佣 + orders.setJjrMoney(BigDecimal.ZERO); + orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); JjrConfig jc = jjrConfigService.getOne(new QueryWrapper()); - if(jc.getIsOpen().equals(1)){ + if(jc!=null && jc.getIsOpen().equals(1)){ UserEntity jjrUser = userService.queryByInvitationCode(user.getBlJjrCode()); - JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); - if(jjrApply.getStatus().equals(1)){ - if(jjrUser!=null && jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ - orders.setJjrUserId(jjrUser.getUserId()); - orders.setJjrUserName(jjrUser.getUserName()); - BigDecimal artificerRate = jc.getArtificerRate(); - BigDecimal agentRate = jc.getAgentRate(); - BigDecimal jjrRate = BigDecimal.ZERO; - if(jc.getType().equals(1)){ - jjrRate = jc.getRate(); - }else{ - int invitationCn = jjrApplyService.getInvitationCn(user.getBlJjrCode()); - List list = jjrConfigServiceLevel.findList(null); - for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ - jjrRate = jjrcl.getRate(); - break; + if(jjrUser!=null){ + JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); + if(jjrApply!=null && jjrApply.getStatus().equals(1)){ + if(jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ + orders.setJjrUserId(jjrUser.getUserId()); + orders.setJjrUserName(jjrUser.getUserName()); + BigDecimal artificerRate = jc.getArtificerRate(); + BigDecimal agentRate = jc.getAgentRate(); + BigDecimal jjrRate = BigDecimal.ZERO; + if(jc.getType().equals(1)){ + jjrRate = jc.getRate(); + }else{ + int invitationCn = jjrApplyService.getInvitationCn(user.getBlJjrCode()); + List list = jjrConfigServiceLevel.findList(null); + for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ + jjrRate = jjrcl.getRate(); + break; + } } } + BigDecimal jjrMoney = subtract.multiply(jjrRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setJjrMoney(jjrMoney); + BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); } - BigDecimal jjrMoney = subtract.multiply(jjrRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setJjrMoney(jjrMoney); - BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); } } - }else{ - orders.setJjrMoney(BigDecimal.ZERO); - orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); } UserEntity artificerUser = userService.selectUserById(artificer.getUserId()); BigDecimal shopMoney = BigDecimal.ZERO; @@ -1821,115 +1825,115 @@ public class AliPayController { // orders.setOneUserMoney(oneUserMoney); //分销商分佣 + orders.setFxyOneMoney(BigDecimal.ZERO); + orders.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); + orders.setFxyTwoMoney(BigDecimal.ZERO); + orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); FxyConfig fc = fxyConfigService.getOne(new QueryWrapper()); - if(fc.getIsOpen().equals(1)){ + if(fc!=null && fc.getIsOpen().equals(1)){ UserEntity fxyOneUser = userService.queryByInvitationCode(user.getBlFxyCode()); - FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); - if(faOne.getStatus().equals(1)){ - if(fxyOneUser!=null && fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ - boolean isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faOne.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy){ - orders.setFxyOneUserId(fxyOneUser.getUserId()); - orders.setFxyOneUserName(fxyOneUser.getUserName()); - BigDecimal fxyMoney = BigDecimal.ZERO; - if(fc.getType().equals(1)){ - fxyMoney = artificerPrice; - } - if(fc.getType().equals(2)){ - fxyMoney = subtract; - } - BigDecimal artificerRate = fc.getArtificerRate(); - BigDecimal mostRate = fc.getMostRate(); - BigDecimal oneRate = fc.getOneRate(); - BigDecimal oneRecommendRate = fc.getOneRecommendRate(); - BigDecimal fxyRate = BigDecimal.ZERO; - if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ - fxyRate = oneRecommendRate; - if(oneRecommendRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; + if(fxyOneUser!=null){ + FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); + if(faOne!=null && faOne.getStatus().equals(1)){ + if(fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ + boolean isCanFxyFy = false; + if(fc.getFxmLimit().equals(2)){ + int fxmLimitDays = fc.getFxmLimitDays(); + String approveTime = faOne.getApproveTime(); + Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(approveDate); + calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); + approveDate = calendar.getTime(); + Date current = new Date(); + if(approveDate.getTime() > current.getTime()){ + isCanFxyFy = true; } }else{ - fxyRate = oneRate; - if(oneRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; - } + isCanFxyFy = true; } - BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setFxyOneMoney(fxyOneMoney); - BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); - if(fxyOneUser.getBlFxyLevel().equals(1)){ - UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); - FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); - if(faTwo.getStatus().equals(1)){ - if(fxyTwoUser!=null && fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ - isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faTwo.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy) { - orders.setFxyTwoUserId(fxyTwoUser.getUserId()); - orders.setFxyTwoUserName(fxyTwoUser.getUserName()); - BigDecimal twoRate = fc.getTwoRate(); - BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); - fxyRate = BigDecimal.ZERO; - if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { - fxyRate = twoRecommendRate; - if (twoRecommendRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; + if(isCanFxyFy){ + orders.setFxyOneUserId(fxyOneUser.getUserId()); + orders.setFxyOneUserName(fxyOneUser.getUserName()); + BigDecimal fxyMoney = BigDecimal.ZERO; + if(fc.getType().equals(1)){ + fxyMoney = artificerPrice; + } + if(fc.getType().equals(2)){ + fxyMoney = subtract; + } + BigDecimal artificerRate = fc.getArtificerRate(); + BigDecimal mostRate = fc.getMostRate(); + BigDecimal oneRate = fc.getOneRate(); + BigDecimal oneRecommendRate = fc.getOneRecommendRate(); + BigDecimal fxyRate = BigDecimal.ZERO; + if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ + fxyRate = oneRecommendRate; + if(oneRecommendRate.compareTo(mostRate)> 0){ + fxyRate = mostRate; + } + }else{ + fxyRate = oneRate; + if(oneRate.compareTo(mostRate)> 0){ + fxyRate = mostRate; + } + } + BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setFxyOneMoney(fxyOneMoney); + BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); + if(fxyOneUser.getBlFxyLevel().equals(1)){ + UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); + if(fxyTwoUser!=null){ + FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); + if(faTwo!=null && faTwo.getStatus().equals(1)){ + if(fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ + isCanFxyFy = false; + if(fc.getFxmLimit().equals(2)){ + int fxmLimitDays = fc.getFxmLimitDays(); + String approveTime = faTwo.getApproveTime(); + Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(approveDate); + calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); + approveDate = calendar.getTime(); + Date current = new Date(); + if(approveDate.getTime() > current.getTime()){ + isCanFxyFy = true; + } + }else{ + isCanFxyFy = true; } - } else { - fxyRate = twoRate; - if (twoRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; + if(isCanFxyFy) { + orders.setFxyTwoUserId(fxyTwoUser.getUserId()); + orders.setFxyTwoUserName(fxyTwoUser.getUserName()); + BigDecimal twoRate = fc.getTwoRate(); + BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); + fxyRate = BigDecimal.ZERO; + if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { + fxyRate = twoRecommendRate; + if (twoRecommendRate.compareTo(mostRate) > 0) { + fxyRate = mostRate; + } + } else { + fxyRate = twoRate; + if (twoRate.compareTo(mostRate) > 0) { + fxyRate = mostRate; + } + } + BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); + orders.setFxyTwoMoney(fxyTwoMoney); + BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); + orders.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); } } - BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - orders.setFxyTwoMoney(fxyTwoMoney); - BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - orders.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); } } } - }else{ - orders.setFxyTwoMoney(BigDecimal.ZERO); - orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } } } } - }else{ - orders.setFxyOneMoney(BigDecimal.ZERO); - orders.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); - orders.setFxyTwoMoney(BigDecimal.ZERO); - orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } // artificerPrice = artificerPrice.subtract(oneArtificerMoney); @@ -2351,39 +2355,41 @@ public class AliPayController { // orders.setOneArtificerMoney(oneArtificerMoney); UserEntity user = userService.selectUserById(orders.getUserId()); + //经纪人分佣 + orders.setJjrMoney(BigDecimal.ZERO); + orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); JjrConfig jc = jjrConfigService.getOne(new QueryWrapper()); - if(jc.getIsOpen().equals(1)){ + if(jc!=null && jc.getIsOpen().equals(1)){ UserEntity jjrUser = userService.queryByInvitationCode(user.getBlJjrCode()); - JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); - if(jjrApply.getStatus().equals(1)){ - if(jjrUser!=null && jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ - orders.setJjrUserId(jjrUser.getUserId()); - orders.setJjrUserName(jjrUser.getUserName()); - BigDecimal artificerRate = jc.getArtificerRate(); - BigDecimal agentRate = jc.getAgentRate(); - BigDecimal jjrRate = BigDecimal.ZERO; - if(jc.getType().equals(1)){ - jjrRate = jc.getRate(); - }else{ - int invitationCn = jjrApplyService.getInvitationCn(user.getBlJjrCode()); - List list = jjrConfigServiceLevel.findList(null); - for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ - jjrRate = jjrcl.getRate(); - break; + if(jjrUser!=null){ + JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); + if(jjrApply!=null && jjrApply.getStatus().equals(1)){ + if(jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ + orders.setJjrUserId(jjrUser.getUserId()); + orders.setJjrUserName(jjrUser.getUserName()); + BigDecimal artificerRate = jc.getArtificerRate(); + BigDecimal agentRate = jc.getAgentRate(); + BigDecimal jjrRate = BigDecimal.ZERO; + if(jc.getType().equals(1)){ + jjrRate = jc.getRate(); + }else{ + int invitationCn = jjrApplyService.getInvitationCn(user.getBlJjrCode()); + List list = jjrConfigServiceLevel.findList(null); + for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ + jjrRate = jjrcl.getRate(); + break; + } } } + BigDecimal jjrMoney = subtract.multiply(jjrRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setJjrMoney(jjrMoney); + BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); } - BigDecimal jjrMoney = subtract.multiply(jjrRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setJjrMoney(jjrMoney); - BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); } } - }else{ - orders.setJjrMoney(BigDecimal.ZERO); - orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); } UserEntity artificerUser = userService.selectUserById(artificer.getUserId()); BigDecimal shopMoney = BigDecimal.ZERO; @@ -2413,115 +2419,115 @@ public class AliPayController { // orders.setOneUserMoney(oneUserMoney); //分销商分佣 + orders.setFxyOneMoney(BigDecimal.ZERO); + orders.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); + orders.setFxyTwoMoney(BigDecimal.ZERO); + orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); FxyConfig fc = fxyConfigService.getOne(new QueryWrapper()); - if(fc.getIsOpen().equals(1)){ + if(fc!=null && fc.getIsOpen().equals(1)){ UserEntity fxyOneUser = userService.queryByInvitationCode(user.getBlFxyCode()); - FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); - if(faOne.getStatus().equals(1)){ - if(fxyOneUser!=null && fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ - boolean isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faOne.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy){ - orders.setFxyOneUserId(fxyOneUser.getUserId()); - orders.setFxyOneUserName(fxyOneUser.getUserName()); - BigDecimal fxyMoney = BigDecimal.ZERO; - if(fc.getType().equals(1)){ - fxyMoney = artificerPrice; - } - if(fc.getType().equals(2)){ - fxyMoney = subtract; - } - BigDecimal artificerRate = fc.getArtificerRate(); - BigDecimal mostRate = fc.getMostRate(); - BigDecimal oneRate = fc.getOneRate(); - BigDecimal oneRecommendRate = fc.getOneRecommendRate(); - BigDecimal fxyRate = BigDecimal.ZERO; - if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ - fxyRate = oneRecommendRate; - if(oneRecommendRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; + if(fxyOneUser!=null){ + FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); + if(faOne!=null && faOne.getStatus().equals(1)){ + if(fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ + boolean isCanFxyFy = false; + if(fc.getFxmLimit().equals(2)){ + int fxmLimitDays = fc.getFxmLimitDays(); + String approveTime = faOne.getApproveTime(); + Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(approveDate); + calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); + approveDate = calendar.getTime(); + Date current = new Date(); + if(approveDate.getTime() > current.getTime()){ + isCanFxyFy = true; } }else{ - fxyRate = oneRate; - if(oneRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; - } + isCanFxyFy = true; } - BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setFxyOneMoney(fxyOneMoney); - BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); - if(fxyOneUser.getBlFxyLevel().equals(1)){ - UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); - FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); - if(faTwo.getStatus().equals(1)){ - if(fxyTwoUser!=null && fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ - isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faTwo.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy) { - orders.setFxyTwoUserId(fxyTwoUser.getUserId()); - orders.setFxyTwoUserName(fxyTwoUser.getUserName()); - BigDecimal twoRate = fc.getTwoRate(); - BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); - fxyRate = BigDecimal.ZERO; - if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { - fxyRate = twoRecommendRate; - if (twoRecommendRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; + if(isCanFxyFy){ + orders.setFxyOneUserId(fxyOneUser.getUserId()); + orders.setFxyOneUserName(fxyOneUser.getUserName()); + BigDecimal fxyMoney = BigDecimal.ZERO; + if(fc.getType().equals(1)){ + fxyMoney = artificerPrice; + } + if(fc.getType().equals(2)){ + fxyMoney = subtract; + } + BigDecimal artificerRate = fc.getArtificerRate(); + BigDecimal mostRate = fc.getMostRate(); + BigDecimal oneRate = fc.getOneRate(); + BigDecimal oneRecommendRate = fc.getOneRecommendRate(); + BigDecimal fxyRate = BigDecimal.ZERO; + if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ + fxyRate = oneRecommendRate; + if(oneRecommendRate.compareTo(mostRate)> 0){ + fxyRate = mostRate; + } + }else{ + fxyRate = oneRate; + if(oneRate.compareTo(mostRate)> 0){ + fxyRate = mostRate; + } + } + BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setFxyOneMoney(fxyOneMoney); + BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); + if(fxyOneUser.getBlFxyLevel().equals(1)){ + UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); + if(fxyTwoUser!=null){ + FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); + if(faTwo!=null && faTwo.getStatus().equals(1)){ + if(fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ + isCanFxyFy = false; + if(fc.getFxmLimit().equals(2)){ + int fxmLimitDays = fc.getFxmLimitDays(); + String approveTime = faTwo.getApproveTime(); + Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(approveDate); + calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); + approveDate = calendar.getTime(); + Date current = new Date(); + if(approveDate.getTime() > current.getTime()){ + isCanFxyFy = true; + } + }else{ + isCanFxyFy = true; } - } else { - fxyRate = twoRate; - if (twoRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; + if(isCanFxyFy) { + orders.setFxyTwoUserId(fxyTwoUser.getUserId()); + orders.setFxyTwoUserName(fxyTwoUser.getUserName()); + BigDecimal twoRate = fc.getTwoRate(); + BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); + fxyRate = BigDecimal.ZERO; + if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { + fxyRate = twoRecommendRate; + if (twoRecommendRate.compareTo(mostRate) > 0) { + fxyRate = mostRate; + } + } else { + fxyRate = twoRate; + if (twoRate.compareTo(mostRate) > 0) { + fxyRate = mostRate; + } + } + BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); + orders.setFxyTwoMoney(fxyTwoMoney); + BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); + orders.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); } } - BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - orders.setFxyTwoMoney(fxyTwoMoney); - BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - orders.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); } } } - }else{ - orders.setFxyTwoMoney(BigDecimal.ZERO); - orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } } } } - }else{ - orders.setFxyOneMoney(BigDecimal.ZERO); - orders.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); - orders.setFxyTwoMoney(BigDecimal.ZERO); - orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } // artificerPrice = artificerPrice.subtract(oneArtificerMoney); diff --git a/src/main/java/com/sqx/modules/pay/service/impl/WxServiceImpl.java b/src/main/java/com/sqx/modules/pay/service/impl/WxServiceImpl.java index 3f23481..1a98b0e 100644 --- a/src/main/java/com/sqx/modules/pay/service/impl/WxServiceImpl.java +++ b/src/main/java/com/sqx/modules/pay/service/impl/WxServiceImpl.java @@ -898,39 +898,41 @@ public class WxServiceImpl implements WxService { orders.setProjectBenefits(artificerPrice); UserEntity user = userService.selectUserById(orders.getUserId()); + //经纪人分佣 + orders.setJjrMoney(BigDecimal.ZERO); + orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); JjrConfig jc = jjrConfigService.getOne(new QueryWrapper()); - if(jc.getIsOpen().equals(1)){ + if(jc!=null && jc.getIsOpen().equals(1)){ UserEntity jjrUser = userService.queryByInvitationCode(user.getBlJjrCode()); - JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); - if(jjrApply.getStatus().equals(1)){ - if(jjrUser!=null && jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ - orders.setJjrUserId(jjrUser.getUserId()); - orders.setJjrUserName(jjrUser.getUserName()); - BigDecimal artificerRate = jc.getArtificerRate(); - BigDecimal agentRate = jc.getAgentRate(); - BigDecimal jjrRate = BigDecimal.ZERO; - if(jc.getType().equals(1)){ - jjrRate = jc.getRate(); - }else{ - int invitationCn = jjrApplyService.getInvitationCn(user.getBlJjrCode()); - List list = jjrConfigServiceLevel.findList(null); - for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ - jjrRate = jjrcl.getRate(); - break; + if(jjrUser!=null){ + JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); + if(jjrApply!=null && jjrApply.getStatus().equals(1)){ + if(jjrUser!=null && jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ + orders.setJjrUserId(jjrUser.getUserId()); + orders.setJjrUserName(jjrUser.getUserName()); + BigDecimal artificerRate = jc.getArtificerRate(); + BigDecimal agentRate = jc.getAgentRate(); + BigDecimal jjrRate = BigDecimal.ZERO; + if(jc.getType().equals(1)){ + jjrRate = jc.getRate(); + }else{ + int invitationCn = jjrApplyService.getInvitationCn(user.getBlJjrCode()); + List list = jjrConfigServiceLevel.findList(null); + for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ + jjrRate = jjrcl.getRate(); + break; + } } } + BigDecimal jjrMoney = subtract.multiply(jjrRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setJjrMoney(jjrMoney); + BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); } - BigDecimal jjrMoney = subtract.multiply(jjrRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setJjrMoney(jjrMoney); - BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); } } - }else{ - orders.setJjrMoney(BigDecimal.ZERO); - orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); } UserEntity artificerUser = userService.selectUserById(artificer.getUserId()); BigDecimal shopMoney = BigDecimal.ZERO; @@ -960,115 +962,115 @@ public class WxServiceImpl implements WxService { // orders.setOneUserMoney(oneUserMoney); //分销商分佣 + orders.setFxyOneMoney(BigDecimal.ZERO); + orders.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); + orders.setFxyTwoMoney(BigDecimal.ZERO); + orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); FxyConfig fc = fxyConfigService.getOne(new QueryWrapper()); - if(fc.getIsOpen().equals(1)){ + if(fc!=null && fc.getIsOpen().equals(1)){ UserEntity fxyOneUser = userService.queryByInvitationCode(user.getBlFxyCode()); - FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); - if(faOne.getStatus().equals(1)){ - if(fxyOneUser!=null && fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ - boolean isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faOne.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy){ - orders.setFxyOneUserId(fxyOneUser.getUserId()); - orders.setFxyOneUserName(fxyOneUser.getUserName()); - BigDecimal fxyMoney = BigDecimal.ZERO; - if(fc.getType().equals(1)){ - fxyMoney = artificerPrice; - } - if(fc.getType().equals(2)){ - fxyMoney = subtract; - } - BigDecimal artificerRate = fc.getArtificerRate(); - BigDecimal mostRate = fc.getMostRate(); - BigDecimal oneRate = fc.getOneRate(); - BigDecimal oneRecommendRate = fc.getOneRecommendRate(); - BigDecimal fxyRate = BigDecimal.ZERO; - if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ - fxyRate = oneRecommendRate; - if(oneRecommendRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; + if(fxyOneUser!=null){ + FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); + if(faOne!=null && faOne.getStatus().equals(1)){ + if(fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ + boolean isCanFxyFy = false; + if(fc.getFxmLimit().equals(2)){ + int fxmLimitDays = fc.getFxmLimitDays(); + String approveTime = faOne.getApproveTime(); + Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(approveDate); + calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); + approveDate = calendar.getTime(); + Date current = new Date(); + if(approveDate.getTime() > current.getTime()){ + isCanFxyFy = true; } }else{ - fxyRate = oneRate; - if(oneRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; - } + isCanFxyFy = true; } - BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setFxyOneMoney(fxyOneMoney); - BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); - if(fxyOneUser.getBlFxyLevel().equals(1)){ - UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); - FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); - if(faTwo.getStatus().equals(1)){ - if(fxyTwoUser!=null && fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ - isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faTwo.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy) { - orders.setFxyTwoUserId(fxyTwoUser.getUserId()); - orders.setFxyTwoUserName(fxyTwoUser.getUserName()); - BigDecimal twoRate = fc.getTwoRate(); - BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); - fxyRate = BigDecimal.ZERO; - if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { - fxyRate = twoRecommendRate; - if (twoRecommendRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; + if(isCanFxyFy){ + orders.setFxyOneUserId(fxyOneUser.getUserId()); + orders.setFxyOneUserName(fxyOneUser.getUserName()); + BigDecimal fxyMoney = BigDecimal.ZERO; + if(fc.getType().equals(1)){ + fxyMoney = artificerPrice; + } + if(fc.getType().equals(2)){ + fxyMoney = subtract; + } + BigDecimal artificerRate = fc.getArtificerRate(); + BigDecimal mostRate = fc.getMostRate(); + BigDecimal oneRate = fc.getOneRate(); + BigDecimal oneRecommendRate = fc.getOneRecommendRate(); + BigDecimal fxyRate = BigDecimal.ZERO; + if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ + fxyRate = oneRecommendRate; + if(oneRecommendRate.compareTo(mostRate)> 0){ + fxyRate = mostRate; + } + }else{ + fxyRate = oneRate; + if(oneRate.compareTo(mostRate)> 0){ + fxyRate = mostRate; + } + } + BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setFxyOneMoney(fxyOneMoney); + BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); + if(fxyOneUser.getBlFxyLevel().equals(1)){ + UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); + if(fxyTwoUser!=null){ + FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); + if(faTwo!=null && faTwo.getStatus().equals(1)){ + if(fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ + isCanFxyFy = false; + if(fc.getFxmLimit().equals(2)){ + int fxmLimitDays = fc.getFxmLimitDays(); + String approveTime = faTwo.getApproveTime(); + Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(approveDate); + calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); + approveDate = calendar.getTime(); + Date current = new Date(); + if(approveDate.getTime() > current.getTime()){ + isCanFxyFy = true; + } + }else{ + isCanFxyFy = true; } - } else { - fxyRate = twoRate; - if (twoRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; + if(isCanFxyFy) { + orders.setFxyTwoUserId(fxyTwoUser.getUserId()); + orders.setFxyTwoUserName(fxyTwoUser.getUserName()); + BigDecimal twoRate = fc.getTwoRate(); + BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); + fxyRate = BigDecimal.ZERO; + if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { + fxyRate = twoRecommendRate; + if (twoRecommendRate.compareTo(mostRate) > 0) { + fxyRate = mostRate; + } + } else { + fxyRate = twoRate; + if (twoRate.compareTo(mostRate) > 0) { + fxyRate = mostRate; + } + } + BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); + orders.setFxyTwoMoney(fxyTwoMoney); + BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); + orders.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); } } - BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - orders.setFxyTwoMoney(fxyTwoMoney); - BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - orders.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); } } } - }else{ - orders.setFxyTwoMoney(BigDecimal.ZERO); - orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } } } } - }else{ - orders.setFxyOneMoney(BigDecimal.ZERO); - orders.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); - orders.setFxyTwoMoney(BigDecimal.ZERO); - orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } // artificerPrice = artificerPrice.subtract(oneArtificerMoney); @@ -1680,39 +1682,41 @@ public class WxServiceImpl implements WxService { orders.setProjectBenefits(artificerPrice); UserEntity user = userService.selectUserById(orders.getUserId()); + //经纪人分佣 + orders.setJjrMoney(BigDecimal.ZERO); + orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); JjrConfig jc = jjrConfigService.getOne(new QueryWrapper()); - if(jc.getIsOpen().equals(1)){ + if(jc!=null && jc.getIsOpen().equals(1)){ UserEntity jjrUser = userService.queryByInvitationCode(user.getBlJjrCode()); - JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); - if(jjrApply.getStatus().equals(1)){ - if(jjrUser!=null && jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ - orders.setJjrUserId(jjrUser.getUserId()); - orders.setJjrUserName(jjrUser.getUserName()); - BigDecimal artificerRate = jc.getArtificerRate(); - BigDecimal agentRate = jc.getAgentRate(); - BigDecimal jjrRate = BigDecimal.ZERO; - if(jc.getType().equals(1)){ - jjrRate = jc.getRate(); - }else{ - int invitationCn = jjrApplyService.getInvitationCn(user.getBlJjrCode()); - List list = jjrConfigServiceLevel.findList(null); - for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ - jjrRate = jjrcl.getRate(); - break; + if(jjrUser!=null){ + JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); + if(jjrApply!=null && jjrApply.getStatus().equals(1)){ + if( jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ + orders.setJjrUserId(jjrUser.getUserId()); + orders.setJjrUserName(jjrUser.getUserName()); + BigDecimal artificerRate = jc.getArtificerRate(); + BigDecimal agentRate = jc.getAgentRate(); + BigDecimal jjrRate = BigDecimal.ZERO; + if(jc.getType().equals(1)){ + jjrRate = jc.getRate(); + }else{ + int invitationCn = jjrApplyService.getInvitationCn(user.getBlJjrCode()); + List list = jjrConfigServiceLevel.findList(null); + for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ + jjrRate = jjrcl.getRate(); + break; + } } } + BigDecimal jjrMoney = subtract.multiply(jjrRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setJjrMoney(jjrMoney); + BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); } - BigDecimal jjrMoney = subtract.multiply(jjrRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setJjrMoney(jjrMoney); - BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); } } - }else{ - orders.setJjrMoney(BigDecimal.ZERO); - orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); } UserEntity artificerUser = userService.selectUserById(artificer.getUserId()); BigDecimal shopMoney = BigDecimal.ZERO; @@ -1742,115 +1746,115 @@ public class WxServiceImpl implements WxService { // orders.setOneUserMoney(oneUserMoney); //分销商分佣 + orders.setFxyOneMoney(BigDecimal.ZERO); + orders.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); + orders.setFxyTwoMoney(BigDecimal.ZERO); + orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); FxyConfig fc = fxyConfigService.getOne(new QueryWrapper()); - if(fc.getIsOpen().equals(1)){ + if(fc!=null && fc.getIsOpen().equals(1)){ UserEntity fxyOneUser = userService.queryByInvitationCode(user.getBlFxyCode()); - FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); - if(faOne.getStatus().equals(1)){ - if(fxyOneUser!=null && fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ - boolean isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faOne.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy){ - orders.setFxyOneUserId(fxyOneUser.getUserId()); - orders.setFxyOneUserName(fxyOneUser.getUserName()); - BigDecimal fxyMoney = BigDecimal.ZERO; - if(fc.getType().equals(1)){ - fxyMoney = artificerPrice; - } - if(fc.getType().equals(2)){ - fxyMoney = subtract; - } - BigDecimal artificerRate = fc.getArtificerRate(); - BigDecimal mostRate = fc.getMostRate(); - BigDecimal oneRate = fc.getOneRate(); - BigDecimal oneRecommendRate = fc.getOneRecommendRate(); - BigDecimal fxyRate = BigDecimal.ZERO; - if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ - fxyRate = oneRecommendRate; - if(oneRecommendRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; + if(fxyOneUser!=null){ + FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); + if(faOne!=null && faOne.getStatus().equals(1)){ + if(fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ + boolean isCanFxyFy = false; + if(fc.getFxmLimit().equals(2)){ + int fxmLimitDays = fc.getFxmLimitDays(); + String approveTime = faOne.getApproveTime(); + Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(approveDate); + calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); + approveDate = calendar.getTime(); + Date current = new Date(); + if(approveDate.getTime() > current.getTime()){ + isCanFxyFy = true; } }else{ - fxyRate = oneRate; - if(oneRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; - } + isCanFxyFy = true; } - BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setFxyOneMoney(fxyOneMoney); - BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); - if(fxyOneUser.getBlFxyLevel().equals(1)){ - UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); - FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); - if(faTwo.getStatus().equals(1)){ - if(fxyTwoUser!=null && fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ - isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faTwo.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy) { - orders.setFxyTwoUserId(fxyTwoUser.getUserId()); - orders.setFxyTwoUserName(fxyTwoUser.getUserName()); - BigDecimal twoRate = fc.getTwoRate(); - BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); - fxyRate = BigDecimal.ZERO; - if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { - fxyRate = twoRecommendRate; - if (twoRecommendRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; + if(isCanFxyFy){ + orders.setFxyOneUserId(fxyOneUser.getUserId()); + orders.setFxyOneUserName(fxyOneUser.getUserName()); + BigDecimal fxyMoney = BigDecimal.ZERO; + if(fc.getType().equals(1)){ + fxyMoney = artificerPrice; + } + if(fc.getType().equals(2)){ + fxyMoney = subtract; + } + BigDecimal artificerRate = fc.getArtificerRate(); + BigDecimal mostRate = fc.getMostRate(); + BigDecimal oneRate = fc.getOneRate(); + BigDecimal oneRecommendRate = fc.getOneRecommendRate(); + BigDecimal fxyRate = BigDecimal.ZERO; + if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ + fxyRate = oneRecommendRate; + if(oneRecommendRate.compareTo(mostRate)> 0){ + fxyRate = mostRate; + } + }else{ + fxyRate = oneRate; + if(oneRate.compareTo(mostRate)> 0){ + fxyRate = mostRate; + } + } + BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setFxyOneMoney(fxyOneMoney); + BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); + if(fxyOneUser.getBlFxyLevel().equals(1)){ + UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); + if(fxyTwoUser!=null){ + FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); + if(faTwo!=null && faTwo.getStatus().equals(1)){ + if(fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ + isCanFxyFy = false; + if(fc.getFxmLimit().equals(2)){ + int fxmLimitDays = fc.getFxmLimitDays(); + String approveTime = faTwo.getApproveTime(); + Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(approveDate); + calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); + approveDate = calendar.getTime(); + Date current = new Date(); + if(approveDate.getTime() > current.getTime()){ + isCanFxyFy = true; + } + }else{ + isCanFxyFy = true; } - } else { - fxyRate = twoRate; - if (twoRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; + if(isCanFxyFy) { + orders.setFxyTwoUserId(fxyTwoUser.getUserId()); + orders.setFxyTwoUserName(fxyTwoUser.getUserName()); + BigDecimal twoRate = fc.getTwoRate(); + BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); + fxyRate = BigDecimal.ZERO; + if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { + fxyRate = twoRecommendRate; + if (twoRecommendRate.compareTo(mostRate) > 0) { + fxyRate = mostRate; + } + } else { + fxyRate = twoRate; + if (twoRate.compareTo(mostRate) > 0) { + fxyRate = mostRate; + } + } + BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); + orders.setFxyTwoMoney(fxyTwoMoney); + BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); + orders.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); } } - BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - orders.setFxyTwoMoney(fxyTwoMoney); - BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - orders.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); } } } - }else{ - orders.setFxyTwoMoney(BigDecimal.ZERO); - orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } } } } - }else{ - orders.setFxyOneMoney(BigDecimal.ZERO); - orders.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); - orders.setFxyTwoMoney(BigDecimal.ZERO); - orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } // artificerPrice = artificerPrice.subtract(oneArtificerMoney); @@ -2681,39 +2685,41 @@ public class WxServiceImpl implements WxService { orders.setProjectBenefits(artificerPrice); UserEntity user = userService.selectUserById(orders.getUserId()); + //经纪人分佣 + orders.setJjrMoney(BigDecimal.ZERO); + orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); JjrConfig jc = jjrConfigService.getOne(new QueryWrapper()); - if(jc.getIsOpen().equals(1)){ + if(jc!=null && jc.getIsOpen().equals(1)){ UserEntity jjrUser = userService.queryByInvitationCode(user.getBlJjrCode()); - JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); - if(jjrApply.getStatus().equals(1)){ - if(jjrUser!=null && jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ - orders.setJjrUserId(jjrUser.getUserId()); - orders.setJjrUserName(jjrUser.getUserName()); - BigDecimal artificerRate = jc.getArtificerRate(); - BigDecimal agentRate = jc.getAgentRate(); - BigDecimal jjrRate = BigDecimal.ZERO; - if(jc.getType().equals(1)){ - jjrRate = jc.getRate(); - }else{ - int invitationCn = jjrApplyService.getInvitationCn(user.getBlJjrCode()); - List list = jjrConfigServiceLevel.findList(null); - for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ - jjrRate = jjrcl.getRate(); - break; + if(jjrUser!=null){ + JjrApply jjrApply = jjrApplyService.findByUserId(jjrUser.getUserId()); + if(jjrApply!=null && jjrApply.getStatus().equals(1)){ + if(jjrUser.getBlIsJjr() !=null && jjrUser.getBlIsJjr() ==1){ + orders.setJjrUserId(jjrUser.getUserId()); + orders.setJjrUserName(jjrUser.getUserName()); + BigDecimal artificerRate = jc.getArtificerRate(); + BigDecimal agentRate = jc.getAgentRate(); + BigDecimal jjrRate = BigDecimal.ZERO; + if(jc.getType().equals(1)){ + jjrRate = jc.getRate(); + }else{ + int invitationCn = jjrApplyService.getInvitationCn(user.getBlJjrCode()); + List list = jjrConfigServiceLevel.findList(null); + for(int i=0;ijjrcl.getMinNumber() && invitationCn<=jjrcl.getMaxNumber()){ + jjrRate = jjrcl.getRate(); + break; + } } } + BigDecimal jjrMoney = subtract.multiply(jjrRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setJjrMoney(jjrMoney); + BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); } - BigDecimal jjrMoney = subtract.multiply(jjrRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setJjrMoney(jjrMoney); - BigDecimal jjrOneArtificerDeductMoney = jjrMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setJjrArtificerDeductMoney(jjrOneArtificerDeductMoney); } } - }else{ - orders.setJjrMoney(BigDecimal.ZERO); - orders.setJjrArtificerDeductMoney(BigDecimal.ZERO); } UserEntity artificerUser = userService.selectUserById(artificer.getUserId()); BigDecimal shopMoney = BigDecimal.ZERO; @@ -2743,115 +2749,115 @@ public class WxServiceImpl implements WxService { // orders.setOneUserMoney(oneUserMoney); //分销商分佣 + orders.setFxyOneMoney(BigDecimal.ZERO); + orders.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); + orders.setFxyTwoMoney(BigDecimal.ZERO); + orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); FxyConfig fc = fxyConfigService.getOne(new QueryWrapper()); - if(fc.getIsOpen().equals(1)){ + if(fc!=null && fc.getIsOpen().equals(1)){ UserEntity fxyOneUser = userService.queryByInvitationCode(user.getBlFxyCode()); - FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); - if(faOne.getStatus().equals(1)){ - if(fxyOneUser!=null && fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ - boolean isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faOne.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy){ - orders.setFxyOneUserId(fxyOneUser.getUserId()); - orders.setFxyOneUserName(fxyOneUser.getUserName()); - BigDecimal fxyMoney = BigDecimal.ZERO; - if(fc.getType().equals(1)){ - fxyMoney = artificerPrice; - } - if(fc.getType().equals(2)){ - fxyMoney = subtract; - } - BigDecimal artificerRate = fc.getArtificerRate(); - BigDecimal mostRate = fc.getMostRate(); - BigDecimal oneRate = fc.getOneRate(); - BigDecimal oneRecommendRate = fc.getOneRecommendRate(); - BigDecimal fxyRate = BigDecimal.ZERO; - if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ - fxyRate = oneRecommendRate; - if(oneRecommendRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; + if(fxyOneUser!=null){ + FxyApply faOne = fxyApplyService.findByUserId(fxyOneUser.getUserId()); + if(faOne!=null && faOne.getStatus().equals(1)){ + if(fxyOneUser.getBlIsFxy() !=null && fxyOneUser.getBlIsFxy() ==1){ + boolean isCanFxyFy = false; + if(fc.getFxmLimit().equals(2)){ + int fxmLimitDays = fc.getFxmLimitDays(); + String approveTime = faOne.getApproveTime(); + Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(approveDate); + calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); + approveDate = calendar.getTime(); + Date current = new Date(); + if(approveDate.getTime() > current.getTime()){ + isCanFxyFy = true; } }else{ - fxyRate = oneRate; - if(oneRate.compareTo(mostRate)> 0){ - fxyRate = mostRate; - } + isCanFxyFy = true; } - BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setFxyOneMoney(fxyOneMoney); - BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); - orders.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); - if(fxyOneUser.getBlFxyLevel().equals(1)){ - UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); - FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); - if(faTwo.getStatus().equals(1)){ - if(fxyTwoUser!=null && fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ - isCanFxyFy = false; - if(fc.getFxmLimit().equals(2)){ - int fxmLimitDays = fc.getFxmLimitDays(); - String approveTime = faTwo.getApproveTime(); - Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(approveDate); - calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); - approveDate = calendar.getTime(); - Date current = new Date(); - if(approveDate.getTime() > current.getTime()){ - isCanFxyFy = true; - } - }else{ - isCanFxyFy = true; - } - if(isCanFxyFy) { - orders.setFxyTwoUserId(fxyTwoUser.getUserId()); - orders.setFxyTwoUserName(fxyTwoUser.getUserName()); - BigDecimal twoRate = fc.getTwoRate(); - BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); - fxyRate = BigDecimal.ZERO; - if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { - fxyRate = twoRecommendRate; - if (twoRecommendRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; + if(isCanFxyFy){ + orders.setFxyOneUserId(fxyOneUser.getUserId()); + orders.setFxyOneUserName(fxyOneUser.getUserName()); + BigDecimal fxyMoney = BigDecimal.ZERO; + if(fc.getType().equals(1)){ + fxyMoney = artificerPrice; + } + if(fc.getType().equals(2)){ + fxyMoney = subtract; + } + BigDecimal artificerRate = fc.getArtificerRate(); + BigDecimal mostRate = fc.getMostRate(); + BigDecimal oneRate = fc.getOneRate(); + BigDecimal oneRecommendRate = fc.getOneRecommendRate(); + BigDecimal fxyRate = BigDecimal.ZERO; + if(oneRate == null || oneRate.compareTo(BigDecimal.ZERO) == 0){ + fxyRate = oneRecommendRate; + if(oneRecommendRate.compareTo(mostRate)> 0){ + fxyRate = mostRate; + } + }else{ + fxyRate = oneRate; + if(oneRate.compareTo(mostRate)> 0){ + fxyRate = mostRate; + } + } + BigDecimal fxyOneMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setFxyOneMoney(fxyOneMoney); + BigDecimal fxyOneArtificerDeductMoney = fxyOneMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP); + orders.setFxyOneArtificerDeductMoney(fxyOneArtificerDeductMoney); + if(fxyOneUser.getBlFxyLevel().equals(1)){ + UserEntity fxyTwoUser = userService.queryByInvitationCode(fxyOneUser.getBlFxyCode()); + if(fxyTwoUser!=null){ + FxyApply faTwo = fxyApplyService.findByUserId(fxyTwoUser.getUserId()); + if(faTwo!=null && faTwo.getStatus().equals(1)){ + if(fxyTwoUser.getBlIsFxy() !=null && fxyTwoUser.getBlIsFxy() ==1){ + isCanFxyFy = false; + if(fc.getFxmLimit().equals(2)){ + int fxmLimitDays = fc.getFxmLimitDays(); + String approveTime = faTwo.getApproveTime(); + Date approveDate = DateUtils.stringToDate(approveTime,DateUtils.DATE_TIME_PATTERN); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(approveDate); + calendar.add(Calendar.DAY_OF_MONTH, fxmLimitDays); + approveDate = calendar.getTime(); + Date current = new Date(); + if(approveDate.getTime() > current.getTime()){ + isCanFxyFy = true; + } + }else{ + isCanFxyFy = true; } - } else { - fxyRate = twoRate; - if (twoRate.compareTo(mostRate) > 0) { - fxyRate = mostRate; + if(isCanFxyFy) { + orders.setFxyTwoUserId(fxyTwoUser.getUserId()); + orders.setFxyTwoUserName(fxyTwoUser.getUserName()); + BigDecimal twoRate = fc.getTwoRate(); + BigDecimal twoRecommendRate = fc.getTwoRecommendRate(); + fxyRate = BigDecimal.ZERO; + if (twoRate == null || twoRate.compareTo(BigDecimal.ZERO) == 0) { + fxyRate = twoRecommendRate; + if (twoRecommendRate.compareTo(mostRate) > 0) { + fxyRate = mostRate; + } + } else { + fxyRate = twoRate; + if (twoRate.compareTo(mostRate) > 0) { + fxyRate = mostRate; + } + } + BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); + orders.setFxyTwoMoney(fxyTwoMoney); + BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); + orders.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); } } - BigDecimal fxyTwoMoney = fxyMoney.multiply(fxyRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - orders.setFxyTwoMoney(fxyTwoMoney); - BigDecimal fxyTwoArtificerDeductMoney = fxyTwoMoney.multiply(artificerRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP); - orders.setFxyTwoArtificerDeductMoney(fxyTwoArtificerDeductMoney); } } } - }else{ - orders.setFxyTwoMoney(BigDecimal.ZERO); - orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } } } } - }else{ - orders.setFxyOneMoney(BigDecimal.ZERO); - orders.setFxyOneArtificerDeductMoney(BigDecimal.ZERO); - orders.setFxyTwoMoney(BigDecimal.ZERO); - orders.setFxyTwoArtificerDeductMoney(BigDecimal.ZERO); } // artificerPrice = artificerPrice.subtract(oneArtificerMoney);