Commit 85e72158 by jianan

4and5-保单发佣明细报表14

parent 440785ab
...@@ -62,10 +62,12 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -62,10 +62,12 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
private AclUserDALService userDalService; private AclUserDALService userDalService;
@Autowired @Autowired
private AclPractitionerSubordinateSystemDALService aclPractitionerSubordinateSystemDalService; private AclPractitionerSubordinateSystemDALService aclPractitionerSubordinateSystemDalService;
@Autowired @Autowired
public void setAclCustomerFortuneDalService(AclCustomerFortuneDALService customerFortuneDalService) { public void setAclCustomerFortuneDalService(AclCustomerFortuneDALService customerFortuneDalService) {
this.customerFortuneDalService = customerFortuneDalService; this.customerFortuneDalService = customerFortuneDalService;
} }
@Autowired @Autowired
public void setAclCustomerFortuneWithdrawDalService(AclCustomerFortuneWithdrawDALService customerFortuneWithdrawDalService) { public void setAclCustomerFortuneWithdrawDalService(AclCustomerFortuneWithdrawDALService customerFortuneWithdrawDalService) {
this.customerFortuneWithdrawDalService = customerFortuneWithdrawDalService; this.customerFortuneWithdrawDalService = customerFortuneWithdrawDalService;
...@@ -77,29 +79,30 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -77,29 +79,30 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
} }
@Autowired @Autowired
public void setAgmsFortuneDalService(AgmsFortuneDALService agmsFortuneDalService){ public void setAgmsFortuneDalService(AgmsFortuneDALService agmsFortuneDalService) {
this.agmsFortuneDalService = agmsFortuneDalService; this.agmsFortuneDalService = agmsFortuneDalService;
} }
@Autowired @Autowired
public void setSystemConfigService(SystemConfigService systemConfigService){ public void setSystemConfigService(SystemConfigService systemConfigService) {
this.systemConfigService = systemConfigService; this.systemConfigService = systemConfigService;
} }
@Autowired @Autowired
public void setAclCustomerFortunePayoutBatchDALService(AclCustomerFortunePayoutBatchDALService customerFortunePayoutBatchDalService){ public void setAclCustomerFortunePayoutBatchDALService(AclCustomerFortunePayoutBatchDALService customerFortunePayoutBatchDalService) {
this.customerFortunePayoutBatchDalService = customerFortunePayoutBatchDalService; this.customerFortunePayoutBatchDalService = customerFortunePayoutBatchDalService;
} }
@Autowired @Autowired
public void setAclUserDALService(AclUserDALService userDalService){ public void setAclUserDALService(AclUserDALService userDalService) {
this.userDalService = userDalService; this.userDalService = userDalService;
} }
@Autowired @Autowired
public void setAclCustomerFortuneStatisticDALService(AclCustomerFortuneStatisticDALService customerFortuneStatisticDalService){ public void setAclCustomerFortuneStatisticDALService(AclCustomerFortuneStatisticDALService customerFortuneStatisticDalService) {
this.customerFortuneStatisticDalService = customerFortuneStatisticDalService; this.customerFortuneStatisticDalService = customerFortuneStatisticDalService;
} }
@Autowired @Autowired
private PoOrderDALService poOrderDALService; private PoOrderDALService poOrderDALService;
@Autowired @Autowired
...@@ -126,7 +129,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -126,7 +129,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
List<AclCustomerFortune> customerFortunes = customerFortuneDalService.findByIds(fortuneIds); List<AclCustomerFortune> customerFortunes = customerFortuneDalService.findByIds(fortuneIds);
//已作废的记录不能修改状态 //已作废的记录不能修改状态
for (AclCustomerFortune customerFortune: customerFortunes) { for (AclCustomerFortune customerFortune : customerFortunes) {
if ("0".equals(customerFortune.getStatus())) { if ("0".equals(customerFortune.getStatus())) {
responseVO.setCommonResult(new CommonResult(false, ZHBErrorConfig.getErrorInfo("830039"))); responseVO.setCommonResult(new CommonResult(false, ZHBErrorConfig.getErrorInfo("830039")));
return responseVO; return responseVO;
...@@ -154,8 +157,8 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -154,8 +157,8 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
CommonResult commonResult = new CommonResult(); CommonResult commonResult = new CommonResult();
boolean success = true; boolean success = true;
String message = ZHBErrorConfig.getErrorInfo("800000"); String message = ZHBErrorConfig.getErrorInfo("800000");
if (("2").equals(requestVO.getPaymentStatus())){ if (("2").equals(requestVO.getPaymentStatus())) {
if (CommonUtil.isNullOrBlank(requestVO.getPayoutBatch())){ if (CommonUtil.isNullOrBlank(requestVO.getPayoutBatch())) {
message = ZHBErrorConfig.getErrorInfo("830021"); message = ZHBErrorConfig.getErrorInfo("830021");
success = false; success = false;
} }
...@@ -166,7 +169,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -166,7 +169,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
Long[] fortuneIds = requestVO.getFortuneIds(); Long[] fortuneIds = requestVO.getFortuneIds();
List<AclCustomerFortuneWithdraw> withdraws = customerFortuneWithdrawDalService.findByFortuneIds(fortuneIds); List<AclCustomerFortuneWithdraw> withdraws = customerFortuneWithdrawDalService.findByFortuneIds(fortuneIds);
for (AclCustomerFortuneWithdraw withdraw : withdraws) { for (AclCustomerFortuneWithdraw withdraw : withdraws) {
if (withdraw.getIsPaid()==1){ if (withdraw.getIsPaid() == 1) {
message = ZHBErrorConfig.getErrorInfo("830024"); message = ZHBErrorConfig.getErrorInfo("830024");
commonResult.setSuccess(false); commonResult.setSuccess(false);
commonResult.setMessage(message); commonResult.setMessage(message);
...@@ -179,11 +182,11 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -179,11 +182,11 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
} }
private Long findPayoutBatchIdByPayoutBatch(String payoutBatch, Long loginId) { private Long findPayoutBatchIdByPayoutBatch(String payoutBatch, Long loginId) {
if (CommonUtil.isNullOrBlank(payoutBatch)){ if (CommonUtil.isNullOrBlank(payoutBatch)) {
return null; return null;
} }
AclCustomerFortunePayoutBatch customerFortunePayoutBatch = customerFortunePayoutBatchDalService.findByPayoutYearmonth(payoutBatch); AclCustomerFortunePayoutBatch customerFortunePayoutBatch = customerFortunePayoutBatchDalService.findByPayoutYearmonth(payoutBatch);
if (customerFortunePayoutBatch == null){ if (customerFortunePayoutBatch == null) {
customerFortunePayoutBatch = new AclCustomerFortunePayoutBatch(); customerFortunePayoutBatch = new AclCustomerFortunePayoutBatch();
customerFortunePayoutBatch.setPayoutYearmonth(payoutBatch); customerFortunePayoutBatch.setPayoutYearmonth(payoutBatch);
customerFortunePayoutBatch.setCreatedBy(loginId); customerFortunePayoutBatch.setCreatedBy(loginId);
...@@ -196,23 +199,23 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -196,23 +199,23 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
} }
@Override @Override
public void canPaymentUpDate(String paymentStatus, Long payoutBatchId , Long loginId, List<AclCustomerFortune> customerFortunes) { public void canPaymentUpDate(String paymentStatus, Long payoutBatchId, Long loginId, List<AclCustomerFortune> customerFortunes) {
System.out.println("canPaymentUpDate"); System.out.println("canPaymentUpDate");
//将查询出来的财富列表根据customerId经行分类 //将查询出来的财富列表根据customerId经行分类
Map<Long,List<AclCustomerFortune>> customerFortuneMap = changeCustomerFortunesByFieldName(customerFortunes,"customerId"); Map<Long, List<AclCustomerFortune>> customerFortuneMap = changeCustomerFortunesByFieldName(customerFortunes, "customerId");
//获得所有需要修改佣金发放状的customerIds //获得所有需要修改佣金发放状的customerIds
Set<Long> customerIds = customerFortuneMap.keySet(); Set<Long> customerIds = customerFortuneMap.keySet();
//可直接修改的withdraw记录 //可直接修改的withdraw记录
Map<Long,Long> customerWithdrawMap = directModificationCustomerWithdrawMap(customerIds, payoutBatchId); Map<Long, Long> customerWithdrawMap = directModificationCustomerWithdrawMap(customerIds, payoutBatchId);
//没有最后一笔提现 记录客户信息和此次提现的财富记录 customerId fortunes //没有最后一笔提现 记录客户信息和此次提现的财富记录 customerId fortunes
Map<Long,List<AclCustomerFortune>> newCustomerWithdrawMap = new HashMap<>(16); Map<Long, List<AclCustomerFortune>> newCustomerWithdrawMap = new HashMap<>(16);
//可直接修改的fortune记录(需修改佣金发放状态) //可直接修改的fortune记录(需修改佣金发放状态)
List<AclCustomerFortune> fortuneUpdates = new ArrayList<>(); List<AclCustomerFortune> fortuneUpdates = new ArrayList<>();
//记录可直接修改的fortune对应的withdraw //记录可直接修改的fortune对应的withdraw
List<Long> withdrawUpdateIds = new ArrayList<>(); List<Long> withdrawUpdateIds = new ArrayList<>();
for(Map.Entry<Long, List<AclCustomerFortune>> customerFortune:customerFortuneMap.entrySet()){ for (Map.Entry<Long, List<AclCustomerFortune>> customerFortune : customerFortuneMap.entrySet()) {
//获取需要修改佣金发放状态的经纪人 //获取需要修改佣金发放状态的经纪人
Long customerId = customerFortune.getKey(); Long customerId = customerFortune.getKey();
//此customer最后一笔提现记录id //此customer最后一笔提现记录id
...@@ -222,7 +225,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -222,7 +225,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
//获取休要修改的佣金发放状态的财富记录 //获取休要修改的佣金发放状态的财富记录
List<AclCustomerFortune> fortunes = customerFortune.getValue(); List<AclCustomerFortune> fortunes = customerFortune.getValue();
//判断这些财富记录中佣金发放状态和要修改的状态是否一致,如一致,则不需要修改 //判断这些财富记录中佣金发放状态和要修改的状态是否一致,如一致,则不需要修改
for(AclCustomerFortune fortune : fortunes) { for (AclCustomerFortune fortune : fortunes) {
//不一致,进行修改,并保存需修改的fortune和记录需要新生成的fortune //不一致,进行修改,并保存需修改的fortune和记录需要新生成的fortune
if (!paymentStatus.equals(fortune.getStatus())) { if (!paymentStatus.equals(fortune.getStatus())) {
fortune.setCommissionPayoutStatus(paymentStatus); fortune.setCommissionPayoutStatus(paymentStatus);
...@@ -230,18 +233,18 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -230,18 +233,18 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
fortune.setCommissionPayoutBy(loginId); fortune.setCommissionPayoutBy(loginId);
fortune.setCommissionPayoutAt(new Date()); fortune.setCommissionPayoutAt(new Date());
fortune.setPayoutBatchId(payoutBatchId); fortune.setPayoutBatchId(payoutBatchId);
if (CommonUtil.isNullOrZero(withdrawId)){ if (CommonUtil.isNullOrZero(withdrawId)) {
//需生成新的withdraw //需生成新的withdraw
newFortunes.add(fortune); newFortunes.add(fortune);
}else { } else {
//可直接修改fortune //可直接修改fortune
fortune.setWithdrawedId(withdrawId); fortune.setWithdrawedId(withdrawId);
fortuneUpdates.add(fortune); fortuneUpdates.add(fortune);
withdrawUpdateIds.add(withdrawId); withdrawUpdateIds.add(withdrawId);
} }
}else { } else {
//paymentStatus一致,都是可发放,判断其支付批次,是否一致,一致不需要修改,不一致需要修改两笔withdraw //paymentStatus一致,都是可发放,判断其支付批次,是否一致,一致不需要修改,不一致需要修改两笔withdraw
if (!payoutBatchId.equals(fortune.getPayoutBatchId())){ if (!payoutBatchId.equals(fortune.getPayoutBatchId())) {
//订单原来所属withdraw //订单原来所属withdraw
withdrawUpdateIds.add(fortune.getWithdrawedId()); withdrawUpdateIds.add(fortune.getWithdrawedId());
fortune.setCommissionPayoutAt(new Date()); fortune.setCommissionPayoutAt(new Date());
...@@ -249,12 +252,12 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -249,12 +252,12 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
fortune.setPayoutBatchId(payoutBatchId); fortune.setPayoutBatchId(payoutBatchId);
fortune.setStatus("2"); fortune.setStatus("2");
fortune.setCommissionPayoutStatus("2"); fortune.setCommissionPayoutStatus("2");
if (CommonUtil.isNullOrZero(withdrawId)){ if (CommonUtil.isNullOrZero(withdrawId)) {
//需生成新的withdraw //需生成新的withdraw
newFortunes.add(fortune); newFortunes.add(fortune);
fortune.setWithdrawedId(null); fortune.setWithdrawedId(null);
fortuneUpdates.add(fortune); fortuneUpdates.add(fortune);
}else { } else {
//可直接修改fortune //可直接修改fortune
fortune.setWithdrawedId(withdrawId); fortune.setWithdrawedId(withdrawId);
fortuneUpdates.add(fortune); fortuneUpdates.add(fortune);
...@@ -264,8 +267,8 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -264,8 +267,8 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
} }
} }
//记录客户信息和此次提现的财富记录 //记录客户信息和此次提现的财富记录
if (!newFortunes.isEmpty()){ if (!newFortunes.isEmpty()) {
newCustomerWithdrawMap.put(customerId,newFortunes); newCustomerWithdrawMap.put(customerId, newFortunes);
} }
} }
...@@ -278,26 +281,26 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -278,26 +281,26 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
} }
//重新计算受到影响的withdraw //重新计算受到影响的withdraw
withdrawUpdateIds.removeAll(Collections.singleton(null)); withdrawUpdateIds.removeAll(Collections.singleton(null));
if (!withdrawUpdateIds.isEmpty()){ if (!withdrawUpdateIds.isEmpty()) {
Collections.sort(withdrawUpdateIds); Collections.sort(withdrawUpdateIds);
} }
recalculateWithdraw(withdrawUpdateIds,customerIds,loginId); recalculateWithdraw(withdrawUpdateIds, customerIds, loginId);
//更新生成新的提现记录,及支付记录,fortune中记录对应的withdraw.id //更新生成新的提现记录,及支付记录,fortune中记录对应的withdraw.id
insertWithdraw(newCustomerWithdrawMap,loginId); insertWithdraw(newCustomerWithdrawMap, loginId);
} }
private Map<Long, Long> directModificationCustomerWithdrawMap(Set<Long> customerIds, Long payoutBatchId) { private Map<Long, Long> directModificationCustomerWithdrawMap(Set<Long> customerIds, Long payoutBatchId) {
//查询这些customerId是这个批次的最后一笔未完成的提现记录(ag_acl_customer_fortune_withdraw) //查询这些customerId是这个批次的最后一笔未完成的提现记录(ag_acl_customer_fortune_withdraw)
Map<Long,Long> customerWithdrawNoPayMap = customerFortuneWithdrawDalService.findFinalWithdrawNoPayByCustomerIds(customerIds, payoutBatchId); Map<Long, Long> customerWithdrawNoPayMap = customerFortuneWithdrawDalService.findFinalWithdrawNoPayByCustomerIds(customerIds, payoutBatchId);
//查询这些customerId最后一笔已完成的提现记录(ag_acl_customer_fortune_withdraw) //查询这些customerId最后一笔已完成的提现记录(ag_acl_customer_fortune_withdraw)
// Map<Long,Long> customerWithdrawPayMap = customerFortuneWithdrawDalService.findFinalWithdrawPayByCustomerIds(customerIds); // Map<Long,Long> customerWithdrawPayMap = customerFortuneWithdrawDalService.findFinalWithdrawPayByCustomerIds(customerIds);
Map<Long,Long> customerWithdrawMap = new HashMap<>(16); Map<Long, Long> customerWithdrawMap = new HashMap<>(16);
//循环未完成记录,并于已完成的记录经行比较,如果未完成的id大于已完成的,则可以直接修改withdraw;如果未完成的id小于已完成的id,则需要生成新的withdraw //循环未完成记录,并于已完成的记录经行比较,如果未完成的id大于已完成的,则可以直接修改withdraw;如果未完成的id小于已完成的id,则需要生成新的withdraw
for (Map.Entry<Long,Long> customerWithdrawNoPay: customerWithdrawNoPayMap.entrySet()){ for (Map.Entry<Long, Long> customerWithdrawNoPay : customerWithdrawNoPayMap.entrySet()) {
// Long payWithdrewId = customerWithdrawPayMap.get(customerWithdrawNoPay.getKey()); // Long payWithdrewId = customerWithdrawPayMap.get(customerWithdrawNoPay.getKey());
// if (CommonUtil.isNullOrZero(payWithdrewId)){ // if (CommonUtil.isNullOrZero(payWithdrewId)){
customerWithdrawMap.put(customerWithdrawNoPay.getKey(),customerWithdrawNoPay.getValue()); customerWithdrawMap.put(customerWithdrawNoPay.getKey(), customerWithdrawNoPay.getValue());
continue; continue;
// } // }
// if (BigDecimal.valueOf(payWithdrewId).compareTo(BigDecimal.valueOf(customerWithdrawNoPay.getValue())) > 0){ // if (BigDecimal.valueOf(payWithdrewId).compareTo(BigDecimal.valueOf(customerWithdrawNoPay.getValue())) > 0){
// continue; // continue;
...@@ -307,13 +310,13 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -307,13 +310,13 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
return customerWithdrawMap; return customerWithdrawMap;
} }
private void noPaymentUpDate(String paymentStatus,Long payoutBatchId, Long loginId, List<AclCustomerFortune> customerFortunes) { private void noPaymentUpDate(String paymentStatus, Long payoutBatchId, Long loginId, List<AclCustomerFortune> customerFortunes) {
System.out.println("noPaymentUpDate"); System.out.println("noPaymentUpDate");
//需要修改的fortune记录(需修改佣金发放状态) //需要修改的fortune记录(需修改佣金发放状态)
List<AclCustomerFortune> fortuneUpdates = new ArrayList<>(); List<AclCustomerFortune> fortuneUpdates = new ArrayList<>();
//需要重新计算的withdraw.id //需要重新计算的withdraw.id
List<Long> withdrawUpdateIds = new ArrayList<>(); List<Long> withdrawUpdateIds = new ArrayList<>();
for(AclCustomerFortune fortune : customerFortunes){ for (AclCustomerFortune fortune : customerFortunes) {
//不一致,进行修改,并保存需修改的fortune和需重新计算的withdrawIds //不一致,进行修改,并保存需修改的fortune和需重新计算的withdrawIds
if (!paymentStatus.equals(fortune.getStatus())) { if (!paymentStatus.equals(fortune.getStatus())) {
if ("0".equals(paymentStatus)) { if ("0".equals(paymentStatus)) {
...@@ -342,15 +345,15 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -342,15 +345,15 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
//批量更新需要修改的fortune记录 //批量更新需要修改的fortune记录
customerFortuneDalService.updateBatch(fortuneUpdates); customerFortuneDalService.updateBatch(fortuneUpdates);
//重新计算受到影响的withdraw //重新计算受到影响的withdraw
if (!withdrawUpdateIds.isEmpty()){ if (!withdrawUpdateIds.isEmpty()) {
Collections.sort(withdrawUpdateIds); Collections.sort(withdrawUpdateIds);
} }
recalculateWithdraw(withdrawUpdateIds,null,loginId); recalculateWithdraw(withdrawUpdateIds, null, loginId);
} }
private void recalculateWithdraw(List<Long> withdrawUpdateIds,Set<Long> customerIds,Long loginId) { private void recalculateWithdraw(List<Long> withdrawUpdateIds, Set<Long> customerIds, Long loginId) {
//重新统计提现记录 //重新统计提现记录
if (withdrawUpdateIds.isEmpty()){ if (withdrawUpdateIds.isEmpty()) {
return; return;
} }
System.out.println("recalculateWithdraw"); System.out.println("recalculateWithdraw");
...@@ -365,20 +368,20 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -365,20 +368,20 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
// withdraws.forEach(p-> System.out.println(p.toString())); // withdraws.forEach(p-> System.out.println(p.toString()));
//查询出修改withdraw的customerId //查询出修改withdraw的customerId
if (customerIds == null){ if (customerIds == null) {
Map<Long,List<AclCustomerFortune>> customerFortuneMap = changeCustomerFortunesByFieldName(fortunes,"customerId"); Map<Long, List<AclCustomerFortune>> customerFortuneMap = changeCustomerFortunesByFieldName(fortunes, "customerId");
customerIds = customerFortuneMap.keySet(); customerIds = customerFortuneMap.keySet();
} }
//如果customerIds为null,则此次需修改的withdraw提现金额为0 //如果customerIds为null,则此次需修改的withdraw提现金额为0
if (customerIds.isEmpty()){ if (customerIds.isEmpty()) {
//修改withdraws/pays提现金额为0 //修改withdraws/pays提现金额为0
updateWithdrawAmountToZero(withdraws,pays,loginId); updateWithdrawAmountToZero(withdraws, pays, loginId);
return; return;
} }
//查询customerIds的基本财富信息(历史累积财富 已退保财富 已提现财富 等) customerId CustomerFortuneStatisticalInfo //查询customerIds的基本财富信息(历史累积财富 已退保财富 已提现财富 等) customerId CustomerFortuneStatisticalInfo
Map<Long,CustomerFortuneStatisticalInfo> customerFortuneStatisticalMap = agmsFortuneDalService.findFortuneStatisticalByCustomers(customerIds); Map<Long, CustomerFortuneStatisticalInfo> customerFortuneStatisticalMap = agmsFortuneDalService.findFortuneStatisticalByCustomers(customerIds);
//按withdrawedId经行整理 //按withdrawedId经行整理
Map<Long, List<AclCustomerFortune>> withdrawsFortunes = changeCustomerFortunesByFieldName(fortunes,"withdrawedId"); Map<Long, List<AclCustomerFortune>> withdrawsFortunes = changeCustomerFortunesByFieldName(fortunes, "withdrawedId");
for (AclCustomerFortuneWithdraw withdraw : withdraws) { for (AclCustomerFortuneWithdraw withdraw : withdraws) {
//withdrawId //withdrawId
Long withdrawId = withdraw.getId(); Long withdrawId = withdraw.getId();
...@@ -443,8 +446,8 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -443,8 +446,8 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
customerFortuneDalService.updateBatch(fortuneUpdates); customerFortuneDalService.updateBatch(fortuneUpdates);
} }
private void updateWithdrawAmountToZero(List<AclCustomerFortuneWithdraw> withdraws, List<AclCustomerFortunePay> pays,Long loginId) { private void updateWithdrawAmountToZero(List<AclCustomerFortuneWithdraw> withdraws, List<AclCustomerFortunePay> pays, Long loginId) {
withdraws.forEach(w->{ withdraws.forEach(w -> {
w.setWithdrawAmount(BigDecimal.ZERO); w.setWithdrawAmount(BigDecimal.ZERO);
w.setWithdrawAfterAmount(w.getWithdrawBeforeAmount()); w.setWithdrawAfterAmount(w.getWithdrawBeforeAmount());
w.setCreatedAt(new Date()); w.setCreatedAt(new Date());
...@@ -452,7 +455,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -452,7 +455,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
w.setTaxAmount(BigDecimal.ZERO); w.setTaxAmount(BigDecimal.ZERO);
w.setPaidAmount(BigDecimal.ZERO); w.setPaidAmount(BigDecimal.ZERO);
}); });
pays.forEach(pay->{ pays.forEach(pay -> {
pay.setWithdrawAmount(BigDecimal.ZERO); pay.setWithdrawAmount(BigDecimal.ZERO);
pay.setPayAmount(BigDecimal.ZERO); pay.setPayAmount(BigDecimal.ZERO);
pay.setTaxAmount(BigDecimal.ZERO); pay.setTaxAmount(BigDecimal.ZERO);
...@@ -465,8 +468,8 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -465,8 +468,8 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
customerFortunePayDalService.updateAll(pays); customerFortunePayDalService.updateAll(pays);
} }
private void insertWithdraw(Map<Long, List<AclCustomerFortune>> newCustomerWithdrawMap,Long loginId) { private void insertWithdraw(Map<Long, List<AclCustomerFortune>> newCustomerWithdrawMap, Long loginId) {
if (newCustomerWithdrawMap.isEmpty()){ if (newCustomerWithdrawMap.isEmpty()) {
return; return;
} }
System.out.println("insertWithdraw"); System.out.println("insertWithdraw");
...@@ -474,8 +477,8 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -474,8 +477,8 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
List<AclCustomerFortune> fortuneList = new ArrayList<>(); List<AclCustomerFortune> fortuneList = new ArrayList<>();
//查询customerIds的基本财富信息(历史累积财富 已退保财富 已提现财富 等) customerId CustomerFortuneStatisticalInfo //查询customerIds的基本财富信息(历史累积财富 已退保财富 已提现财富 等) customerId CustomerFortuneStatisticalInfo
Map<Long,CustomerFortuneStatisticalInfo> customerFortuneStatisticalMap = agmsFortuneDalService.findFortuneStatisticalByCustomers(newCustomerWithdrawMap.keySet()); Map<Long, CustomerFortuneStatisticalInfo> customerFortuneStatisticalMap = agmsFortuneDalService.findFortuneStatisticalByCustomers(newCustomerWithdrawMap.keySet());
for (Map.Entry<Long, List<AclCustomerFortune>> customerWithdraw: newCustomerWithdrawMap.entrySet()){ for (Map.Entry<Long, List<AclCustomerFortune>> customerWithdraw : newCustomerWithdrawMap.entrySet()) {
Long customerId = customerWithdraw.getKey(); Long customerId = customerWithdraw.getKey();
List<AclCustomerFortune> fortunes = customerWithdraw.getValue(); List<AclCustomerFortune> fortunes = customerWithdraw.getValue();
//基本财富信息(历史累积财富 已退保财富 已提现财富 等) //基本财富信息(历史累积财富 已退保财富 已提现财富 等)
...@@ -491,7 +494,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -491,7 +494,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
BigDecimal withdrawAfterAmount = withdrawBeforeAmount.subtract(withdrawAmount); BigDecimal withdrawAfterAmount = withdrawBeforeAmount.subtract(withdrawAmount);
//重新计算税额 //重新计算税额
BigDecimal yearDrawnFortune = customerFortuneStatisticalInfo.getYearDrawnFortune(); BigDecimal yearDrawnFortune = customerFortuneStatisticalInfo.getYearDrawnFortune();
BigDecimal taxAmount = calcuPersonalTax(withdrawAmount,yearDrawnFortune); BigDecimal taxAmount = calcuPersonalTax(withdrawAmount, yearDrawnFortune);
//可提现金额 //可提现金额
BigDecimal paidAmount = withdrawAmount.subtract(taxAmount); BigDecimal paidAmount = withdrawAmount.subtract(taxAmount);
//保存withdraw记录 //保存withdraw记录
...@@ -506,7 +509,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -506,7 +509,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
withdraw.setRequestorName(customerFortuneStatisticalInfo.getCustomerName()); withdraw.setRequestorName(customerFortuneStatisticalInfo.getCustomerName());
withdraw.setRequestorIdTypeId(customerFortuneStatisticalInfo.getCustomerIdTypeId()); withdraw.setRequestorIdTypeId(customerFortuneStatisticalInfo.getCustomerIdTypeId());
withdraw.setRequestorId(customerFortuneStatisticalInfo.getCustomerIdNo()); withdraw.setRequestorId(customerFortuneStatisticalInfo.getCustomerIdNo());
withdraw.setRequestorBirthdate(CommonUtil.stringParseDate("yyyy-MM-dd",customerFortuneStatisticalInfo.getCustomerBirthdate())); withdraw.setRequestorBirthdate(CommonUtil.stringParseDate("yyyy-MM-dd", customerFortuneStatisticalInfo.getCustomerBirthdate()));
withdraw.setRequestorGender(customerFortuneStatisticalInfo.getCustomerGender()); withdraw.setRequestorGender(customerFortuneStatisticalInfo.getCustomerGender());
withdraw.setStatus(0); withdraw.setStatus(0);
withdraw.setCreatedAt(new Date()); withdraw.setCreatedAt(new Date());
...@@ -544,7 +547,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -544,7 +547,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
//drawnFortune为此次提现额 //drawnFortune为此次提现额
//yearDrawnFortune今年已提现费用 //yearDrawnFortune今年已提现费用
//计算今年已交税额 //计算今年已交税额
if (!CommonUtil.isNullOrZero(yearDrawnFortune)){ if (!CommonUtil.isNullOrZero(yearDrawnFortune)) {
yearDrawnFortune = BigDecimal.ZERO; yearDrawnFortune = BigDecimal.ZERO;
} }
BigDecimal yearTax = calculateTax(yearDrawnFortune); BigDecimal yearTax = calculateTax(yearDrawnFortune);
...@@ -553,19 +556,19 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -553,19 +556,19 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
BigDecimal tax = calculateTax(amount); BigDecimal tax = calculateTax(amount);
//总税额减去已交税额 //总税额减去已交税额
tax=tax.subtract(yearTax); tax = tax.subtract(yearTax);
return tax.setScale(2,BigDecimal.ROUND_HALF_UP); return tax.setScale(2, BigDecimal.ROUND_HALF_UP);
} }
private BigDecimal calculateTax(BigDecimal yearTax) { private BigDecimal calculateTax(BigDecimal yearTax) {
List<MdIncometaxRate> incometaxs = systemConfigService.findIncometax(); List<MdIncometaxRate> incometaxs = systemConfigService.findIncometax();
//累计提现金额 /1.06* (1-20%)*(1-25%) = 应纳税所得额 //累计提现金额 /1.06* (1-20%)*(1-25%) = 应纳税所得额
yearTax=yearTax.divide(BigDecimal.valueOf(1.06),3,BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(0.6)); yearTax = yearTax.divide(BigDecimal.valueOf(1.06), 3, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(0.6));
for (MdIncometaxRate incometax: incometaxs){ for (MdIncometaxRate incometax : incometaxs) {
if (incometax.getTaxableFrom().compareTo(yearTax)<=0 && yearTax.compareTo(incometax.getTaxableTo()) < 0){ if (incometax.getTaxableFrom().compareTo(yearTax) <= 0 && yearTax.compareTo(incometax.getTaxableTo()) < 0) {
//已交税额 //已交税额
yearTax = yearTax.multiply(BigDecimal.valueOf(incometax.getTaxRate())) yearTax = yearTax.multiply(BigDecimal.valueOf(incometax.getTaxRate()))
.divide(BigDecimal.valueOf(100),3,BigDecimal.ROUND_HALF_UP) .divide(BigDecimal.valueOf(100), 3, BigDecimal.ROUND_HALF_UP)
.subtract(incometax.getEstDeductable()); .subtract(incometax.getEstDeductable());
break; break;
} }
...@@ -575,19 +578,20 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -575,19 +578,20 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
/** /**
* 根据name(字段名整理fortune记录) * 根据name(字段名整理fortune记录)
* @param customerFortunes 未整理的fortune记录 *
* @param fieldName 根据哪个字段名整理 * @param customerFortunes 未整理的fortune记录
* @return 整理后的fortune * @param fieldName 根据哪个字段名整理
* @return 整理后的fortune
*/ */
private Map<Long, List<AclCustomerFortune>> changeCustomerFortunesByFieldName(List<AclCustomerFortune> customerFortunes,String fieldName) { private Map<Long, List<AclCustomerFortune>> changeCustomerFortunesByFieldName(List<AclCustomerFortune> customerFortunes, String fieldName) {
Map<Long, List<AclCustomerFortune>> map = new HashMap<>(16); Map<Long, List<AclCustomerFortune>> map = new HashMap<>(16);
for (AclCustomerFortune list: customerFortunes) { for (AclCustomerFortune list : customerFortunes) {
List<AclCustomerFortune> customerFortuneList = map.get(getFieldValueByName(fieldName,list)); List<AclCustomerFortune> customerFortuneList = map.get(getFieldValueByName(fieldName, list));
customerFortuneList = Optional.ofNullable(customerFortuneList).orElse(new ArrayList<>()); customerFortuneList = Optional.ofNullable(customerFortuneList).orElse(new ArrayList<>());
if (customerFortuneList.isEmpty()){ if (customerFortuneList.isEmpty()) {
customerFortuneList.add(list); customerFortuneList.add(list);
map.put(getFieldValueByName(fieldName,list),customerFortuneList); map.put(getFieldValueByName(fieldName, list), customerFortuneList);
}else { } else {
customerFortuneList.add(list); customerFortuneList.add(list);
} }
} }
...@@ -596,13 +600,13 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -596,13 +600,13 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
/** /**
* 根据属性名获取属性值 * 根据属性名获取属性值
* */ */
private Long getFieldValueByName(String fieldName, Object o) { private Long getFieldValueByName(String fieldName, Object o) {
try { try {
String firstLetter = fieldName.substring(0, 1).toUpperCase(); String firstLetter = fieldName.substring(0, 1).toUpperCase();
String getter = "get" + firstLetter + fieldName.substring(1); String getter = "get" + firstLetter + fieldName.substring(1);
Method method = o.getClass().getMethod(getter); Method method = o.getClass().getMethod(getter);
return (Long) method.invoke(o, new Object[] {}); return (Long) method.invoke(o, new Object[]{});
} catch (Exception e) { } catch (Exception e) {
return null; return null;
} }
...@@ -610,13 +614,13 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -610,13 +614,13 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
@Override @Override
public CommissionPayoutStatusQueryResponseVO commissionPayoutStatusQuery(CommissionPayoutStatusQueryRequestVO requestVO){ public CommissionPayoutStatusQueryResponseVO commissionPayoutStatusQuery(CommissionPayoutStatusQueryRequestVO requestVO) {
CommissionPayoutStatusQueryResponseVO responseVO = new CommissionPayoutStatusQueryResponseVO(); CommissionPayoutStatusQueryResponseVO responseVO = new CommissionPayoutStatusQueryResponseVO();
CommissionPayoutStatusQueryInfo info = new CommissionPayoutStatusQueryInfo(); CommissionPayoutStatusQueryInfo info = new CommissionPayoutStatusQueryInfo();
BeanUtils.copyProperties(requestVO,info); BeanUtils.copyProperties(requestVO, info);
//体系查询调整,如果体系为S3,则需要查询它下面的所有子集 //体系查询调整,如果体系为S3,则需要查询它下面的所有子集
PractitionerSubordinateInfo practitionerSubordinateInfo = new PractitionerSubordinateInfo(); PractitionerSubordinateInfo practitionerSubordinateInfo = new PractitionerSubordinateInfo();
BeanUtils.copyProperties(requestVO,practitionerSubordinateInfo); BeanUtils.copyProperties(requestVO, practitionerSubordinateInfo);
practitionerSubordinateInfo.setDeptId(requestVO.getInsurerBranchDeptId()); practitionerSubordinateInfo.setDeptId(requestVO.getInsurerBranchDeptId());
List<Long> subsystemIdList = aclPractitionerSubordinateSystemDalService.getLongs(practitionerSubordinateInfo); List<Long> subsystemIdList = aclPractitionerSubordinateSystemDalService.getLongs(practitionerSubordinateInfo);
info.setSubsystemIdList(subsystemIdList); info.setSubsystemIdList(subsystemIdList);
...@@ -632,13 +636,13 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -632,13 +636,13 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
Long orderId = commissionPayoutStatus.getOrderId(); Long orderId = commissionPayoutStatus.getOrderId();
totalReferralAmount = totalReferralAmount.add(commissionPayoutStatus.getReferralAmount() == null ? BigDecimal.ZERO : commissionPayoutStatus.getReferralAmount()); totalReferralAmount = totalReferralAmount.add(commissionPayoutStatus.getReferralAmount() == null ? BigDecimal.ZERO : commissionPayoutStatus.getReferralAmount());
if(orderId != null){ if (orderId != null) {
if (orderIdList.contains(orderId)){ if (orderIdList.contains(orderId)) {
continue; continue;
} }
orderIdList.add(orderId); orderIdList.add(orderId);
++totalSingular; ++totalSingular;
totalOrderPrice = totalOrderPrice.add(commissionPayoutStatus.getOrderPrice() == null ? BigDecimal.ZERO : commissionPayoutStatus.getOrderPrice()); totalOrderPrice = totalOrderPrice.add(commissionPayoutStatus.getOrderPrice() == null ? BigDecimal.ZERO : commissionPayoutStatus.getOrderPrice());
} }
} }
responseVO.setLifePractitionerCount(nameSet.size()); responseVO.setLifePractitionerCount(nameSet.size());
...@@ -670,13 +674,13 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -670,13 +674,13 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
} }
@Override @Override
public WithdrawQueryResponseVO withdrawQuery(WithdrawQueryRequestVO requestVO){ public WithdrawQueryResponseVO withdrawQuery(WithdrawQueryRequestVO requestVO) {
WithdrawQueryResponseVO responseVO = new WithdrawQueryResponseVO(); WithdrawQueryResponseVO responseVO = new WithdrawQueryResponseVO();
WithdrawQueryInfo info = new WithdrawQueryInfo(); WithdrawQueryInfo info = new WithdrawQueryInfo();
BeanUtils.copyProperties(requestVO,info); BeanUtils.copyProperties(requestVO, info);
//体系查询调整,如果体系为S3,则需要查询它下面的所有子集 //体系查询调整,如果体系为S3,则需要查询它下面的所有子集
PractitionerSubordinateInfo practitionerSubordinateInfo = new PractitionerSubordinateInfo(); PractitionerSubordinateInfo practitionerSubordinateInfo = new PractitionerSubordinateInfo();
BeanUtils.copyProperties(requestVO,practitionerSubordinateInfo); BeanUtils.copyProperties(requestVO, practitionerSubordinateInfo);
practitionerSubordinateInfo.setDeptId(requestVO.getInsurerBranchDeptId()); practitionerSubordinateInfo.setDeptId(requestVO.getInsurerBranchDeptId());
List<Long> subsystemIdList = aclPractitionerSubordinateSystemDalService.getLongs(practitionerSubordinateInfo); List<Long> subsystemIdList = aclPractitionerSubordinateSystemDalService.getLongs(practitionerSubordinateInfo);
info.setSubsystemIdList(subsystemIdList); info.setSubsystemIdList(subsystemIdList);
...@@ -685,9 +689,9 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -685,9 +689,9 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
responseVO.setTotalPeople(withdraws.size()); responseVO.setTotalPeople(withdraws.size());
BigDecimal totalReferralAmount = withdraws.stream() BigDecimal totalReferralAmount = withdraws.stream()
.map(f -> f.getReferralAmount() == null ? BigDecimal.ZERO : f.getReferralAmount()) .map(f -> f.getReferralAmount() == null ? BigDecimal.ZERO : f.getReferralAmount())
.reduce(BigDecimal.ZERO,BigDecimal::add); .reduce(BigDecimal.ZERO, BigDecimal::add);
responseVO.setTotalReferralAmount(totalReferralAmount); responseVO.setTotalReferralAmount(totalReferralAmount);
responseVO.setCommonResult(new CommonResult(true,ZHBErrorConfig.getErrorInfo("800000"))); responseVO.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
responseVO.setWithdraws(withdraws); responseVO.setWithdraws(withdraws);
return responseVO; return responseVO;
} }
...@@ -700,10 +704,10 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -700,10 +704,10 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
List<FortunePayToOrderInfo> fortunePayToOrderInfos = agmsFortuneDalService.fortunePayToOrder(new Long[]{payId}); List<FortunePayToOrderInfo> fortunePayToOrderInfos = agmsFortuneDalService.fortunePayToOrder(new Long[]{payId});
BigDecimal totalOrderPrice = fortunePayToOrderInfos.stream() BigDecimal totalOrderPrice = fortunePayToOrderInfos.stream()
.map(f -> f.getOrderPrice() == null ? BigDecimal.ZERO : f.getOrderPrice()) .map(f -> f.getOrderPrice() == null ? BigDecimal.ZERO : f.getOrderPrice())
.reduce(BigDecimal.ZERO,BigDecimal::add); .reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal totalReferralAmount = fortunePayToOrderInfos.stream() BigDecimal totalReferralAmount = fortunePayToOrderInfos.stream()
.map(f -> f.getReferralAmount() == null ? BigDecimal.ZERO : f.getReferralAmount()) .map(f -> f.getReferralAmount() == null ? BigDecimal.ZERO : f.getReferralAmount())
.reduce(BigDecimal.ZERO,BigDecimal::add); .reduce(BigDecimal.ZERO, BigDecimal::add);
responseVO.setTotalSingular(fortunePayToOrderInfos.size()); responseVO.setTotalSingular(fortunePayToOrderInfos.size());
responseVO.setTotalOrderPrice(totalOrderPrice); responseVO.setTotalOrderPrice(totalOrderPrice);
responseVO.setTotalReferralAmount(totalReferralAmount); responseVO.setTotalReferralAmount(totalReferralAmount);
...@@ -724,34 +728,34 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -724,34 +728,34 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
//查询所有pay记录和withdraw记录 //查询所有pay记录和withdraw记录
List<AclCustomerFortunePay> customerFortunePays = customerFortunePayDalService.findByIds(payIds); List<AclCustomerFortunePay> customerFortunePays = customerFortunePayDalService.findByIds(payIds);
Long[] withdrawIds = new Long[customerFortunePays.size()]; Long[] withdrawIds = new Long[customerFortunePays.size()];
for(int i = 0; i < customerFortunePays.size();i++){ for (int i = 0; i < customerFortunePays.size(); i++) {
withdrawIds[i] = customerFortunePays.get(i).getWithdrawId(); withdrawIds[i] = customerFortunePays.get(i).getWithdrawId();
} }
List<AclCustomerFortuneWithdraw> customerFortuneWithdraws = customerFortuneWithdrawDalService.findByIds(Arrays.asList(withdrawIds)); List<AclCustomerFortuneWithdraw> customerFortuneWithdraws = customerFortuneWithdrawDalService.findByIds(Arrays.asList(withdrawIds));
//查询经纪人的静态记录 //查询经纪人的静态记录
Long[] customerIds = new Long[customerFortunePays.size()]; Long[] customerIds = new Long[customerFortunePays.size()];
for(int i = 0; i < customerFortunePays.size();i++){ for (int i = 0; i < customerFortunePays.size(); i++) {
customerIds[i] = customerFortunePays.get(i).getCustomerId(); customerIds[i] = customerFortunePays.get(i).getCustomerId();
} }
List<AclCustomerFortuneStatistic> customerFortuneStatistics = customerFortuneStatisticDalService.findByCustomerIds(customerIds); List<AclCustomerFortuneStatistic> customerFortuneStatistics = customerFortuneStatisticDalService.findByCustomerIds(customerIds);
//fortune记录 //fortune记录
List<AclCustomerFortune> fortunes = customerFortuneDalService.findByWithdrawIds(Arrays.asList(withdrawIds)); List<AclCustomerFortune> fortunes = customerFortuneDalService.findByWithdrawIds(Arrays.asList(withdrawIds));
//更新静态表 //更新静态表
for (AclCustomerFortuneStatistic statistic: customerFortuneStatistics){ for (AclCustomerFortuneStatistic statistic : customerFortuneStatistics) {
Long customerId = statistic.getCustomerId(); Long customerId = statistic.getCustomerId();
BeanPropertyValueEqualsPredicate predicateClause = new BeanPropertyValueEqualsPredicate( "customerId", customerId); BeanPropertyValueEqualsPredicate predicateClause = new BeanPropertyValueEqualsPredicate("customerId", customerId);
List<AclCustomerFortuneWithdraw> withdraws = (List<AclCustomerFortuneWithdraw>) CollectionUtils.select(customerFortuneWithdraws,predicateClause); List<AclCustomerFortuneWithdraw> withdraws = (List<AclCustomerFortuneWithdraw>) CollectionUtils.select(customerFortuneWithdraws, predicateClause);
if (withdraws.isEmpty()){ if (withdraws.isEmpty()) {
continue; continue;
} }
for (AclCustomerFortuneWithdraw withdraw: withdraws) { for (AclCustomerFortuneWithdraw withdraw : withdraws) {
// if (CommonUtil.isNullOrZero(withdraw.getIsPaid())){ // if (CommonUtil.isNullOrZero(withdraw.getIsPaid())){
BigDecimal drawnFortune = statistic.getDrawnFortune(); BigDecimal drawnFortune = statistic.getDrawnFortune();
if (CommonUtil.isNullOrZero(drawnFortune)){ if (CommonUtil.isNullOrZero(drawnFortune)) {
drawnFortune = BigDecimal.ZERO; drawnFortune = BigDecimal.ZERO;
} }
drawnFortune = drawnFortune.add(withdraw.getWithdrawAmount()); drawnFortune = drawnFortune.add(withdraw.getWithdrawAmount());
statistic.setDrawnFortune(drawnFortune); statistic.setDrawnFortune(drawnFortune);
// } // }
} }
} }
...@@ -787,7 +791,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -787,7 +791,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
boolean success = true; boolean success = true;
String message = ZHBErrorConfig.getErrorInfo("800000"); String message = ZHBErrorConfig.getErrorInfo("800000");
Long[] payIds = requestVO.getPayIds(); Long[] payIds = requestVO.getPayIds();
if (payIds == null || payIds.length == 0){ if (payIds == null || payIds.length == 0) {
success = false; success = false;
message = ZHBErrorConfig.getErrorInfo("830022"); message = ZHBErrorConfig.getErrorInfo("830022");
} }
...@@ -804,9 +808,9 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -804,9 +808,9 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
Long orderId = requestVO.getOrderId(); Long orderId = requestVO.getOrderId();
//判断此订单是否可以退保 //判断此订单是否可以退保
//保单财富以进行提现申请,无法进行退保 //保单财富以进行提现申请,无法进行退保
PoOrder poOrder = poOrderDALService.findByIdAndStatus(orderId,3); PoOrder poOrder = poOrderDALService.findByIdAndStatus(orderId, 3);
if(poOrder == null){ if (poOrder == null) {
resp.setCommonResult(new CommonResult(false,ZHBErrorConfig.getErrorInfo("830065"))); resp.setCommonResult(new CommonResult(false, ZHBErrorConfig.getErrorInfo("830065")));
return resp; return resp;
} }
...@@ -816,11 +820,11 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -816,11 +820,11 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
//财富此订单对应的财富 //财富此订单对应的财富
List<AclCustomerFortune> fortunes = customerFortuneDalService.findByOrderId(orderId); List<AclCustomerFortune> fortunes = customerFortuneDalService.findByOrderId(orderId);
for (AclCustomerFortune fortune : fortunes){ for (AclCustomerFortune fortune : fortunes) {
//查询财富对应的customer的statistic //查询财富对应的customer的statistic
AclCustomerFortuneStatistic statistic = customerFortuneStatisticDalService.findByCustomerId(fortune.getCustomerId()); AclCustomerFortuneStatistic statistic = customerFortuneStatisticDalService.findByCustomerId(fortune.getCustomerId());
BigDecimal cancelledFortune = statistic.getCancelledFortune(); BigDecimal cancelledFortune = statistic.getCancelledFortune();
if (CommonUtil.isNullOrZero(cancelledFortune)){ if (CommonUtil.isNullOrZero(cancelledFortune)) {
cancelledFortune = BigDecimal.ZERO; cancelledFortune = BigDecimal.ZERO;
} }
cancelledFortune = cancelledFortune cancelledFortune = cancelledFortune
...@@ -830,7 +834,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -830,7 +834,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
//生成对应的负向记录 (commission_amount/fyc_amount/referral_amount) //生成对应的负向记录 (commission_amount/fyc_amount/referral_amount)
AclCustomerFortune fortuneNew = new AclCustomerFortune(); AclCustomerFortune fortuneNew = new AclCustomerFortune();
org.springframework.beans.BeanUtils.copyProperties(fortune,fortuneNew); org.springframework.beans.BeanUtils.copyProperties(fortune, fortuneNew);
Double commissionAmount = -fortune.getCommissionAmount().doubleValue(); Double commissionAmount = -fortune.getCommissionAmount().doubleValue();
fortuneNew.setCommissionAmount(BigDecimal.valueOf(commissionAmount)); fortuneNew.setCommissionAmount(BigDecimal.valueOf(commissionAmount));
...@@ -855,11 +859,11 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -855,11 +859,11 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
PoOrder order = poOrderDALService.findByOrderId(orderId); PoOrder order = poOrderDALService.findByOrderId(orderId);
Integer configLevel = order.getConfigLevel(); Integer configLevel = order.getConfigLevel();
String name = ""; String name = "";
if(configLevel == 2){ if (configLevel == 2) {
Long productId = order.getProductId(); Long productId = order.getProductId();
Product product = productDALService.findById(productId); Product product = productDALService.findById(productId);
name = product.getName(); name = product.getName();
}else if (configLevel == 3){ } else if (configLevel == 3) {
Long planId = order.getPlanId(); Long planId = order.getPlanId();
ProductPlan productPlan = productPlanDALService.findById(planId); ProductPlan productPlan = productPlanDALService.findById(planId);
name = productPlan.getName(); name = productPlan.getName();
...@@ -867,15 +871,15 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -867,15 +871,15 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
String messageText = "订单id:" + order.getId() + "<br>" + String messageText = "订单id:" + order.getId() + "<br>" +
"订单号:" + order.getOrderNo() + "<br>" + "订单号:" + order.getOrderNo() + "<br>" +
"产品名称:" + name + "<br>" + "产品名称:" + name + "<br>" +
"产品金额:" + order.getOrderPrice() + "<br>" ; "产品金额:" + order.getOrderPrice() + "<br>";
List<AclPolicyholder> policyHolders = aclPolicyholderService.findByOrderId(orderId); List<AclPolicyholder> policyHolders = aclPolicyholderService.findByOrderId(orderId);
for(AclPolicyholder policyHolder : policyHolders){ for (AclPolicyholder policyHolder : policyHolders) {
Integer type = policyHolder.getType(); Integer type = policyHolder.getType();
if (type == 2){ if (type == 2) {
messageText += "投标人:<br>" + messageText += "投标人:<br>" +
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;姓名:" + policyHolder.getName() + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;姓名:" + policyHolder.getName() +
"&nbsp;&nbsp;&nbsp;&nbsp;电话" + policyHolder.getMobileNo() + "<br>"; "&nbsp;&nbsp;&nbsp;&nbsp;电话" + policyHolder.getMobileNo() + "<br>";
}else if (type == 3){ } else if (type == 3) {
messageText += "被保人:<br>" + messageText += "被保人:<br>" +
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;姓名:" + policyHolder.getName(); "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;姓名:" + policyHolder.getName();
if (!CommonUtil.isNullOrBlank(policyHolder.getMobileNo())) { if (!CommonUtil.isNullOrBlank(policyHolder.getMobileNo())) {
...@@ -886,7 +890,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -886,7 +890,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
String subject = "回退财富"; String subject = "回退财富";
sendService.sendEmailOrSMS("email", email, "3", messageText, null, subject, ccAddresses, "回复财富", 99, null); sendService.sendEmailOrSMS("email", email, "3", messageText, null, subject, ccAddresses, "回复财富", 99, null);
resp.setCommonResult(new CommonResult(true,ZHBErrorConfig.getErrorInfo("800000"))); resp.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
return resp; return resp;
} }
...@@ -894,21 +898,21 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -894,21 +898,21 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
public ExportFortunePayResponseVO exportFortunePay(ExportFortunePayRequestVO requestVO, HttpServletResponse response) { public ExportFortunePayResponseVO exportFortunePay(ExportFortunePayRequestVO requestVO, HttpServletResponse response) {
ExportFortunePayResponseVO responseVO = new ExportFortunePayResponseVO(); ExportFortunePayResponseVO responseVO = new ExportFortunePayResponseVO();
WithdrawQueryInfo info = new WithdrawQueryInfo(); WithdrawQueryInfo info = new WithdrawQueryInfo();
BeanUtils.copyProperties(requestVO,info); BeanUtils.copyProperties(requestVO, info);
//体系查询调整,如果体系为S3,则需要查询它下面的所有子集 //体系查询调整,如果体系为S3,则需要查询它下面的所有子集
PractitionerSubordinateInfo practitionerSubordinateInfo = new PractitionerSubordinateInfo(); PractitionerSubordinateInfo practitionerSubordinateInfo = new PractitionerSubordinateInfo();
BeanUtils.copyProperties(requestVO,practitionerSubordinateInfo); BeanUtils.copyProperties(requestVO, practitionerSubordinateInfo);
practitionerSubordinateInfo.setDeptId(requestVO.getInsurerBranchDeptId()); practitionerSubordinateInfo.setDeptId(requestVO.getInsurerBranchDeptId());
List<Long> subsystemIdList = aclPractitionerSubordinateSystemDalService.getLongs(practitionerSubordinateInfo); List<Long> subsystemIdList = aclPractitionerSubordinateSystemDalService.getLongs(practitionerSubordinateInfo);
info.setSubsystemIdList(subsystemIdList); info.setSubsystemIdList(subsystemIdList);
List<WithdrawLabelInfo> withdraws = agmsFortuneDalService.transformForWithdrawLabel(info); List<WithdrawLabelInfo> withdraws = agmsFortuneDalService.transformForWithdrawLabel(info);
Long[] payIds = new Long[withdraws.size()]; Long[] payIds = new Long[withdraws.size()];
for (int i = 0; i < withdraws.size(); i ++){ for (int i = 0; i < withdraws.size(); i++) {
payIds[i] = withdraws.get(i).getPayId(); payIds[i] = withdraws.get(i).getPayId();
} }
List<FortunePayToOrderInfo> fortunePayToOrderInfos = agmsFortuneDalService.fortunePayToOrder(payIds); List<FortunePayToOrderInfo> fortunePayToOrderInfos = agmsFortuneDalService.fortunePayToOrder(payIds);
createCSV(fortunePayToOrderInfos,response); createCSV(fortunePayToOrderInfos, response);
responseVO.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000"))); responseVO.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
return responseVO; return responseVO;
} }
...@@ -1001,7 +1005,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -1001,7 +1005,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
exportSalaryDetailsSheet2queryOrganization(dataList); exportSalaryDetailsSheet2queryOrganization(dataList);
} }
// 3.遍历数据,产生数据行 // 3.遍历数据,产生数据行
if ( null != dataList) { if (null != dataList) {
for (int i = 0; i < dataList.size(); i++) { for (int i = 0; i < dataList.size(); i++) {
Map<String, Object> values = dataList.get(i); Map<String, Object> values = dataList.get(i);
rownum = sheet2.createRow(i + 1); rownum = sheet2.createRow(i + 1);
...@@ -1038,7 +1042,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -1038,7 +1042,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
//数据字典 //数据字典
MdDropOptions dropOptions = null; MdDropOptions dropOptions = null;
Map<String, Object> item = null; Map<String, Object> item = null;
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
item = list.get(i); item = list.get(i);
//FYC体系 [19] //FYC体系 [19]
...@@ -1053,8 +1057,14 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -1053,8 +1057,14 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
} }
//续期辅导人 [25] //续期辅导人 [25]
if (null != item.get("25") && StringUtils.isNotBlank(item.get("25").toString())) { if (null != item.get("25") && StringUtils.isNotBlank(item.get("25").toString())) {
practitioner = aclPractitionerMap.get(Long.valueOf(item.get("25").toString())); String[] ids = item.get("25").toString().split(",");
item.put("25", practitioner != null ? practitioner.getName() : null); for (int j = 0; j < ids.length; j++) {
practitioner = aclPractitionerMap.get(Long.valueOf(ids[j]));
if (practitioner != null) {
ids[j] = practitioner.getName();
}
}
item.put("25", Joiner.on(",").join(Arrays.asList(ids)));
} }
//推荐人 [30] //推荐人 [30]
if (null != item.get("30") && StringUtils.isNotBlank(item.get("30").toString())) { if (null != item.get("30") && StringUtils.isNotBlank(item.get("30").toString())) {
...@@ -1074,7 +1084,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -1074,7 +1084,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
//所属S1分部 [43] //所属S1分部 [43]
if (null != item.get("43") && StringUtils.isNotBlank(item.get("43").toString())) { if (null != item.get("43") && StringUtils.isNotBlank(item.get("43").toString())) {
subordinateSystem = subordinateSystemMap.get(Long.valueOf(item.get("43").toString())); subordinateSystem = subordinateSystemMap.get(Long.valueOf(item.get("43").toString()));
item.put("43", subordinateSystem != null ? subordinateSystem.getName() : null); item.put("43", subordinateSystem != null ? subordinateSystem.getName() : null);
} }
//所属S2体系 [49] //所属S2体系 [49]
if (null != item.get("49") && StringUtils.isNotBlank(item.get("49").toString())) { if (null != item.get("49") && StringUtils.isNotBlank(item.get("49").toString())) {
...@@ -1106,6 +1116,9 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -1106,6 +1116,9 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
item.put("57", this.processMerge(item.get("57"), aclPractitionerMap)); item.put("57", this.processMerge(item.get("57"), aclPractitionerMap));
item.put("58", this.processMerge(item.get("58"), aclPractitionerMap)); item.put("58", this.processMerge(item.get("58"), aclPractitionerMap));
item.put("59", this.processMerge(item.get("59"), aclPractitionerMap)); item.put("59", this.processMerge(item.get("59"), aclPractitionerMap));
//71-72
item.put("71", this.processMerge(item.get("71"), aclPractitionerMap));
item.put("72", this.processMerge(item.get("72"), aclPractitionerMap));
} }
} }
...@@ -1192,8 +1205,8 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -1192,8 +1205,8 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
os.flush(); os.flush();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
}finally { } finally {
if(os != null){ if (os != null) {
try { try {
os.close(); os.close();
} catch (IOException e) { } catch (IOException e) {
...@@ -1230,7 +1243,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -1230,7 +1243,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
private void createCSV(List<FortunePayToOrderInfo> fortunePayToOrderInfos, HttpServletResponse response) { private void createCSV(List<FortunePayToOrderInfo> fortunePayToOrderInfos, HttpServletResponse response) {
String charset = "UTF-8"; // 读取字符编码 String charset = "UTF-8"; // 读取字符编码
String[] columnName = new String[]{"序号","预计发佣年月","经纪人","佣金","应发佣金","首年销售佣金(fyc)","保单号","保费","佣金率","发佣状态","佣金类型","手机号","职级","分公司","营业部","体系","购买方案"}; String[] columnName = new String[]{"序号", "预计发佣年月", "经纪人", "佣金", "应发佣金", "首年销售佣金(fyc)", "保单号", "保费", "佣金率", "发佣状态", "佣金类型", "手机号", "职级", "分公司", "营业部", "体系", "购买方案"};
String tableName = "YD_Export_Fortune_Pay"; String tableName = "YD_Export_Fortune_Pay";
String CSV_COLUMN_SEPARATOR = ",";//CSV文件列分隔符 String CSV_COLUMN_SEPARATOR = ",";//CSV文件列分隔符
String CSV_ROW_SEPARATOR = "\r\n";//CSV文件行分隔符 String CSV_ROW_SEPARATOR = "\r\n";//CSV文件行分隔符
...@@ -1251,22 +1264,22 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -1251,22 +1264,22 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
buf.append(info.getCommissionAmount() == null ? 0 : info.getCommissionAmount()).append(CSV_COLUMN_SEPARATOR); buf.append(info.getCommissionAmount() == null ? 0 : info.getCommissionAmount()).append(CSV_COLUMN_SEPARATOR);
buf.append(info.getReferralAmount() == null ? 0 : info.getReferralAmount()).append(CSV_COLUMN_SEPARATOR); buf.append(info.getReferralAmount() == null ? 0 : info.getReferralAmount()).append(CSV_COLUMN_SEPARATOR);
buf.append(info.getFycAmount() == null ? 0 : info.getFycAmount()).append(CSV_COLUMN_SEPARATOR); buf.append(info.getFycAmount() == null ? 0 : info.getFycAmount()).append(CSV_COLUMN_SEPARATOR);
buf.append(info.getPolicyNo() == null ? "": "P_" +info.getPolicyNo()).append(CSV_COLUMN_SEPARATOR); buf.append(info.getPolicyNo() == null ? "" : "P_" + info.getPolicyNo()).append(CSV_COLUMN_SEPARATOR);
buf.append(info.getOrderPrice() == null ? 0 : info.getOrderPrice()).append(CSV_COLUMN_SEPARATOR); buf.append(info.getOrderPrice() == null ? 0 : info.getOrderPrice()).append(CSV_COLUMN_SEPARATOR);
buf.append(info.getCommissionRate() == null ? 0: info.getCommissionRate()).append(CSV_COLUMN_SEPARATOR); buf.append(info.getCommissionRate() == null ? 0 : info.getCommissionRate()).append(CSV_COLUMN_SEPARATOR);
buf.append(info.getCommissionPayoutStatus()).append(CSV_COLUMN_SEPARATOR); buf.append(info.getCommissionPayoutStatus()).append(CSV_COLUMN_SEPARATOR);
buf.append(info.getCommissionType() == null ? "": info.getCommissionType()).append(CSV_COLUMN_SEPARATOR); buf.append(info.getCommissionType() == null ? "" : info.getCommissionType()).append(CSV_COLUMN_SEPARATOR);
buf.append(info.getMobileNo()).append(CSV_COLUMN_SEPARATOR); buf.append(info.getMobileNo()).append(CSV_COLUMN_SEPARATOR);
buf.append(info.getPractitionerLevel() == null ? "" : info.getPractitionerLevel()).append(CSV_COLUMN_SEPARATOR); buf.append(info.getPractitionerLevel() == null ? "" : info.getPractitionerLevel()).append(CSV_COLUMN_SEPARATOR);
buf.append(info.getInsurerBranchName() == null ? "" : info.getInsurerBranchName()).append(CSV_COLUMN_SEPARATOR); buf.append(info.getInsurerBranchName() == null ? "" : info.getInsurerBranchName()).append(CSV_COLUMN_SEPARATOR);
buf.append(info.getInsurerBranchDeptName() == null ? "" : info.getInsurerBranchDeptName()).append(CSV_COLUMN_SEPARATOR); buf.append(info.getInsurerBranchDeptName() == null ? "" : info.getInsurerBranchDeptName()).append(CSV_COLUMN_SEPARATOR);
buf.append(info.getSubordinateSystemName() == null ? "": info.getSubordinateSystemName()).append(CSV_COLUMN_SEPARATOR); buf.append(info.getSubordinateSystemName() == null ? "" : info.getSubordinateSystemName()).append(CSV_COLUMN_SEPARATOR);
buf.append(info.getProductName() == null ? "" : info.getProductName()).append(CSV_COLUMN_SEPARATOR); buf.append(info.getProductName() == null ? "" : info.getProductName()).append(CSV_COLUMN_SEPARATOR);
buf.append(CSV_ROW_SEPARATOR); buf.append(CSV_ROW_SEPARATOR);
} }
} }
// 设置文件后缀 // 设置文件后缀
String fn = tableName + System.currentTimeMillis() + ".csv"; String fn = tableName + System.currentTimeMillis() + ".csv";
String headStr = "attachment; filename=\"" + fn + "\""; String headStr = "attachment; filename=\"" + fn + "\"";
// 设置响应 // 设置响应
response.setContentType("APPLICATION/ms-csv.numberformat"); response.setContentType("APPLICATION/ms-csv.numberformat");
...@@ -1282,8 +1295,8 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService { ...@@ -1282,8 +1295,8 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
os.flush(); os.flush();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
}finally { } finally {
if(os != null){ if (os != null) {
try { try {
os.close(); os.close();
} catch (IOException e) { } catch (IOException e) {
......
...@@ -453,13 +453,17 @@ ...@@ -453,13 +453,17 @@
sum(case when drop_option_code ='C01' then f.referral_amount else null end) '23' /*首年销售佣金*/, sum(case when drop_option_code ='C01' then f.referral_amount else null end) '23' /*首年销售佣金*/,
sum(case when drop_option_code ='C02' then f.referral_amount else null end) '24' /*续年销售佣金*/, sum(case when drop_option_code ='C02' then f.referral_amount else null end) '24' /*续年销售佣金*/,
if(f.commission_period!=1,l.mentor_id,'') '25' /*续期辅导人*/, (SELECT group_concat(t.practitioner_id) from ag_acl_customer_fortune t
if(f.commission_period!=1, where t.drop_option_code ='R03' and order_id=f.order_id and t.sale_practitioner_id=l.practitioner_id
(SELECT group_concat(calculation_rate) from ag_acl_customer_fortune where order_id=f.order_id and drop_option_code ='C06' and practitioner_id = l.mentor_id), ) '25' /*续期辅导人*/,
'') '26' /*续期辅导奖金率*/, (SELECT group_concat(CONCAT_WS('-', t.practitioner_id, referral_amount))
if(f.commission_period!=1, from ag_acl_customer_fortune t
(SELECT group_concat(referral_amount) from ag_acl_customer_fortune where order_id=f.order_id and drop_option_code ='C06' and practitioner_id = l.mentor_id), where t.drop_option_code ='R03' and order_id=f.order_id and t.sale_practitioner_id=l.practitioner_id
'') '27' /*续期辅导奖*/, ) '26' /*续期辅导奖金率*/,
(SELECT group_concat(CONCAT_WS('-', t.practitioner_id, referral_amount))
from ag_acl_customer_fortune t
where t.drop_option_code ='R03' and order_id=f.order_id and t.sale_practitioner_id=l.practitioner_id
) '27' /*续期辅导奖*/,
sum(case when drop_option_code ='C04' then f.calculation_rate else null end) '28' /*'经纪人月销售加码奖金%'*/, sum(case when drop_option_code ='C04' then f.calculation_rate else null end) '28' /*'经纪人月销售加码奖金%'*/,
sum(case when drop_option_code ='C04' then f.referral_amount else null end) '29' /*经纪人月销售加码奖金*/, sum(case when drop_option_code ='C04' then f.referral_amount else null end) '29' /*经纪人月销售加码奖金*/,
...@@ -607,13 +611,13 @@ ...@@ -607,13 +611,13 @@
sum(case when drop_option_code ='S01' then f.referral_amount else null end) '67' /*S01-首年度销售佣金*/, sum(case when drop_option_code ='S01' then f.referral_amount else null end) '67' /*S01-首年度销售佣金*/,
sum(case when drop_option_code ='S03' then f.referral_amount else null end) '68' /*S03-首年度辅导奖金*/, sum(case when drop_option_code ='S03' then f.referral_amount else null end) '68' /*S03-首年度辅导奖金*/,
sum(case when drop_option_code ='R01' then f.referral_amount else null end) '69' /*R01-首年度直接销售佣金(旧)*/, sum(case when drop_option_code ='C95' then f.referral_amount else null end) '69' /*R01-首年度直接销售佣金(旧)*/,
sum(case when drop_option_code ='R02' then f.referral_amount else null end) '70' /*R02-续年度直接销售拥金(旧)*/, sum(case when drop_option_code ='R02' then f.referral_amount else null end) '70' /*R02-续年度直接销售拥金(旧)*/,
(SELECT group_concat(CONCAT_WS('-', t.practitioner_id, calculation_rate)) (SELECT group_concat(CONCAT_WS('-', t.practitioner_id, referral_amount))
from ag_acl_customer_fortune t from ag_acl_customer_fortune t
where t.drop_option_code ='R03' and order_id=f.order_id and t.practitioner_id=l.mentor_id where t.drop_option_code ='R03' and order_id=f.order_id and t.sale_practitioner_id=l.practitioner_id
) '71' /*R03-续年度辅导佣金(旧)*/, ) '71' /*R03-续年度辅导佣金(旧)*/,
(SELECT group_concat(CONCAT_WS('-', t.practitioner_id, calculation_rate)) (SELECT group_concat(CONCAT_WS('-', t.practitioner_id, referral_amount))
from ag_acl_customer_fortune t from ag_acl_customer_fortune t
where t.drop_option_code ='R04' and order_id=f.order_id and t.sale_practitioner_id=l.practitioner_id where t.drop_option_code ='R04' and order_id=f.order_id and t.sale_practitioner_id=l.practitioner_id
) '72' /*R04-续年度绩效奖金(旧)*/, ) '72' /*R04-续年度绩效奖金(旧)*/,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment