Commit c8c0399b by yao.xiao

修改佣金发放状态

parent 2bd7f88c
......@@ -4,17 +4,23 @@ import com.yd.api.agms.service.AgmsFortuneService;
import com.yd.api.agms.vo.fortune.CommissionPayoutStatusUpdateRequestVO;
import com.yd.api.agms.vo.fortune.CommissionPayoutStatusUpdateResponseVO;
import com.yd.api.result.CommonResult;
import com.yd.dal.entity.agms.fortune.CustomerFortuneStatisticalInfo;
import com.yd.dal.entity.customer.AclCustomerFortune;
import com.yd.dal.entity.customer.AclCustomerFortunePay;
import com.yd.dal.entity.customer.AclCustomerFortuneWithdraw;
import com.yd.dal.entity.meta.MdIncometaxRate;
import com.yd.dal.service.agms.AgmsFortuneDALService;
import com.yd.dal.service.customer.AclCustomerFortuneDALService;
import com.yd.dal.service.customer.AclCustomerFortunePayDALService;
import com.yd.dal.service.customer.AclCustomerFortuneWithdrawDALService;
import com.yd.rmi.cache.SystemConfigService;
import com.yd.util.CommonUtil;
import com.yd.util.config.ZHBErrorConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.lang.reflect.Method;
import java.security.acl.Acl;
import java.math.BigDecimal;
import java.util.*;
/**
......@@ -25,6 +31,9 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
private AclCustomerFortuneDALService customerFortuneDalService;
private AclCustomerFortuneWithdrawDALService customerFortuneWithdrawDalService;
private AclCustomerFortunePayDALService customerFortunePayDalService;
private AgmsFortuneDALService agmsFortuneDalService;
private SystemConfigService systemConfigService;
@Autowired
public void setAclCustomerFortuneDalService(AclCustomerFortuneDALService customerFortuneDalService) {
......@@ -35,6 +44,20 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
this.customerFortuneWithdrawDalService = customerFortuneWithdrawDalService;
}
@Autowired
public void setCustomerFortunePayDalService(AclCustomerFortunePayDALService customerFortunePayDalService) {
this.customerFortunePayDalService = customerFortunePayDalService;
}
@Autowired
public void setAgmsFortuneDalService(AgmsFortuneDALService agmsFortuneDalService){
this.agmsFortuneDalService = agmsFortuneDalService;
}
@Autowired
public void setSystemConfigService(SystemConfigService systemConfigService){
this.systemConfigService = systemConfigService;
}
@Override
public CommissionPayoutStatusUpdateResponseVO commissionPayoutStatusUpdate(CommissionPayoutStatusUpdateRequestVO requestVO) {
......@@ -59,17 +82,20 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
}
private void canPaymentUpDate(String paymentStatus, Long loginId, List<AclCustomerFortune> customerFortunes) {
System.out.println("canPaymentUpDate");
//将查询出来的财富列表根据customerId经行分类
Map<Long,List<AclCustomerFortune>> customerFortuneMap = changeCustomerFortunes(customerFortunes);
Map<Long,List<AclCustomerFortune>> customerFortuneMap = changeCustomerFortunesByFieldName(customerFortunes,"customerId");
//获得所有需要修改佣金发放状的customerIds
Set<Long> customerIds = customerFortuneMap.keySet();
//查询这些customerId最后一笔未完成的提现记录ag_acl_customer_fortune_withdraw,需重新计算withdraw
Map<Long,Long> customerWithdrawMap = customerFortuneWithdrawDalService.findFinalWithdrawNoPayByCustomerIds(customerIds);
//没有最后一笔提现记录客户信息和此次提现的财富记录 customerId fortunes
//可直接修改的withdraw记录
Map<Long,Long> customerWithdrawMap = directModificationCustomerWithdrawMap(customerIds);
//没有最后一笔提现 记录客户信息和此次提现的财富记录 customerId fortunes
Map<Long,List<AclCustomerFortune>> newCustomerWithdrawMap = new HashMap<>(16);
//可直接修改的fortune记录(需修改佣金发放状态)
List<AclCustomerFortune> fortuneUpdates = new ArrayList<>();
//记录可直接修改的fortune对应的withdraw
List<Long> withdrawUpdateIds = new ArrayList<>();
for(Map.Entry<Long, List<AclCustomerFortune>> customerFortune:customerFortuneMap.entrySet()){
//获取需要修改佣金发放状态的经纪人
Long customerId = customerFortune.getKey();
......@@ -80,7 +106,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
//获取休要修改的佣金发放状态的财富记录
List<AclCustomerFortune> fortunes = customerFortune.getValue();
//判断这些财富记录中佣金发放状态和要修改的状态是否一致,如一致,则不需要修改
for(AclCustomerFortune fortune : customerFortunes) {
for(AclCustomerFortune fortune : fortunes) {
//不一致,进行修改,并保存需修改的fortune和记录需要新生成的fortune
if (!paymentStatus.equals(fortune.getCommissionPayoutStatus())) {
fortune.setCommissionPayoutStatus(paymentStatus);
......@@ -93,9 +119,11 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
//可直接修改fortune
fortune.setWithdrawedId(withdrawId);
fortuneUpdates.add(fortune);
withdrawUpdateIds.add(withdrawId);
}
}
}
//记录客户信息和此次提现的财富记录
if (!newFortunes.isEmpty()){
newCustomerWithdrawMap.put(customerId,newFortunes);
}
......@@ -104,13 +132,34 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
//批量更新需要修改的fortune记录
customerFortuneDalService.updateBatch(fortuneUpdates);
//重新计算受到影响的withdraw
List<Long> withdrawUpdateIds = new ArrayList<>(customerWithdrawMap.keySet());
recalculateWithdraw(withdrawUpdateIds);
recalculateWithdraw(withdrawUpdateIds,customerIds,loginId);
//更新生成新的提现记录,及支付记录,fortune中记录对应的withdraw.id
insertWithdraw(newCustomerWithdrawMap);
insertWithdraw(newCustomerWithdrawMap,loginId);
}
private Map<Long, Long> directModificationCustomerWithdrawMap(Set<Long> customerIds) {
//查询这些customerId最后一笔未完成的提现记录(ag_acl_customer_fortune_withdraw)
Map<Long,Long> customerWithdrawNoPayMap = customerFortuneWithdrawDalService.findFinalWithdrawNoPayByCustomerIds(customerIds);
//查询这些customerId最后一笔已完成的提现记录(ag_acl_customer_fortune_withdraw)
Map<Long,Long> customerWithdrawPayMap = customerFortuneWithdrawDalService.findFinalWithdrawPayByCustomerIds(customerIds);
Map<Long,Long> customerWithdrawMap = new HashMap<>(16);
//循环未完成记录,并于已完成的记录经行比较,如果未完成的id大于已完成的,则可以直接修改withdraw;如果未完成的id小于已完成的id,则需要生成新的withdraw
for (Map.Entry<Long,Long> customerWithdrawNoPay: customerWithdrawNoPayMap.entrySet()){
Long payWithdrewId = customerWithdrawPayMap.get(customerWithdrawNoPay.getKey());
if (CommonUtil.isNullOrZero(payWithdrewId)){
customerWithdrawMap.put(customerWithdrawNoPay.getKey(),customerWithdrawNoPay.getValue());
continue;
}
if (payWithdrewId > customerWithdrawNoPay.getKey()){
continue;
}
customerWithdrawMap.put(customerWithdrawNoPay.getKey(),customerWithdrawNoPay.getValue());
}
return customerWithdrawMap;
}
private void noPaymentUpDate(String paymentStatus, Long loginId, List<AclCustomerFortune> customerFortunes) {
System.out.println("noPaymentUpDate");
//需要修改的fortune记录(需修改佣金发放状态)
List<AclCustomerFortune> fortuneUpdates = new ArrayList<>();
//需要重新计算的withdraw.id
......@@ -123,6 +172,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
fortune.setCommissionPayoutAt(new Date());
Long withdrawId = fortune.getWithdrawedId();
fortune.setWithdrawedId(null);
fortune.setFortunePayedId(null);
fortuneUpdates.add(fortune);
if (!CommonUtil.isNullOrZero(withdrawId)){
withdrawUpdateIds.add(withdrawId);
......@@ -132,34 +182,212 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
//批量更新需要修改的fortune记录
customerFortuneDalService.updateBatch(fortuneUpdates);
//重新计算受到影响的withdraw
recalculateWithdraw(withdrawUpdateIds);
recalculateWithdraw(withdrawUpdateIds,null,loginId);
}
private void recalculateWithdraw(List<Long> withdrawUpdateIds) {
private void recalculateWithdraw(List<Long> withdrawUpdateIds,Set<Long> customerIds,Long loginId) {
//重新统计提现记录
if (withdrawUpdateIds.isEmpty()){
return;
}
System.out.println("recalculateWithdraw");
// List<AclCustomerFortune> fortunes = customerFortuneDalService.findByWithdrawIds(withdrawUpdateIds);
//查询原提现记录
List<AclCustomerFortuneWithdraw> withdraws = customerFortuneWithdrawDalService.findByIds(withdrawUpdateIds);
//查询原待支付记录
List<AclCustomerFortunePay> pays = customerFortunePayDalService.findByWithdrawIds(withdrawUpdateIds);
// pays.forEach(p-> System.out.println(p.toString()));
//查询所有提现财富
List<AclCustomerFortune> fortunes = customerFortuneDalService.findByWithdrawIds(withdrawUpdateIds);
List<AclCustomerFortune> fortuneUpdates = new ArrayList<>();
// withdraws.forEach(p-> System.out.println(p.toString()));
//查询出修改withdraw的customerId
if (customerIds == null){
Map<Long,List<AclCustomerFortune>> customerFortuneMap = changeCustomerFortunesByFieldName(fortunes,"customerId");
customerIds = customerFortuneMap.keySet();
}
//查询customerIds的基本财富信息(历史累积财富 已退保财富 已提现财富 等) customerId CustomerFortuneStatisticalInfo
Map<Long,CustomerFortuneStatisticalInfo> customerFortuneStatisticalMap = agmsFortuneDalService.findFortuneStatisticalByCustomers(customerIds);
//按withdrawedId经行整理
Map<Long, List<AclCustomerFortune>> withdrawsFortunes = changeCustomerFortunesByFieldName(fortunes,"withdrawedId");
for(Map.Entry<Long, List<AclCustomerFortune>> withdrawsFortune: withdrawsFortunes.entrySet()){
//withdrawId
Long withdrawId = withdrawsFortune.getKey();
//需要重新计算withdraw根据的fortune记录
List<AclCustomerFortune> fortuneWithdraw = withdrawsFortune.getValue();
//统计此次提现总金额
BigDecimal withdrawAmount = fortuneWithdraw.stream()
.map(item -> item.getReferralAmount() == null ? BigDecimal.ZERO : item.getReferralAmount())
.reduce(BigDecimal.ZERO, BigDecimal::add);
//找到对应的withdraw记录
for (AclCustomerFortuneWithdraw withdraw: withdraws){
if (withdraw.getId().equals(withdrawId)){
//基本财富信息(历史累积财富 已退保财富 已提现财富 等)
CustomerFortuneStatisticalInfo customerFortuneStatisticalInfo = customerFortuneStatisticalMap.get(withdraw.getCustomerId());
//根据customerId查询未提现财富金额 可提现财富+不可体现财富+需修改的withdraw原提现金额
BigDecimal withdrawBeforeAmount = customerFortuneStatisticalInfo.getCashableFortune()
.add(customerFortuneStatisticalInfo.getUncashableFortune())
.add(withdraw.getWithdrawAmount());
//重新计算此次体现后剩余金额
BigDecimal withdrawAfterAmount = withdrawBeforeAmount.subtract(withdrawAmount);
//重新计算税额
BigDecimal yearDrawnFortune = customerFortuneStatisticalInfo.getYearDrawnFortune().subtract(withdraw.getWithdrawAmount());
BigDecimal taxAmount = calcuPersonalTax(withdrawAmount,yearDrawnFortune);
//可提现金额
BigDecimal paidAmount = withdrawAmount.subtract(taxAmount);
withdraw.setWithdrawBeforeAmount(withdrawBeforeAmount);
withdraw.setWithdrawAmount(withdrawAmount);
withdraw.setWithdrawAfterAmount(withdrawAfterAmount);
withdraw.setTaxAmount(taxAmount);
withdraw.setPaidAmount(paidAmount);
withdraw.setCreatedBy(loginId);
withdraw.setCreatedAt(new Date());
//找到对应的pay记录
for (AclCustomerFortunePay pay: pays){
if (pay.getWithdrawId().equals(withdrawId)){
pay.setWithdrawAmount(withdrawAmount);
pay.setPayAmount(paidAmount);
pay.setTaxAmount(taxAmount);
pay.setUpdatedBy(loginId);
pay.setUpdatedAt(new Date());
fortuneWithdraw.forEach(f->f.setFortunePayedId(pay.getId()));
fortuneUpdates.addAll(fortuneWithdraw);
}
}
}
}
}
//批量更新withdraw记录
customerFortuneWithdrawDalService.updateAll(withdraws);
withdraws.forEach(p-> System.out.println(p.toString()));
//批量更新pay记录
customerFortunePayDalService.updateAll(pays);
pays.forEach(p-> System.out.println(p.toString()));
//再次更新fortune->payId
customerFortuneDalService.updateBatch(fortuneUpdates);
}
private void insertWithdraw(Map<Long, List<AclCustomerFortune>> newCustomerWithdrawMap) {
private void insertWithdraw(Map<Long, List<AclCustomerFortune>> newCustomerWithdrawMap,Long loginId) {
if (newCustomerWithdrawMap.isEmpty()){
return;
}
System.out.println("insertWithdraw");
//暂存需要修改的fortune信息
List<AclCustomerFortune> fortuneList = new ArrayList<>();
//查询customerIds的基本财富信息(历史累积财富 已退保财富 已提现财富 等) customerId CustomerFortuneStatisticalInfo
Map<Long,CustomerFortuneStatisticalInfo> customerFortuneStatisticalMap = agmsFortuneDalService.findFortuneStatisticalByCustomers(newCustomerWithdrawMap.keySet());
for (Map.Entry<Long, List<AclCustomerFortune>> customerWithdraw: newCustomerWithdrawMap.entrySet()){
Long customerId = customerWithdraw.getKey();
List<AclCustomerFortune> fortunes = customerWithdraw.getValue();
//基本财富信息(历史累积财富 已退保财富 已提现财富 等)
CustomerFortuneStatisticalInfo customerFortuneStatisticalInfo = customerFortuneStatisticalMap.get(customerId);
//根据customerId查询未提现财富金额 可提现+不可体现
BigDecimal withdrawBeforeAmount = customerFortuneStatisticalInfo.getCashableFortune()
.add(customerFortuneStatisticalInfo.getUncashableFortune());
//计算此次提现财富
BigDecimal withdrawAmount = fortunes.stream()
.map(item -> item.getReferralAmount() == null ? BigDecimal.ZERO : item.getReferralAmount())
.reduce(BigDecimal.ZERO, BigDecimal::add);
//重新计算此次体现后剩余金额
BigDecimal withdrawAfterAmount = withdrawBeforeAmount.subtract(withdrawAmount);
//重新计算税额
BigDecimal yearDrawnFortune = customerFortuneStatisticalInfo.getYearDrawnFortune();
BigDecimal taxAmount = calcuPersonalTax(withdrawAmount,yearDrawnFortune);
//可提现金额
BigDecimal paidAmount = withdrawAmount.subtract(taxAmount);
//保存withdraw记录
AclCustomerFortuneWithdraw withdraw = new AclCustomerFortuneWithdraw();
withdraw.setCustomerId(customerId);
withdraw.setWithdrawBeforeAmount(withdrawBeforeAmount);
withdraw.setWithdrawAmount(withdrawAmount);
withdraw.setWithdrawAfterAmount(withdrawAfterAmount);
withdraw.setIsPaid(0);
withdraw.setPaidAmount(paidAmount);
withdraw.setTaxAmount(taxAmount);
withdraw.setRequestorName(customerFortuneStatisticalInfo.getCustomerName());
withdraw.setRequestorIdTypeId(customerFortuneStatisticalInfo.getCustomerIdTypeId());
withdraw.setRequestorId(customerFortuneStatisticalInfo.getCustomerIdNo());
withdraw.setRequestorBirthdate(CommonUtil.stringParseDate("yyyy-MM-dd",customerFortuneStatisticalInfo.getCustomerBirthdate()));
withdraw.setRequestorGender(customerFortuneStatisticalInfo.getCustomerGender());
withdraw.setStatus(0);
withdraw.setCreatedAt(new Date());
withdraw.setCreatedBy(loginId);
customerFortuneWithdrawDalService.save(withdraw);
//保存pay记录
AclCustomerFortunePay pay = new AclCustomerFortunePay();
pay.setWithdrawId(withdraw.getId());
pay.setWithdrawAmount(withdrawAmount);
pay.setCustomerId(customerId);
pay.setCustomerName(customerFortuneStatisticalInfo.getCustomerName());
pay.setPaidMethod(1);
pay.setPayStatus(0);
pay.setCreatedAt(new Date());
pay.setCreatedBy(loginId);
pay.setUpdatedAt(new Date());
pay.setUpdatedBy(loginId);
customerFortunePayDalService.save(pay);
//保存fortune记录
fortunes.forEach(f -> {
f.setWithdrawedId(withdraw.getId());
f.setCommissionPayoutStatus("2");
f.setCommissionPayoutAt(new Date());
f.setCommissionPayoutBy(loginId);
f.setFortunePayedId(pay.getId());
});
fortuneList.addAll(fortunes);
}
customerFortuneDalService.updateBatch(fortuneList);
}
private BigDecimal calcuPersonalTax(BigDecimal drawnFortune, BigDecimal yearDrawnFortune) {
//drawnFortune为此次提现额
//yearDrawnFortune今年已提现费用
//计算今年已交税额
if (!CommonUtil.isNullOrZero(yearDrawnFortune)){
yearDrawnFortune = BigDecimal.ZERO;
}
BigDecimal yearTax = calculateTax(yearDrawnFortune);
//总共提现金额
BigDecimal amount = drawnFortune.add(yearDrawnFortune);
BigDecimal tax = calculateTax(amount);
//总税额减去已交税额
tax=tax.subtract(yearTax);
return tax.setScale(2,BigDecimal.ROUND_HALF_UP);
}
private BigDecimal calculateTax(BigDecimal yearTax) {
List<MdIncometaxRate> incometaxs = systemConfigService.findIncometax();
//累计提现金额 /1.06* (1-20%)*(1-25%) = 应纳税所得额
yearTax=yearTax.divide(BigDecimal.valueOf(1.06),3,BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(0.6));
for (MdIncometaxRate incometax: incometaxs){
if (incometax.getTaxableFrom().compareTo(yearTax)<=0 && yearTax.compareTo(incometax.getTaxableTo()) < 0){
//已交税额
yearTax = yearTax.multiply(BigDecimal.valueOf(incometax.getTaxRate()))
.divide(BigDecimal.valueOf(100),3,BigDecimal.ROUND_HALF_UP)
.subtract(incometax.getEstDeductable());
break;
}
}
return yearTax;
}
private Map<Long, List<AclCustomerFortune>> changeCustomerFortunes(List<AclCustomerFortune> customerFortunes) {
/**
* 根据name(字段名整理fortune记录)
* @param customerFortunes 未整理的fortune记录
* @param fieldName 根据哪个字段名整理
* @return 整理后的fortune
*/
private Map<Long, List<AclCustomerFortune>> changeCustomerFortunesByFieldName(List<AclCustomerFortune> customerFortunes,String fieldName) {
Map<Long, List<AclCustomerFortune>> map = new HashMap<>(16);
for (AclCustomerFortune list: customerFortunes) {
List<AclCustomerFortune> customerFortuneList = map.get(list.getCustomerId());
List<AclCustomerFortune> customerFortuneList = map.get(getFieldValueByName(fieldName,list));
customerFortuneList = Optional.ofNullable(customerFortuneList).orElse(new ArrayList<>());
if (customerFortuneList.isEmpty()){
customerFortuneList.add(list);
map.put(list.getCustomerId(),customerFortuneList);
map.put(getFieldValueByName(fieldName,list),customerFortuneList);
}else {
customerFortuneList.add(list);
}
......@@ -167,22 +395,6 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
return map;
}
private Map<Long, List<Object>> changeList(List<Object> objList ,String name) {
Map<Long, List<Object>> map = new HashMap<>(16);
for (Object obj: objList) {
List<Object> list = map.get(getFieldValueByName(name,obj));
list = Optional.ofNullable(list).orElse(new ArrayList<>());
if (list.isEmpty()){
list.add(list);
map.put(getFieldValueByName(name,obj),list);
}else {
list.add(list);
}
}
return map;
}
/**
* 根据属性名获取属性值
* */
......@@ -190,7 +402,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
try {
String firstLetter = fieldName.substring(0, 1).toUpperCase();
String getter = "get" + firstLetter + fieldName.substring(1);
Method method = o.getClass().getMethod(getter, new Class[] {});
Method method = o.getClass().getMethod(getter);
return (Long) method.invoke(o, new Object[] {});
} catch (Exception e) {
return null;
......
package com.yd.dal.entity.agms.fortune;
import com.yd.util.CommonUtil;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author xxy
*/
public class CustomerFortuneStatisticalInfo {
private Long customerId;
private String mobileNo;
private String customerName;
private String customerIdNo;
private Long customerIdTypeId;
private String customerBirthdate;
private Integer customerGender;
/**
* 历史累积财富
*/
private BigDecimal accumulatedFortune;
/**
* 剩余总财富
*/
private BigDecimal totalFortune;
/**
* 可提现财富
*/
private BigDecimal cashableFortune;
/**
* 暂不可提现财富
*/
private BigDecimal uncashableFortune;
/**
* 已提现财富
*/
private BigDecimal drawnFortune;
/**
* 已退保财富
*/
private BigDecimal cancelledFortune;
/**
* 提现中
*/
private BigDecimal processing;
/**
* 今年已提现金额
*/
private BigDecimal yearDrawnFortune;
/**
* 净资产
*/
private BigDecimal netAssets;
/**
* 获取
*
* @return customerId
*/
public Long getCustomerId() {
return this.customerId;
}
/**
* 设置
*
* @param customerId
*/
public void setCustomerId(Long customerId) {
this.customerId = customerId;
}
/**
* 获取
*
* @return mobileNo
*/
public String getMobileNo() {
return this.mobileNo;
}
/**
* 设置
*
* @param mobileNo
*/
public void setMobileNo(String mobileNo) {
this.mobileNo = mobileNo;
}
/**
* 获取
*
* @return customerName
*/
public String getCustomerName() {
return this.customerName;
}
/**
* 设置
*
* @param customerName
*/
public void setCustomerName(String customerName) {
this.customerName = customerName;
}
/**
* 获取
*
* @return customerIdNo
*/
public String getCustomerIdNo() {
return this.customerIdNo;
}
/**
* 设置
*
* @param customerIdNo
*/
public void setCustomerIdNo(String customerIdNo) {
this.customerIdNo = customerIdNo;
}
/**
* 获取
*
* @return customerIdTypeId
*/
public Long getCustomerIdTypeId() {
return this.customerIdTypeId;
}
/**
* 设置
*
* @param customerIdTypeId
*/
public void setCustomerIdTypeId(Long customerIdTypeId) {
this.customerIdTypeId = customerIdTypeId;
}
/**
* 获取
*
* @return customerBirthdate
*/
public String getCustomerBirthdate() {
return this.customerBirthdate;
}
/**
* 设置
*
* @param customerBirthdate
*/
public void setCustomerBirthdate(String customerBirthdate) {
this.customerBirthdate = customerBirthdate;
}
/**
* 获取
*
* @return customerGender
*/
public Integer getCustomerGender() {
return this.customerGender;
}
/**
* 设置
*
* @param customerGender
*/
public void setCustomerGender(Integer customerGender) {
this.customerGender = customerGender;
}
/**
* 获取 历史累积财富
*
* @return accumulatedFortune 历史累积财富
*/
public BigDecimal getAccumulatedFortune() {
return CommonUtil.isNullOrZero(this.accumulatedFortune)? BigDecimal.ZERO: this.accumulatedFortune;
}
/**
* 设置 历史累积财富
*
* @param accumulatedFortune 历史累积财富
*/
public void setAccumulatedFortune(BigDecimal accumulatedFortune) {
this.accumulatedFortune = accumulatedFortune;
}
/**
* 获取 剩余总财富
*
* @return totalFortune 剩余总财富
*/
public BigDecimal getTotalFortune() {
return CommonUtil.isNullOrZero(this.totalFortune)? BigDecimal.ZERO: this.totalFortune;
}
/**
* 设置 剩余总财富
*
* @param totalFortune 剩余总财富
*/
public void setTotalFortune(BigDecimal totalFortune) {
this.totalFortune = totalFortune;
}
/**
* 获取 可提现财富
*
* @return cashableFortune 可提现财富
*/
public BigDecimal getCashableFortune() {
return CommonUtil.isNullOrZero(this.cashableFortune)? BigDecimal.ZERO: this.cashableFortune;
}
/**
* 设置 可提现财富
*
* @param cashableFortune 可提现财富
*/
public void setCashableFortune(BigDecimal cashableFortune) {
this.cashableFortune = cashableFortune;
}
/**
* 获取 暂不可提现财富
*
* @return uncashableFortune 暂不可提现财富
*/
public BigDecimal getUncashableFortune() {
return CommonUtil.isNullOrZero(this.uncashableFortune)? BigDecimal.ZERO: this.uncashableFortune;
}
/**
* 设置 暂不可提现财富
*
* @param uncashableFortune 暂不可提现财富
*/
public void setUncashableFortune(BigDecimal uncashableFortune) {
this.uncashableFortune = uncashableFortune;
}
/**
* 获取 已提现财富
*
* @return drawnFortune 已提现财富
*/
public BigDecimal getDrawnFortune() {
return CommonUtil.isNullOrZero(this.drawnFortune)? BigDecimal.ZERO: this.drawnFortune;
}
/**
* 设置 已提现财富
*
* @param drawnFortune 已提现财富
*/
public void setDrawnFortune(BigDecimal drawnFortune) {
this.drawnFortune = drawnFortune;
}
/**
* 获取 已退保财富
*
* @return cancelledFortune 已退保财富
*/
public BigDecimal getCancelledFortune() {
return CommonUtil.isNullOrZero(this.cancelledFortune)? BigDecimal.ZERO: this.cancelledFortune;
}
/**
* 设置 已退保财富
*
* @param cancelledFortune 已退保财富
*/
public void setCancelledFortune(BigDecimal cancelledFortune) {
this.cancelledFortune = cancelledFortune;
}
/**
* 获取 提现中
*
* @return processing 提现中
*/
public BigDecimal getProcessing() {
return CommonUtil.isNullOrZero(this.processing)? BigDecimal.ZERO: this.processing;
}
/**
* 设置 提现中
*
* @param processing 提现中
*/
public void setProcessing(BigDecimal processing) {
this.processing = processing;
}
/**
* 获取 今年已提现金额
*
* @return yearDrawnFortune 今年已提现金额
*/
public BigDecimal getYearDrawnFortune() {
return CommonUtil.isNullOrZero(this.yearDrawnFortune)? BigDecimal.ZERO: this.yearDrawnFortune;
}
/**
* 设置 今年已提现金额
*
* @param yearDrawnFortune 今年已提现金额
*/
public void setYearDrawnFortune(BigDecimal yearDrawnFortune) {
this.yearDrawnFortune = yearDrawnFortune;
}
/**
* 获取 净资产
*
* @return netAssets 净资产
*/
public BigDecimal getNetAssets() {
return CommonUtil.isNullOrZero(this.netAssets)? BigDecimal.ZERO: this.netAssets;
}
/**
* 设置 净资产
*
* @param netAssets 净资产
*/
public void setNetAssets(BigDecimal netAssets) {
this.netAssets = netAssets;
}
}
......@@ -7,7 +7,6 @@ import lombok.Data;
/**
* fortune record of customer
*/
@Data
public class AclCustomerFortune {
private static final long serialVersionUID = 1L;
/**
......@@ -149,4 +148,562 @@ public class AclCustomerFortune {
* FK ag_acl_customer.id
*/
private Long createdBy;
/**
* Gets the value of id. *
*
* @return the value of id
*/
public Long getId() {
return id;
}
/**
* Sets the id. *
* <p>You can use getId() to get the value of id</p>
* * @param id id
*/
public void setId(Long id) {
this.id = id;
}
/**
* Gets the value of shareId. *
*
* @return the value of shareId
*/
public Long getShareId() {
return shareId;
}
/**
* Sets the shareId. *
* <p>You can use getShareId() to get the value of shareId</p>
* * @param shareId shareId
*/
public void setShareId(Long shareId) {
this.shareId = shareId;
}
/**
* Gets the value of customerId. *
*
* @return the value of customerId
*/
public Long getCustomerId() {
return customerId;
}
/**
* Sets the customerId. *
* <p>You can use getCustomerId() to get the value of customerId</p>
* * @param customerId customerId
*/
public void setCustomerId(Long customerId) {
this.customerId = customerId;
}
/**
* Gets the value of orderId. *
*
* @return the value of orderId
*/
public Long getOrderId() {
return orderId;
}
/**
* Sets the orderId. *
* <p>You can use getOrderId() to get the value of orderId</p>
* * @param orderId orderId
*/
public void setOrderId(Long orderId) {
this.orderId = orderId;
}
/**
* Gets the value of orderDate. *
*
* @return the value of orderDate
*/
public Date getOrderDate() {
return orderDate;
}
/**
* Sets the orderDate. *
* <p>You can use getOrderDate() to get the value of orderDate</p>
* * @param orderDate orderDate
*/
public void setOrderDate(Date orderDate) {
this.orderDate = orderDate;
}
/**
* Gets the value of orderPrice. *
*
* @return the value of orderPrice
*/
public BigDecimal getOrderPrice() {
return orderPrice;
}
/**
* Sets the orderPrice. *
* <p>You can use getOrderPrice() to get the value of orderPrice</p>
* * @param orderPrice orderPrice
*/
public void setOrderPrice(BigDecimal orderPrice) {
this.orderPrice = orderPrice;
}
/**
* Gets the value of commissionRate. *
*
* @return the value of commissionRate
*/
public BigDecimal getCommissionRate() {
return commissionRate;
}
/**
* Sets the commissionRate. *
* <p>You can use getCommissionRate() to get the value of commissionRate</p>
* * @param commissionRate commissionRate
*/
public void setCommissionRate(BigDecimal commissionRate) {
this.commissionRate = commissionRate;
}
/**
* Gets the value of commissionAmount. *
*
* @return the value of commissionAmount
*/
public BigDecimal getCommissionAmount() {
return commissionAmount;
}
/**
* Sets the commissionAmount. *
* <p>You can use getCommissionAmount() to get the value of commissionAmount</p>
* * @param commissionAmount commissionAmount
*/
public void setCommissionAmount(BigDecimal commissionAmount) {
this.commissionAmount = commissionAmount;
}
/**
* Gets the value of fycRate. *
*
* @return the value of fycRate
*/
public BigDecimal getFycRate() {
return fycRate;
}
/**
* Sets the fycRate. *
* <p>You can use getFycRate() to get the value of fycRate</p>
* * @param fycRate fycRate
*/
public void setFycRate(BigDecimal fycRate) {
this.fycRate = fycRate;
}
/**
* Gets the value of fycAmount. *
*
* @return the value of fycAmount
*/
public BigDecimal getFycAmount() {
return fycAmount;
}
/**
* Sets the fycAmount. *
* <p>You can use getFycAmount() to get the value of fycAmount</p>
* * @param fycAmount fycAmount
*/
public void setFycAmount(BigDecimal fycAmount) {
this.fycAmount = fycAmount;
}
/**
* Gets the value of gradeCommissionRate. *
*
* @return the value of gradeCommissionRate
*/
public BigDecimal getGradeCommissionRate() {
return gradeCommissionRate;
}
/**
* Sets the gradeCommissionRate. *
* <p>You can use getGradeCommissionRate() to get the value of gradeCommissionRate</p>
* * @param gradeCommissionRate gradeCommissionRate
*/
public void setGradeCommissionRate(BigDecimal gradeCommissionRate) {
this.gradeCommissionRate = gradeCommissionRate;
}
/**
* Gets the value of shareRate. *
*
* @return the value of shareRate
*/
public BigDecimal getShareRate() {
return shareRate;
}
/**
* Sets the shareRate. *
* <p>You can use getShareRate() to get the value of shareRate</p>
* * @param shareRate shareRate
*/
public void setShareRate(BigDecimal shareRate) {
this.shareRate = shareRate;
}
/**
* Gets the value of referralRate. *
*
* @return the value of referralRate
*/
public BigDecimal getReferralRate() {
return referralRate;
}
/**
* Sets the referralRate. *
* <p>You can use getReferralRate() to get the value of referralRate</p>
* * @param referralRate referralRate
*/
public void setReferralRate(BigDecimal referralRate) {
this.referralRate = referralRate;
}
/**
* Gets the value of referralAmount. *
*
* @return the value of referralAmount
*/
public BigDecimal getReferralAmount() {
return referralAmount;
}
/**
* Sets the referralAmount. *
* <p>You can use getReferralAmount() to get the value of referralAmount</p>
* * @param referralAmount referralAmount
*/
public void setReferralAmount(BigDecimal referralAmount) {
this.referralAmount = referralAmount;
}
/**
* Gets the value of monthPeriod. *
*
* @return the value of monthPeriod
*/
public String getMonthPeriod() {
return monthPeriod;
}
/**
* Sets the monthPeriod. *
* <p>You can use getMonthPeriod() to get the value of monthPeriod</p>
* * @param monthPeriod monthPeriod
*/
public void setMonthPeriod(String monthPeriod) {
this.monthPeriod = monthPeriod;
}
/**
* Gets the value of commissionType. *
*
* @return the value of commissionType
*/
public String getCommissionType() {
return commissionType;
}
/**
* Sets the commissionType. *
* <p>You can use getCommissionType() to get the value of commissionType</p>
* * @param commissionType commissionType
*/
public void setCommissionType(String commissionType) {
this.commissionType = commissionType;
}
/**
* Gets the value of dropOptionCode. *
*
* @return the value of dropOptionCode
*/
public String getDropOptionCode() {
return dropOptionCode;
}
/**
* Sets the dropOptionCode. *
* <p>You can use getDropOptionCode() to get the value of dropOptionCode</p>
* * @param dropOptionCode dropOptionCode
*/
public void setDropOptionCode(String dropOptionCode) {
this.dropOptionCode = dropOptionCode;
}
/**
* Gets the value of practitionerLevel. *
*
* @return the value of practitionerLevel
*/
public String getPractitionerLevel() {
return practitionerLevel;
}
/**
* Sets the practitionerLevel. *
* <p>You can use getPractitionerLevel() to get the value of practitionerLevel</p>
* * @param practitionerLevel practitionerLevel
*/
public void setPractitionerLevel(String practitionerLevel) {
this.practitionerLevel = practitionerLevel;
}
/**
* Gets the value of isTax. *
*
* @return the value of isTax
*/
public Integer getIsTax() {
return isTax;
}
/**
* Sets the isTax. *
* <p>You can use getIsTax() to get the value of isTax</p>
* * @param isTax isTax
*/
public void setIsTax(Integer isTax) {
this.isTax = isTax;
}
/**
* Gets the value of taxAmount. *
*
* @return the value of taxAmount
*/
public BigDecimal getTaxAmount() {
return taxAmount;
}
/**
* Sets the taxAmount. *
* <p>You can use getTaxAmount() to get the value of taxAmount</p>
* * @param taxAmount taxAmount
*/
public void setTaxAmount(BigDecimal taxAmount) {
this.taxAmount = taxAmount;
}
/**
* Gets the value of netAmount. *
*
* @return the value of netAmount
*/
public BigDecimal getNetAmount() {
return netAmount;
}
/**
* Sets the netAmount. *
* <p>You can use getNetAmount() to get the value of netAmount</p>
* * @param netAmount netAmount
*/
public void setNetAmount(BigDecimal netAmount) {
this.netAmount = netAmount;
}
/**
* Gets the value of campaignId. *
*
* @return the value of campaignId
*/
public Long getCampaignId() {
return campaignId;
}
/**
* Sets the campaignId. *
* <p>You can use getCampaignId() to get the value of campaignId</p>
* * @param campaignId campaignId
*/
public void setCampaignId(Long campaignId) {
this.campaignId = campaignId;
}
/**
* Gets the value of campaignName. *
*
* @return the value of campaignName
*/
public String getCampaignName() {
return campaignName;
}
/**
* Sets the campaignName. *
* <p>You can use getCampaignName() to get the value of campaignName</p>
* * @param campaignName campaignName
*/
public void setCampaignName(String campaignName) {
this.campaignName = campaignName;
}
/**
* Gets the value of withdrawableDate. *
*
* @return the value of withdrawableDate
*/
public Date getWithdrawableDate() {
return withdrawableDate;
}
/**
* Sets the withdrawableDate. *
* <p>You can use getWithdrawableDate() to get the value of withdrawableDate</p>
* * @param withdrawableDate withdrawableDate
*/
public void setWithdrawableDate(Date withdrawableDate) {
this.withdrawableDate = withdrawableDate;
}
/**
* Gets the value of commissionPayoutStatus. *
*
* @return the value of commissionPayoutStatus
*/
public String getCommissionPayoutStatus() {
return commissionPayoutStatus;
}
/**
* Sets the commissionPayoutStatus. *
* <p>You can use getCommissionPayoutStatus() to get the value of commissionPayoutStatus</p>
* * @param commissionPayoutStatus commissionPayoutStatus
*/
public void setCommissionPayoutStatus(String commissionPayoutStatus) {
this.commissionPayoutStatus = commissionPayoutStatus;
}
/**
* Gets the value of commissionPayoutAt. *
*
* @return the value of commissionPayoutAt
*/
public Date getCommissionPayoutAt() {
return commissionPayoutAt;
}
/**
* Sets the commissionPayoutAt. *
* <p>You can use getCommissionPayoutAt() to get the value of commissionPayoutAt</p>
* * @param commissionPayoutAt commissionPayoutAt
*/
public void setCommissionPayoutAt(Date commissionPayoutAt) {
this.commissionPayoutAt = commissionPayoutAt;
}
/**
* Gets the value of commissionPayoutBy. *
*
* @return the value of commissionPayoutBy
*/
public Long getCommissionPayoutBy() {
return commissionPayoutBy;
}
/**
* Sets the commissionPayoutBy. *
* <p>You can use getCommissionPayoutBy() to get the value of commissionPayoutBy</p>
* * @param commissionPayoutBy commissionPayoutBy
*/
public void setCommissionPayoutBy(Long commissionPayoutBy) {
this.commissionPayoutBy = commissionPayoutBy;
}
/**
* Gets the value of withdrawedId. *
*
* @return the value of withdrawedId
*/
public Long getWithdrawedId() {
return withdrawedId;
}
/**
* Sets the withdrawedId. *
* <p>You can use getWithdrawedId() to get the value of withdrawedId</p>
* * @param withdrawedId withdrawedId
*/
public void setWithdrawedId(Long withdrawedId) {
this.withdrawedId = withdrawedId;
}
/**
* Gets the value of fortunePayedId. *
*
* @return the value of fortunePayedId
*/
public Long getFortunePayedId() {
return fortunePayedId;
}
/**
* Sets the fortunePayedId. *
* <p>You can use getFortunePayedId() to get the value of fortunePayedId</p>
* * @param fortunePayedId fortunePayedId
*/
public void setFortunePayedId(Long fortunePayedId) {
this.fortunePayedId = fortunePayedId;
}
/**
* Gets the value of createdAt. *
*
* @return the value of createdAt
*/
public Date getCreatedAt() {
return createdAt;
}
/**
* Sets the createdAt. *
* <p>You can use getCreatedAt() to get the value of createdAt</p>
* * @param createdAt createdAt
*/
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
/**
* Gets the value of createdBy. *
*
* @return the value of createdBy
*/
public Long getCreatedBy() {
return createdBy;
}
/**
* Sets the createdBy. *
* <p>You can use getCreatedBy() to get the value of createdBy</p>
* * @param createdBy createdBy
*/
public void setCreatedBy(Long createdBy) {
this.createdBy = createdBy;
}
}
\ No newline at end of file
package com.yd.dal.entity.meta;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;
/**
* 个人所得税预扣率表(居民个人工资、薪金所得预扣预缴适用)
* @author xxy
*/
@Data
public class MdIncometaxRate implements Serializable {
/**
* serial id
*/
private Long id;
/**
* 级数
*/
private Integer taxLevel;
/**
* 累计预扣预缴应纳税所得额 from
*/
private BigDecimal taxableFrom;
/**
* 累计预扣预缴应纳税所得额 to
*/
private BigDecimal taxableTo;
/**
* 预扣率(%)
*/
private Integer taxRate;
/**
* 速算扣除数
*/
private BigDecimal estDeductable;
/**
* 建置日
*/
private Date createdAt;
/**
* 建置者
*/
private Long createdBy;
/**
* 更新日
*/
private Date updatedAt;
/**
* 更新者
*/
private Long updatedBy;
}
\ No newline at end of file
package com.yd.dal.mapper.agms;
import com.yd.dal.entity.agms.fortune.CustomerFortuneStatisticalInfo;
import java.util.List;
/**
* @author xxy
*/
public interface AgmsFortuneMapper {
/**
* 通过customerid查询财富基本信息(历史累积财富 已退保财富 已提现财富 等)
* @param customerIdList customerIds
* @return 财富基本信息(历史累积财富 已退保财富 已提现财富 等)
*/
List<CustomerFortuneStatisticalInfo> findFortuneStatisticalByCustomers(List<Long> customerIdList);
}
......@@ -26,4 +26,6 @@ public interface AclCustomerFortuneMapper {
List<AclCustomerFortuneStatistics> findBySubordinateSystemStatistics(@Param("subordinateSystemId") Long subordinateSystemId, @Param("time") Integer time);
List<AclCustomerFortune> findByIds(Long[] fortuneIds);
List<AclCustomerFortune> findByWithdrawIds(List<Long> withdrawUpdateIds);
}
\ No newline at end of file
......@@ -22,4 +22,6 @@ public interface AclCustomerFortunePayMapper {
int updateBatchSelective(List<AclCustomerFortunePay> list);
int batchInsert(@Param("list") List<AclCustomerFortunePay> list);
List<AclCustomerFortunePay> findByWithdrawIds(List<Long> withdrawIds);
}
\ No newline at end of file
......@@ -27,4 +27,8 @@ public interface AclCustomerFortuneWithdrawMapper {
int batchInsert(@Param("list") List<AclCustomerFortuneWithdraw> list);
List<Map<String, Object>> findFinalWithdrawNoPayByCustomerIds(List<Long> customerIdList);
List<AclCustomerFortuneWithdraw> findByIds(List<Long> withdrawUpdateIds);
List<Map<String, Object>> findFinalWithdrawPayByCustomerIds(List<Long> customerIdList);
}
\ No newline at end of file
package com.yd.dal.mapper.meta;
import com.yd.dal.entity.meta.MdIncometaxRate;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface MdIncometaxRateMapper {
int deleteByPrimaryKey(Long id);
int insert(MdIncometaxRate record);
int insertSelective(MdIncometaxRate record);
MdIncometaxRate selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(MdIncometaxRate record);
int updateByPrimaryKey(MdIncometaxRate record);
int updateBatch(List<MdIncometaxRate> list);
int updateBatchSelective(List<MdIncometaxRate> list);
int batchInsert(@Param("list") List<MdIncometaxRate> list);
List<MdIncometaxRate> findAll();
}
\ No newline at end of file
package com.yd.dal.service.agms;
import com.yd.dal.entity.agms.fortune.CustomerFortuneStatisticalInfo;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author xxy
*/
public interface AgmsFortuneDALService {
/**
* 通过customerid查询财富基本信息(历史累积财富 已退保财富 已提现财富 等)
* @param customerIds customerIds
* @return 财富基本信息(历史累积财富 已退保财富 已提现财富 等)
*/
Map<Long,CustomerFortuneStatisticalInfo> findFortuneStatisticalByCustomers(Set<Long> customerIds);
}
package com.yd.dal.service.agms.impl;
import com.yd.dal.entity.agms.fortune.CustomerFortuneStatisticalInfo;
import com.yd.dal.mapper.agms.AgmsFortuneMapper;
import com.yd.dal.service.agms.AgmsFortuneDALService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
/**
* @author xxy
*/
@Service("agmsFortuneDALService")
public class AgmsFortuneDALServiceImpl implements AgmsFortuneDALService {
@Autowired
private AgmsFortuneMapper agmsFortuneMapper;
@Override
public Map<Long,CustomerFortuneStatisticalInfo> findFortuneStatisticalByCustomers(Set<Long> customerIds) {
List<Long> customerIdList = new ArrayList<>(customerIds);
List<CustomerFortuneStatisticalInfo> statisticalInfoList = agmsFortuneMapper.findFortuneStatisticalByCustomers(customerIdList);
Map<Long,CustomerFortuneStatisticalInfo> customerFortuneStatisticalMap = new HashMap<>(statisticalInfoList.size());
for (CustomerFortuneStatisticalInfo statisticalInfo: statisticalInfoList){
//可提现金额 历史累积财富-已提现财富-已退保财富-暂不可提现财富-申请中
BigDecimal cashableFortune = statisticalInfo.getAccumulatedFortune()
.subtract(statisticalInfo.getUncashableFortune())
.subtract(statisticalInfo.getDrawnFortune())
.subtract(statisticalInfo.getCancelledFortune())
.subtract(statisticalInfo.getProcessing());
statisticalInfo.setCashableFortune(cashableFortune);
//计算剩余总财富 历史累积财富-已提现财富-已退保财富
BigDecimal totalFortune = statisticalInfo.getAccumulatedFortune()
.subtract(statisticalInfo.getDrawnFortune())
.subtract(statisticalInfo.getCancelledFortune());
statisticalInfo.setTotalFortune(totalFortune);
//净资产 历史累积财富-已提现财富
BigDecimal netAssets = statisticalInfo.getAccumulatedFortune()
.subtract(statisticalInfo.getCancelledFortune());
statisticalInfo.setNetAssets(netAssets);
customerFortuneStatisticalMap.put(statisticalInfo.getCustomerId(),statisticalInfo);
}
return customerFortuneStatisticalMap;
}
}
......@@ -16,4 +16,6 @@ public interface AclCustomerFortuneDALService {
List<AclCustomerFortune> findByIds(Long[] fortuneIds);
void updateBatch(List<AclCustomerFortune> fortuneUpdates);
List<AclCustomerFortune> findByWithdrawIds(List<Long> withdrawUpdateIds);
}
package com.yd.dal.service.customer;
import com.yd.dal.entity.customer.AclCustomerFortunePay;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author xxy
*/
public interface AclCustomerFortunePayDALService {
/**
* 通过withdrawId批量查询
* @param withdrawIds withdrawIds
* @return List<AclCustomerFortunePay>
*/
List<AclCustomerFortunePay> findByWithdrawIds(List<Long> withdrawIds);
/**
* 批量更新
* @param pays pays
*/
void updateAll(List<AclCustomerFortunePay> pays);
Long save(AclCustomerFortunePay pay);
}
......@@ -3,6 +3,7 @@ package com.yd.dal.service.customer;
import com.yd.dal.entity.customer.AclCustomerFortuneWithdraw;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.Set;
......@@ -17,4 +18,26 @@ public interface AclCustomerFortuneWithdrawDALService {
* @return map customerId withdrawId
*/
Map<Long, Long> findFinalWithdrawNoPayByCustomerIds(Set<Long> customerIds);
/**
* 通过id批量查询
* @param withdrawUpdateIds ids
* @return AclCustomerFortuneWithdraw
*/
List<AclCustomerFortuneWithdraw> findByIds(List<Long> withdrawUpdateIds);
/**
* 批量更新
* @param withdraws withdraws
*/
void updateAll(List<AclCustomerFortuneWithdraw> withdraws);
/**
* 查询这些customerId最后一笔已完成的提现记录
* @param customerIds 客户id
* @return map customerId withdrawId
*/
Map<Long, Long> findFinalWithdrawPayByCustomerIds(Set<Long> customerIds);
Long save(AclCustomerFortuneWithdraw withdraw);
}
......@@ -29,4 +29,9 @@ public class AclCustomerFortuneDALServiceImpl implements AclCustomerFortuneDALSe
aclCustomerFortuneMapper.updateBatch(fortuneUpdates);
}
}
@Override
public List<AclCustomerFortune> findByWithdrawIds(List<Long> withdrawUpdateIds) {
return aclCustomerFortuneMapper.findByWithdrawIds(withdrawUpdateIds);
}
}
package com.yd.dal.service.customer.impl;
import com.yd.dal.entity.customer.AclCustomerFortunePay;
import com.yd.dal.mapper.customer.AclCustomerFortunePayMapper;
import com.yd.dal.service.customer.AclCustomerFortunePayDALService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author xxy
*/
@Service("aclCustomerFortunePayDALService")
public class AclCustomerFortunePayDALServiceImpl implements AclCustomerFortunePayDALService {
@Autowired
private AclCustomerFortunePayMapper customerFortunePayMapper;
@Override
public List<AclCustomerFortunePay> findByWithdrawIds(List<Long> withdrawIds) {
return customerFortunePayMapper.findByWithdrawIds(withdrawIds);
}
@Override
public void updateAll(List<AclCustomerFortunePay> pays) {
customerFortunePayMapper.updateBatch(pays);
}
@Override
public Long save(AclCustomerFortunePay pay) {
return (long)customerFortunePayMapper.insert(pay);
}
}
package com.yd.dal.service.customer.impl;
import com.yd.dal.entity.customer.AclCustomerFortuneWithdraw;
import com.yd.dal.mapper.customer.AclCustomerFortuneWithdrawMapper;
import com.yd.dal.service.customer.AclCustomerFortuneWithdrawDALService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -20,6 +21,32 @@ public class AclCustomerFortuneWithdrawDALServiceImpl implements AclCustomerFort
public Map<Long, Long> findFinalWithdrawNoPayByCustomerIds(Set<Long> customerIds) {
List<Long> customerIdList = new ArrayList<>(customerIds);
List<Map<String,Object>> customerWithdrawList = customerFortuneWithdrawMapper.findFinalWithdrawNoPayByCustomerIds(customerIdList);
return changeCustomerWithdrawMap(customerWithdrawList);
}
@Override
public List<AclCustomerFortuneWithdraw> findByIds(List<Long> withdrawUpdateIds) {
return customerFortuneWithdrawMapper.findByIds(withdrawUpdateIds);
}
@Override
public void updateAll(List<AclCustomerFortuneWithdraw> withdraws) {
customerFortuneWithdrawMapper.updateBatch(withdraws);
}
@Override
public Map<Long, Long> findFinalWithdrawPayByCustomerIds(Set<Long> customerIds) {
List<Long> customerIdList = new ArrayList<>(customerIds);
List<Map<String,Object>> customerWithdrawList = customerFortuneWithdrawMapper.findFinalWithdrawPayByCustomerIds(customerIdList);
return changeCustomerWithdrawMap(customerWithdrawList);
}
@Override
public Long save(AclCustomerFortuneWithdraw withdraw) {
return (long) customerFortuneWithdrawMapper.insert(withdraw);
}
private Map<Long, Long> changeCustomerWithdrawMap(List<Map<String, Object>> customerWithdrawList) {
Map<Long, Long> customerWithdrawMap = new HashMap<>(16);
for (Map<String, Object> customerWithdraw : customerWithdrawList) {
Long customerId = (Long) customerWithdraw.get("customerId");
......
package com.yd.dal.service.meta;
import com.yd.dal.entity.meta.MdIncometaxRate;
import java.util.List;
/**
* @author xxy
*/
public interface MdIncometaxRateDALService {
/**
* 查询所有
* @return 所有
*/
List<MdIncometaxRate> findAll();
}
package com.yd.dal.service.meta.impl;
import com.yd.dal.entity.meta.MdIncometaxRate;
import com.yd.dal.mapper.meta.MdIncometaxRateMapper;
import com.yd.dal.service.meta.MdIncometaxRateDALService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author xxy
*/
@Service("mdIncometaxRateDALService")
public class MdIncometaxRateDALServiceImpl implements MdIncometaxRateDALService {
@Autowired
private MdIncometaxRateMapper incometaxRateMapper;
@Override
public List<MdIncometaxRate> findAll() {
return incometaxRateMapper.findAll();
}
}
package com.yd.rmi.cache;
import com.yd.dal.entity.meta.MdCode;
import com.yd.dal.entity.meta.MdIncometaxRate;
import com.yd.dal.entity.meta.MdMkCampaign;
import com.yd.dal.service.meta.MdCodeDALService;
import com.yd.dal.service.meta.MdIncometaxRateDALService;
import com.yd.dal.service.meta.MdMkCampaignDALService;
import com.yd.rmi.ali.ossinterf.service.AliOssInterfService;
import com.yd.util.CommonUtil;
......@@ -220,4 +222,20 @@ public class SystemConfigService implements CommandLineRunner{
}
return configValue;
}
@Autowired
private MdIncometaxRateDALService mdIncometaxRateDALService;
@SuppressWarnings("unchecked")
public List<MdIncometaxRate> findIncometax(){
List<MdIncometaxRate> incometaxRates = new ArrayList<>();
Element element = systemConfigCache.get("MdIncometaxRate");
if(element != null && element.getObjectValue() != null){
incometaxRates = (List<MdIncometaxRate>)element.getObjectValue();
}else{
incometaxRates = mdIncometaxRateDALService.findAll();
element = new Element("MdIncometaxRate",incometaxRates);
systemConfigCache.put(element);
}
return incometaxRates;
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yd.dal.mapper.agms.AgmsFortuneMapper">
<select id="findFortuneStatisticalByCustomers" parameterType="list" resultType="com.yd.dal.entity.agms.fortune.CustomerFortuneStatisticalInfo">
select
s.customer_id customerId,
s.accumulated_fortune accumulatedFortune,
s.cancelled_fortune cancelledFortune,
s.drawn_fortune drawnFortune,
(SELECT sum(w.withdraw_amount) from ag_acl_customer_fortune_withdraw w where w.customer_id = s.customer_id and w.is_paid = 0 and lottery_draws_id is NULL) processing,
(SELECT sum(w.withdraw_amount) from ag_acl_customer_fortune_withdraw w where w.customer_id = s.customer_id and w.is_paid = 1 and YEAR(w.paid_date ) = YEAR(NOW( )) and w.lottery_draws_id is null) yearDrawnFortune,
(SELECT sum(f.referral_amount) from ag_acl_customer_fortune f LEFT JOIN ag_po_order o on o.id = f.order_id where o.`status` = 3 and f.customer_id = s.customer_id and f.withdrawable_date > now() and f.withdrawed_id is null) uncashableFortune,
c.name customerName,
c.mobile_no mobileNo,
c.id_no customerIdNo,
c.id_type_id customerIdTypeId,
c.birth_date customerBirthdate,
c.gender customerGender
from ag_acl_customer_fortune_statistic s
left join ag_acl_customer c on c.id=s.customer_id
where s.customer_id in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>
\ No newline at end of file
......@@ -849,4 +849,14 @@
#{item}
</foreach>
</select>
<select id="findByWithdrawIds" parameterType="list" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from ag_acl_customer_fortune
where withdrawed_id in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>
\ No newline at end of file
......@@ -681,4 +681,15 @@
#{item.updatedBy,jdbcType=BIGINT})
</foreach>
</insert>
<select id="findByWithdrawIds" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List" />
from ag_acl_customer_fortune_pay
where withdraw_id in
<foreach collection="list" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</select>
</mapper>
\ No newline at end of file
......@@ -550,4 +550,26 @@
and is_paid != 1
group by customer_id
</select>
<select id="findByIds" parameterType="list" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from ag_acl_customer_fortune_withdraw
where id in
<foreach collection="list" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</select>
<select id="findFinalWithdrawPayByCustomerIds" resultType="java.util.Map">
select customer_id customerId,
group_concat(id order by id) withdrawIds
from ag_acl_customer_fortune_withdraw
where customer_id in
<foreach collection="list" item="item" separator="," open="(" close=")">
#{item}
</foreach>
and is_paid = 1
group by customer_id
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yd.dal.mapper.meta.MdIncometaxRateMapper">
<resultMap id="BaseResultMap" type="com.yd.dal.entity.meta.MdIncometaxRate">
<!--@mbg.generated-->
<!--@Table ag_md_incometax_rate-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="tax_level" jdbcType="INTEGER" property="taxLevel" />
<result column="taxable_from" jdbcType="DECIMAL" property="taxableFrom" />
<result column="taxable_to" jdbcType="DECIMAL" property="taxableTo" />
<result column="tax_rate" jdbcType="INTEGER" property="taxRate" />
<result column="est_deductable" jdbcType="DECIMAL" property="estDeductable" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="created_by" jdbcType="BIGINT" property="createdBy" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="updated_by" jdbcType="BIGINT" property="updatedBy" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, tax_level, taxable_from, taxable_to, tax_rate, est_deductable, created_at, created_by,
updated_at, updated_by
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List" />
from ag_md_incometax_rate
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
<!--@mbg.generated-->
delete from ag_md_incometax_rate
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.meta.MdIncometaxRate" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into ag_md_incometax_rate (tax_level, taxable_from, taxable_to,
tax_rate, est_deductable, created_at,
created_by, updated_at, updated_by
)
values (#{taxLevel,jdbcType=INTEGER}, #{taxableFrom,jdbcType=DECIMAL}, #{taxableTo,jdbcType=DECIMAL},
#{taxRate,jdbcType=INTEGER}, #{estDeductable,jdbcType=DECIMAL}, #{createdAt,jdbcType=TIMESTAMP},
#{createdBy,jdbcType=BIGINT}, #{updatedAt,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=BIGINT}
)
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.meta.MdIncometaxRate" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into ag_md_incometax_rate
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="taxLevel != null">
tax_level,
</if>
<if test="taxableFrom != null">
taxable_from,
</if>
<if test="taxableTo != null">
taxable_to,
</if>
<if test="taxRate != null">
tax_rate,
</if>
<if test="estDeductable != null">
est_deductable,
</if>
<if test="createdAt != null">
created_at,
</if>
<if test="createdBy != null">
created_by,
</if>
<if test="updatedAt != null">
updated_at,
</if>
<if test="updatedBy != null">
updated_by,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="taxLevel != null">
#{taxLevel,jdbcType=INTEGER},
</if>
<if test="taxableFrom != null">
#{taxableFrom,jdbcType=DECIMAL},
</if>
<if test="taxableTo != null">
#{taxableTo,jdbcType=DECIMAL},
</if>
<if test="taxRate != null">
#{taxRate,jdbcType=INTEGER},
</if>
<if test="estDeductable != null">
#{estDeductable,jdbcType=DECIMAL},
</if>
<if test="createdAt != null">
#{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="createdBy != null">
#{createdBy,jdbcType=BIGINT},
</if>
<if test="updatedAt != null">
#{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedBy != null">
#{updatedBy,jdbcType=BIGINT},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yd.dal.entity.meta.MdIncometaxRate">
<!--@mbg.generated-->
update ag_md_incometax_rate
<set>
<if test="taxLevel != null">
tax_level = #{taxLevel,jdbcType=INTEGER},
</if>
<if test="taxableFrom != null">
taxable_from = #{taxableFrom,jdbcType=DECIMAL},
</if>
<if test="taxableTo != null">
taxable_to = #{taxableTo,jdbcType=DECIMAL},
</if>
<if test="taxRate != null">
tax_rate = #{taxRate,jdbcType=INTEGER},
</if>
<if test="estDeductable != null">
est_deductable = #{estDeductable,jdbcType=DECIMAL},
</if>
<if test="createdAt != null">
created_at = #{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="createdBy != null">
created_by = #{createdBy,jdbcType=BIGINT},
</if>
<if test="updatedAt != null">
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedBy != null">
updated_by = #{updatedBy,jdbcType=BIGINT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.yd.dal.entity.meta.MdIncometaxRate">
<!--@mbg.generated-->
update ag_md_incometax_rate
set tax_level = #{taxLevel,jdbcType=INTEGER},
taxable_from = #{taxableFrom,jdbcType=DECIMAL},
taxable_to = #{taxableTo,jdbcType=DECIMAL},
tax_rate = #{taxRate,jdbcType=INTEGER},
est_deductable = #{estDeductable,jdbcType=DECIMAL},
created_at = #{createdAt,jdbcType=TIMESTAMP},
created_by = #{createdBy,jdbcType=BIGINT},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
updated_by = #{updatedBy,jdbcType=BIGINT}
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateBatch" parameterType="java.util.List">
<!--@mbg.generated-->
update ag_md_incometax_rate
<trim prefix="set" suffixOverrides=",">
<trim prefix="tax_level = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.taxLevel,jdbcType=INTEGER}
</foreach>
</trim>
<trim prefix="taxable_from = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.taxableFrom,jdbcType=DECIMAL}
</foreach>
</trim>
<trim prefix="taxable_to = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.taxableTo,jdbcType=DECIMAL}
</foreach>
</trim>
<trim prefix="tax_rate = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.taxRate,jdbcType=INTEGER}
</foreach>
</trim>
<trim prefix="est_deductable = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.estDeductable,jdbcType=DECIMAL}
</foreach>
</trim>
<trim prefix="created_at = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.createdAt,jdbcType=TIMESTAMP}
</foreach>
</trim>
<trim prefix="created_by = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.createdBy,jdbcType=BIGINT}
</foreach>
</trim>
<trim prefix="updated_at = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.updatedAt,jdbcType=TIMESTAMP}
</foreach>
</trim>
<trim prefix="updated_by = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=BIGINT} then #{item.updatedBy,jdbcType=BIGINT}
</foreach>
</trim>
</trim>
where id in
<foreach close=")" collection="list" item="item" open="(" separator=", ">
#{item.id,jdbcType=BIGINT}
</foreach>
</update>
<update id="updateBatchSelective" parameterType="java.util.List">
<!--@mbg.generated-->
update ag_md_incometax_rate
<trim prefix="set" suffixOverrides=",">
<trim prefix="tax_level = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.taxLevel != null">
when id = #{item.id,jdbcType=BIGINT} then #{item.taxLevel,jdbcType=INTEGER}
</if>
</foreach>
</trim>
<trim prefix="taxable_from = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.taxableFrom != null">
when id = #{item.id,jdbcType=BIGINT} then #{item.taxableFrom,jdbcType=DECIMAL}
</if>
</foreach>
</trim>
<trim prefix="taxable_to = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.taxableTo != null">
when id = #{item.id,jdbcType=BIGINT} then #{item.taxableTo,jdbcType=DECIMAL}
</if>
</foreach>
</trim>
<trim prefix="tax_rate = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.taxRate != null">
when id = #{item.id,jdbcType=BIGINT} then #{item.taxRate,jdbcType=INTEGER}
</if>
</foreach>
</trim>
<trim prefix="est_deductable = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.estDeductable != null">
when id = #{item.id,jdbcType=BIGINT} then #{item.estDeductable,jdbcType=DECIMAL}
</if>
</foreach>
</trim>
<trim prefix="created_at = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.createdAt != null">
when id = #{item.id,jdbcType=BIGINT} then #{item.createdAt,jdbcType=TIMESTAMP}
</if>
</foreach>
</trim>
<trim prefix="created_by = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.createdBy != null">
when id = #{item.id,jdbcType=BIGINT} then #{item.createdBy,jdbcType=BIGINT}
</if>
</foreach>
</trim>
<trim prefix="updated_at = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.updatedAt != null">
when id = #{item.id,jdbcType=BIGINT} then #{item.updatedAt,jdbcType=TIMESTAMP}
</if>
</foreach>
</trim>
<trim prefix="updated_by = case" suffix="end,">
<foreach collection="list" index="index" item="item">
<if test="item.updatedBy != null">
when id = #{item.id,jdbcType=BIGINT} then #{item.updatedBy,jdbcType=BIGINT}
</if>
</foreach>
</trim>
</trim>
where id in
<foreach close=")" collection="list" item="item" open="(" separator=", ">
#{item.id,jdbcType=BIGINT}
</foreach>
</update>
<insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into ag_md_incometax_rate
(tax_level, taxable_from, taxable_to, tax_rate, est_deductable, created_at, created_by,
updated_at, updated_by)
values
<foreach collection="list" item="item" separator=",">
(#{item.taxLevel,jdbcType=INTEGER}, #{item.taxableFrom,jdbcType=DECIMAL}, #{item.taxableTo,jdbcType=DECIMAL},
#{item.taxRate,jdbcType=INTEGER}, #{item.estDeductable,jdbcType=DECIMAL}, #{item.createdAt,jdbcType=TIMESTAMP},
#{item.createdBy,jdbcType=BIGINT}, #{item.updatedAt,jdbcType=TIMESTAMP}, #{item.updatedBy,jdbcType=BIGINT}
)
</foreach>
</insert>
<select id="findAll" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from ag_md_incometax_rate
</select>
</mapper>
\ No newline at end of file
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