Commit 2a73b1e5 by kangxiaoshan

金额改double

parent 281bd949
......@@ -263,7 +263,7 @@ public class ADIAccountServiceImpl implements ADIAccountService {
}
if (payMap.containsKey(aw.getEmail())) {
List<Contract> contractList = payMap.get(aw.getEmail());
aw.setMoney(contractList.get(contractList.size() - 1).getPayMoney());
//aw.setMoney(contractList.get(contractList.size() - 1).getPayMoney());
aw.setContractStatus(contractRepository.findByPlatformAndEmailLimit1("adi", aw.getEmail(), ContractTypeEnum.MAIN.getKey()).getStatus());
aw.setContractTime(contractList.size());
} else {
......
......@@ -189,7 +189,7 @@ public class ContractController {
byte[] content = new byte[0];
StringBuilder sb = new StringBuilder();
Long parseSum = 0L;
Double parseSum = 0d;
if (ValidateUtil.isValid(moneyList)) {
for (ContractMoney c : moneyList) {
sb.append(c.getDs()).append(",")
......@@ -279,7 +279,7 @@ public class ContractController {
@RequestMapping(value = "find/rebat", method = RequestMethod.GET)
@ResponseBody
public ResultModel rebat(@CurrentAccount User loginAccount, @RequestParam String product, @RequestParam Integer level, @RequestParam Long money) {
public ResultModel rebat(@CurrentAccount User loginAccount, @RequestParam String product, @RequestParam Integer level, @RequestParam Double money) {
return ResultModel.OK(service.getRebat(product, level, money));
}
......
......@@ -28,7 +28,7 @@ public class Contract {
//套餐
private Long priceLevel;
private String priceLevelName;
private Long money; //合同金额
private Double money; //合同金额
private Double rebate; //
private Long sale;
......@@ -37,7 +37,7 @@ public class Contract {
private String status; // 作废 先回款待录入
private String saleName;
private Long payMoney; // 回款金额
private Double payMoney; // 回款金额
private Integer backStatus; // 1 未回款 2 部分回款 3 已回款
private Long invoice; // 开票次数
private BigDecimal invoiceMoney; // 发票金额
......@@ -193,11 +193,11 @@ public class Contract {
this.priceLevel = priceLevel;
}
public Long getMoney() {
public Double getMoney() {
return money;
}
public void setMoney(Long money) {
public void setMoney(Double money) {
this.money = money;
}
......@@ -273,11 +273,11 @@ public class Contract {
this.status = status;
}
public Long getPayMoney() {
public Double getPayMoney() {
return payMoney;
}
public void setPayMoney(Long payMoney) {
public void setPayMoney(Double payMoney) {
this.payMoney = payMoney;
}
......@@ -346,6 +346,7 @@ public class Contract {
public void setSaleName(String saleName) {
this.saleName = saleName;
}
@Transient
public String getPriceLevelName() {
return priceLevelName;
......@@ -555,7 +556,6 @@ public class Contract {
}
public Integer getShareSign() {
return shareSign;
}
......
......@@ -18,7 +18,7 @@ public class ContractChange {
private String content;
private String marke; //备注
private Long level;
private Long money;
private Double money;
private Long user;
private String createName;
private String platform;
......@@ -139,11 +139,11 @@ public class ContractChange {
this.level = level;
}
public Long getMoney() {
public Double getMoney() {
return money;
}
public void setMoney(Long money) {
public void setMoney(Double money) {
this.money = money;
}
......
......@@ -17,7 +17,7 @@ public class ContractMoney {
private String company;
private String ds;
private String type;
private Long money;
private Double money;
private Long user;
private String createName;
private String platform;
......@@ -66,11 +66,11 @@ public class ContractMoney {
this.type = type;
}
public Long getMoney() {
public Double getMoney() {
return money;
}
public void setMoney(Long money) {
public void setMoney(Double money) {
this.money = money;
}
......
......@@ -24,7 +24,7 @@ public interface ContractService {
//增值服务
List<ContractIncrement> findIncrement();
Double getRebat(String product, Integer level, Long money);
Double getRebat(String product, Integer level, Double money);
List<Sales> getSales();
......@@ -77,5 +77,4 @@ public interface ContractService {
ResultModel uploadBatchInfo(MultipartFile file, String platform);
List<Contract> shareIncomeList(User loginAccount, String startDate, String endDate, String platform, String bodyCode,String serchName);
}
\ No newline at end of file
......@@ -419,7 +419,7 @@ public class ContractServiceImpl implements ContractService {
}
@Override
public Double getRebat(String product, Integer level, Long money) {
public Double getRebat(String product, Integer level, Double money) {
Double rebat = 1d;
try {
PriceLevelMoney levelMoney = priceLevelMoneyRepository.getOne(product, level);
......@@ -479,7 +479,7 @@ public class ContractServiceImpl implements ContractService {
extraFlow = 0L;
}
if (resource.getPayMoney() == null) {
resource.setPayMoney(0L);
resource.setPayMoney(0d);
}
resource.setDs(DateUtil.getBeforeDays(0));
......@@ -642,7 +642,7 @@ public class ContractServiceImpl implements ContractService {
resource.setContractCode(contractCode);
}
resource.setPayMoney(0L);
resource.setPayMoney(0d);
resource.setInvoice(0L);
Long extraFlow = resource.getExtraFlow();
resource.setDs(DateUtil.getBeforeDays(0));
......@@ -1057,7 +1057,7 @@ public class ContractServiceImpl implements ContractService {
if (resource.getPayMoney() != null) {
if (resource.getMoney() == null) {
resource.setMoney(0L);
resource.setMoney(0d);
}
if (ContractStatusEnum.MONEY_BACK_FIRST.getKey().equals(resource.getStatus())) {
......@@ -1105,7 +1105,7 @@ public class ContractServiceImpl implements ContractService {
}
if (resource.getPayMoney() == null) {
resource.setPayMoney(0L);
resource.setPayMoney(0d);
}
if (resource.getInvoiceMoney() == null) {
......@@ -1150,7 +1150,7 @@ public class ContractServiceImpl implements ContractService {
} else if (money.getType().equals("pay")) {
money.setMoney(contract.getMoney());
} else {
money.setMoney(contract.getInvoiceMoney().longValue());
money.setMoney(contract.getInvoiceMoney().doubleValue());
}
......@@ -2430,124 +2430,7 @@ public class ContractServiceImpl implements ContractService {
return true;
}
@Deprecated
@Override
public List<Contract> shareIncomeList(User loginAccount, String startDate, String endDate, String
platform, String bodyCode, String serchName) {
List<Contract> contracts = new ArrayList<>();
if ("all".equals(bodyCode)) {
bodyCode = null;
}
List<String> financeBodies = null;
if (RoleEnum.FINANCE.getKey().equals(loginAccount.getRole())) {
Auth auth = authRepository.findByUser(loginAccount.getId());
financeBodies = JSONArray.fromObject(auth.getAuthExtend());
}
String endCreate = new DateTime(endDate).plusDays(1).toString("yyyy-MM-dd");
if (!StringUtils.isEmpty(bodyCode) && !StringUtils.isEmpty(serchName)) {
if (financeBodies != null && !financeBodies.contains(bodyCode)) {
//沒有权限查看
return contracts;
} else {
contracts = contractRepository.findShareContranctByDate1(startDate, endDate, platform, bodyCode, serchName);
}
} else if (!StringUtils.isEmpty(bodyCode)) {
if (financeBodies != null && !financeBodies.contains(bodyCode)) {
//沒有权限查看
return contracts;
} else {
contracts = contractRepository.findShareContranctByDate2(startDate, endDate, platform, bodyCode);
}
} else if (!StringUtils.isEmpty(serchName)) {
if (financeBodies != null) {
contracts = contractRepository.findShareContranctByDateSercheFinace(startDate, endDate, platform, serchName, financeBodies);
} else {
contracts = contractRepository.findShareContranctByDateSerche(startDate, endDate, platform, serchName);
}
} else {
if (financeBodies != null) {
contracts = contractRepository.findShareContranctByDateFinace(startDate, endDate, platform, financeBodies);
} else {
contracts = contractRepository.findShareContranctByDate3(startDate, endDate, platform);
}
}
List<ContractBody> bodies = contractBodyRepository.findAll();
Map<String, String> bodiesNameMap = bodies.stream().collect(
Collectors.toMap(ContractBody::getCode, ContractBody::getName, (v1, v2) -> v1));
DecimalFormat decimalFormat = new DecimalFormat("###,###.00");
contracts.forEach(v -> {
v.setMyBodyName(bodiesNameMap.get(v.getMyBodyCode()));
//不含稅收入
//以下结果统一 *100
// Long excludTax = v.getMoney() * 6 / 100;
Long excludTax = v.getMoney() * 100 - (long) (v.getMoney() * 100 * 0.06);
v.setIncomeExcludingTax(excludTax);
DateTime formStart = new DateTime(startDate);
DateTime formEnd = new DateTime(endDate);
DateTime contractStart = new DateTime(v.getStartDate());
DateTime contractEnd = new DateTime(v.getEndDate());
// 时间范围是否包含合同结束日期
boolean containEnd = formEnd.compareTo(contractEnd) >= 0;
// 时间范围是否包含合同结束开始日期
boolean containStart = formStart.compareTo(contractStart) <= 0;
//所选结束时间包含合同结束时间 取合同结束时间 反之 取所选结束时间
DateTime usedEnd = containEnd ? contractEnd : formEnd;
//所选开始时间包含合同开始时间 则取合同开始时间 反之 取所选开始时间
DateTime usedStart = containStart ? contractStart : formStart;
v.setIntervalUseDays(Days.daysBetween(contractStart, usedEnd).getDays() + 1);//区间使用天数
//合同总天数
int contracAllDays = Days.daysBetween(contractStart, contractEnd).getDays() + 1;
// 处理后的选择范围天数
int contractFormRange = Days.daysBetween(usedStart, usedEnd).getDays() + 1;
//区间分摊收入
//以下结果统一 *100
Long intervalIncome = 0L;
if (containEnd) {
//时间范围合同结束时间时 分两部分计算
//第一部分
double valuePart1 = v.getIncomeExcludingTax() * 1.0 / 100 / contracAllDays * (contractFormRange - 1);
//此处 除100 计算完成再扩大100倍
double valuePart2 = v.getIncomeExcludingTax() * 1.0 / 100 -
((v.getIncomeExcludingTax() * 1.0 / 100 / contracAllDays * (contracAllDays - 1)));
intervalIncome = new BigDecimal(valuePart1 + valuePart2).setScale(2, BigDecimal.ROUND_HALF_UP)
.multiply(new BigDecimal(100L)).longValue();
v.setIntervaIncomeShare(intervalIncome);
} else {
intervalIncome = (new BigDecimal(v.getIncomeExcludingTax() * 1.0 / 100 / contracAllDays * contractFormRange).
setScale(2, BigDecimal.ROUND_HALF_UP)
.multiply(new BigDecimal(100L))).longValue();
v.setIntervaIncomeShare(intervalIncome);
}
if (v.getAdjustmentFund() == null) {
v.setAdjustmentFund(0L);
}
//分摊总收入
v.setIncomeShareAll(intervalIncome + v.getAdjustmentFund());
});
return contracts;
}
public static void main(String[] args) {
// String dateStr1 = "2019-04-30";
......
......@@ -354,211 +354,6 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
return dateTime1.isBefore(dateTime2) || dateTime1.isEqual(dateTime2);
}
@Deprecated
private void caculateShareIncome(Contract contract, DateTime start, DateTime end) {
DateTime create = new DateTime(new DateTime(contract.getCreateTime()).toString("yyyy-MM-dd"));
DateTime contractStart = new DateTime(contract.getStartDate());
DateTime contractEnd = new DateTime(contract.getEndDate());
// 时间范围是否包含合同结束日期
boolean containEnd = end.compareTo(contractEnd) >= 0;
// 时间范围是否包含合同开始日期
boolean containStart = start.compareTo(contractStart) <= 0;
//所选结束时间包含合同结束时间 取合同结束时间 反之 取所选结束时间
DateTime usedEnd = containEnd ? contractEnd : end;
//所选开始时间包含合同开始时间 则取合同开始时间 反之 取所选开始时间
DateTime usedStart = containStart ? contractStart : start;
contract.setIntervalUseDays(Days.daysBetween(contractStart, usedEnd).getDays() + 1);//区间使用天数
int allDay = Days.daysBetween(contractStart, contractEnd).getDays() + 1;
Long excludTax = contract.getMoney() * 94;//不含税收入*100 :contract.getMoney()*100 - contract.getMoney()*0.06*100 = contract.getMoney()*94
contract.setIncomeExcludingTax(excludTax);
//每天的分摊收入
//Long shareIncomDay = contract.getMoney() * 94 / allDay;
//处理精度
Long shareIncomDay = new BigDecimal(contract.getMoney() * 94 * 1.0 / allDay)
.setScale(0, BigDecimal.ROUND_HALF_UP).longValue();
DateTime creatMonth = create.dayOfMonth().withMinimumValue();//合同录入月1号
int aferDays = 9;
if (contractStart.monthOfYear().get() == 12) {
// 12月份的合同 次月30号(包含)
aferDays = 29;
}
DateTime nextMonth = null;
Long adjustmentFund = 0L;
int betweenMonth = create.getMonthOfYear() - contractStart.getMonthOfYear();
if (ContractStatusEnum.CANCEL.getKey().equals(contract.getStatus()) || ContractStatusEnum.SUSPEND.getKey().equals(contract.getStatus())) {
//合同作废
boolean isCancel = ContractStatusEnum.CANCEL.getKey().equals(contract.getStatus()) ? true : false;
String contentKey = isCancel ? ContractStatusEnum.CANCEL.getValue() : ContractStatusEnum.SUSPEND.getValue();
ContractChange contractChange = contractChangeRepository.findByContentCode(contentKey, contract.getContractCode());
if (contractChange == null) {
contract.setAdjustmentFund(0L);
contract.setIntervaIncomeShare(0L);
contract.setIncomeShareAll(0L);
return;
}
// 合同终止日 或 作废日
DateTime cancelDate = new DateTime(contractChange.getDs());
if (isCancel) {
adjustmentFund = new BigDecimal((Days.daysBetween(contractStart, cancelDate).getDays() + 1) * excludTax * 1.0 / allDay)
.setScale(0, BigDecimal.ROUND_HALF_UP).longValue() * -1;
usedEnd = usedEnd.compareTo(cancelDate) <= 0 ? usedEnd : cancelDate;
int daysIncom = Days.daysBetween(usedStart, usedEnd).getDays() + 1;
daysIncom = daysIncom < 0 ? 0 : daysIncom;
//区间分摊总收入
contract.setIntervaIncomeShare(shareIncomDay * daysIncom);
boolean fullRange = Days.daysBetween(start, end).getDays()
>= Days.daysBetween(contractStart, cancelDate).getDays() ? true : false;
if (fullRange) {
contract.setAdjustmentFund(-1 * contract.getIntervaIncomeShare());
} else if (checkTwoTime(start, cancelDate) && checkTwoTime(cancelDate, end)) {
contract.setAdjustmentFund(adjustmentFund);
} else {
contract.setAdjustmentFund(0L);
}
contract.setIncomeShareAll(contract.getIntervaIncomeShare() + contract.getAdjustmentFund());
} else {
//中止操作入库时间
DateTime suspendDate = new DateTime(new DateTime(contractChange.getCreateTime()).toString("yyyy-MM-dd"));
if (checkTwoTime(suspendDate, cancelDate)) {
adjustmentFund = 0L;
} else {
adjustmentFund = new BigDecimal((Days.daysBetween(cancelDate, suspendDate).getDays() + 1) * excludTax * 1.0 / allDay)
.setScale(0, BigDecimal.ROUND_HALF_UP).longValue() * -1;
}
usedEnd = usedEnd.compareTo(cancelDate) <= 0 ? usedEnd : cancelDate;
int daysIncom = Days.daysBetween(usedStart, usedEnd).getDays() + 1;
daysIncom = daysIncom < 0 ? 0 : daysIncom;
//区间分摊总收入
contract.setIntervaIncomeShare(shareIncomDay * daysIncom);
if (checkTwoTime(start, cancelDate) && checkTwoTime(cancelDate, end)) {
contract.setAdjustmentFund(adjustmentFund);
} else {
contract.setAdjustmentFund(0L);
}
contract.setIncomeShareAll(contract.getIntervaIncomeShare() + contract.getAdjustmentFund());
}
//中止 取消 合同逻辑结束
return;
} else if (contractStart.dayOfMonth().withMaximumValue().plusDays(aferDays).isBefore(create)) {
//录入时间在次月10以后 或次月30日以后
if (betweenMonth == 1) {
//相差一月
nextMonth = contractStart.dayOfMonth().withMaximumValue().plusDays(1);//合同开始次月1号 与调整金对应 = 合同录入月1号
} else if (betweenMonth > 1) {
//相差多月
nextMonth = creatMonth;//合同录入月1号 与调整金对应
} else {
//相差小于1月
nextMonth = null;
}
if (nextMonth != null && end.isBefore(nextMonth.plusDays(betweenMonth > 1 ? -1 : 0))) {
//当月(上月)及之前 无分摊收入
contract.setIntervaIncomeShare(0L);
} else if (nextMonth == null || (checkTwoTime(nextMonth, end))) {
if (nextMonth == null) {
//执行期内的分摊金额开始时间
nextMonth = usedStart;
}
//筛选结束时间包含合同开始次月1号 则计算分摊收入
//时间范围内用于计算分摊金额的天数
DateTime shareStart = start.compareTo(nextMonth) <= 0 ? nextMonth : start;
int daysIncom = Days.daysBetween(shareStart, usedEnd).getDays() + 1;
//区间分摊收入
contract.setIntervaIncomeShare(shareIncomDay * daysIncom);
} else {
contract.setIntervaIncomeShare(0L);
}
//调证金 筛选时间包含录入月1号 则计算调证金
//调证金:(合同开始月最后一日 - 合同开始日期 + 1)* (不含税收入 / 合同总天数)
if (betweenMonth == 1) {
adjustmentFund = nextMonth == null ? 0 : new BigDecimal((contractStart.dayOfMonth().withMaximumValue().dayOfMonth().get()
- contractStart.getDayOfMonth() + 1) * excludTax * 1.0 / allDay)
.setScale(0, BigDecimal.ROUND_HALF_UP).longValue();
} else {
adjustmentFund = nextMonth == null ? 0 :
new BigDecimal((Days.daysBetween(contractStart, creatMonth.plusDays(-1)).getDays() + 1) * 1.0 * excludTax / allDay)
.setScale(0, BigDecimal.ROUND_HALF_UP).longValue();
}
if (nextMonth != null && checkTwoTime(start, nextMonth) && checkTwoTime(nextMonth, end)) {
contract.setAdjustmentFund(adjustmentFund);
//筛选开始时间包含次月1号,则分摊金需加上调证金
contract.setIntervaIncomeShare(contract.getIntervaIncomeShare() + adjustmentFund);
contract.setIncomeShareAll(contract.getIntervaIncomeShare());
} else {
contract.setAdjustmentFund(0L);
}
} else {
//时间范围内用于计算分摊金额的天数
int daysIncom = Days.daysBetween(start, usedEnd).getDays() + 1;
//区间分摊总收入
contract.setIntervaIncomeShare(shareIncomDay * daysIncom);
contract.setAdjustmentFund(0L);
contract.setIncomeShareAll(contract.getIntervaIncomeShare());
adjustmentFund = 0L;
}
DateTime dayShareStartDate;
dayShareStartDate = nextMonth == null ? contractStart : nextMonth;
//最后一日 包含最后一日 时 分摊金处理
//adjustmentFund = adjustmentFund < 0 ? 0 : adjustmentFund;
Long lastDay = excludTax - adjustmentFund - shareIncomDay * (Days.daysBetween(dayShareStartDate, contractEnd).getDays());
if (start.isEqual(end) && start.isEqual(contractEnd)) {
//最后一日分摊金处理
contract.setIntervaIncomeShare(lastDay);
contract.setIncomeShareAll(contract.getIntervaIncomeShare());
} else if (checkTwoTime(contractEnd, end)) {
//包含最后一日 时
contract.setIntervaIncomeShare(contract.getIntervaIncomeShare() - shareIncomDay + lastDay);
contract.setIncomeShareAll(contract.getIntervaIncomeShare());
} else {
contract.setIncomeShareAll(contract.getIntervaIncomeShare());
}
}
public static void main(String[] args) {
......
......@@ -209,7 +209,7 @@ public class TkioAccountServiceImpl implements TkioAccountService {
}
if(payMap.containsKey(aw.getEmail())){
List<Contract> contractList = payMap.get(aw.getEmail());
aw.setMoney(contractList.get(contractList.size() - 1 ).getPayMoney());
//aw.setMoney(contractList.get(contractList.size() - 1 ).getPayMoney());
aw.setContractStatus(contractRepository.findByPlatformAndEmailLimit1("tkio", aw.getEmail(), ContractTypeEnum.MAIN.getKey()).getStatus());
aw.setContractTime(contractList.size());
} else{
......@@ -274,7 +274,7 @@ public class TkioAccountServiceImpl implements TkioAccountService {
}
List<Contract> contractList = contractRepository.findByPlatformAndEmail("tkio", email,ContractTypeEnum.MAIN.getKey());
if(ValidateUtil.isValid(contractList)){
aw.setMoney(contractList.get(contractList.size() - 1 ).getPayMoney());
//aw.setMoney(contractList.get(contractList.size() - 1 ).getPayMoney());
aw.setContractStatus(contractList.get(contractList.size() - 1 ).getStatus());
aw.setContractTime(contractList.size());
} else{
......
......@@ -89,7 +89,7 @@ public class TrackAccountServiceImpl implements TrackAccountService{
}
if(payMap.containsKey(aw.getEmail())){
List<Contract> contractList = payMap.get(aw.getEmail());
aw.setMoney(contractList.get(contractList.size() - 1 ).getPayMoney());
//aw.setMoney(contractList.get(contractList.size() - 1 ).getPayMoney());
aw.setContractStatus(contractList.get(contractList.size() - 1 ).getStatus());
aw.setContractTime(contractList.size());
} else{
......@@ -143,7 +143,7 @@ public class TrackAccountServiceImpl implements TrackAccountService{
}
List<Contract> contractList = contractRepository.findByPlatformAndEmail("track", email, ContractTypeEnum.MAIN.getKey());
if(ValidateUtil.isValid(contractList)){
aw.setMoney(contractList.get(contractList.size() - 1 ).getPayMoney());
//aw.setMoney(contractList.get(contractList.size() - 1 ).getPayMoney());
aw.setContractStatus(contractList.get(contractList.size() - 1 ).getStatus());
aw.setContractTime(contractList.size());
} else{
......
......@@ -203,7 +203,7 @@ public class IOAccountServiceImpl implements IOAccountService {
}
if(payMap.containsKey(aw.getEmail())){
List<Contract> contractList = payMap.get(aw.getEmail());
aw.setMoney(contractList.get(contractList.size() - 1 ).getPayMoney());
//aw.setMoney(contractList.get(contractList.size() - 1 ).getPayMoney());
aw.setContractStatus(contractRepository.findByPlatformAndEmailLimit1("io", aw.getEmail(), ContractTypeEnum.MAIN.getKey()).getStatus());
aw.setContractTime(contractList.size());
} else{
......@@ -245,7 +245,7 @@ public class IOAccountServiceImpl implements IOAccountService {
}
List<Contract> contractList = contractRepository.findByPlatformAndEmail("io", email,ContractTypeEnum.MAIN.getKey());
if(ValidateUtil.isValid(contractList)){
aw.setMoney(contractList.get(contractList.size() - 1 ).getPayMoney());
//aw.setMoney(contractList.get(contractList.size() - 1 ).getPayMoney());
aw.setContractStatus(contractList.get(contractList.size() - 1 ).getStatus());
aw.setContractTime(contractList.size());
} else{
......
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