diff --git a/mallinkAdmin/src/main/resources/db/migration/V202411000000001.sql b/mallinkAdmin/src/main/resources/db/migration/V202411000000001.sql index 749b57bb6..80499ca38 100644 --- a/mallinkAdmin/src/main/resources/db/migration/V202411000000001.sql +++ b/mallinkAdmin/src/main/resources/db/migration/V202411000000001.sql @@ -166,6 +166,108 @@ alter table wx_all_bill_97 drop column merchant_id; alter table wx_all_bill_98 drop column merchant_id; alter table wx_all_bill_99 drop column merchant_id; +alter table wx_all_bill_0 drop column shop_number; +alter table wx_all_bill_1 drop column shop_number; +alter table wx_all_bill_2 drop column shop_number; +alter table wx_all_bill_3 drop column shop_number; +alter table wx_all_bill_4 drop column shop_number; +alter table wx_all_bill_5 drop column shop_number; +alter table wx_all_bill_6 drop column shop_number; +alter table wx_all_bill_7 drop column shop_number; +alter table wx_all_bill_8 drop column shop_number; +alter table wx_all_bill_9 drop column shop_number; +alter table wx_all_bill_10 drop column shop_number; +alter table wx_all_bill_11 drop column shop_number; +alter table wx_all_bill_12 drop column shop_number; +alter table wx_all_bill_13 drop column shop_number; +alter table wx_all_bill_14 drop column shop_number; +alter table wx_all_bill_15 drop column shop_number; +alter table wx_all_bill_16 drop column shop_number; +alter table wx_all_bill_17 drop column shop_number; +alter table wx_all_bill_18 drop column shop_number; +alter table wx_all_bill_19 drop column shop_number; +alter table wx_all_bill_20 drop column shop_number; +alter table wx_all_bill_21 drop column shop_number; +alter table wx_all_bill_22 drop column shop_number; +alter table wx_all_bill_23 drop column shop_number; +alter table wx_all_bill_24 drop column shop_number; +alter table wx_all_bill_25 drop column shop_number; +alter table wx_all_bill_26 drop column shop_number; +alter table wx_all_bill_27 drop column shop_number; +alter table wx_all_bill_28 drop column shop_number; +alter table wx_all_bill_29 drop column shop_number; +alter table wx_all_bill_30 drop column shop_number; +alter table wx_all_bill_31 drop column shop_number; +alter table wx_all_bill_32 drop column shop_number; +alter table wx_all_bill_33 drop column shop_number; +alter table wx_all_bill_34 drop column shop_number; +alter table wx_all_bill_35 drop column shop_number; +alter table wx_all_bill_36 drop column shop_number; +alter table wx_all_bill_37 drop column shop_number; +alter table wx_all_bill_38 drop column shop_number; +alter table wx_all_bill_39 drop column shop_number; +alter table wx_all_bill_40 drop column shop_number; +alter table wx_all_bill_41 drop column shop_number; +alter table wx_all_bill_42 drop column shop_number; +alter table wx_all_bill_43 drop column shop_number; +alter table wx_all_bill_44 drop column shop_number; +alter table wx_all_bill_45 drop column shop_number; +alter table wx_all_bill_46 drop column shop_number; +alter table wx_all_bill_47 drop column shop_number; +alter table wx_all_bill_48 drop column shop_number; +alter table wx_all_bill_49 drop column shop_number; +alter table wx_all_bill_50 drop column shop_number; +alter table wx_all_bill_51 drop column shop_number; +alter table wx_all_bill_52 drop column shop_number; +alter table wx_all_bill_53 drop column shop_number; +alter table wx_all_bill_54 drop column shop_number; +alter table wx_all_bill_55 drop column shop_number; +alter table wx_all_bill_56 drop column shop_number; +alter table wx_all_bill_57 drop column shop_number; +alter table wx_all_bill_58 drop column shop_number; +alter table wx_all_bill_59 drop column shop_number; +alter table wx_all_bill_60 drop column shop_number; +alter table wx_all_bill_61 drop column shop_number; +alter table wx_all_bill_62 drop column shop_number; +alter table wx_all_bill_63 drop column shop_number; +alter table wx_all_bill_64 drop column shop_number; +alter table wx_all_bill_65 drop column shop_number; +alter table wx_all_bill_66 drop column shop_number; +alter table wx_all_bill_67 drop column shop_number; +alter table wx_all_bill_68 drop column shop_number; +alter table wx_all_bill_69 drop column shop_number; +alter table wx_all_bill_70 drop column shop_number; +alter table wx_all_bill_71 drop column shop_number; +alter table wx_all_bill_72 drop column shop_number; +alter table wx_all_bill_73 drop column shop_number; +alter table wx_all_bill_74 drop column shop_number; +alter table wx_all_bill_75 drop column shop_number; +alter table wx_all_bill_76 drop column shop_number; +alter table wx_all_bill_77 drop column shop_number; +alter table wx_all_bill_78 drop column shop_number; +alter table wx_all_bill_79 drop column shop_number; +alter table wx_all_bill_80 drop column shop_number; +alter table wx_all_bill_81 drop column shop_number; +alter table wx_all_bill_82 drop column shop_number; +alter table wx_all_bill_83 drop column shop_number; +alter table wx_all_bill_84 drop column shop_number; +alter table wx_all_bill_85 drop column shop_number; +alter table wx_all_bill_86 drop column shop_number; +alter table wx_all_bill_87 drop column shop_number; +alter table wx_all_bill_88 drop column shop_number; +alter table wx_all_bill_89 drop column shop_number; +alter table wx_all_bill_90 drop column shop_number; +alter table wx_all_bill_91 drop column shop_number; +alter table wx_all_bill_92 drop column shop_number; +alter table wx_all_bill_93 drop column shop_number; +alter table wx_all_bill_94 drop column shop_number; +alter table wx_all_bill_95 drop column shop_number; +alter table wx_all_bill_96 drop column shop_number; +alter table wx_all_bill_97 drop column shop_number; +alter table wx_all_bill_98 drop column shop_number; +alter table wx_all_bill_99 drop column shop_number; + + alter table wx_all_bill_0 modify column shop_id bigint(20) not null; alter table wx_all_bill_1 modify column shop_id bigint(20) not null; alter table wx_all_bill_2 modify column shop_id bigint(20) not null; diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxAllBill.java b/mallinkService/src/main/java/com/iformall/domain/po/WxAllBill.java index 9453638a6..a47101b5e 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxAllBill.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxAllBill.java @@ -39,6 +39,7 @@ public class WxAllBill extends TenantEntity { public Long shopId; @Excel(name = "商铺号", width = 20, orderNum = "1") + @TableField(exist = false) public String shopNumber; @Excel(name = "制单时间", format = "yyyy-MM-dd HH:mm:ss", width = 20, orderNum = "13") @@ -419,8 +420,6 @@ public class WxAllBill extends TenantEntity { @TableField(exist = false) private String cusPhone; @TableField(exist = false) - private String queryShopNumber; - @TableField(exist = false) private Date receiveDateEnd; @TableField(exist = false) private List shopIdList; diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxMerchant.java b/mallinkService/src/main/java/com/iformall/domain/po/WxMerchant.java index bee3c4efc..cea49c69f 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxMerchant.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxMerchant.java @@ -449,10 +449,6 @@ public class WxMerchant extends TenantEntity { private String initLog; - //账单完结备注 - @TableField(exist = false) - private String billCompleteRemark; - @TableField(exist = false) private String shopNumber; @TableField(exist = false) diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxShop.java b/mallinkService/src/main/java/com/iformall/domain/po/WxShop.java index 030df17bc..09ea92f69 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxShop.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxShop.java @@ -197,7 +197,6 @@ public class WxShop extends TenantEntity { private List typeList; @TableField(exist = false) private String queryShopNumber; - @TableField(exist = false) private Date starttime; @TableField(exist = false) @@ -229,6 +228,9 @@ public class WxShop extends TenantEntity { @TableField(exist = false) public String feesIdListStr; @TableField(exist = false) - public List feesIdList; + public List feesIdList; + //账单完结备注 + @TableField(exist = false) + private String billCompleteRemark; } diff --git a/mallinkService/src/main/java/com/iformall/service/WxAllBillService.java b/mallinkService/src/main/java/com/iformall/service/WxAllBillService.java index 80eb56241..a39275626 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxAllBillService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxAllBillService.java @@ -10,6 +10,7 @@ import com.iformall.domain.po.WxMerchant; import com.iformall.domain.po.WxMerchantBUser; import com.iformall.domain.po.WxPropertyContract; import com.iformall.domain.po.WxRentContract; +import com.iformall.domain.po.WxShop; import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.WxBillHotNotify; import com.iformall.domain.vo.WxBillNotify; @@ -53,7 +54,7 @@ public interface WxAllBillService { void bad(WxBillPayDTO dto,MallUserInfo user); - void completeBill(EnumBillStatus status,WxMerchant wxMerchant,MallUserInfo user); + void completeBill(EnumBillStatus status,WxShop wxShop,MallUserInfo user); List getMerchantAdvanceGroupSumList(WxAllBill wxBillRent); @@ -79,8 +80,6 @@ public interface WxAllBillService { ResultData saveOrUpdate(WxAllBill record, MallUserInfo user); - ResultData updateRevenue(WxAllBill wxBillRent, MallUserInfo user); - void exportBill(HttpServletRequest request, HttpServletResponse response, WxAllBill wxBillRent); void deleteEnergyReadingBills(WxAllBill wxBillDaily); diff --git a/mallinkService/src/main/java/com/iformall/service/helper/WxBillAllHelper.java b/mallinkService/src/main/java/com/iformall/service/helper/WxBillAllHelper.java index 9a3b91f88..bc139baed 100644 --- a/mallinkService/src/main/java/com/iformall/service/helper/WxBillAllHelper.java +++ b/mallinkService/src/main/java/com/iformall/service/helper/WxBillAllHelper.java @@ -361,8 +361,8 @@ public class WxBillAllHelper { wxAllBillService.bad(dto, user); } - public void completeBill(EnumBillStatus status,WxMerchant wxMerchant,MallUserInfo user) { - wxAllBillService.completeBill(status,wxMerchant, user); + public void completeBill(EnumBillStatus status,WxShop wxShop,MallUserInfo user) { + wxAllBillService.completeBill(status,wxShop, user); } public List getMerchantAdvanceGroupSumList(WxAllBill bill) { @@ -458,11 +458,6 @@ public class WxBillAllHelper { wxAllBillService.propertyContractStop(propertyContract, user); } - //终止商户除了租赁账单以外的 - public void stopMerchantOtherBills(WxMerchant wxMerchant,MallUserInfo user) { - wxAllBillService.stopMerchantBills(wxMerchant, user); - } - public void saveOrUpdateBill(WxAllBill bill,MallUserInfo user) { wxAllBillService.saveOrUpdate(bill, user); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxAllBillServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxAllBillServiceImpl.java index 1ac58b9c2..8a28eecdb 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxAllBillServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxAllBillServiceImpl.java @@ -479,14 +479,14 @@ public class WxAllBillServiceImpl extends WxBillBaseService implements WxAllBill } @Override - public void completeBill(EnumBillStatus status, WxMerchant wxMerchant, MallUserInfo user) { + public void completeBill(EnumBillStatus status, WxShop wxShop, MallUserInfo user) { WxAllBill bill = new WxAllBill(); - bill.updateTenantInfo(wxMerchant); - bill.setFloorForRule(wxMerchant.getFloorForRule()); - bill.setBusinessForRule(wxMerchant.getBusinessForRule()); - bill.setBuilding(wxMerchant.getBuilding()); - bill.setFloor(wxMerchant.getFloor()); - bill.setMerchantId(wxMerchant.getId()); + bill.updateTenantInfo(wxShop); + bill.setFloorForRule(wxShop.getFloorForRule()); + bill.setBusinessForRule(wxShop.getBusinessForRule()); + bill.setBuilding(wxShop.getBuilding()); + bill.setFloor(wxShop.getFloor()); + bill.setShopId(wxShop.getId()); //bill.setStatus(status.getCode()); updateQueryParam(bill); PageInfo bpage = this.listAsPage(bill, 1, 100); @@ -508,7 +508,7 @@ public class WxAllBillServiceImpl extends WxBillBaseService implements WxAllBill wxBillAction.setBillType(b.getBillType()); wxBillAction.setAction(EnumBillAction.STATUS_CHANGE.getCode()); //wxBillAction.setDetails(EnumBillAction.STATUS_CHANGE.getDescription(null, null,null,null,EnumBillStatus.getEnum(b.getStatus()),EnumBillStatus.INVALID)); - wxBillAction.setRemark(wxMerchant.getBillCompleteRemark()); + wxBillAction.setRemark(wxShop.getBillCompleteRemark()); this.addBillAction(wxBillAction, user); } } @@ -691,41 +691,41 @@ public class WxAllBillServiceImpl extends WxBillBaseService implements WxAllBill @Override public void stopMerchantBills(WxMerchant wxMerchant, MallUserInfo userInfo) { - WxAllBill ddel = new WxAllBill(); - ddel.setMerchantId(wxMerchant.getId()); - ddel.updateTenantInfo(wxMerchant); - ddel.setShopEndtime(new Date()); - wxAllBillMapper.deleteNoNeedPayBill(ddel); - - - WxAllBill wxBillRent = new WxAllBill(); - wxBillRent.setMerchantId(wxMerchant.getId()); - wxBillRent.updateTenantInfo(wxMerchant); - List brList = wxAllBillMapper.findList(wxBillRent); - List realRentList = new ArrayList(); - List actionList = new ArrayList(); - Date current = DateUtils.getDayEnd(new Date()); - if (null != brList && brList.size() > 0 ) { - for (int i = 0 ; i < brList.size() ; i ++ ) { - WxAllBill brent = brList.get(i); - WxBillAction action = new WxBillAction(); - boolean isUpdate = wxBillAllHelper.billEndCalcute(2,current, brent, action); - if (isUpdate) { - realRentList.add(brent); - actionList.add(action); - } - } - } - - for (int i = 0 ; i < realRentList.size() ; i ++) { - WxAllBill rbrent = realRentList.get(i); - wxAllBillMapper.updateById(rbrent); - } - - for (int i = 0 ; i < actionList.size() ; i ++) { - WxBillAction ba = actionList.get(i); - this.addBillAction(ba, userInfo); - } +// WxAllBill ddel = new WxAllBill(); +// ddel.setMerchantId(wxMerchant.getId()); +// ddel.updateTenantInfo(wxMerchant); +// ddel.setShopEndtime(new Date()); +// wxAllBillMapper.deleteNoNeedPayBill(ddel); +// +// +// WxAllBill wxBillRent = new WxAllBill(); +// wxBillRent.setMerchantId(wxMerchant.getId()); +// wxBillRent.updateTenantInfo(wxMerchant); +// List brList = wxAllBillMapper.findList(wxBillRent); +// List realRentList = new ArrayList(); +// List actionList = new ArrayList(); +// Date current = DateUtils.getDayEnd(new Date()); +// if (null != brList && brList.size() > 0 ) { +// for (int i = 0 ; i < brList.size() ; i ++ ) { +// WxAllBill brent = brList.get(i); +// WxBillAction action = new WxBillAction(); +// boolean isUpdate = wxBillAllHelper.billEndCalcute(2,current, brent, action); +// if (isUpdate) { +// realRentList.add(brent); +// actionList.add(action); +// } +// } +// } +// +// for (int i = 0 ; i < realRentList.size() ; i ++) { +// WxAllBill rbrent = realRentList.get(i); +// wxAllBillMapper.updateById(rbrent); +// } +// +// for (int i = 0 ; i < actionList.size() ; i ++) { +// WxBillAction ba = actionList.get(i); +// this.addBillAction(ba, userInfo); +// } } @Override @@ -768,136 +768,13 @@ public class WxAllBillServiceImpl extends WxBillBaseService implements WxAllBill return months; } - @Override - @Transactional(rollbackFor = {Exception.class}) - public ResultData updateRevenue(WxAllBill record, MallUserInfo user) { - WxAllBill wxBillRent = wxAllBillMapper.selectById(record.getId(),user.getTenantId()); - WxRentContract wxRentContract = wxRentContractMapper.selectById(wxBillRent.getRentContractId()); - SimpleDateFormat sdD = new SimpleDateFormat("d"); - SimpleDateFormat sdM = new SimpleDateFormat("yyyy-MM"); - - int startInt = Integer.parseInt(sdD.format(wxBillRent.getStarttime())); - int endInt = Integer.parseInt(sdD.format(DateUtils.getDaySet(wxBillRent.getEndtime(),Calendar.DATE,1))); - int months = getMonths(sdM.format(wxBillRent.getStarttime())+"-01",sdM.format(DateUtils.getDaySet(wxBillRent.getEndtime(),Calendar.DATE,1))+"-01"); - - //wxBillRent.setRevenue(record.getRevenue()); - - String ratio = "0"; - RatioVo ratioVo = null; - if(StringUtils.isNotBlank(wxRentContract.getPayRatio())){ - ratio = wxRentContract.getPayRatio(); - }else{ -// if(StringUtils.isNotBlank(wxRentContract.getBusDiscountRatio())){ -// long dayCount = DateUtils.startToEnd(wxBillRent.getStarttime(),wxBillRent.getEndtime()) + 1; -// if(EnumBusRatioTime.YEAR.getCode().equals(wxRentContract.getBusDiscountTime())){ -// if(startInt == endInt && months == 12){ -// //刚好1年 -// ratioVo = WxRentContractServiceImpl.getPayRatio(Constant.default_long_decimal_size,EnumGetRatioFrom.BILL.getCode(), -// wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.OTHER.getCode(),dayCount,0,null); -// }else{ -// ratioVo = WxRentContractServiceImpl.getPayRatio(Constant.default_long_decimal_size,EnumGetRatioFrom.BILL.getCode(), -// wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.YEAR.getCode(),dayCount,0,null); -// } -// }else if(EnumBusRatioTime.MONTH.getCode().equals(wxRentContract.getBusDiscountTime())){ -// if(startInt == endInt && months == 1){ -// //刚好1个月 -// ratioVo = WxRentContractServiceImpl.getPayRatio(Constant.default_long_decimal_size,EnumGetRatioFrom.BILL.getCode(), -// wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.OTHER.getCode(),dayCount,0,null); -// }else{ -// ratioVo = WxRentContractServiceImpl.getPayRatio(Constant.default_long_decimal_size,EnumGetRatioFrom.BILL.getCode(), -// wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(),EnumMissTimeType.MONTH.getCode(),dayCount,0,null); -// } -// }else if(EnumBusRatioTime.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())){ -// ratioVo = WxRentContractServiceImpl.getPayRatio(Constant.default_long_decimal_size,EnumGetRatioFrom.BILL.getCode(),wxBillRent.getRevenue(),wxRentContract.getBusDiscountRatio(), -// EnumMissTimeType.PERIOD.getCode(),dayCount,wxRentContract.getReceivePeriod(),wxRentContract.getReceivePeriodUnit()); -// } -// } - } - - String newReceivePay; - if(ratioVo != null){ - newReceivePay = ratioVo.getPrice(); - //wxBillRent.setPayRatio(ratioVo.getRatio().longValue()); - //如果在跳点区间中,修改扣点率 -// if(StringUtils.isNotBlank(wxRentContract.getBusDiscountRatio())){ -// //wxBillRent.setBusDiscountRatio(ratioVo.getUseRatio()); -// } - }else{ - //BigDecimal revenue = new BigDecimal(StringUtils.isBlank(record.getRevenue()) ? "0" : record.getRevenue()); - BigDecimal revenue = new BigDecimal(0); - BigDecimal payRatio = new BigDecimal(ratio).divide(new BigDecimal(10000)); - BigDecimal price = revenue.multiply(payRatio).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN); - newReceivePay = price.toPlainString(); - } - //wxBillRent.setJoinRentPrice(newReceivePay); - if(new BigDecimal(newReceivePay).compareTo(new BigDecimal(wxBillRent.getReceivePay())) > 0){ - wxBillRent.setReceivePay(newReceivePay); - } - - String oldPrice = wxBillRent.getReceivePay(); - String newPrice = newReceivePay; - wxBillRent.setUpdatetime(new Date()); - wxBillRent.setUpdateBy(user.getId()); - wxBillRent.setUpdateByName(user.getName()); - String latePayPrice = StringUtils.isBlank(wxBillRent.getBillLatePay()) ? "0" : wxBillRent.getBillLatePay(); - //wxBillRent.setOwe(new BigDecimal(newPrice).add(new BigDecimal(wxBillRent.getServiceChargePay())).add(new BigDecimal(latePayPrice)).subtract(new BigDecimal(wxBillRent.getPay())).toPlainString()); - //wxBillRent.setOwe(new BigDecimal(newPrice).subtract(new BigDecimal(wxBillRent.getPay())).toPlainString()); - wxAllBillMapper.updateById(wxBillRent); - - if (!oldPrice.equals(newPrice)) { - //日志 - WxBillAction wxBillAction = new WxBillAction(); - wxBillAction.updateTenantInfo(user); - wxBillAction.setBillId(wxBillRent.getId()); - String oldPriceStr = new BigDecimal(oldPrice).divide(new BigDecimal(100)).toPlainString(); - String newPriceStr = new BigDecimal(newPrice).divide(new BigDecimal(100)).toPlainString(); - wxBillAction.setDetails("录入营业额时应收金额" + oldPriceStr + "元变更成" + newPriceStr + "元"); - wxBillAction.setAction(EnumBillAction.UPDATE_BILL.getCode()); - wxBillAction.setUserId(user.getId()); - wxBillAction.setUserName(user.getName()); - wxBillAction.setPhone(user.getPhone()); - wxBillAction.updateTenantInfo(wxBillRent); - try { - wxBillActionService.save(wxBillAction); - } catch (Exception e) { - logger.error("添加租赁账单行为日志,e:" + e.getMessage()); - throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "修改营业额失败"); - } - } - return new ResultData(Result.SUCCESS, "修改营业额成功", wxBillRent); - } - @Override public void exportBill(HttpServletRequest request, HttpServletResponse response, WxAllBill wxBillRent) { String billName = "账单"; PageInfo billRentList = listAsPage(wxBillRent,1,10000); List datalist = new ArrayList(); if (null != billRentList && null != billRentList.getList()) { - Map> collect = billRentList.getList().parallelStream() - .collect(Collectors.groupingBy(WxAllBill::getMerchantId)); - Set>> entries = collect.entrySet(); - for (Map.Entry> entry : entries) { - List list = entry.getValue(); - for (WxAllBill rent : list) { - //if (rent.getDepositStatus() == null) { - // rent.setDepositStatus(0); - //} - String shopNumber = rent.getShopNumber(); - if (StringUtils.isEmpty(shopNumber)) { - String shopInfo = rent.getShopInfo(); - if (StringUtils.isNotEmpty(shopInfo) && !shopInfo.equals("[]")) { - JSONObject jsonObject = JSONObject.parseObject(shopInfo); - StringBuffer sb = new StringBuffer(); - Set> sets = jsonObject.entrySet(); - sets.forEach(x -> sb.append(x.getKey()).append(",")); - if(StringUtils.isNotBlank(sb)){ - rent.setShopNumber(sb.deleteCharAt(sb.length() - 1).toString()); - } - } - } - datalist.add(rent); - } - } + datalist = billRentList.getList(); } excelService.exportExcel(datalist, null, billName, WxAllBill.class, billName + ".xlsx", response, false); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java index ed134cc33..967760a13 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java @@ -372,15 +372,6 @@ public class WxMerchantServiceImpl implements WxMerchantService { wxMerchantShop.setIsDel(EnumDelStatus.NOT_DEL.getCode()); List> shops = new ArrayList<>(); - - WxRentContract wxRentContract = new WxRentContract(); - wxRentContract.setMerchantId(wxMerchant.getId()); - //List lrc = wxRentContractMapper.selectRentContractByMerchantId(wxRentContract); - //if (!lrc.isEmpty()) { - // wxMerchant.setRentalStartDate(lrc.get(0).getRentalStartDate()); - // wxMerchant.setRentalEndDate(lrc.get(0).getRentalEndDate()); - //} - List wxMerchantShopList = wxMerchantShopMapper.findList(wxMerchantShop); for (WxMerchantShop merchantShop : wxMerchantShopList) { WxShop record = new WxShop(); @@ -488,75 +479,48 @@ public class WxMerchantServiceImpl implements WxMerchantService { logger.info("不能停用停车商户"); return; } - //是否有租赁合同 - //查询该商户下是否有计租中和已签约未计租类型的合同 - WxRentContract wxRentContract = new WxRentContract(); - wxRentContract.setMerchantId(id); - long countRentContract = wxRentContractMapper.selectList(new QueryWrapper<>(wxRentContract)).parallelStream(). - filter(c -> EnumRentContractStatus.getValidStatus().contains(c.getStatus())).count(); - if(countRentContract > 0){ - throw new MallinkException(ErrorCode.SHOP_CONTRACT_HAS_CONNECT.getCode(),"存在租赁合同"); + wxMerchant.setStatus(EnumMerchantStatus.NOT_VALID.getCode()); + wxMerchant.setUpdateDate(new Date()); + wxMerchantMapper.updateById(wxMerchant); + WxMerchantShop wxMerchantShopQuery = new WxMerchantShop(); + wxMerchantShopQuery.updateTenantInfo(wxMerchant); + wxMerchantShopQuery.setMerchantId(wxMerchant.getId()); + wxMerchantShopQuery.setIsDel(EnumDelStatus.NOT_DEL.getCode()); + List wxMerchantShopList = wxMerchantShopMapper.findList(wxMerchantShopQuery); + for (WxMerchantShop wxMerchantShop : wxMerchantShopList) { + wxMerchantShop.setIsDel(EnumDelStatus.DEL.getCode()); + wxMerchantShop.setUpdateDate(new Date()); + wxMerchantShopMapper.updateById(wxMerchantShop); + //更新商铺状态 + WxShop wxShop = new WxShop(); + wxShop.updateTenantInfo(wxMerchant); + wxShop.setId(wxMerchantShop.getShopId()); + wxShop.setStatus(EnumShopStatus.NOT_RENT.getCode()); + wxShop.setUpdateDate(new Date()); + wxShopMapper.updateById(wxShop); } - //是否有物业合同 - WxPropertyContract wxPropertyContract = new WxPropertyContract(); - wxPropertyContract.setMerchantId(id); - long countPropertyContract = wxPropertyContractMapper.selectList(new QueryWrapper<>(wxPropertyContract)).parallelStream(). - filter(c -> EnumRentContractStatus.getValidStatus().contains(c.getStatus())).count(); - //商户状态停用-没有租赁合同和物业合同才允许停用 -// if (countRentContract == 0 || countPropertyContract == 0){ -// wxMerchant.setStatus(EnumMerchantStatus.NOT_VALID.getCode()); -// wxMerchantMapper.updateById(wxMerchant); -// } - if(countPropertyContract > 0){ - throw new MallinkException(ErrorCode.SHOP_CONTRACT_HAS_CONNECT.getCode(),"存在物业合同"); + //解绑用户 + WxMerchantBUser bUser = new WxMerchantBUser(); + bUser.setMerchantId(wxMerchant.getId()); + List wxMerchantBUserMapperList = wxMerchantBUserMapper.findList(bUser); + for (WxMerchantBUser wxMerchantBUser : wxMerchantBUserMapperList) { + wxMerchantBUser.setStatus(EnumMerchantBUserStatus.INVALID.getCode()); + wxMerchantBUser.setUpdateDate(new Date()); + wxMerchantBUserMapper.updateById(wxMerchantBUser); } - //解绑商铺-没有租赁合同或物业合同才可以 - if (countRentContract == 0 || countPropertyContract == 0) { - wxMerchant.setStatus(EnumMerchantStatus.NOT_VALID.getCode()); - wxMerchant.setUpdateDate(new Date()); - wxMerchantMapper.updateById(wxMerchant); - WxMerchantShop wxMerchantShopQuery = new WxMerchantShop(); - wxMerchantShopQuery.updateTenantInfo(wxMerchant); - wxMerchantShopQuery.setMerchantId(wxMerchant.getId()); - wxMerchantShopQuery.setIsDel(EnumDelStatus.NOT_DEL.getCode()); - List wxMerchantShopList = wxMerchantShopMapper.findList(wxMerchantShopQuery); - for (WxMerchantShop wxMerchantShop : wxMerchantShopList) { - wxMerchantShop.setIsDel(EnumDelStatus.DEL.getCode()); - wxMerchantShop.setUpdateDate(new Date()); - wxMerchantShopMapper.updateById(wxMerchantShop); - //更新商铺状态 - WxShop wxShop = new WxShop(); - wxShop.updateTenantInfo(wxMerchant); - wxShop.setId(wxMerchantShop.getShopId()); - wxShop.setStatus(EnumShopStatus.NOT_RENT.getCode()); - wxShop.setUpdateDate(new Date()); - wxShopMapper.updateById(wxShop); - } - //解绑用户 - WxMerchantBUser bUser = new WxMerchantBUser(); - bUser.setMerchantId(wxMerchant.getId()); - List wxMerchantBUserMapperList = wxMerchantBUserMapper.findList(bUser); - for (WxMerchantBUser wxMerchantBUser : wxMerchantBUserMapperList) { - wxMerchantBUser.setStatus(EnumMerchantBUserStatus.INVALID.getCode()); - wxMerchantBUser.setUpdateDate(new Date()); - wxMerchantBUserMapper.updateById(wxMerchantBUser); - } - //作废卡券 - WxCouponMerchant wxCouponMerchant = new WxCouponMerchant(); - wxCouponMerchant.updateTenantInfo(wxMerchant); - wxCouponMerchant.setMerchantId(wxMerchant.getId()); - wxCouponMerchant.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); - List wxCouponMerchantList = wxCouponMerchantMapper.findList(wxCouponMerchant); - List couponIds = wxCouponMerchantList.stream().map(cm -> cm.getProductId()).collect(Collectors.toList()); - - couponIds.stream().filter(cid -> !isCouponMerchantValid(cid,wxCouponMerchant)).forEach(cid -> { - wxCouponService.disable(wxMerchant,cid, null); - CouponCacheUtils.removeCouponMerchantCache(redisTemplate, cid,null); - }); + //作废卡券 + WxCouponMerchant wxCouponMerchant = new WxCouponMerchant(); + wxCouponMerchant.updateTenantInfo(wxMerchant); + wxCouponMerchant.setMerchantId(wxMerchant.getId()); + wxCouponMerchant.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); + List wxCouponMerchantList = wxCouponMerchantMapper.findList(wxCouponMerchant); + List couponIds = wxCouponMerchantList.stream().map(cm -> cm.getProductId()).collect(Collectors.toList()); + + couponIds.stream().filter(cid -> !isCouponMerchantValid(cid,wxCouponMerchant)).forEach(cid -> { + wxCouponService.disable(wxMerchant,cid, null); + CouponCacheUtils.removeCouponMerchantCache(redisTemplate, cid,null); + }); - //处理商户非租赁账单 - //wxBillAllHelper.stopMerchantOtherBills(wxMerchant, userInfo); - } } @Transactional(rollbackFor = {Exception.class}) @@ -753,17 +717,6 @@ public class WxMerchantServiceImpl implements WxMerchantService { coldShopIds.addAll(oldShopIds); oldShopIds.removeAll(shopIds); if (null != oldShopIds && oldShopIds.size() > 0 ) { - for (Long osid : oldShopIds) { - WxRentContract wrc = new WxRentContract(); - wrc.setMerchantId(wxMerchant.getId()); - wrc.setQueryShopId(osid); - wrc.setStatuss(EnumRentContractStatus.getValidStatus()); - wrc.updateTenantInfo(wxMerchant); - List clist = wxRentContractService.findList(wrc); - if (null != clist && clist.size() > 0 ) { - return new ResultData(ErrorCode.MERCHANT_HASRENTCONTRACT.getCode(),"店铺["+osid+"]存在有效的合同,不能解除绑定."); - } - } //都验证过了之后,先把之前的商铺释放,删除关系 wxShopMapper.updateUnRentByIds(oldShopIds); wxMerchantShopMapper.realDelByMerchantId(wxMerchant.getId(),oldShopIds); @@ -1214,25 +1167,6 @@ public class WxMerchantServiceImpl implements WxMerchantService { record.setAdminTypes(EnumMerchantAdmin.getOrdinaryTypes()); } - if (hasRentContractInfo) { - WxRentContract wxRentContractQ = new WxRentContract(); - wxRentContractQ.updateTenantInfo(record); - List statusList = new ArrayList(); - statusList.add(2); - statusList.add(3); - statusList.add(4); - wxRentContractQ.setStatuss(statusList); - List rentList = wxRentContractMapper.findList(wxRentContractQ); - if (null != rentList) { - for (int i = 0 ; i < rentList.size(); i++) { - WxRentContract contract = rentList.get(i); - if (null != contract && null != contract.getMerchantId()) { - merchantRentMap.put(contract.getMerchantId(), contract); - } - } - } - } - List merchantIds = record.getIds(); if (null == merchantIds) { merchantIds = new ArrayList(); @@ -1753,41 +1687,24 @@ public class WxMerchantServiceImpl implements WxMerchantService { public void disableMerchat(Long id) { WxMerchant wxMerchant = wxMerchantMapper.selectById(id); if (wxMerchant != null){ - //查询该商户下是否有计租中和已签约未计租类型的合同 - WxRentContract wxRentContract = new WxRentContract(); - wxRentContract.setMerchantId(id); - long countRentContract = wxRentContractMapper.selectList(new QueryWrapper<>(wxRentContract)).parallelStream(). -// filter(c -> c.getStatus().equals(EnumRentContractStatus.READY_FOR_PAING.getCode()) || -// c.getStatus().equals(EnumRentContractStatus.PAING.getCode())).count(); - filter(c -> EnumRentContractStatus.getValidStatus().contains(c.getStatus())).count(); - - - //是否有物业合同 - WxPropertyContract wxPropertyContract = new WxPropertyContract(); - wxPropertyContract.setMerchantId(id); - long countPropertyContract = wxPropertyContractMapper.selectList(new QueryWrapper<>(wxPropertyContract)).parallelStream(). - filter(c -> EnumRentContractStatus.getValidStatus().contains(c.getStatus())).count(); - //没有租赁合同和物业合同才允许停用商户和解绑商铺 - if (countRentContract == 0 || countPropertyContract == 0){ - //停用商户 - wxMerchant.setStatus(EnumMerchantStatus.NOT_VALID.getCode()); - wxMerchantMapper.updateById(wxMerchant); - //解绑商铺 - WxMerchantShop wxMerchantShopQuery = new WxMerchantShop(); - wxMerchantShopQuery.updateTenantInfo(wxMerchant); - wxMerchantShopQuery.setMerchantId(wxMerchant.getId()); - wxMerchantShopQuery.setIsDel(EnumDelStatus.NOT_DEL.getCode()); - List wxMerchantShopList = wxMerchantShopMapper.findList(wxMerchantShopQuery); - for (WxMerchantShop wxMerchantShop : wxMerchantShopList) { - wxMerchantShop.setIsDel(EnumDelStatus.DEL.getCode()); - wxMerchantShopMapper.updateById(wxMerchantShop); - //更新商铺状态 - WxShop wxShop = new WxShop(); - wxShop.updateTenantInfo(wxMerchant); - wxShop.setId(wxMerchantShop.getShopId()); - wxShop.setStatus(EnumShopStatus.NOT_RENT.getCode()); - wxShopMapper.updateById(wxShop); - } + //停用商户 + wxMerchant.setStatus(EnumMerchantStatus.NOT_VALID.getCode()); + wxMerchantMapper.updateById(wxMerchant); + //解绑商铺 + WxMerchantShop wxMerchantShopQuery = new WxMerchantShop(); + wxMerchantShopQuery.updateTenantInfo(wxMerchant); + wxMerchantShopQuery.setMerchantId(wxMerchant.getId()); + wxMerchantShopQuery.setIsDel(EnumDelStatus.NOT_DEL.getCode()); + List wxMerchantShopList = wxMerchantShopMapper.findList(wxMerchantShopQuery); + for (WxMerchantShop wxMerchantShop : wxMerchantShopList) { + wxMerchantShop.setIsDel(EnumDelStatus.DEL.getCode()); + wxMerchantShopMapper.updateById(wxMerchantShop); + //更新商铺状态 + WxShop wxShop = new WxShop(); + wxShop.updateTenantInfo(wxMerchant); + wxShop.setId(wxMerchantShop.getShopId()); + wxShop.setStatus(EnumShopStatus.NOT_RENT.getCode()); + wxShopMapper.updateById(wxShop); } } } diff --git a/mallinkService/src/main/resources/mapper/WxAllBillMapper.xml b/mallinkService/src/main/resources/mapper/WxAllBillMapper.xml index 35a2307d7..8a1088d6f 100644 --- a/mallinkService/src/main/resources/mapper/WxAllBillMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxAllBillMapper.xml @@ -6,7 +6,6 @@ - @@ -50,9 +49,9 @@ - `id`,`tenant_id`,`parent_tenant_id`,`createtime`,`create_by`,`create_by_name`,`updatetime`,`update_by`,`update_by_name`, + `id`,`tenant_id`,`parent_tenant_id`,`shop_id`,`createtime`,`create_by`,`create_by_name`,`updatetime`,`update_by`,`update_by_name`, `price_detail`,`need_pay`,`receive_pay`,`pay`,`bill_type`,`pay_way`,`pay_date`,`set_off`,`use_money`,`starttime`,`endtime`,`status`,`energy_fees_id`,`return_pay`, - `bill_remark`,`last_owe_call_time`,`last_owe_call_user`,`bussiness_manage_fee_need_pay`,`operating_manage_fee_need_pay`,`shop_id`,`shop_number`,`receive_date`,`period`, + `bill_remark`,`last_owe_call_time`,`last_owe_call_user`,`bussiness_manage_fee_need_pay`,`operating_manage_fee_need_pay`,`receive_date`,`period`, `is_preview`,`shop_info`,`rent_contract_id`,`rent_contract_agile_fees_type`,`property_contract_id`,`parent_bill_id`,`energy_reading_calcuteId`,`energy_reading_id`,`extra_create_from`,`rent_area`, `can_edit`,`cus_name` @@ -82,8 +81,6 @@ and `extra_create_from` is null and bill_type = 6 and IFNULL(`pay`,'0') - IFNULL(`use_money`,'0') > 0 and `can_edit` = #{canEdit} - and shop_number like concat('%',#{shopNumber},'%') - and shop_number like concat('%,',#{shopNumber},',%') and date_format(starttime,'%Y-%m') <= #{month} and date_format(endtime,'%Y-%m') >= #{month} @@ -368,12 +365,12 @@ VALUES ( - #{item.id},#{item.tenantId},#{item.parentTenantId},#{item.createtime}, + #{item.id},#{item.tenantId},#{item.parentTenantId},#{item.shopId},#{item.createtime}, #{item.createBy},#{item.createByName},#{item.updatetime},#{item.updateBy},#{item.updateByName},#{item.priceDetail}, #{item.needPay},#{item.receivePay},#{item.pay},#{item.billType},#{item.payWay},#{item.payDate},#{item.setOff},#{item.useMoney}, #{item.starttime},#{item.endtime},#{item.status},#{item.energyFeesId},#{item.returnPay},#{item.billRemark}, #{item.lastOweCallTime},#{item.lastOweCallUser},#{item.bussinessManageFeeNeedPay},#{item.operatingManageFeeNeedPay}, - #{item.shopId},#{item.shopNumber},#{item.receiveDate},#{item.period},#{item.isPreview},#{item.shopInfo},#{item.rentContractId},#{item.rentContractAgileFeesType},#{item.propertyContractId}, + #{item.receiveDate},#{item.period},#{item.isPreview},#{item.shopInfo},#{item.rentContractId},#{item.rentContractAgileFeesType},#{item.propertyContractId}, #{item.parentBillId},#{item.energyReadingCalcuteId},#{item.energyReadingId},#{item.extraCreateFrom},#{item.rentArea},#{item.canEdit},#{item.cusName} )