diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java index 6ccd412cc..6be4e6f0c 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java @@ -56,39 +56,14 @@ public class WxRentContractController extends BaseController { WxBillRentMapper wxBillRentMapper; @Autowired WxBillPropertyMapper wxBillPropertyMapper; - @Autowired - private WxBillActionMapper wxBillActionMapper; - @Autowired - private WxBillPropertyService wxBillPropertyService; @GetMapping("autolatePay") @SystemControllerLog(description = "autolatePay") public ResultData autolatePay(String startDate, String endDate) throws Exception{ try { logger.info("账单滞纳金更新开始"); - final IdWorker idWorker = IdWorker.get(); - List billRentList = wxBillRentService.findLatePayBill(); - for (WxBillRent wxBillRent : billRentList) { - WxBillAction billAction = new WxBillAction(); - billAction.setId(idWorker.nextId()); - billAction.setUserName("系统端"); - billAction.setAction(EnumBillAction.UPDATE_LATE_PAY_MONEY.getCode()); - billAction.setBillId(wxBillRent.getId()); - BigDecimal divide = new BigDecimal(wxBillRent.getOwe()).multiply(new BigDecimal(wxBillRent.getLatePayRatio())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); - billAction.setDetails("系统计入"+ divide.toString()+"元"); - wxBillActionMapper.insertSelective(billAction); - } - - List billPropertyList = wxBillPropertyService.findLatePayBill(); - for (WxBillProperty wxBillRent : billPropertyList) { - WxBillAction billAction = new WxBillAction(); - billAction.setId(idWorker.nextId()); - billAction.setUserName("系统端"); - billAction.setAction(EnumBillAction.UPDATE_LATE_PAY_MONEY.getCode()); - billAction.setBillId(wxBillRent.getId()); - BigDecimal divide = new BigDecimal(wxBillRent.getOwe()).multiply(new BigDecimal(wxBillRent.getLatePayRatio())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); - billAction.setDetails("系统计入"+ divide.toString()+"元"); - wxBillActionMapper.insertSelective(billAction); - } + wxBillRentMapper.insertBillAction(); + wxBillPropertyMapper.insertBillAction(); + wxBillRentMapper.autoAddLatePayPrice(); wxBillPropertyMapper.autoAddLatePayPrice(); logger.info("账单滞纳金更新结束"); diff --git a/mallinkAdmin/src/main/resources/db/migration/V201908021153__L_ALTER_CONTENT.sql b/mallinkAdmin/src/main/resources/db/migration/V201908021153__L_ALTER_CONTENT.sql new file mode 100644 index 000000000..887c759c5 --- /dev/null +++ b/mallinkAdmin/src/main/resources/db/migration/V201908021153__L_ALTER_CONTENT.sql @@ -0,0 +1,2 @@ +alter table wx_rent_contract modify `late_pay_day` INT(10) DEFAULT 0; +alter table wx_property_contract modify `late_pay_day` INT(10) DEFAULT 0; \ No newline at end of file diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxCouponChannelController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxCouponChannelController.java index 0150bfadb..0e13d506f 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxCouponChannelController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxCouponChannelController.java @@ -106,8 +106,7 @@ public class WxCouponChannelController extends BaseController { wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); wxCouponChannel.setCouponStatus(EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode()); wxCouponChannel.setSortColumns(BaseEntity.SortField.UpdateDate_DESC, BaseEntity.SortField.Id_DESC); - WxCouponChannelVo vo = wxCouponChannelService.change(wxCouponChannel); - return new ResultData(vo); + return wxCouponChannelService.change(wxCouponChannel); } diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/LatePayBillActionSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/LatePayBillActionSchedule.java index b3764334b..98d1772fc 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/LatePayBillActionSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/LatePayBillActionSchedule.java @@ -1,22 +1,12 @@ package com.iformall.schedule; -import com.iformall.common.IdWorker; -import com.iformall.domain.po.WxBillAction; -import com.iformall.domain.po.WxBillProperty; -import com.iformall.domain.po.WxBillRent; -import com.iformall.enums.EnumBillAction; -import com.iformall.mapper.WxBillActionMapper; import com.iformall.mapper.WxBillPropertyMapper; import com.iformall.mapper.WxBillRentMapper; -import com.iformall.service.WxBillPropertyService; -import com.iformall.service.WxBillRentService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; -import java.math.BigDecimal; -import java.util.List; /** * @author luozukai @@ -24,13 +14,6 @@ import java.util.List; @Component public class LatePayBillActionSchedule { private final Logger logger = LoggerFactory.getLogger(this.getClass()); - - @Autowired - private WxBillRentService wxBillRentService; - @Autowired - private WxBillPropertyService wxBillPropertyService; - @Autowired - private WxBillActionMapper wxBillActionMapper; @Autowired private WxBillRentMapper wxBillRentMapper; @Autowired @@ -42,30 +25,9 @@ public class LatePayBillActionSchedule { public void updateBillStatus() { try { logger.info("账单滞纳金更新开始"); - final IdWorker idWorker = IdWorker.get(); - List billRentList = wxBillRentService.findLatePayBill(); - for (WxBillRent wxBillRent : billRentList) { - WxBillAction billAction = new WxBillAction(); - billAction.setId(idWorker.nextId()); - billAction.setUserName("系统端"); - billAction.setAction(EnumBillAction.UPDATE_LATE_PAY_MONEY.getCode()); - billAction.setBillId(wxBillRent.getId()); - BigDecimal divide = new BigDecimal(wxBillRent.getOwe()).multiply(new BigDecimal(wxBillRent.getLatePayRatio())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); - billAction.setDetails("系统计入"+ divide.toString()+"元"); - wxBillActionMapper.insertSelective(billAction); - } + wxBillRentMapper.insertBillAction(); + wxBillPropertyMapper.insertBillAction(); - List billPropertyList = wxBillPropertyService.findLatePayBill(); - for (WxBillProperty wxBillRent : billPropertyList) { - WxBillAction billAction = new WxBillAction(); - billAction.setId(idWorker.nextId()); - billAction.setUserName("系统端"); - billAction.setAction(EnumBillAction.UPDATE_LATE_PAY_MONEY.getCode()); - billAction.setBillId(wxBillRent.getId()); - BigDecimal divide = new BigDecimal(wxBillRent.getOwe()).multiply(new BigDecimal(wxBillRent.getLatePayRatio())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); - billAction.setDetails("系统计入"+ divide.toString()+"元"); - wxBillActionMapper.insertSelective(billAction); - } wxBillRentMapper.autoAddLatePayPrice(); wxBillPropertyMapper.autoAddLatePayPrice(); logger.info("账单滞纳金更新结束"); diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java b/mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java index 808f4bd0c..1b46e7207 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java @@ -40,6 +40,7 @@ public class WxScoreRules extends BaseEntity { " {\"businessId\":8,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + " {\"businessId\":9,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + " {\"businessId\":10,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + + " {\"businessId\":11,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + " {\"businessId\":6,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}" + "]}," + "{\"id\":3,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"绑定车牌1个\"}," + @@ -62,6 +63,7 @@ public class WxScoreRules extends BaseEntity { " {\"businessId\":8,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + " {\"businessId\":9,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + " {\"businessId\":10,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + + " {\"businessId\":11,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + " {\"businessId\":6,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}" + "]}," + "{\"id\":3,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"绑定车牌1个\"}," + diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxBillPropertyMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxBillPropertyMapper.java index 53ce3ae72..d7511c725 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxBillPropertyMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxBillPropertyMapper.java @@ -52,4 +52,9 @@ public interface WxBillPropertyMapper extends CommonMapper * 累加每一天的滞纳金 */ void autoAddLatePayPrice(); + + /** + * 保存billAction + */ + void insertBillAction(); } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxBillRentMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxBillRentMapper.java index 67f7bf2e4..b39254a4b 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxBillRentMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxBillRentMapper.java @@ -49,4 +49,9 @@ public interface WxBillRentMapper extends CommonMapper { * 累加每一天的滞纳金 */ void autoAddLatePayPrice(); + + /** + * 保存billAction + */ + void insertBillAction(); } diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java index 70974113c..70d3b5043 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java @@ -70,6 +70,6 @@ public interface WxCouponChannelService { void updateStatusByCouponId(Long couponId,String tenantId,int status); - WxCouponChannelVo change(WxCouponChannel wxCouponChannel); + ResultData change(WxCouponChannel wxCouponChannel); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java index 9b5b86653..12f5447b7 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java @@ -4,6 +4,7 @@ import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.iformall.common.ErrorCode; import com.iformall.common.IdWorker; +import com.iformall.common.Result; import com.iformall.common.ResultData; import com.iformall.domain.po.WxCoupon; import com.iformall.domain.po.WxCouponChannel; @@ -138,7 +139,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { } @Override - public WxCouponChannelVo change(WxCouponChannel record) { + public ResultData change(WxCouponChannel record) { Long couponId = 0L; if (record.getCouponId() != null) { couponId = record.getCouponId(); @@ -146,10 +147,13 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { } List voList = wxCouponChannelMapper.findVoList(record); if (voList.isEmpty()) { - return null; + return new ResultData(Result.SUCCESS, "查询成功", null); } + Map data = new HashMap<>(); if (voList.size() == 1) { - return voList.get(0); + data.put("size", 1); + data.put("data", voList.get(0)); + return new ResultData(Result.SUCCESS, "查询成功", data); } Long finalCouponId = couponId; voList = voList.stream() @@ -157,7 +161,9 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { .collect(Collectors.toList()); int size = voList.size(); Random random = new Random(); - return voList.get(random.nextInt(size)); + data.put("size", size); + data.put("data", voList.get(random.nextInt(size))); + return new ResultData(Result.SUCCESS, "查询成功", data); } private boolean isCouponMerchantValid(Long couponId) { diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java index ef677e9e5..f63f42500 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -1000,6 +1000,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { return shopInfoStr; } + public Map buildRent(int receivePeriod, long[] priceArrs, List yearList, int dayType, WxRentContract wxRentContract, Long userId, int billcount, Integer isPreview, String shopInfoStr,boolean saveDb) { SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); Map resultMap = new HashedMap(); @@ -1050,8 +1051,12 @@ public class WxRentContractServiceImpl implements WxRentContractService { if(sd.format(billTimeVo.getStartDate()).equals(sd.format(billTimeVo.getEndDate()))){ needpayFront = getNeedPayMoney(wxRentContract,priceArrs[index-1],billTimeVo.getStartDate(),endDate,i,billTimeVoList.size(),saveDb); }else{ - needpayFront = getNeedPayMoney(wxRentContract,priceArrs[index-1],billTimeVo.getStartDate(),endDate,i,billTimeVoList.size(),saveDb); - needpayAfter = getNeedPayMoney(wxRentContract,priceArrs[index],endDate,billTimeVo.getEndDate(),i,billTimeVoList.size(),saveDb); + if(billTimeVo.getStartDate().before(endDate)){ + needpayFront = getNeedPayMoney(wxRentContract, priceArrs[index - 1], billTimeVo.getStartDate(), endDate, i, billTimeVoList.size(), saveDb); + needpayAfter = getNeedPayMoney(wxRentContract, priceArrs[index], endDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb); + }else{ + needpayFront = getNeedPayMoney(wxRentContract, priceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb); + } } needpay = needpayFront+needpayAfter; flag = true; diff --git a/mallinkService/src/main/resources/mapper/WxBillPropertyMapper.xml b/mallinkService/src/main/resources/mapper/WxBillPropertyMapper.xml index ca7195c3d..c536190ea 100644 --- a/mallinkService/src/main/resources/mapper/WxBillPropertyMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillPropertyMapper.xml @@ -139,9 +139,9 @@ update wx_bill_property b set b.status=#{notPaid},b.expired_day= - DATEDIFF(now(), date_add(b.receive_date,interval(select late_pay_day from wx_rent_contract where id = b.`property_contract_id`) day)) + DATEDIFF(now(), date_add(b.receive_date,interval(select late_pay_day from wx_property_contract where id = b.`property_contract_id`) day)) where b.tenant_id=#{tenantId} and b.status!=#{paid} and b.status!=6 and - DATEDIFF(now(), date_add(b.receive_date,interval(select late_pay_day from wx_rent_contract where id = b.`property_contract_id`) day)) >0 + DATEDIFF(now(), date_add(b.receive_date,interval(select late_pay_day from wx_property_contract where id = b.`property_contract_id`) day)) >0 @@ -226,17 +226,41 @@ AND date_format(starttime,'%Y-%m-%d 00:00:00.0') = #{starttime} AND date_format(endtime,'%Y-%m-%d 00:00:00.0') = #{endtime} - + and DATEDIFF(now(), date_add(b.receive_date,interval(c.late_pay_day) day)) >0 + and b.status!=3 and b.status!=6 + - update wx_bill_property b set b.late_pay_price = b.late_pay_price + - round( - b.owe * (select late_pay_ratio from wx_property_contract where id = b.`property_contract_id`) /10000 - ,2) + update wx_bill_property b set b.late_pay_price = + if(b.late_pay_price is null, + round( + b.owe * (select late_pay_ratio from wx_property_contract where id = b.`property_contract_id`) + * DATEDIFF(now(), date_add(b.receive_date,interval(select late_pay_day from wx_property_contract where id = b.`property_contract_id`) day)) /100 + ,2) + , + b.late_pay_price + + round( + b.owe * (select late_pay_ratio from wx_property_contract where id = b.`property_contract_id`) /100 + ,2) + ) where b.status!=3 and b.status!=6 and (select late_pay_ratio from wx_property_contract where id = b.`property_contract_id`) > 0 and DATEDIFF(now(), date_add(b.receive_date,interval(select late_pay_day from wx_property_contract where id = b.`property_contract_id`) day)) >0; diff --git a/mallinkService/src/main/resources/mapper/WxBillRentMapper.xml b/mallinkService/src/main/resources/mapper/WxBillRentMapper.xml index f3fc95312..8d20ec925 100644 --- a/mallinkService/src/main/resources/mapper/WxBillRentMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillRentMapper.xml @@ -228,17 +228,41 @@ AND date_format(starttime,'%Y-%m-%d 00:00:00.0') = #{starttime} AND date_format(endtime,'%Y-%m-%d 00:00:00.0') = #{endtime} - + + insert into wx_bill_action(id,user_name,`action`,bill_id,details) + select + (select unix_timestamp(now()) + CEILING(RAND()*90000+10000)) id + ,'系统端' user_name,7 `action`,b.id bill_id, + CONCAT('系统计入', + if(b.late_pay_price is null, + round( + b.owe * c.late_pay_ratio * DATEDIFF(now(), date_add(b.receive_date,interval(c.late_pay_day) day)) /10000 + ,2) + , + round( + b.owe * (c.late_pay_ratio) /10000 + ,2) + ) + ,'元') details + from wx_bill_rent b left join wx_rent_contract c on(b.rent_contract_id=c.id) + where c.late_pay_ratio >0 + and DATEDIFF(now(), date_add(b.receive_date,interval(c.late_pay_day) day)) >0 + and b.status!=3 and b.status!=6 + - update wx_bill_rent b set b.late_pay_price = b.late_pay_price + - round( - b.owe * (select late_pay_ratio from wx_rent_contract where id = b.`rent_contract_id`) /10000 - ,2) + update wx_bill_rent b set b.late_pay_price = + if(b.late_pay_price is null, + round( + b.owe * (select late_pay_ratio from wx_rent_contract where id = b.`rent_contract_id`) + * DATEDIFF(now(), date_add(b.receive_date,interval(select late_pay_day from wx_rent_contract where id = b.`rent_contract_id`) day)) /100 + ,2) + , + b.late_pay_price + + round( + b.owe * (select late_pay_ratio from wx_rent_contract where id = b.`rent_contract_id`) /100 + ,2) + ) where b.status!=3 and b.status!=6 and (select late_pay_ratio from wx_rent_contract where id = b.`rent_contract_id`) > 0 and DATEDIFF(now(), date_add(b.receive_date,interval(select late_pay_day from wx_rent_contract where id = b.`rent_contract_id`) day)) >0;