| @@ -10,7 +10,7 @@ import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.dto.WxPropertyContractUpdateDto; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxBillProperty; | |||
| import com.iformall.domain.po.WxAllBill; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxPropertyContract; | |||
| import com.iformall.domain.po.WxRentContract; | |||
| @@ -27,10 +27,8 @@ import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.math.BigDecimal; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| @@ -49,7 +47,7 @@ public class WxPropertyContractController extends WxContractBaseController { | |||
| @Autowired | |||
| private WxPropertyContractService wxPropertyContractService; | |||
| @Autowired | |||
| private WxBillPropertyService wxBillPropertyService; | |||
| private WxAllBillService wxAllBillService; | |||
| @Autowired | |||
| private WxPropertyContractMapper wxPropertyContractMapper; | |||
| @Autowired | |||
| @@ -585,7 +583,7 @@ public class WxPropertyContractController extends WxContractBaseController { | |||
| if(dbRent.getRentStartType()!=null && dbRent.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){ | |||
| dbRent.setRentalStartDate(dbRent.getStartDate()); | |||
| } | |||
| List<WxBillProperty> result = wxPropertyContractService.buildProperty(new WxMerchant(),getUser(),dbRent, EnumIsPreview.YES.getCode(), false); | |||
| List<WxAllBill> result = wxPropertyContractService.buildProperty(new WxMerchant(),getUser(),dbRent, EnumIsPreview.YES.getCode(), false); | |||
| return new ResultData(result); | |||
| } | |||
| @@ -13,8 +13,6 @@ import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.base.BaseEntity.SortField; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.WxBillPropertyMapper; | |||
| import com.iformall.mapper.WxBillRentMapper; | |||
| import com.iformall.mapper.WxRentContractMapper; | |||
| import com.iformall.service.*; | |||
| import com.iformall.utils.Constant; | |||
| @@ -26,7 +24,6 @@ import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.text.SimpleDateFormat; | |||
| @@ -43,7 +40,7 @@ public class WxRentContractController extends WxContractBaseController { | |||
| @Autowired | |||
| private WxRentContractService wxRentContractService; | |||
| @Autowired | |||
| private WxBillRentService wxBillRentService; | |||
| private WxAllBillService wxAllBillService; | |||
| @Autowired | |||
| private WxPayAccountBillService payAccountBillService; | |||
| @Autowired | |||
| @@ -51,10 +48,6 @@ public class WxRentContractController extends WxContractBaseController { | |||
| @Autowired | |||
| private WxRentContractMapper wxRentContractMapper; | |||
| @Autowired | |||
| WxBillRentMapper wxBillRentMapper; | |||
| @Autowired | |||
| WxBillPropertyMapper wxBillPropertyMapper; | |||
| @Autowired | |||
| private WxRentPropertyContractService wxRentPropertyContractService; | |||
| @Autowired | |||
| private WxShopService wxShopService; | |||
| @@ -255,9 +248,9 @@ public class WxRentContractController extends WxContractBaseController { | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::findById"); | |||
| // 同步欠缴状态 | |||
| WxBillRent wxBillRent = new WxBillRent(); | |||
| wxBillRent.updateTenantInfo(getTenantInfo()); | |||
| wxBillRentService.updateBillStatus(wxBillRent); | |||
| // WxAllBill wxBillRent = new WxAllBill(); | |||
| // wxBillRent.updateTenantInfo(getTenantInfo()); | |||
| // wxBillRentService.updateBillStatus(wxBillRent); | |||
| try { | |||
| Map<String, Object> data = wxRentContractService.getById(id); | |||
| return new ResultData(data); | |||
| @@ -803,7 +796,7 @@ public class WxRentContractController extends WxContractBaseController { | |||
| if(dbRent.getRentStartType()!=null && dbRent.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){ | |||
| dbRent.setRentalStartDate(dbRent.getStartDate()); | |||
| } | |||
| List<WxBillRent> result = wxRentContractService.buildRent(getUser(),dbRent, EnumIsPreview.YES.getCode(), false); | |||
| List<WxAllBill> result = wxRentContractService.buildRent(getUser(),dbRent, EnumIsPreview.YES.getCode(), false); | |||
| return new ResultData(result); | |||
| } | |||
| @@ -5,8 +5,6 @@ import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxAllBill; | |||
| import com.iformall.domain.po.WxBillProperty; | |||
| import com.iformall.domain.po.WxBillRent; | |||
| import com.iformall.domain.po.WxPropertyContract; | |||
| import com.iformall.domain.po.WxRentContract; | |||
| import com.iformall.domain.po.WxSettleMerchant; | |||
| @@ -14,9 +12,7 @@ import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.enums.EnumRentContractStatus; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.WxBillPropertyMapper; | |||
| import com.iformall.service.WxBillPropertyService; | |||
| import com.iformall.service.WxBillRentService; | |||
| import com.iformall.service.WxAllBillService; | |||
| import com.iformall.service.WxPropertyContractService; | |||
| import com.iformall.service.WxRentContractService; | |||
| import com.iformall.service.WxRentPropertyContractService; | |||
| @@ -51,14 +47,10 @@ public class WxSettleMerchantController extends BaseController { | |||
| @Autowired | |||
| private WxRentContractService wxRentContractService; | |||
| @Autowired | |||
| private WxBillRentService wxBillRentService; | |||
| private WxAllBillService wxAllBillService; | |||
| @Autowired | |||
| WxPropertyContractService wxPropertyContractService; | |||
| @Lazy | |||
| @Autowired | |||
| WxBillPropertyService wxBillPropertyService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @@ -160,14 +152,14 @@ public class WxSettleMerchantController extends BaseController { | |||
| br.setStarttime(wxSettleMerchant.getBeginTime()); | |||
| br.setEndtime(wxSettleMerchant.getEndTime()); | |||
| PageInfo<WxBillRent> rpage = wxBillRentService.findByRentContractId(br, 1, 1000); | |||
| PageInfo<WxAllBill> rpage = wxAllBillService.listAsPage(br, 1, 1000); | |||
| if (null == rpage || null == rpage.getList() || rpage.getList().size() <= 0 ) { | |||
| return new ResultData(Result.ERROR,"租金合同无对应账单"); | |||
| } | |||
| BigDecimal all = new BigDecimal(0); | |||
| List<WxBillRent> blist = rpage.getList(); | |||
| List<WxAllBill> blist = rpage.getList(); | |||
| for (int i = 0 ; i < blist.size() ; i ++) { | |||
| WxBillRent r = blist.get(i); | |||
| WxAllBill r = blist.get(i); | |||
| BigDecimal _np = new BigDecimal(0); | |||
| if (null != r.getNeedPay()) { | |||
| _np = new BigDecimal(r.getNeedPay()); | |||
| @@ -204,19 +196,19 @@ public class WxSettleMerchantController extends BaseController { | |||
| return new ResultData(Result.ERROR,"无计租中物业合同"); | |||
| } | |||
| WxPropertyContract property = rlist.get(0); | |||
| WxBillProperty br = new WxBillProperty(); | |||
| WxAllBill br = new WxAllBill(); | |||
| br.setMerchantId(wxSettleMerchant.getMerchantId()); | |||
| br.setPropertyContractId(property.getId()); | |||
| br.setStarttime(wxSettleMerchant.getBeginTime()); | |||
| br.setEndtime(wxSettleMerchant.getEndTime()); | |||
| PageInfo<WxBillProperty> blist = wxBillPropertyService.listAsPage(br,1, 10000); | |||
| PageInfo<WxAllBill> blist = wxAllBillService.listAsPage(br,1, 10000); | |||
| if (null == blist || null == blist.getList() || blist.getList().size() <= 0 ) { | |||
| return new ResultData(Result.ERROR,"物业合同无对应账单"); | |||
| } | |||
| BigDecimal all = new BigDecimal(0); | |||
| for (int i = 0 ; i < blist.getList().size() ; i ++) { | |||
| WxBillProperty r = blist.getList().get(i); | |||
| WxAllBill r = blist.getList().get(i); | |||
| String _np = "0"; | |||
| if (null != r.getNeedPay()) { | |||
| _np = r.getNeedPay(); | |||
| @@ -8,11 +8,9 @@ import cn.afterturn.easypoi.handler.inter.IExcelDataHandler; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxShop; | |||
| import com.iformall.domain.vo.WxBillDailyVo; | |||
| import com.iformall.enums.EnumDelStatus; | |||
| import com.iformall.enums.EnumShopStatus; | |||
| import com.iformall.mapper.WxShopMapper; | |||
| import com.iformall.service.WxBillDailyService; | |||
| import org.apache.shiro.session.UnknownSessionException; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -31,138 +29,138 @@ import java.util.concurrent.TimeUnit; | |||
| public class BillDailyAsyncTask { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxBillDailyService wxBillDailyService; | |||
| @Autowired | |||
| StringRedisTemplate stringRedisTemplate; | |||
| @Autowired | |||
| WxShopMapper wxShopMapper; | |||
| private class BillDailyExcelHandler extends ExcelDataHandlerDefaultImpl<WxBillDailyVo> { | |||
| @Override | |||
| public Object importHandler(WxBillDailyVo obj, String name, Object value) { | |||
| if (value == null) { | |||
| value = ""; | |||
| } | |||
| System.out.println(name + " + " + value.toString()); | |||
| return super.importHandler(obj, name, value); | |||
| } | |||
| } | |||
| private void set_redis_value(String importKey, String allCount, String allSuccessCount, String processCount, String failCount, boolean fail) { | |||
| stringRedisTemplate.opsForHash().put(importKey, "allCount", allCount); | |||
| stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", allSuccessCount); | |||
| stringRedisTemplate.opsForHash().put(importKey, "processCount", processCount); | |||
| stringRedisTemplate.opsForHash().put(importKey, "failCount", failCount); | |||
| if (fail) { | |||
| stringRedisTemplate.expire(importKey, 10, TimeUnit.SECONDS); | |||
| } | |||
| } | |||
| @Async | |||
| public void importExcelData(File file, MallUserInfo user, String importKey) { | |||
| ImportParams params = new ImportParams(); | |||
| // 需要验证 | |||
| params.setImportFields(new String[]{"商铺号*", "费用类型*", "实际应收金额(元)*", "实收金额(元)*", "缴款截止日期*", "租赁商铺类型*"}); | |||
| IExcelDataHandler<WxBillDailyVo> handler = new BillDailyAsyncTask.BillDailyExcelHandler(); | |||
| handler.setNeedHandlerFields(new String[]{"商铺号*", "费用类型*", "实际应收金额(元)*", "实收金额(元)*", "缴款截止日期*", "租赁商铺类型*"}); | |||
| params.setNeedVerify(true); | |||
| ExcelImportResult<WxBillDailyVo> datalist = null; | |||
| try { | |||
| datalist = ExcelImportUtil.importExcelMore(file, WxBillDailyVo.class, params); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| logger.error(e.getMessage()); | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| return; | |||
| } | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| if (datalist == null) { | |||
| logger.error("导入模板失败: 模板数据解析失败"); | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| return; | |||
| } | |||
| List<WxBillDailyVo> successList = datalist.getList(); | |||
| List<WxBillDailyVo> failList = datalist.getFailList(); | |||
| List<WxBillDailyVo> processList = new ArrayList<>(); | |||
| int fail = 0; | |||
| for (WxBillDailyVo vo : successList) { | |||
| //店铺 | |||
| WxShop shop = new WxShop(); | |||
| shop.setShopNumber(vo.getShopNumber()); | |||
| shop.updateTenantInfo(user); | |||
| shop.setType(vo.getRentShopType()); | |||
| shop.setStatus(EnumShopStatus.RENT.getCode()); | |||
| shop.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | |||
| WxShop wxShop = wxShopMapper.selectOne(new QueryWrapper(shop)); | |||
| if (wxShop == null) { | |||
| logger.error("店铺不存在", vo.toString()); | |||
| fail++; | |||
| continue; | |||
| } | |||
| String receivePayStr = vo.getReceivePayStr(); | |||
| BigDecimal receivePay = new BigDecimal(receivePayStr); | |||
| if (receivePay.compareTo(new BigDecimal(0)) <= 0) { | |||
| logger.error("实际应收金额小于等于0", vo.toString()); | |||
| fail++; | |||
| continue; | |||
| } | |||
| String payStr = vo.getPayStr(); | |||
| BigDecimal pay = new BigDecimal(payStr); | |||
| if (pay.compareTo(new BigDecimal(0)) < 0) { | |||
| logger.error("实收金额小于0", vo.toString()); | |||
| fail++; | |||
| continue; | |||
| } | |||
| if (receivePay.compareTo(pay) < 0) { | |||
| logger.error("实际应收金额小于实收金额", vo.toString()); | |||
| fail++; | |||
| continue; | |||
| } | |||
| vo.setReceivePay(receivePay.toPlainString()); | |||
| vo.setPay(pay.toPlainString()); | |||
| vo.updateTenantInfo(user); | |||
| vo.setShopId(wxShop.getId()); | |||
| vo.setRentShopType(wxShop.getType()); | |||
| processList.add(vo); | |||
| } | |||
| logger.info("验证通过的数量: " + processList.size()); | |||
| logger.info("验证未通过的数量: " + failList.size()); | |||
| int all_success = processList.size(); | |||
| int all_fail = failList.size() + fail; | |||
| int total = processList.size() + all_fail; | |||
| //添加到redis里 | |||
| set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); | |||
| if (processList.size() > 0) { | |||
| try { | |||
| processList.parallelStream().forEach(billDaily -> { | |||
| try { | |||
| //插入数据 | |||
| wxBillDailyService.insertData(billDaily, importKey, user); | |||
| } catch (UnknownSessionException ue) { | |||
| logger.error("session :" + ue.getMessage()); | |||
| } | |||
| }); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| e.printStackTrace(); | |||
| logger.error("导入模板失败:" + e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| // @Autowired | |||
| // private WxBillDailyService wxBillDailyService; | |||
| // | |||
| // @Autowired | |||
| // StringRedisTemplate stringRedisTemplate; | |||
| // | |||
| // @Autowired | |||
| // WxShopMapper wxShopMapper; | |||
| // | |||
| // private class BillDailyExcelHandler extends ExcelDataHandlerDefaultImpl<WxBillDailyVo> { | |||
| // @Override | |||
| // public Object importHandler(WxBillDailyVo obj, String name, Object value) { | |||
| // if (value == null) { | |||
| // value = ""; | |||
| // } | |||
| // System.out.println(name + " + " + value.toString()); | |||
| // return super.importHandler(obj, name, value); | |||
| // } | |||
| // | |||
| // } | |||
| // | |||
| // private void set_redis_value(String importKey, String allCount, String allSuccessCount, String processCount, String failCount, boolean fail) { | |||
| // stringRedisTemplate.opsForHash().put(importKey, "allCount", allCount); | |||
| // stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", allSuccessCount); | |||
| // stringRedisTemplate.opsForHash().put(importKey, "processCount", processCount); | |||
| // stringRedisTemplate.opsForHash().put(importKey, "failCount", failCount); | |||
| // if (fail) { | |||
| // stringRedisTemplate.expire(importKey, 10, TimeUnit.SECONDS); | |||
| // } | |||
| // } | |||
| // | |||
| // @Async | |||
| // public void importExcelData(File file, MallUserInfo user, String importKey) { | |||
| // ImportParams params = new ImportParams(); | |||
| // // 需要验证 | |||
| // params.setImportFields(new String[]{"商铺号*", "费用类型*", "实际应收金额(元)*", "实收金额(元)*", "缴款截止日期*", "租赁商铺类型*"}); | |||
| // IExcelDataHandler<WxBillDailyVo> handler = new BillDailyAsyncTask.BillDailyExcelHandler(); | |||
| // handler.setNeedHandlerFields(new String[]{"商铺号*", "费用类型*", "实际应收金额(元)*", "实收金额(元)*", "缴款截止日期*", "租赁商铺类型*"}); | |||
| // params.setNeedVerify(true); | |||
| // | |||
| // ExcelImportResult<WxBillDailyVo> datalist = null; | |||
| // | |||
| // try { | |||
| // datalist = ExcelImportUtil.importExcelMore(file, WxBillDailyVo.class, params); | |||
| // } catch (Exception e) { | |||
| // set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| // logger.error(e.getMessage()); | |||
| // // 删除缓存文件 | |||
| // file.delete(); | |||
| // return; | |||
| // } | |||
| // // 删除缓存文件 | |||
| // file.delete(); | |||
| // | |||
| // if (datalist == null) { | |||
| // logger.error("导入模板失败: 模板数据解析失败"); | |||
| // set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| // return; | |||
| // } | |||
| // | |||
| // List<WxBillDailyVo> successList = datalist.getList(); | |||
| // List<WxBillDailyVo> failList = datalist.getFailList(); | |||
| // List<WxBillDailyVo> processList = new ArrayList<>(); | |||
| // | |||
| // int fail = 0; | |||
| // for (WxBillDailyVo vo : successList) { | |||
| // | |||
| // //店铺 | |||
| // WxShop shop = new WxShop(); | |||
| // shop.setShopNumber(vo.getShopNumber()); | |||
| // shop.updateTenantInfo(user); | |||
| // shop.setType(vo.getRentShopType()); | |||
| // shop.setStatus(EnumShopStatus.RENT.getCode()); | |||
| // shop.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | |||
| // WxShop wxShop = wxShopMapper.selectOne(new QueryWrapper(shop)); | |||
| // if (wxShop == null) { | |||
| // logger.error("店铺不存在", vo.toString()); | |||
| // fail++; | |||
| // continue; | |||
| // } | |||
| // | |||
| // String receivePayStr = vo.getReceivePayStr(); | |||
| // BigDecimal receivePay = new BigDecimal(receivePayStr); | |||
| // if (receivePay.compareTo(new BigDecimal(0)) <= 0) { | |||
| // logger.error("实际应收金额小于等于0", vo.toString()); | |||
| // fail++; | |||
| // continue; | |||
| // } | |||
| // String payStr = vo.getPayStr(); | |||
| // BigDecimal pay = new BigDecimal(payStr); | |||
| // if (pay.compareTo(new BigDecimal(0)) < 0) { | |||
| // logger.error("实收金额小于0", vo.toString()); | |||
| // fail++; | |||
| // continue; | |||
| // } | |||
| // if (receivePay.compareTo(pay) < 0) { | |||
| // logger.error("实际应收金额小于实收金额", vo.toString()); | |||
| // fail++; | |||
| // continue; | |||
| // } | |||
| // vo.setReceivePay(receivePay.toPlainString()); | |||
| // vo.setPay(pay.toPlainString()); | |||
| // vo.updateTenantInfo(user); | |||
| // vo.setShopId(wxShop.getId()); | |||
| // vo.setRentShopType(wxShop.getType()); | |||
| // processList.add(vo); | |||
| // } | |||
| // logger.info("验证通过的数量: " + processList.size()); | |||
| // logger.info("验证未通过的数量: " + failList.size()); | |||
| // | |||
| // int all_success = processList.size(); | |||
| // int all_fail = failList.size() + fail; | |||
| // int total = processList.size() + all_fail; | |||
| // | |||
| // //添加到redis里 | |||
| // set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); | |||
| // | |||
| // if (processList.size() > 0) { | |||
| // try { | |||
| // processList.parallelStream().forEach(billDaily -> { | |||
| // try { | |||
| // //插入数据 | |||
| // wxBillDailyService.insertData(billDaily, importKey, user); | |||
| // } catch (UnknownSessionException ue) { | |||
| // logger.error("session :" + ue.getMessage()); | |||
| // } | |||
| // }); | |||
| // } catch (Exception e) { | |||
| // set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| // e.printStackTrace(); | |||
| // logger.error("导入模板失败:" + e.getMessage()); | |||
| // } | |||
| // } | |||
| // } | |||
| } | |||
| @@ -39,304 +39,304 @@ import java.util.stream.Collectors; | |||
| public class ImportTemplateTask { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | |||
| @Autowired | |||
| private WxTagsService wxTagsService; | |||
| @Autowired | |||
| StringRedisTemplate stringRedisTemplate; | |||
| @Autowired | |||
| private WxBillAllService wxBillAllService; | |||
| @Autowired | |||
| private WxMerchantMapper wxMerchantMapper; | |||
| @Async | |||
| public void importBillData(File file, MallUserInfo user, String importKey) { | |||
| ImportParams params = new ImportParams(); | |||
| // 需要验证 | |||
| params.setImportFields(new String[]{"商户名*", "费用类型*", "费用属性*", "费用所属期-开始时间*", "费用所属期-结束时间*", "收款金额(元)*", "收款日期*", "截止缴款日*", "收款方式"}); | |||
| params.setNeedVerify(true); | |||
| ExcelImportResult<WxBillExcelTemplate> datalist = null; | |||
| try { | |||
| datalist = ExcelImportUtil.importExcelMore(file, WxBillExcelTemplate.class, params); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| logger.error(e.getMessage()); | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| return; | |||
| } | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| if (datalist == null) { | |||
| logger.error("导入模板失败: 模板数据解析失败"); | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| return; | |||
| } | |||
| List<WxBillExcelTemplate> successList = datalist.getList(); | |||
| List<WxBillExcelTemplate> failList = datalist.getFailList(); | |||
| //此处判断商户是否存在 | |||
| //1 过滤重复商户名 | |||
| Set<String> merchantSet = successList.parallelStream().filter(s -> StringUtils.isNotEmpty(s.getMerchantName())) | |||
| .map(s -> StringUtils.trim(s.getMerchantName())) | |||
| .collect(Collectors.toSet()); | |||
| //2 查询商户名是否存在 | |||
| Map<String, WxMerchant> merchantMap = new HashMap<>(); | |||
| merchantSet.parallelStream().forEach(merchantName -> { | |||
| WxMerchant wxMerchantQuery = new WxMerchant(); | |||
| wxMerchantQuery.updateTenantInfo(user); | |||
| wxMerchantQuery.setName(merchantName); | |||
| wxMerchantQuery.setStatus(EnumMerchantStatus.VALID.getCode()); | |||
| WxMerchant wxMerchant = wxMerchantMapper.selectOne(new QueryWrapper(wxMerchantQuery)); | |||
| if (wxMerchant != null) { | |||
| merchantMap.put(merchantName, wxMerchant); | |||
| } | |||
| }); | |||
| //3 计失败条数 | |||
| List<WxBillExcelTemplate> billSuccessList = new ArrayList<>(); | |||
| successList.parallelStream().forEach(s -> { | |||
| if (StringUtils.isNotEmpty(s.getMerchantName()) && null != s.getBillType() | |||
| && StringUtils.isNotEmpty(s.getBillAttr()) && null != s.getStarttime() | |||
| && null != s.getEndtime() && StringUtils.isNotEmpty(s.getPayStr()) | |||
| && null != s.getPayDate() && null != s.getReceiveDate()) { | |||
| WxMerchant wxMerchant = merchantMap.get(s.getMerchantName()); | |||
| if (wxMerchant != null) { | |||
| Long merchantId = wxMerchant.getId(); | |||
| if (merchantId != null) { | |||
| s.setMerchantId(merchantId); | |||
| Integer type = wxMerchant.getType(); | |||
| s.setMerchantType(type); | |||
| billSuccessList.add(s); | |||
| } | |||
| } | |||
| } | |||
| }); | |||
| int billSuccessSize = billSuccessList.size(); | |||
| int successSize = successList.size(); | |||
| int failSize = failList.size(); | |||
| int total = successSize + failSize; | |||
| int failCount = successSize - billSuccessSize; | |||
| int all_success = billSuccessSize; | |||
| int all_fail = failSize + failCount; | |||
| logger.info("验证通过的数量: " + billSuccessSize); | |||
| logger.info("验证未通过的数量: " + failSize); | |||
| //添加到redis里 | |||
| set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); | |||
| if (billSuccessSize > 0) { | |||
| try { | |||
| billSuccessList.stream().forEach(bill -> { | |||
| try { | |||
| wxBillAllService.importBill(importKey, bill, user); | |||
| } catch (UnknownSessionException ue) { | |||
| logger.error("session :" + ue.getMessage()); | |||
| } | |||
| }); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| e.printStackTrace(); | |||
| logger.error("导入模板失败:" + e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| public void importBillDataOther(File file, MallUserInfo user, String importKey) { | |||
| ImportParams params = new ImportParams(); | |||
| // 需要验证 | |||
| params.setImportFields(new String[]{"商户名*", "费用类型*", "费用名称*", "费用所属期-开始时间*", "费用所属期-结束时间*", "实际应收金额(元)*", "收款金额(元)*", "收款日期", "截止缴款日*", "收款方式"}); | |||
| params.setNeedVerify(true); | |||
| ExcelImportResult<WxBillExcelTemplateOther> datalist = null; | |||
| try { | |||
| datalist = ExcelImportUtil.importExcelMore(file, WxBillExcelTemplateOther.class, params); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| logger.error(e.getMessage()); | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| return; | |||
| } | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| if (datalist == null) { | |||
| logger.error("导入模板失败: 模板数据解析失败"); | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| return; | |||
| } | |||
| List<WxBillExcelTemplateOther> successList = datalist.getList(); | |||
| List<WxBillExcelTemplateOther> failList = datalist.getFailList(); | |||
| //此处判断商户是否存在 | |||
| //1 过滤重复商户名 | |||
| Set<String> merchantSet = successList.parallelStream().filter(s -> StringUtils.isNotEmpty(s.getMerchantName())) | |||
| .map(s -> StringUtils.trim(s.getMerchantName())) | |||
| .collect(Collectors.toSet()); | |||
| //2 查询商户名是否存在 | |||
| Map<String, WxMerchant> merchantMap = new HashMap<>(); | |||
| merchantSet.parallelStream().forEach(merchantName -> { | |||
| WxMerchant wxMerchantQuery = new WxMerchant(); | |||
| wxMerchantQuery.updateTenantInfo(user); | |||
| wxMerchantQuery.setName(merchantName); | |||
| wxMerchantQuery.setStatus(EnumMerchantStatus.VALID.getCode()); | |||
| WxMerchant wxMerchant = wxMerchantMapper.selectOne(new QueryWrapper(wxMerchantQuery)); | |||
| if (wxMerchant != null) { | |||
| merchantMap.put(merchantName, wxMerchant); | |||
| } | |||
| }); | |||
| //3 计失败条数 | |||
| List<WxBillExcelTemplateOther> billSuccessList = new ArrayList<>(); | |||
| successList.parallelStream().forEach(s -> { | |||
| boolean flag = StringUtils.isNotEmpty(s.getMerchantName()) && null != s.getBillType() | |||
| && StringUtils.isNotEmpty(s.getBillAttr()) && null != s.getStarttime() | |||
| && null != s.getEndtime() && StringUtils.isNotEmpty(s.getPayStr()) | |||
| && null != s.getReceiveDate() && StringUtils.isNotEmpty(s.getReceivePayStr()); | |||
| if (flag) { | |||
| double pay = new BigDecimal(s.getPayStr()).doubleValue(); | |||
| //付款大于0且付款日期不为空说明是更新账单 或者 付款为0且付款日期为空是新增账单 满足其一即可继续 | |||
| flag = (pay > 0 && null != s.getPayDate()) || (pay == 0 && null == s.getPayDate()); | |||
| if (flag) { | |||
| WxMerchant wxMerchant = merchantMap.get(s.getMerchantName()); | |||
| if (wxMerchant != null) { | |||
| Long merchantId = wxMerchant.getId(); | |||
| if (merchantId != null) { | |||
| s.setMerchantId(merchantId); | |||
| Integer type = wxMerchant.getType(); | |||
| s.setMerchantType(type); | |||
| billSuccessList.add(s); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| }); | |||
| int billSuccessSize = billSuccessList.size(); | |||
| int successSize = successList.size(); | |||
| int failSize = failList.size(); | |||
| int total = successSize + failSize; | |||
| int failCount = successSize - billSuccessSize; | |||
| int all_success = billSuccessSize; | |||
| int all_fail = failSize + failCount; | |||
| logger.info("验证通过的数量: " + billSuccessSize); | |||
| logger.info("验证未通过的数量: " + failSize); | |||
| //添加到redis里 | |||
| set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); | |||
| if (billSuccessSize > 0) { | |||
| try { | |||
| billSuccessList.stream().forEach(bill -> { | |||
| try { | |||
| wxBillAllService.importBillOther(importKey, bill, user); | |||
| } catch (UnknownSessionException ue) { | |||
| logger.error("session :" + ue.getMessage()); | |||
| } | |||
| }); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| e.printStackTrace(); | |||
| logger.error("导入模板失败:" + e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| private class UserExcelHandler extends ExcelDataHandlerDefaultImpl<CUserBaseInfoT> { | |||
| @Override | |||
| public Object importHandler(CUserBaseInfoT obj, String name, Object value) { | |||
| if (value == null) { | |||
| value = ""; | |||
| } | |||
| System.out.println(name + " + " + value.toString()); | |||
| return super.importHandler(obj, name, value); | |||
| } | |||
| } | |||
| private void set_redis_value(String importKey, String allCount, String allSuccessCount, String processCount, String failCount, boolean fail) { | |||
| stringRedisTemplate.opsForHash().put(importKey, "allCount", allCount); | |||
| stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", allSuccessCount); | |||
| stringRedisTemplate.opsForHash().put(importKey, "processCount", processCount); | |||
| stringRedisTemplate.opsForHash().put(importKey, "failCount", failCount); | |||
| if (fail) { | |||
| stringRedisTemplate.expire(importKey, 10, TimeUnit.SECONDS); | |||
| } | |||
| } | |||
| @Async | |||
| public void importMemberData(File file, MallUserInfo user, String importKey) { | |||
| ImportParams params = new ImportParams(); | |||
| // 需要验证 | |||
| params.setImportFields(new String[]{"姓名", "性别", "手机号*", "微信昵称", "学历", "生日", "地址", "上次活跃时间", "注册时间", "标签", "成长值", "积分"}); | |||
| IExcelDataHandler<CUserBaseInfoT> handler = new ImportTemplateTask.UserExcelHandler(); | |||
| handler.setNeedHandlerFields(new String[]{"手机号*"}); | |||
| params.setNeedVerify(true); | |||
| ExcelImportResult<CUserBaseInfoT> datalist = null; | |||
| try { | |||
| datalist = ExcelImportUtil.importExcelMore(file, CUserBaseInfoT.class, params); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| logger.error(e.getMessage()); | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| return; | |||
| } | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| if (datalist == null) { | |||
| logger.error("导入模板失败: 模板数据解析失败"); | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| return; | |||
| } | |||
| List<CUserBaseInfoT> successList = datalist.getList(); | |||
| List<CUserBaseInfoT> failList = datalist.getFailList(); | |||
| logger.info("验证通过的数量: " + successList.size()); | |||
| logger.info("验证未通过的数量: " + failList.size()); | |||
| int total = successList.size() + failList.size(); | |||
| int all_success = successList.size(); | |||
| int all_fail = failList.size(); | |||
| //添加到redis里 | |||
| set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); | |||
| if (successList.size() > 0) { | |||
| WxTags wxTagsQ = new WxTags(); | |||
| List<WxTags> tagList = wxTagsService.findList(wxTagsQ); | |||
| try { | |||
| successList.parallelStream().forEach(uBase -> { | |||
| try { | |||
| wxCUserBasicInfoService.importOneMem(importKey, tagList, uBase, user); | |||
| } catch (UnknownSessionException ue) { | |||
| logger.error("session :" + ue.getMessage()); | |||
| } | |||
| }); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| e.printStackTrace(); | |||
| logger.error("导入模板失败:" + e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| // @Autowired | |||
| // private WxCUserBasicInfoService wxCUserBasicInfoService; | |||
| // | |||
| // @Autowired | |||
| // private WxTagsService wxTagsService; | |||
| // | |||
| // @Autowired | |||
| // StringRedisTemplate stringRedisTemplate; | |||
| // | |||
| // @Autowired | |||
| // private WxBillAllService wxBillAllService; | |||
| // | |||
| // @Autowired | |||
| // private WxMerchantMapper wxMerchantMapper; | |||
| // | |||
| // | |||
| // @Async | |||
| // public void importBillData(File file, MallUserInfo user, String importKey) { | |||
| // ImportParams params = new ImportParams(); | |||
| // // 需要验证 | |||
| // params.setImportFields(new String[]{"商户名*", "费用类型*", "费用属性*", "费用所属期-开始时间*", "费用所属期-结束时间*", "收款金额(元)*", "收款日期*", "截止缴款日*", "收款方式"}); | |||
| // params.setNeedVerify(true); | |||
| // | |||
| // ExcelImportResult<WxBillExcelTemplate> datalist = null; | |||
| // | |||
| // try { | |||
| // datalist = ExcelImportUtil.importExcelMore(file, WxBillExcelTemplate.class, params); | |||
| // } catch (Exception e) { | |||
| // set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| // logger.error(e.getMessage()); | |||
| // // 删除缓存文件 | |||
| // file.delete(); | |||
| // return; | |||
| // } | |||
| // // 删除缓存文件 | |||
| // file.delete(); | |||
| // | |||
| // if (datalist == null) { | |||
| // logger.error("导入模板失败: 模板数据解析失败"); | |||
| // set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| // return; | |||
| // } | |||
| // | |||
| // List<WxBillExcelTemplate> successList = datalist.getList(); | |||
| // List<WxBillExcelTemplate> failList = datalist.getFailList(); | |||
| // | |||
| // //此处判断商户是否存在 | |||
| // //1 过滤重复商户名 | |||
| // Set<String> merchantSet = successList.parallelStream().filter(s -> StringUtils.isNotEmpty(s.getMerchantName())) | |||
| // .map(s -> StringUtils.trim(s.getMerchantName())) | |||
| // .collect(Collectors.toSet()); | |||
| // //2 查询商户名是否存在 | |||
| // Map<String, WxMerchant> merchantMap = new HashMap<>(); | |||
| // merchantSet.parallelStream().forEach(merchantName -> { | |||
| // WxMerchant wxMerchantQuery = new WxMerchant(); | |||
| // wxMerchantQuery.updateTenantInfo(user); | |||
| // wxMerchantQuery.setName(merchantName); | |||
| // wxMerchantQuery.setStatus(EnumMerchantStatus.VALID.getCode()); | |||
| // WxMerchant wxMerchant = wxMerchantMapper.selectOne(new QueryWrapper(wxMerchantQuery)); | |||
| // if (wxMerchant != null) { | |||
| // merchantMap.put(merchantName, wxMerchant); | |||
| // } | |||
| // }); | |||
| // //3 计失败条数 | |||
| // List<WxBillExcelTemplate> billSuccessList = new ArrayList<>(); | |||
| // successList.parallelStream().forEach(s -> { | |||
| // if (StringUtils.isNotEmpty(s.getMerchantName()) && null != s.getBillType() | |||
| // && StringUtils.isNotEmpty(s.getBillAttr()) && null != s.getStarttime() | |||
| // && null != s.getEndtime() && StringUtils.isNotEmpty(s.getPayStr()) | |||
| // && null != s.getPayDate() && null != s.getReceiveDate()) { | |||
| // WxMerchant wxMerchant = merchantMap.get(s.getMerchantName()); | |||
| // if (wxMerchant != null) { | |||
| // Long merchantId = wxMerchant.getId(); | |||
| // if (merchantId != null) { | |||
| // s.setMerchantId(merchantId); | |||
| // Integer type = wxMerchant.getType(); | |||
| // s.setMerchantType(type); | |||
| // billSuccessList.add(s); | |||
| // } | |||
| // } | |||
| // } | |||
| // }); | |||
| // int billSuccessSize = billSuccessList.size(); | |||
| // int successSize = successList.size(); | |||
| // int failSize = failList.size(); | |||
| // int total = successSize + failSize; | |||
| // int failCount = successSize - billSuccessSize; | |||
| // int all_success = billSuccessSize; | |||
| // int all_fail = failSize + failCount; | |||
| // | |||
| // logger.info("验证通过的数量: " + billSuccessSize); | |||
| // logger.info("验证未通过的数量: " + failSize); | |||
| // | |||
| // //添加到redis里 | |||
| // set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); | |||
| // | |||
| // if (billSuccessSize > 0) { | |||
| // try { | |||
| // billSuccessList.stream().forEach(bill -> { | |||
| // try { | |||
| // wxBillAllService.importBill(importKey, bill, user); | |||
| // } catch (UnknownSessionException ue) { | |||
| // logger.error("session :" + ue.getMessage()); | |||
| // } | |||
| // }); | |||
| // } catch (Exception e) { | |||
| // set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| // e.printStackTrace(); | |||
| // logger.error("导入模板失败:" + e.getMessage()); | |||
| // } | |||
| // } | |||
| // } | |||
| // | |||
| // public void importBillDataOther(File file, MallUserInfo user, String importKey) { | |||
| // ImportParams params = new ImportParams(); | |||
| // // 需要验证 | |||
| // params.setImportFields(new String[]{"商户名*", "费用类型*", "费用名称*", "费用所属期-开始时间*", "费用所属期-结束时间*", "实际应收金额(元)*", "收款金额(元)*", "收款日期", "截止缴款日*", "收款方式"}); | |||
| // params.setNeedVerify(true); | |||
| // | |||
| // ExcelImportResult<WxBillExcelTemplateOther> datalist = null; | |||
| // | |||
| // try { | |||
| // datalist = ExcelImportUtil.importExcelMore(file, WxBillExcelTemplateOther.class, params); | |||
| // } catch (Exception e) { | |||
| // set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| // logger.error(e.getMessage()); | |||
| // // 删除缓存文件 | |||
| // file.delete(); | |||
| // return; | |||
| // } | |||
| // // 删除缓存文件 | |||
| // file.delete(); | |||
| // | |||
| // if (datalist == null) { | |||
| // logger.error("导入模板失败: 模板数据解析失败"); | |||
| // set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| // return; | |||
| // } | |||
| // | |||
| // List<WxBillExcelTemplateOther> successList = datalist.getList(); | |||
| // List<WxBillExcelTemplateOther> failList = datalist.getFailList(); | |||
| // | |||
| // //此处判断商户是否存在 | |||
| // //1 过滤重复商户名 | |||
| // Set<String> merchantSet = successList.parallelStream().filter(s -> StringUtils.isNotEmpty(s.getMerchantName())) | |||
| // .map(s -> StringUtils.trim(s.getMerchantName())) | |||
| // .collect(Collectors.toSet()); | |||
| // //2 查询商户名是否存在 | |||
| // Map<String, WxMerchant> merchantMap = new HashMap<>(); | |||
| // merchantSet.parallelStream().forEach(merchantName -> { | |||
| // WxMerchant wxMerchantQuery = new WxMerchant(); | |||
| // wxMerchantQuery.updateTenantInfo(user); | |||
| // wxMerchantQuery.setName(merchantName); | |||
| // wxMerchantQuery.setStatus(EnumMerchantStatus.VALID.getCode()); | |||
| // WxMerchant wxMerchant = wxMerchantMapper.selectOne(new QueryWrapper(wxMerchantQuery)); | |||
| // if (wxMerchant != null) { | |||
| // merchantMap.put(merchantName, wxMerchant); | |||
| // } | |||
| // }); | |||
| // //3 计失败条数 | |||
| // List<WxBillExcelTemplateOther> billSuccessList = new ArrayList<>(); | |||
| // successList.parallelStream().forEach(s -> { | |||
| // boolean flag = StringUtils.isNotEmpty(s.getMerchantName()) && null != s.getBillType() | |||
| // && StringUtils.isNotEmpty(s.getBillAttr()) && null != s.getStarttime() | |||
| // && null != s.getEndtime() && StringUtils.isNotEmpty(s.getPayStr()) | |||
| // && null != s.getReceiveDate() && StringUtils.isNotEmpty(s.getReceivePayStr()); | |||
| // if (flag) { | |||
| // double pay = new BigDecimal(s.getPayStr()).doubleValue(); | |||
| // //付款大于0且付款日期不为空说明是更新账单 或者 付款为0且付款日期为空是新增账单 满足其一即可继续 | |||
| // flag = (pay > 0 && null != s.getPayDate()) || (pay == 0 && null == s.getPayDate()); | |||
| // if (flag) { | |||
| // WxMerchant wxMerchant = merchantMap.get(s.getMerchantName()); | |||
| // if (wxMerchant != null) { | |||
| // Long merchantId = wxMerchant.getId(); | |||
| // if (merchantId != null) { | |||
| // s.setMerchantId(merchantId); | |||
| // Integer type = wxMerchant.getType(); | |||
| // s.setMerchantType(type); | |||
| // billSuccessList.add(s); | |||
| // } | |||
| // } | |||
| // } | |||
| // } | |||
| // }); | |||
| // int billSuccessSize = billSuccessList.size(); | |||
| // int successSize = successList.size(); | |||
| // int failSize = failList.size(); | |||
| // int total = successSize + failSize; | |||
| // int failCount = successSize - billSuccessSize; | |||
| // int all_success = billSuccessSize; | |||
| // int all_fail = failSize + failCount; | |||
| // | |||
| // logger.info("验证通过的数量: " + billSuccessSize); | |||
| // logger.info("验证未通过的数量: " + failSize); | |||
| // | |||
| // //添加到redis里 | |||
| // set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); | |||
| // | |||
| // if (billSuccessSize > 0) { | |||
| // try { | |||
| // billSuccessList.stream().forEach(bill -> { | |||
| // try { | |||
| // wxBillAllService.importBillOther(importKey, bill, user); | |||
| // } catch (UnknownSessionException ue) { | |||
| // logger.error("session :" + ue.getMessage()); | |||
| // } | |||
| // }); | |||
| // } catch (Exception e) { | |||
| // set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| // e.printStackTrace(); | |||
| // logger.error("导入模板失败:" + e.getMessage()); | |||
| // } | |||
| // } | |||
| // } | |||
| // | |||
| // private class UserExcelHandler extends ExcelDataHandlerDefaultImpl<CUserBaseInfoT> { | |||
| // @Override | |||
| // public Object importHandler(CUserBaseInfoT obj, String name, Object value) { | |||
| // if (value == null) { | |||
| // value = ""; | |||
| // } | |||
| // System.out.println(name + " + " + value.toString()); | |||
| // return super.importHandler(obj, name, value); | |||
| // } | |||
| // | |||
| // } | |||
| // | |||
| // private void set_redis_value(String importKey, String allCount, String allSuccessCount, String processCount, String failCount, boolean fail) { | |||
| // stringRedisTemplate.opsForHash().put(importKey, "allCount", allCount); | |||
| // stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", allSuccessCount); | |||
| // stringRedisTemplate.opsForHash().put(importKey, "processCount", processCount); | |||
| // stringRedisTemplate.opsForHash().put(importKey, "failCount", failCount); | |||
| // if (fail) { | |||
| // stringRedisTemplate.expire(importKey, 10, TimeUnit.SECONDS); | |||
| // } | |||
| // } | |||
| // | |||
| // @Async | |||
| // public void importMemberData(File file, MallUserInfo user, String importKey) { | |||
| // ImportParams params = new ImportParams(); | |||
| // // 需要验证 | |||
| // params.setImportFields(new String[]{"姓名", "性别", "手机号*", "微信昵称", "学历", "生日", "地址", "上次活跃时间", "注册时间", "标签", "成长值", "积分"}); | |||
| // IExcelDataHandler<CUserBaseInfoT> handler = new ImportTemplateTask.UserExcelHandler(); | |||
| // handler.setNeedHandlerFields(new String[]{"手机号*"}); | |||
| // params.setNeedVerify(true); | |||
| // | |||
| // ExcelImportResult<CUserBaseInfoT> datalist = null; | |||
| // | |||
| // try { | |||
| // datalist = ExcelImportUtil.importExcelMore(file, CUserBaseInfoT.class, params); | |||
| // } catch (Exception e) { | |||
| // set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| // logger.error(e.getMessage()); | |||
| // // 删除缓存文件 | |||
| // file.delete(); | |||
| // return; | |||
| // } | |||
| // // 删除缓存文件 | |||
| // file.delete(); | |||
| // | |||
| // if (datalist == null) { | |||
| // logger.error("导入模板失败: 模板数据解析失败"); | |||
| // set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| // return; | |||
| // } | |||
| // | |||
| // List<CUserBaseInfoT> successList = datalist.getList(); | |||
| // List<CUserBaseInfoT> failList = datalist.getFailList(); | |||
| // | |||
| // logger.info("验证通过的数量: " + successList.size()); | |||
| // logger.info("验证未通过的数量: " + failList.size()); | |||
| // | |||
| // int total = successList.size() + failList.size(); | |||
| // int all_success = successList.size(); | |||
| // int all_fail = failList.size(); | |||
| // | |||
| // //添加到redis里 | |||
| // set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); | |||
| // | |||
| // if (successList.size() > 0) { | |||
| // WxTags wxTagsQ = new WxTags(); | |||
| // List<WxTags> tagList = wxTagsService.findList(wxTagsQ); | |||
| // | |||
| // try { | |||
| // successList.parallelStream().forEach(uBase -> { | |||
| // try { | |||
| // wxCUserBasicInfoService.importOneMem(importKey, tagList, uBase, user); | |||
| // } catch (UnknownSessionException ue) { | |||
| // logger.error("session :" + ue.getMessage()); | |||
| // } | |||
| // }); | |||
| // } catch (Exception e) { | |||
| // set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| // e.printStackTrace(); | |||
| // logger.error("导入模板失败:" + e.getMessage()); | |||
| // } | |||
| // } | |||
| // } | |||
| } | |||
| @@ -31,68 +31,68 @@ import javax.servlet.http.HttpServletResponse; | |||
| public class WxBillSettleController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxBillSettleService wxBillSettleService; | |||
| @Autowired | |||
| private WxBillSettleRecordService wxBillSettleRecordService; | |||
| @Autowired | |||
| private WxBillAllService wxBillAllService; | |||
| @GetMapping("list") | |||
| @ApiOperation("账单管理-结算对冲列表") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "账单管理-结算对冲列表") | |||
| public ResultData list(@ModelAttribute WxBillSettle wxBillSettle, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxBillSettleController::list"); | |||
| if (null == wxBillSettle) { | |||
| wxBillSettle = new WxBillSettle(); | |||
| } | |||
| wxBillSettle.updateTenantInfo(getTenantInfo()); | |||
| wxBillSettle.setSortColumns(BaseEntity.SortField.Createtime_DESC,BaseEntity.SortField.Id_DESC); | |||
| final PageInfo<WxBillSettle> page = wxBillSettleService.listAsPage(wxBillSettle, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @ApiOperation("账单管理-结算单-id查找") | |||
| @SystemControllerLog(description = "账单管理-结算单-id查找") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxBillSettleController::findById"); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxBillSettleService.getById(id, EnumFilterSettle.YES.getCode())); | |||
| } | |||
| @PostMapping("addOrUpdate") | |||
| @ApiOperation("账单管理-结算单-新增或编辑") | |||
| @SystemControllerLog(description = "账单管理-结算单-新增或编辑") | |||
| public ResultData addOrUpdate(@RequestBody WxBillSettle wxBillSettle) { | |||
| logger.debug("[" + getIpAddr() + "] WxBillSettleController::addOrUpdate"); | |||
| wxBillSettle.updateTenantInfo(getTenantInfo()); | |||
| return wxBillSettleService.saveOrUpdate(wxBillSettle,getUser()); | |||
| } | |||
| @PostMapping("settle") | |||
| @ApiOperation("账单管理-结算单-结算") | |||
| @SystemControllerLog(description = "账单管理-结算单-结算") | |||
| public ResultData settle(@RequestBody WxBillSettleRecord wxBillSettleRecord) { | |||
| logger.debug("[" + getIpAddr() + "] WxBillSettleController::settle"); | |||
| wxBillSettleRecord.updateTenantInfo(getTenantInfo()); | |||
| return wxBillSettleRecordService.saveOrUpdate(wxBillSettleRecord,getUser(),null); | |||
| } | |||
| @GetMapping("exportSettle") | |||
| @SystemControllerLog(description = "账单管理-结算单-导出") | |||
| public void exportBill(@ModelAttribute WxBillSettle wxBillSettle, HttpServletRequest request, HttpServletResponse response) { | |||
| wxBillSettle.updateTenantInfo(getTenantInfo()); | |||
| wxBillSettleService.exportBill(request, response, wxBillSettle); | |||
| } | |||
| @GetMapping("downloadSettle") | |||
| @SystemControllerLog(description = "账单管理-结算单-下载") | |||
| public void downloadSettle(@ModelAttribute WxBillSettle wxBillSettle, HttpServletRequest request, HttpServletResponse response) { | |||
| wxBillSettle.updateTenantInfo(getTenantInfo()); | |||
| wxBillAllService.exportSettleBill(wxBillSettle,request,response); | |||
| } | |||
| // @Autowired | |||
| // private WxBillSettleService wxBillSettleService; | |||
| // @Autowired | |||
| // private WxBillSettleRecordService wxBillSettleRecordService; | |||
| // @Autowired | |||
| // private WxBillAllService wxBillAllService; | |||
| // | |||
| // @GetMapping("list") | |||
| // @ApiOperation("账单管理-结算对冲列表") | |||
| // @ApiImplicitParams({ | |||
| // @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| // @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| // @SystemControllerLog(description = "账单管理-结算对冲列表") | |||
| // public ResultData list(@ModelAttribute WxBillSettle wxBillSettle, Integer pageNum, Integer pageSize) { | |||
| // logger.debug("[" + getIpAddr() + "] WxBillSettleController::list"); | |||
| // if (null == wxBillSettle) { | |||
| // wxBillSettle = new WxBillSettle(); | |||
| // } | |||
| // wxBillSettle.updateTenantInfo(getTenantInfo()); | |||
| // wxBillSettle.setSortColumns(BaseEntity.SortField.Createtime_DESC,BaseEntity.SortField.Id_DESC); | |||
| // final PageInfo<WxBillSettle> page = wxBillSettleService.listAsPage(wxBillSettle, pageNum, pageSize); | |||
| // return new ResultData(page); | |||
| // } | |||
| // | |||
| // @GetMapping("/findById") | |||
| // @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| // @ApiOperation("账单管理-结算单-id查找") | |||
| // @SystemControllerLog(description = "账单管理-结算单-id查找") | |||
| // public ResultData findById(Long id) { | |||
| // logger.debug("[" + getIpAddr() + "] WxBillSettleController::findById"); | |||
| // return new ResultData(Result.SUCCESS, "查询成功", wxBillSettleService.getById(id, EnumFilterSettle.YES.getCode())); | |||
| // } | |||
| // | |||
| // @PostMapping("addOrUpdate") | |||
| // @ApiOperation("账单管理-结算单-新增或编辑") | |||
| // @SystemControllerLog(description = "账单管理-结算单-新增或编辑") | |||
| // public ResultData addOrUpdate(@RequestBody WxBillSettle wxBillSettle) { | |||
| // logger.debug("[" + getIpAddr() + "] WxBillSettleController::addOrUpdate"); | |||
| // wxBillSettle.updateTenantInfo(getTenantInfo()); | |||
| // return wxBillSettleService.saveOrUpdate(wxBillSettle,getUser()); | |||
| // } | |||
| // | |||
| // @PostMapping("settle") | |||
| // @ApiOperation("账单管理-结算单-结算") | |||
| // @SystemControllerLog(description = "账单管理-结算单-结算") | |||
| // public ResultData settle(@RequestBody WxBillSettleRecord wxBillSettleRecord) { | |||
| // logger.debug("[" + getIpAddr() + "] WxBillSettleController::settle"); | |||
| // wxBillSettleRecord.updateTenantInfo(getTenantInfo()); | |||
| // return wxBillSettleRecordService.saveOrUpdate(wxBillSettleRecord,getUser(),null); | |||
| // } | |||
| // | |||
| // @GetMapping("exportSettle") | |||
| // @SystemControllerLog(description = "账单管理-结算单-导出") | |||
| // public void exportBill(@ModelAttribute WxBillSettle wxBillSettle, HttpServletRequest request, HttpServletResponse response) { | |||
| // wxBillSettle.updateTenantInfo(getTenantInfo()); | |||
| // wxBillSettleService.exportBill(request, response, wxBillSettle); | |||
| // } | |||
| // | |||
| // @GetMapping("downloadSettle") | |||
| // @SystemControllerLog(description = "账单管理-结算单-下载") | |||
| // public void downloadSettle(@ModelAttribute WxBillSettle wxBillSettle, HttpServletRequest request, HttpServletResponse response) { | |||
| // wxBillSettle.updateTenantInfo(getTenantInfo()); | |||
| // wxBillAllService.exportSettleBill(wxBillSettle,request,response); | |||
| // } | |||
| } | |||
| @@ -36,151 +36,151 @@ import java.util.concurrent.TimeUnit; | |||
| public class WxImportTemplateController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private String fmUploadDir; | |||
| @Autowired | |||
| StringRedisTemplate stringRedisTemplate; | |||
| @Autowired | |||
| private ImportTemplateTask importTemplateTask; | |||
| private void set_redis_value(String importKey, String allCount, String allSuccessCount, String processCount, String failCount, boolean fail) { | |||
| stringRedisTemplate.opsForHash().put(importKey, "allCount", allCount); | |||
| stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", allSuccessCount); | |||
| stringRedisTemplate.opsForHash().put(importKey, "processCount", processCount); | |||
| stringRedisTemplate.opsForHash().put(importKey, "failCount", failCount); | |||
| if (fail) { | |||
| stringRedisTemplate.expire(importKey, 10, TimeUnit.SECONDS); | |||
| } | |||
| } | |||
| @PostMapping(value = "/importTemplate", consumes = "multipart/*") | |||
| @SystemControllerLog(description = "导入数据") | |||
| public ResultData importTemplate(@RequestParam("file") MultipartFile mFile, @RequestParam("type") Integer type) { | |||
| logger.debug("[" + getIpAddr() + "] WxImportTemplateController::importTemplate"); | |||
| if (mFile.isEmpty()) { | |||
| throw new MallinkException(Result.ERROR, "上传文件不能为空"); | |||
| } | |||
| //得到当前用户ID | |||
| String typeStr = EnumImportType.getEnum(type).getMessage(); | |||
| final MallUserInfo user = getUser(); | |||
| String userId = typeStr + "_" + user.getId(); | |||
| String importKey = Constant.importMemPrev + userId; | |||
| //查询当前用户得到的值是否为空,为空继续,不为空,返回模板正在导入 | |||
| Boolean allCount = stringRedisTemplate.opsForHash().hasKey(importKey, "allCount"); | |||
| if (allCount) { | |||
| return new ResultData(Result.SUCCESS, "模板正在导入"); | |||
| } | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", 0 + ""); | |||
| stringRedisTemplate.expire(importKey, 30, TimeUnit.MINUTES); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allSuccessCount", 0 + ""); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "processCount", ""); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", ""); | |||
| String fpath = fmUploadDir; | |||
| File targetFile = new File(fpath); | |||
| if (!targetFile.exists()) { | |||
| targetFile.mkdirs(); | |||
| } | |||
| String fileName = type + ".xlsx"; | |||
| int dot = mFile.getOriginalFilename().lastIndexOf('.'); | |||
| fileName = fileName + mFile.getOriginalFilename().substring(dot, mFile.getOriginalFilename().length()); | |||
| File lFile = new File(fpath + File.separator + fileName); | |||
| FileOutputStream fos = null; | |||
| BufferedInputStream fs = null; | |||
| try { | |||
| fos = new FileOutputStream(lFile); | |||
| fs = (BufferedInputStream) mFile.getInputStream(); | |||
| byte[] buffer = new byte[1024]; | |||
| int len = 0; | |||
| while ((len = fs.read(buffer)) != -1) { | |||
| fos.write(buffer, 0, len); | |||
| } | |||
| fos.close(); | |||
| fs.close(); | |||
| } catch (Exception e) { | |||
| stringRedisTemplate.expire(importKey, 3, TimeUnit.SECONDS); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1"); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1"); | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); | |||
| } finally { | |||
| if (fos != null) { | |||
| try { | |||
| fos.close(); | |||
| } catch (IOException e) { | |||
| stringRedisTemplate.expire(importKey, 3, TimeUnit.SECONDS); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1"); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1"); | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); | |||
| } | |||
| } | |||
| if (fs != null) { | |||
| try { | |||
| fs.close(); | |||
| } catch (IOException e) { | |||
| stringRedisTemplate.expire(importKey, 3, TimeUnit.SECONDS); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1"); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1"); | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); | |||
| } | |||
| } | |||
| } | |||
| if (type.equals(EnumImportType.MEMBER.getCode())) { | |||
| importTemplateTask.importMemberData(lFile, user, importKey); | |||
| } else if (type.equals(EnumImportType.SHOP_RENT.getCode()) || type.equals(EnumImportType.POINT_RENT.getCode()) | |||
| || type.equals(EnumImportType.SHOP_PROPERTY.getCode()) || type.equals(EnumImportType.POINT_PROPERTY.getCode())) { | |||
| importTemplateTask.importBillData(lFile, user, importKey); | |||
| } else if (type.equals(EnumImportType.DAILY.getCode()) || type.equals(EnumImportType.OTHER.getCode()) | |||
| || type.equals(EnumImportType.OTHER_DEPOSIT.getCode())) { | |||
| importTemplateTask.importBillDataOther(lFile, user, importKey); | |||
| } | |||
| return new ResultData(Result.SUCCESS, "模板正在导入"); | |||
| } | |||
| @GetMapping("/queryTemplateCount") | |||
| @SystemControllerLog(description = "导入数据查询") | |||
| public ResultData queryTemplateCount(@RequestParam("type") Integer type) { | |||
| String typeStr = EnumImportType.getEnum(type).getMessage(); | |||
| String importKey = Constant.importMemPrev + typeStr + "_" + getUser().getId(); | |||
| Map entries = stringRedisTemplate.opsForHash().entries(importKey); | |||
| logger.info(JSONArray.toJSONString(entries) + ">>>>>>>>>>>>>>>>>>>>>1"); | |||
| if (entries.size() < 4) { | |||
| entries.clear(); | |||
| return new ResultData(Result.SUCCESS, "ok", entries); | |||
| } | |||
| String allCount = entries.get("allCount").toString(); | |||
| String allSuccessCount = entries.get("allSuccessCount").toString(); | |||
| String processCount = entries.get("processCount").toString(); | |||
| String failCount = entries.get("failCount").toString(); | |||
| if (StringUtils.isNotBlank(failCount) && allCount.equals(failCount)) {//stringRedisTemplate.expire(userId,1,TimeUnit.SECONDS); | |||
| logger.info(JSONArray.toJSONString(entries) + ">>>>>>>>>>>>>>>>>>>>>2"); | |||
| //完全失败 | |||
| stringRedisTemplate.opsForHash().delete(importKey, "allCount"); | |||
| stringRedisTemplate.opsForHash().delete(importKey, "allSuccessCount"); | |||
| stringRedisTemplate.opsForHash().delete(importKey, "processCount"); | |||
| stringRedisTemplate.opsForHash().delete(importKey, "failCount"); | |||
| return new ResultData(ErrorCode.MEM_IMPORT_ERR); | |||
| } | |||
| //导入完成 | |||
| if (StringUtils.isNotBlank(allSuccessCount) && allSuccessCount.equals(processCount)) { | |||
| ResultData ok = new ResultData(Result.SUCCESS, "ok", entries); | |||
| stringRedisTemplate.opsForHash().delete(importKey, "allCount"); | |||
| stringRedisTemplate.opsForHash().delete(importKey, "allSuccessCount"); | |||
| stringRedisTemplate.opsForHash().delete(importKey, "processCount"); | |||
| stringRedisTemplate.opsForHash().delete(importKey, "failCount"); | |||
| return ok; | |||
| } | |||
| return new ResultData(Result.SUCCESS, "查询成功", entries); | |||
| } | |||
| // @Autowired | |||
| // private String fmUploadDir; | |||
| // | |||
| // @Autowired | |||
| // StringRedisTemplate stringRedisTemplate; | |||
| // | |||
| // @Autowired | |||
| // private ImportTemplateTask importTemplateTask; | |||
| // | |||
| // private void set_redis_value(String importKey, String allCount, String allSuccessCount, String processCount, String failCount, boolean fail) { | |||
| // stringRedisTemplate.opsForHash().put(importKey, "allCount", allCount); | |||
| // stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", allSuccessCount); | |||
| // stringRedisTemplate.opsForHash().put(importKey, "processCount", processCount); | |||
| // stringRedisTemplate.opsForHash().put(importKey, "failCount", failCount); | |||
| // if (fail) { | |||
| // stringRedisTemplate.expire(importKey, 10, TimeUnit.SECONDS); | |||
| // } | |||
| // } | |||
| // | |||
| // @PostMapping(value = "/importTemplate", consumes = "multipart/*") | |||
| // @SystemControllerLog(description = "导入数据") | |||
| // public ResultData importTemplate(@RequestParam("file") MultipartFile mFile, @RequestParam("type") Integer type) { | |||
| // logger.debug("[" + getIpAddr() + "] WxImportTemplateController::importTemplate"); | |||
| // if (mFile.isEmpty()) { | |||
| // throw new MallinkException(Result.ERROR, "上传文件不能为空"); | |||
| // } | |||
| // //得到当前用户ID | |||
| // String typeStr = EnumImportType.getEnum(type).getMessage(); | |||
| // final MallUserInfo user = getUser(); | |||
| // String userId = typeStr + "_" + user.getId(); | |||
| // String importKey = Constant.importMemPrev + userId; | |||
| // | |||
| // //查询当前用户得到的值是否为空,为空继续,不为空,返回模板正在导入 | |||
| // Boolean allCount = stringRedisTemplate.opsForHash().hasKey(importKey, "allCount"); | |||
| // if (allCount) { | |||
| // return new ResultData(Result.SUCCESS, "模板正在导入"); | |||
| // } | |||
| // | |||
| // stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", 0 + ""); | |||
| // stringRedisTemplate.expire(importKey, 30, TimeUnit.MINUTES); | |||
| // stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allSuccessCount", 0 + ""); | |||
| // stringRedisTemplate.opsForHash().putIfAbsent(importKey, "processCount", ""); | |||
| // stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", ""); | |||
| // | |||
| // String fpath = fmUploadDir; | |||
| // File targetFile = new File(fpath); | |||
| // if (!targetFile.exists()) { | |||
| // targetFile.mkdirs(); | |||
| // } | |||
| // String fileName = type + ".xlsx"; | |||
| // int dot = mFile.getOriginalFilename().lastIndexOf('.'); | |||
| // fileName = fileName + mFile.getOriginalFilename().substring(dot, mFile.getOriginalFilename().length()); | |||
| // | |||
| // File lFile = new File(fpath + File.separator + fileName); | |||
| // | |||
| // FileOutputStream fos = null; | |||
| // BufferedInputStream fs = null; | |||
| // try { | |||
| // fos = new FileOutputStream(lFile); | |||
| // fs = (BufferedInputStream) mFile.getInputStream(); | |||
| // byte[] buffer = new byte[1024]; | |||
| // int len = 0; | |||
| // while ((len = fs.read(buffer)) != -1) { | |||
| // fos.write(buffer, 0, len); | |||
| // } | |||
| // fos.close(); | |||
| // fs.close(); | |||
| // } catch (Exception e) { | |||
| // stringRedisTemplate.expire(importKey, 3, TimeUnit.SECONDS); | |||
| // stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1"); | |||
| // stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1"); | |||
| // logger.error(e.getMessage()); | |||
| // return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); | |||
| // } finally { | |||
| // if (fos != null) { | |||
| // try { | |||
| // fos.close(); | |||
| // } catch (IOException e) { | |||
| // stringRedisTemplate.expire(importKey, 3, TimeUnit.SECONDS); | |||
| // stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1"); | |||
| // stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1"); | |||
| // logger.error(e.getMessage()); | |||
| // return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); | |||
| // } | |||
| // } | |||
| // if (fs != null) { | |||
| // try { | |||
| // fs.close(); | |||
| // } catch (IOException e) { | |||
| // stringRedisTemplate.expire(importKey, 3, TimeUnit.SECONDS); | |||
| // stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1"); | |||
| // stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1"); | |||
| // logger.error(e.getMessage()); | |||
| // return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); | |||
| // } | |||
| // } | |||
| // } | |||
| // if (type.equals(EnumImportType.MEMBER.getCode())) { | |||
| // importTemplateTask.importMemberData(lFile, user, importKey); | |||
| // } else if (type.equals(EnumImportType.SHOP_RENT.getCode()) || type.equals(EnumImportType.POINT_RENT.getCode()) | |||
| // || type.equals(EnumImportType.SHOP_PROPERTY.getCode()) || type.equals(EnumImportType.POINT_PROPERTY.getCode())) { | |||
| // importTemplateTask.importBillData(lFile, user, importKey); | |||
| // } else if (type.equals(EnumImportType.DAILY.getCode()) || type.equals(EnumImportType.OTHER.getCode()) | |||
| // || type.equals(EnumImportType.OTHER_DEPOSIT.getCode())) { | |||
| // importTemplateTask.importBillDataOther(lFile, user, importKey); | |||
| // } | |||
| // return new ResultData(Result.SUCCESS, "模板正在导入"); | |||
| // } | |||
| // | |||
| // | |||
| // @GetMapping("/queryTemplateCount") | |||
| // @SystemControllerLog(description = "导入数据查询") | |||
| // public ResultData queryTemplateCount(@RequestParam("type") Integer type) { | |||
| // String typeStr = EnumImportType.getEnum(type).getMessage(); | |||
| // String importKey = Constant.importMemPrev + typeStr + "_" + getUser().getId(); | |||
| // Map entries = stringRedisTemplate.opsForHash().entries(importKey); | |||
| // logger.info(JSONArray.toJSONString(entries) + ">>>>>>>>>>>>>>>>>>>>>1"); | |||
| // if (entries.size() < 4) { | |||
| // entries.clear(); | |||
| // return new ResultData(Result.SUCCESS, "ok", entries); | |||
| // } | |||
| // String allCount = entries.get("allCount").toString(); | |||
| // String allSuccessCount = entries.get("allSuccessCount").toString(); | |||
| // String processCount = entries.get("processCount").toString(); | |||
| // String failCount = entries.get("failCount").toString(); | |||
| // | |||
| // if (StringUtils.isNotBlank(failCount) && allCount.equals(failCount)) {//stringRedisTemplate.expire(userId,1,TimeUnit.SECONDS); | |||
| // logger.info(JSONArray.toJSONString(entries) + ">>>>>>>>>>>>>>>>>>>>>2"); | |||
| // //完全失败 | |||
| // stringRedisTemplate.opsForHash().delete(importKey, "allCount"); | |||
| // stringRedisTemplate.opsForHash().delete(importKey, "allSuccessCount"); | |||
| // stringRedisTemplate.opsForHash().delete(importKey, "processCount"); | |||
| // stringRedisTemplate.opsForHash().delete(importKey, "failCount"); | |||
| // return new ResultData(ErrorCode.MEM_IMPORT_ERR); | |||
| // } | |||
| // //导入完成 | |||
| // if (StringUtils.isNotBlank(allSuccessCount) && allSuccessCount.equals(processCount)) { | |||
| // ResultData ok = new ResultData(Result.SUCCESS, "ok", entries); | |||
| // stringRedisTemplate.opsForHash().delete(importKey, "allCount"); | |||
| // stringRedisTemplate.opsForHash().delete(importKey, "allSuccessCount"); | |||
| // stringRedisTemplate.opsForHash().delete(importKey, "processCount"); | |||
| // stringRedisTemplate.opsForHash().delete(importKey, "failCount"); | |||
| // return ok; | |||
| // } | |||
| // return new ResultData(Result.SUCCESS, "查询成功", entries); | |||
| // } | |||
| } | |||
| @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.iformall.common.SortColumn; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.FinanceSetOffDetailVo; | |||
| import com.iformall.domain.vo.WxBillFeesStandardsListVo; | |||
| import com.iformall.enums.EnumBillAction; | |||
| import com.iformall.enums.EnumBillAllType; | |||
| @@ -280,6 +281,9 @@ public class WxAllBill extends TenantEntity { | |||
| @TableField(exist = false) | |||
| public List<WxAllBill> childList; | |||
| @TableField(exist = false) | |||
| List<WxBillFeesStandardsListVo> unFixedbillFeesStandardsList; | |||
| @TableField(exist = false) | |||
| private Integer hasMerchant; | |||
| @TableField(exist = false) | |||
| @@ -2,6 +2,7 @@ package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.WxAllBill; | |||
| import com.iformall.domain.po.WxPropertyContract; | |||
| import com.iformall.domain.po.WxRentContract; | |||
| import com.iformall.domain.vo.WxBillHotNotify; | |||
| import com.iformall.domain.vo.WxBillNotify; | |||
| @@ -19,6 +20,7 @@ public interface WxAllBillMapper extends CommonMapper<WxAllBill, Long> { | |||
| List<WxBillNotify> getBillNotifyList(WxAllBill record); | |||
| void deleteBillByContract(WxRentContract wxRentContract); | |||
| void deleteBillByPropertyContract(WxPropertyContract wxPropertyContract); | |||
| void deletePreviewBill(WxAllBill wxBillRent); | |||
| void deleteNoNeedPayBill(WxAllBill wxBillRent); | |||
| @@ -37,5 +39,7 @@ public interface WxAllBillMapper extends CommonMapper<WxAllBill, Long> { | |||
| void deleteById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||
| void deleteEnergyReadingBills(@Param("energyReadingCalcuteId")Long energyReadingCalcuteId,@Param("tenantId")String tenantId); | |||
| void updatePropertyBillInvalidStatusByRent(WxRentContract wxRentContract); | |||
| } | |||
| @@ -74,13 +74,13 @@ public interface WxPropertyContractService { | |||
| void updatePropertyPreviewBill(WxPropertyContract record); | |||
| List<WxBillProperty> getWxBillPropertyPreview(TenantEntity tenantEntity,Long id); | |||
| List<WxAllBill> getWxBillPropertyPreview(TenantEntity tenantEntity,Long id); | |||
| //Map<String, Object> updateStatus(WxPropertyContract record); | |||
| List<WxBillProperty> buildProperty(WxMerchant wxMerchant, MallUserInfo user, WxPropertyContract propertyContract, Integer isPreview,boolean saveDb); | |||
| List<WxAllBill> buildProperty(WxMerchant wxMerchant, MallUserInfo user, WxPropertyContract propertyContract, Integer isPreview,boolean saveDb); | |||
| WxPropertyContract getByBill(WxBillProperty billRent); | |||
| WxPropertyContract getByBill(WxAllBill billRent); | |||
| ResultData apply(WxPropertyContract wxPropertyContract,MallUserInfo user); | |||
| @@ -3,7 +3,7 @@ package com.iformall.service; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxBillRent; | |||
| import com.iformall.domain.po.WxAllBill; | |||
| import com.iformall.domain.po.WxMall; | |||
| import com.iformall.domain.po.WxRentContract; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| @@ -78,7 +78,7 @@ public interface WxRentContractService { | |||
| void updateApplyStatus(WxRentContract wxRentContract); | |||
| List<WxBillRent> buildRent(MallUserInfo user,WxRentContract rentContract,Integer isPreview,boolean saveDb); | |||
| List<WxAllBill> buildRent(MallUserInfo user,WxRentContract rentContract,Integer isPreview,boolean saveDb); | |||
| void buildDeposit( TenantEntity tenantEntity,MallUserInfo user,Long rentContractId); | |||
| @@ -98,7 +98,7 @@ public interface WxRentContractService { | |||
| //Map<String, Object> updateStatus(WxRentContract record); | |||
| WxRentContract getByBill(WxBillRent billRent); | |||
| WxRentContract getByBill(WxAllBill billRent); | |||
| //Map<Long,WxRentContract> selectRentContractByShopIds(Collection<Long> shopIds, String shopIdsRegexp, TenantEntity tenantEntity); | |||
| @@ -25,16 +25,7 @@ import com.iformall.domain.dto.WxBillReceiveUpdateDTO; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.SysConfig; | |||
| import com.iformall.domain.po.WxBillAction; | |||
| import com.iformall.domain.po.WxBillAdvance; | |||
| import com.iformall.domain.po.WxAllBill; | |||
| import com.iformall.domain.po.WxBillDaily; | |||
| import com.iformall.domain.po.WxBillDeposit; | |||
| import com.iformall.domain.po.WxBillOther; | |||
| import com.iformall.domain.po.WxBillOtherDeposit; | |||
| import com.iformall.domain.po.WxBillProperty; | |||
| import com.iformall.domain.po.WxBillPropertyDeposit; | |||
| import com.iformall.domain.po.WxBillRent; | |||
| import com.iformall.domain.po.WxBillRentManage; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxMerchantBUser; | |||
| import com.iformall.domain.po.WxPropertyContract; | |||
| @@ -55,15 +46,6 @@ import com.iformall.enums.EnumSystemUserType; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.service.WxAllBillService; | |||
| import com.iformall.service.WxBillActionService; | |||
| import com.iformall.service.WxBillAdvanceService; | |||
| import com.iformall.service.WxBillDailyService; | |||
| import com.iformall.service.WxBillDepositService; | |||
| import com.iformall.service.WxBillOtherDepositService; | |||
| import com.iformall.service.WxBillOtherService; | |||
| import com.iformall.service.WxBillPropertyDepositService; | |||
| import com.iformall.service.WxBillPropertyService; | |||
| import com.iformall.service.WxBillRentManageService; | |||
| import com.iformall.service.WxBillRentService; | |||
| import com.iformall.service.WxMallService; | |||
| import com.iformall.service.WxMerchantService; | |||
| import com.iformall.service.WxShopService; | |||
| @@ -92,6 +92,9 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| @Lazy | |||
| @Autowired | |||
| WxBillAllHelper wxBillAllHelper; | |||
| @Autowired | |||
| WxAllBillMapper wxAllBillMapper; | |||
| @Override | |||
| public PageInfo<WxPropertyContract> listAsPage(WxPropertyContract record, Integer pageIndex, Integer pageSize) { | |||
| @@ -241,31 +244,31 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| } | |||
| //查询预账单用于展示 | |||
| List<WxBillProperty> resultList = getWxBillPropertyPreview(wxPropertyContract,id); | |||
| List<WxAllBill> resultList = getWxBillPropertyPreview(wxPropertyContract,id); | |||
| result.put("previewBillRentList", resultList); | |||
| return result; | |||
| } | |||
| @Override | |||
| public List<WxBillProperty> getWxBillPropertyPreview(TenantEntity tenantEntity,Long id) { | |||
| public List<WxAllBill> getWxBillPropertyPreview(TenantEntity tenantEntity,Long id) { | |||
| //查询主账单列表,排除其他标砖费用,包括一次性费用,非一次性费用 | |||
| WxBillProperty wxBillRent = new WxBillProperty(); | |||
| WxAllBill wxBillRent = new WxAllBill(); | |||
| wxBillRent.setPropertyContractId(id); | |||
| wxBillRent.setSortColumns(BaseEntity.SortField.Period_ASC); | |||
| wxBillRent.updateTenantInfo(tenantEntity); | |||
| //一次性的和非一次性的都有这个属性,过滤掉,就是物业主账单 | |||
| wxBillRent.setHasFeesStardarsId(EnumYesOrNo.NO.getCode()); | |||
| List<WxBillProperty> retList = wxBillPropertyMapper.findList(wxBillRent); | |||
| List<WxAllBill> retList = wxAllBillMapper.findList(wxBillRent); | |||
| //非一次性的有这个属性 | |||
| wxBillRent.setHasFeesStardarsId(EnumYesOrNo.YES.getCode()); | |||
| wxBillRent.setHasParentBillId(EnumYesOrNo.YES.getCode()); | |||
| List<WxBillProperty> unFixedList = wxBillPropertyMapper.findList(wxBillRent); | |||
| List<WxAllBill> unFixedList = wxAllBillMapper.findList(wxBillRent); | |||
| Map<Long,List<WxAllBill>> childMap = null; | |||
| if (null != unFixedList && unFixedList.size() > 0 ) { | |||
| childMap = new HashMap<Long,List<WxAllBill>>(); | |||
| for (int i = 0 ; i < unFixedList.size(); i++) { | |||
| WxBillProperty ub = unFixedList.get(i); | |||
| WxAllBill ub = unFixedList.get(i); | |||
| if (null != ub) { | |||
| List<WxAllBill> childList = childMap.get(ub.getParentBillId()); | |||
| if (null == childList) { | |||
| @@ -278,7 +281,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| } | |||
| if (null != childMap ) { | |||
| for (int i = 0 ; i < retList.size(); i ++) { | |||
| WxBillProperty ub = retList.get(i); | |||
| WxAllBill ub = retList.get(i); | |||
| List<WxAllBill> childList = childMap.get(ub.getId()); | |||
| ub.setChildList(childList); | |||
| } | |||
| @@ -294,11 +297,11 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| if(CollectionUtils.isEmpty(record.getPreviewBillRentList())){ | |||
| return; | |||
| } | |||
| wxBillPropertyMapper.deleteBillByContract(record); | |||
| wxAllBillMapper.deleteBillByPropertyContract(record); | |||
| WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(record); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| int count = 1; | |||
| for (WxBillProperty bill:record.getPreviewBillRentList()) { | |||
| for (WxAllBill bill:record.getPreviewBillRentList()) { | |||
| bill.setId(idWorker.nextId()); | |||
| Date date = new Date(); | |||
| bill.setPropertyContractId(record.getId()); | |||
| @@ -306,33 +309,27 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| bill.setCreateBy(user.getId()); | |||
| bill.setCreateByName(user.getName()); | |||
| bill.updateTenantInfo(wxPayAccountBill); | |||
| //bill.setOwe(bill.getReceivePay()); | |||
| bill.setNeedPay(bill.getNeedPay()); | |||
| bill.setUpdatetime(date); | |||
| bill.setUpdateBy(user.getId()); | |||
| bill.setUpdateByName(user.getName()); | |||
| bill.setRentShopType(record.getRentShopType()); | |||
| bill.setPeriod(count); | |||
| bill.setIsPreview(EnumIsPreview.YES.getCode()); | |||
| bill.setShopInfo(getShopInfoStr(record)); | |||
| bill.setRevenue("0"); | |||
| bill.setLatePayRatio(0); | |||
| bill.setPay("0"); | |||
| bill.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | |||
| bill.setBillType(EnumBillAllType.PROPERTY.getCode()); | |||
| //bill.setShopId(record.getShopId()); | |||
| bill.setExpiredDay(0L); | |||
| //setExpiredDay(bill,Calendar.MONTH,record.getReceivePeriod()); | |||
| if (bill.getReceivePay().equals("0")) { | |||
| bill.setStatus(EnumBillStatus.PAID.getCode()); | |||
| bill.setPayDate(date); | |||
| } | |||
| BigDecimal servicePay = new BigDecimal(bill.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(100), record.getDecimalSize(), BigDecimal.ROUND_HALF_UP); | |||
| bill.setServiceChargePay(servicePay.toPlainString()); | |||
| //BigDecimal servicePay = new BigDecimal(bill.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(100), record.getDecimalSize(), BigDecimal.ROUND_HALF_UP); | |||
| //bill.setServiceChargePay(servicePay.toPlainString()); | |||
| //bill.setOwe(new BigDecimal(bill.getReceivePay()).add(new BigDecimal(bill.getServiceChargePay())).toPlainString()); | |||
| //bill.setOwe(new BigDecimal(bill.getReceivePay()).toPlainString()); | |||
| count++; | |||
| } | |||
| wxBillPropertyMapper.insertBills(record.getTenantId(),record.getPreviewBillRentList()); | |||
| wxAllBillMapper.insertBills(record.getTenantId(),record.getPreviewBillRentList()); | |||
| } | |||
| @Override | |||
| @@ -424,7 +421,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| if (record.getReceivePeriod() != null && record.getLease() != null && record.getPrice() != null | |||
| && !record.getReceivePeriod().equals(0) && !record.getLease().equals(0) && !record.getPrice().equals("0")) { | |||
| //删除预账单,重新生成 | |||
| wxBillPropertyMapper.deleteBillByContract(record); | |||
| wxAllBillMapper.deleteBillByPropertyContract(record); | |||
| //重新生成 | |||
| record.setRentalStartDate(wxPropertyContract.getRentalStartDate()); | |||
| record.setRentalEndDate(wxPropertyContract.getRentalEndDate()); | |||
| @@ -435,7 +432,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| record.setCreateType(wxPropertyContract.getCreateType()); | |||
| record.setShopIds(wxPropertyContract.getShopIds()); | |||
| record.setFeeStandards(wxPropertyContract.getFeesStardarsList()); | |||
| List<WxBillProperty> billList = buildProperty(new WxMerchant(),user,record,EnumIsPreview.YES.getCode(),true); | |||
| List<WxAllBill> billList = buildProperty(new WxMerchant(),user,record,EnumIsPreview.YES.getCode(),true); | |||
| record.setPreviewBillRentList(billList); | |||
| } | |||
| @@ -444,7 +441,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| @Override | |||
| public void deletePreviewBill(WxPropertyContract record) { | |||
| wxBillPropertyMapper.deleteBillByContract(record); | |||
| wxAllBillMapper.deleteBillByPropertyContract(record); | |||
| } | |||
| @@ -512,12 +509,12 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| @Override | |||
| public void updatePropertyPreviewBill(WxPropertyContract record) { | |||
| WxBillProperty billProperty = new WxBillProperty(); | |||
| WxAllBill billProperty = new WxAllBill(); | |||
| billProperty.setPropertyContractId(record.getId()); | |||
| billProperty.setIsPreview(EnumIsPreview.NO.getCode()); | |||
| billProperty.setMerchantId(record.getMerchantId()); | |||
| billProperty.updateTenantInfo(record); | |||
| wxBillPropertyMapper.updatePreviewStatus(billProperty); | |||
| wxAllBillMapper.updatePreviewStatus(billProperty); | |||
| if(new BigDecimal(record.getDeposit()).compareTo(new BigDecimal(0)) > 0) { | |||
| buildDeposit(record); | |||
| } | |||
| @@ -531,8 +528,9 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| //找到计租方式 | |||
| int dayType = wxPropertyContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_DAY.getCode()) ? Calendar.DAY_OF_MONTH : Calendar.MONTH; | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| WxBillPropertyDeposit wxBillDeposit = new WxBillPropertyDeposit(); | |||
| WxAllBill wxBillDeposit = new WxAllBill(); | |||
| wxBillDeposit.setId(idWorker.nextId()); | |||
| wxBillDeposit.setBillType(EnumBillAllType.PROPERTY_DEPOSIT.getCode()); | |||
| wxBillDeposit.setPropertyContractId(wxPropertyContract.getId()); | |||
| wxBillDeposit.setPay("0"); | |||
| String needpay = wxPropertyContract.getDeposit(); | |||
| @@ -544,35 +542,30 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| instance.setTime(wxPropertyContract.getRentalStartDate()); | |||
| instance.add(Calendar.DAY_OF_MONTH, -1); | |||
| Date time = instance.getTime(); | |||
| wxBillDeposit.setReceiveDate(time); | |||
| //账单开始时间 | |||
| instance.clear(); | |||
| instance.setTime(wxBillDeposit.getReceiveDate()); | |||
| instance.setTime(time); | |||
| instance.add(Calendar.DAY_OF_MONTH, 1); | |||
| wxBillDeposit.setStarttime(instance.getTime()); | |||
| //账单结束时间 | |||
| instance.clear(); | |||
| instance.setTime(wxBillDeposit.getReceiveDate()); | |||
| instance.setTime(time); | |||
| instance.add(dayType, wxPropertyContract.getLease()); | |||
| wxBillDeposit.setEndtime(instance.getTime()); | |||
| wxBillDeposit.setStatus(EnumBillStatus.WAIT_PAY.getCode()); | |||
| wxBillDeposit.setExpiredDay(0L); | |||
| wxBillDeposit.updateTenantInfo(wxPropertyContract); | |||
| wxBillDeposit.setIsDel(0); | |||
| wxBillDeposit.setMerchantId(record.getMerchantId()); | |||
| //wxBillDeposit.setShopId(wxPropertyContract.getShopId()); | |||
| wxBillDeposit.setCreatetime(date); | |||
| //wxBillDeposit.setCreateBy(user.getId()); | |||
| //wxBillDeposit.setCreateByName(user.getName()); | |||
| wxBillDeposit.setUpdatetime(date); | |||
| //wxBillDeposit.setUpdateBy(user.getId()); | |||
| //wxBillDeposit.setUpdateByName(user.getName()); | |||
| wxBillDeposit.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | |||
| wxBillDeposit.setRentShopType(wxPropertyContract.getRentShopType()); | |||
| wxBillDeposit.setShopInfo(getShopInfoStr(wxPropertyContract)); | |||
| wxBillDeposit.setEnergyFeesId(EnumBillAllType.PROPERTY_DEPOSIT.getEnergyFeesId()); | |||
| try { | |||
| wxBillPropertyDepositMapper.insert(wxBillDeposit); | |||
| wxAllBillMapper.insert(wxBillDeposit); | |||
| } catch (Exception e) { | |||
| logger.error("添加物业押金账单失败,e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||
| @@ -593,7 +586,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| return JSONObject.toJSONString(shopInfo); | |||
| } | |||
| public List<WxBillProperty> buildRentMonth(WxMerchant wxMerchant, MallUserInfo user,WxPropertyContract wxPropertyContract, int receivePeriod, Integer lease, Date rentalStartDate, String price, Integer isPreview,boolean saveDb) { | |||
| public List<WxAllBill> buildRentMonth(WxMerchant wxMerchant, MallUserInfo user,WxPropertyContract wxPropertyContract, int receivePeriod, Integer lease, Date rentalStartDate, String price, Integer isPreview,boolean saveDb) { | |||
| String adjustRatio = wxPropertyContract.getAdjustRatio(); | |||
| Map<String, Object> shopInfo = new HashMap<>(); | |||
| if (wxPropertyContract.getCreateType().intValue() == EnumPropertyCreateType.BY_SHOP.getCode().intValue()) { | |||
| @@ -656,7 +649,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| } | |||
| int billcount = 0; | |||
| List<WxBillProperty> resultList = new ArrayList<>(); | |||
| List<WxAllBill> resultList = new ArrayList<WxAllBill>(); | |||
| List<Date> yearList = new ArrayList<>(); | |||
| for (int i = 0; i < size; i++) { | |||
| @@ -679,7 +672,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| yearList.add(startDate); | |||
| } | |||
| Map<String, Object> resultMap = buildRent(receivePeriod, priceArr, yearList, wxPropertyContract.getReceivePeriodUnit(), wxPropertyContract, user, wxMerchant, billcount, isPreview, shopInfo,saveDb); | |||
| List<WxBillProperty> billRentList = (List<WxBillProperty>)resultMap.get("billList"); | |||
| List<WxAllBill> billRentList = (List<WxAllBill>)resultMap.get("billList"); | |||
| resultList.addAll(billRentList); | |||
| return resultList; | |||
| } | |||
| @@ -688,8 +681,8 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(wxPropertyContract); | |||
| SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); | |||
| Map<String,Object> resultMap = new HashedMap(); | |||
| List<WxBillProperty> propertyResultList = new ArrayList<>(); | |||
| List<WxBillProperty> allResultList = new ArrayList<>(); | |||
| List<WxAllBill> propertyResultList = new ArrayList<WxAllBill>(); | |||
| List<WxAllBill> allResultList = new ArrayList<WxAllBill>(); | |||
| Date endDate = null; | |||
| if(yearList.size() > 1){ | |||
| @@ -701,7 +694,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| billTimeVoList = WxRentContractServiceImpl.initBillTimeList(wxPropertyContract.getRentalStartDate(),wxPropertyContract.getRentalEndDate(),wxPropertyContract.getAdjustPeriod(),dayType,receivePeriod); | |||
| }else{ | |||
| //预账单编辑账期,生成金额 | |||
| for (WxBillProperty rent:wxPropertyContract.getPreviewBillRentList()) { | |||
| for (WxAllBill rent:wxPropertyContract.getPreviewBillRentList()) { | |||
| BillTimeVo billTimeVo = new BillTimeVo(); | |||
| billTimeVo.setStartDate(rent.getStarttime()); | |||
| billTimeVo.setEndDate(rent.getEndtime()); | |||
| @@ -778,7 +771,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| ++billcount; | |||
| //物业主账单 | |||
| WxBillProperty wxBillProperty = generateBillProperty(wxPayAccountBill,wxPropertyContract,isPreview,billTimeVo.getStartDate(),billTimeVo.getEndDate(),billTimeVo.getReceiveDate(),needpay,user,billcount,shopInfo,standarsTotal,"",null,null); | |||
| WxAllBill wxBillProperty = generateBillProperty(wxPayAccountBill,wxPropertyContract,isPreview,billTimeVo.getStartDate(),billTimeVo.getEndDate(),billTimeVo.getReceiveDate(),needpay,user,billcount,shopInfo,standarsTotal,"",null,null); | |||
| //设置物业科目 | |||
| wxBillProperty.setEnergyFeesId(EnumBillAllType.PROPERTY.getEnergyFeesId()); | |||
| //非一次性账单 | |||
| @@ -790,7 +783,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| for (int j = 0 ; j < unFixedList.size(); j ++ ) { | |||
| WxBillFeesStandardsListVo svo = unFixedList.get(j); | |||
| svo.setParentBillId(wxBillProperty.getId()); | |||
| WxBillProperty property = generateBillPropertyByBillStandards(wxPayAccountBill,wxPropertyContract,isPreview,user,svo,billcount,shopInfo); | |||
| WxAllBill property = generateBillPropertyByBillStandards(wxPayAccountBill,wxPropertyContract,isPreview,user,svo,billcount,shopInfo); | |||
| //设置科目 | |||
| property.setEnergyFeesId(svo.getFeeStandards().getId()); | |||
| allResultList.add(property); | |||
| @@ -806,14 +799,14 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| if (null != fixedList && fixedList.size() > 0 ) { | |||
| for (int i = 0 ; i < fixedList.size(); i ++ ) { | |||
| WxBillFeesStandardsListVo svo = fixedList.get(i); | |||
| WxBillProperty property = generateBillPropertyByBillStandards(wxPayAccountBill,wxPropertyContract,isPreview,user,svo,billcount,shopInfo); | |||
| WxAllBill property = generateBillPropertyByBillStandards(wxPayAccountBill,wxPropertyContract,isPreview,user,svo,billcount,shopInfo); | |||
| allResultList.add(property); | |||
| } | |||
| } | |||
| //批量生成预账单 | |||
| if(saveDb && allResultList.size() > 0 ) { | |||
| wxBillPropertyMapper.insertBills(wxPropertyContract.getTenantId() ,allResultList); | |||
| wxAllBillMapper.insertBills(wxPropertyContract.getTenantId() ,allResultList); | |||
| //for (int i = 0 ; i < resultList.size() ; i++) { | |||
| // wxBillPropertyMapper.insert(resultList.get(i)); | |||
| //} | |||
| @@ -824,23 +817,23 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| } | |||
| private WxBillProperty generateBillPropertyByBillStandards(WxPayAccountBill wxPayAccountBill,WxPropertyContract wxPropertyContract,Integer isPreview,MallUserInfo user,WxBillFeesStandardsListVo svo, | |||
| private WxAllBill generateBillPropertyByBillStandards(WxPayAccountBill wxPayAccountBill,WxPropertyContract wxPropertyContract,Integer isPreview,MallUserInfo user,WxBillFeesStandardsListVo svo, | |||
| Integer billcount,Map<String, Object> shopInfo) { | |||
| Long feesStandardsId = svo.getFeeStandards().getId(); | |||
| return generateBillProperty(wxPayAccountBill,wxPropertyContract,isPreview,svo.getStart(),svo.getEnd(),svo.getReceiveDate(),svo.getTotal(),user,billcount,shopInfo,"0",svo.getBillName(),svo.getParentBillId(),feesStandardsId); | |||
| } | |||
| private WxBillProperty generateBillProperty(WxPayAccountBill wxPayAccountBill,WxPropertyContract wxPropertyContract,Integer isPreview,Date start,Date end,Date receiveDate,String needpay, | |||
| private WxAllBill generateBillProperty(WxPayAccountBill wxPayAccountBill,WxPropertyContract wxPropertyContract,Integer isPreview,Date start,Date end,Date receiveDate,String needpay, | |||
| MallUserInfo user,Integer billcount,Map<String, Object> shopInfo,String standarsTotal,String remark,Long parentBillId,Long feesStandardsId) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| WxBillProperty wxBillProperty = new WxBillProperty(); | |||
| WxAllBill wxBillProperty = new WxAllBill(); | |||
| wxBillProperty.setIsPreview(isPreview); | |||
| wxBillProperty.setId(idWorker.nextId()); | |||
| wxBillProperty.setBillType(EnumBillAllType.PROPERTY.getCode()); | |||
| wxBillProperty.setPropertyContractId(wxPropertyContract.getId()); | |||
| wxBillProperty.setPay("0"); | |||
| wxBillProperty.setStarttime(start); | |||
| wxBillProperty.setEndtime(end); | |||
| wxBillProperty.setReceiveDate(receiveDate); | |||
| wxBillProperty.setNeedPay(needpay); | |||
| //wxBillProperty.setOwe(needpay); | |||
| @@ -850,9 +843,8 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| Date date = new Date(); | |||
| //setExpiredDay(wxBillProperty,dayType,receivePeriod); | |||
| wxBillProperty.updateTenantInfo(wxPropertyContract); | |||
| wxBillProperty.setIsDel(0); | |||
| wxBillProperty.setMerchantId(wxPropertyContract.getMerchantId()); | |||
| wxBillProperty.setUserId(user.getId()); | |||
| //wxBillProperty.setUserId(user.getId()); | |||
| //wxBillProperty.setShopId(wxPropertyContract.getShopId()); | |||
| wxBillProperty.setCreatetime(date); | |||
| wxBillProperty.setCreateBy(user.getId()); | |||
| @@ -860,22 +852,22 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| wxBillProperty.setUpdatetime(date); | |||
| wxBillProperty.setUpdateBy(user.getId()); | |||
| wxBillProperty.setUpdateByName(user.getName()); | |||
| wxBillProperty.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | |||
| //wxBillProperty.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | |||
| wxBillProperty.setStatus(EnumBillStatus.WAIT_PAY.getCode()); | |||
| wxBillProperty.setRentShopType(wxPropertyContract.getRentShopType()); | |||
| wxBillProperty.setPeriod(billcount); | |||
| //wxBillProperty.setPeriod(billcount); | |||
| if (shopInfo != null) { | |||
| wxBillProperty.setShopInfo(JSONObject.toJSONString(shopInfo)); | |||
| } | |||
| wxBillProperty.setLatePayRatio(0); | |||
| //wxBillProperty.setLatePayRatio(0); | |||
| wxBillProperty.setTotalFee(new BigDecimal(needpay).add(new BigDecimal(standarsTotal)).toPlainString()); | |||
| wxBillProperty.setComments(remark); | |||
| wxBillProperty.setBillRemark(remark); | |||
| wxBillProperty.setParentBillId(parentBillId); | |||
| wxBillProperty.setEnergyFeesId(feesStandardsId); | |||
| //计算手续费 | |||
| BigDecimal servicePay = new BigDecimal(wxBillProperty.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(100), wxPropertyContract.getDecimalSize(), BigDecimal.ROUND_HALF_UP); | |||
| wxBillProperty.setServiceChargePay(servicePay.toPlainString()); | |||
| //BigDecimal servicePay = new BigDecimal(wxBillProperty.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(100), wxPropertyContract.getDecimalSize(), BigDecimal.ROUND_HALF_UP); | |||
| //wxBillProperty.setServiceChargePay(servicePay.toPlainString()); | |||
| //wxBillProperty.setOwe(new BigDecimal(wxBillProperty.getReceivePay()).add(new BigDecimal(wxBillProperty.getServiceChargePay())).toPlainString()); | |||
| //wxBillProperty.setOwe(new BigDecimal(wxBillProperty.getReceivePay()).toPlainString()); | |||
| @@ -1011,8 +1003,8 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| */ | |||
| @Override | |||
| //@Transactional(rollbackFor = {Exception.class}) | |||
| public List<WxBillProperty> buildProperty(WxMerchant wxMerchant,MallUserInfo user,WxPropertyContract propertyContract,Integer isPreview,boolean saveDb) { | |||
| List<WxBillProperty> result = new ArrayList<>(); | |||
| public List<WxAllBill> buildProperty(WxMerchant wxMerchant,MallUserInfo user,WxPropertyContract propertyContract,Integer isPreview,boolean saveDb) { | |||
| List<WxAllBill> result = new ArrayList<WxAllBill>(); | |||
| WxPropertyContract wxPropertyContract; | |||
| if(propertyContract == null){ | |||
| @@ -1040,9 +1032,9 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| //按月计租 | |||
| result = buildRentMonth(wxMerchant, user, propertyContract, receivePeriod, lease, rentalStartDate, price,isPreview,saveDb); | |||
| } | |||
| for (int i = 0; i < result.size(); i++) { | |||
| result.get(i).setPeriod(i+1); | |||
| } | |||
| //for (int i = 0; i < result.size(); i++) { | |||
| // result.get(i).setPeriod(i+1); | |||
| //} | |||
| return result; | |||
| } | |||
| @@ -1271,7 +1263,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| } | |||
| @Override | |||
| public WxPropertyContract getByBill(WxBillProperty billRent) { | |||
| public WxPropertyContract getByBill(WxAllBill billRent) { | |||
| return wxPropertyContractMapper.getByBill(billRent); | |||
| } | |||
| @@ -66,12 +66,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| @Autowired | |||
| WxMerchantService wxMerchantService; | |||
| @Autowired | |||
| WxBillRentMapper wxBillRentMapper; | |||
| @Autowired | |||
| WxBillDepositMapper wxBillDepositMapper; | |||
| @Autowired | |||
| WxPropertyContractMapper wxPropertyContractMapper; | |||
| @@ -108,9 +102,9 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| @Autowired | |||
| WxFlowRecordMapper wxFlowRecordMapper; | |||
| @Autowired | |||
| WxBillPropertyMapper wxBillPropertyMapper; | |||
| WxAllBillMapper wxAllBillMapper; | |||
| @Lazy | |||
| @Autowired | |||
| @@ -124,9 +118,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| @Autowired | |||
| WxShopService wxShopService; | |||
| @Autowired | |||
| WxBillRentManageMapper wxBillRentManageMapper; | |||
| @Autowired | |||
| WxMerchantTradeDailyMapper wxMerchantTradeDailyMapper; | |||
| @@ -281,11 +272,11 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| } | |||
| //查询预账单用于展示 | |||
| WxBillRent wxBillRent = new WxBillRent(); | |||
| WxAllBill wxBillRent = new WxAllBill(); | |||
| wxBillRent.setRentContractId(id); | |||
| wxBillRent.setSortColumns(BaseEntity.SortField.Period_ASC); | |||
| wxBillRent.updateTenantInfo(wxRentContract); | |||
| List<WxBillRent> resultList = wxBillRentMapper.findList(wxBillRent); | |||
| List<WxAllBill> resultList = wxAllBillMapper.findList(wxBillRent); | |||
| result.put("previewBillRentList",resultList); | |||
| return result; | |||
| @@ -585,12 +576,12 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| @Override | |||
| public ResultData update(WxRentContract record, MallUserInfo user,String userName,int from,Date oldRentStartDate,boolean writeComplate) { | |||
| //查询预账单用于展示 | |||
| WxBillRent wxBillRent = new WxBillRent(); | |||
| WxAllBill wxBillRent = new WxAllBill(); | |||
| wxBillRent.setRentContractId(record.getId()); | |||
| wxBillRent.setSortColumns(BaseEntity.SortField.Period_ASC); | |||
| wxBillRent.setIsPreview(EnumIsPreview.YES.getCode()); | |||
| wxBillRent.updateTenantInfo(record); | |||
| List<WxBillRent> resultList = wxBillRentMapper.findList(wxBillRent); | |||
| List<WxAllBill> resultList = wxAllBillMapper.findList(wxBillRent); | |||
| //更新 | |||
| ResultData resultData = getResultDataForUpdate(record, user,from,oldRentStartDate,writeComplate); | |||
| @@ -643,12 +634,12 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| @Override | |||
| public ResultData updateOneStep(WxRentContract record, MallUserInfo user,String userName,int from,Date oldRentStartDate,boolean writeComplate) { | |||
| //查询预账单用于展示 | |||
| WxBillRent wxBillRent = new WxBillRent(); | |||
| WxAllBill wxBillRent = new WxAllBill(); | |||
| wxBillRent.setRentContractId(record.getId()); | |||
| wxBillRent.setSortColumns(BaseEntity.SortField.Period_ASC); | |||
| wxBillRent.setIsPreview(EnumIsPreview.YES.getCode()); | |||
| wxBillRent.updateTenantInfo(record); | |||
| List<WxBillRent> resultList = wxBillRentMapper.findList(wxBillRent); | |||
| List<WxAllBill> resultList = wxAllBillMapper.findList(wxBillRent); | |||
| //更新 | |||
| ResultData resultData = getResultDataForUpdate(record, user,from,oldRentStartDate,writeComplate); | |||
| @@ -671,14 +662,15 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| if (null == record.getDecimalSize()) { | |||
| record.setDecimalSize(Constant.default_short_decimal_size); | |||
| } | |||
| wxBillRentMapper.deleteBillByContract(record); | |||
| wxAllBillMapper.deleteBillByContract(record); | |||
| WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(record); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| int count = 1; | |||
| List<Long> shopIds = record.shopIdsByRentInfo(); | |||
| for (WxBillRent bill:record.getPreviewBillRentList()) { | |||
| for (WxAllBill bill:record.getPreviewBillRentList()) { | |||
| bill.setId(idWorker.nextId()); | |||
| Date date = new Date(); | |||
| bill.setBillType(EnumBillAllType.RENT.getCode()); | |||
| bill.setRentContractId(record.getId()); | |||
| bill.setCreatetime(date); | |||
| bill.setCreateBy(user.getId()); | |||
| @@ -686,8 +678,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| bill.updateTenantInfo(record); | |||
| bill.setNeedPay(bill.getNeedPay()); | |||
| bill.setReceivePay(bill.getNeedPay()); | |||
| // bill.setBussinessManageFeeNeedPay(bill.getBussinessManageFeeNeedPay()); | |||
| // bill.setOperatingManageFeeNeedPay(bill.getOperatingManageFeeNeedPay()); | |||
| bill.setBussinessManageFeeNeedPay(bill.getBussinessManageFeeNeedPay()); | |||
| bill.setOperatingManageFeeNeedPay(bill.getOperatingManageFeeNeedPay()); | |||
| bill.setUpdatetime(date); bill.setUpdateBy(user.getId()); | |||
| bill.setUpdateByName(user.getName()); | |||
| bill.setRentShopType(record.getRentShopType()); | |||
| @@ -710,13 +702,13 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| bill.setPayDate(date); | |||
| } | |||
| //计算手续费 | |||
| BigDecimal servicePay = new BigDecimal(bill.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(10000), record.getDecimalSize(), BigDecimal.ROUND_HALF_UP); | |||
| bill.setServiceChargePay(servicePay.toPlainString()); | |||
| //BigDecimal servicePay = new BigDecimal(bill.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(10000), record.getDecimalSize(), BigDecimal.ROUND_HALF_UP); | |||
| //bill.setServiceChargePay(servicePay.toPlainString()); | |||
| //bill.setOwe(bill.getReceivePay() + bill.getServiceChargePay()); | |||
| //bill.setOwe(bill.getReceivePay()); | |||
| count++; | |||
| } | |||
| wxBillRentMapper.insertBills(record.getTenantId(),record.getPreviewBillRentList()); | |||
| wxAllBillMapper.insertBills(record.getTenantId(),record.getPreviewBillRentList()); | |||
| } | |||
| /** | |||
| @@ -729,39 +721,46 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| if (null == record.getDecimalSize()) { | |||
| record.setDecimalSize(Constant.default_short_decimal_size); | |||
| } | |||
| WxBillRentManage wxBillRentManage = new WxBillRentManage(); | |||
| wxBillRentManage.setRentContractId(record.getId()); | |||
| //wxBillRentManage.setManageFeeType(feeType.getCode()); | |||
| wxBillRentManage.updateTenantInfo(record); | |||
| wxBillRentManageMapper.deletePreviewBill(wxBillRentManage); | |||
| //租金已经把这些账单都删除了 | |||
| //WxAllBill wxBillRentManage = new WxAllBill(); | |||
| //wxBillRentManage.setRentContractId(record.getId()); | |||
| //wxBillRentManage.setBillType(EnumBillAllType.); | |||
| //wxBillRentManage.updateTenantInfo(record); | |||
| //wxAllBillManageMapper.deletePreviewBill(wxBillRentManage); | |||
| WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(record); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| int count = 1; | |||
| List<Long> shopIds = record.shopIdsByRentInfo(); | |||
| List<WxBillRentManage> billList = new ArrayList<WxBillRentManage>(); | |||
| for (WxBillRent _bi:record.getPreviewBillRentList()) { | |||
| List<WxAllBill> billList = new ArrayList<WxAllBill>(); | |||
| for (WxAllBill _bi:record.getPreviewBillRentList()) { | |||
| BigDecimal needPay = new BigDecimal("0"); | |||
| Integer billType = null; | |||
| if (feeType.getCode() == EnumRentContractManageFeeType.RENT_BUSSINESS_MANAGE_FEE.getCode()) { | |||
| if (null != _bi.getBussinessManageFeeNeedPay()) { | |||
| needPay = new BigDecimal(_bi.getBussinessManageFeeNeedPay()); | |||
| } | |||
| billType = EnumBillAllType.RENT_BUSSINESS_MANAGE.getCode(); | |||
| }else if (feeType.getCode() == EnumRentContractManageFeeType.RENT_OPERATING_MANAGE_FEE.getCode()) { | |||
| if (null != _bi.getOperatingManageFeeNeedPay()) { | |||
| needPay = new BigDecimal(_bi.getOperatingManageFeeNeedPay()); | |||
| } | |||
| billType = EnumBillAllType.RENT_OPERATION_MANAGE.getCode(); | |||
| } | |||
| if (needPay.compareTo(new BigDecimal(0)) <= 0) { | |||
| continue; | |||
| } | |||
| WxBillRentManage bill = new WxBillRentManage(); | |||
| //bill.initByBillRent(_bi); | |||
| WxAllBill bill = new WxAllBill(); | |||
| bill.setId(idWorker.nextId()); | |||
| Date date = new Date(); | |||
| bill.setBillType(billType); | |||
| bill.setRentContractId(record.getId()); | |||
| bill.setCreatetime(date); | |||
| bill.setCreateBy(user.getId()); | |||
| bill.setCreateByName(user.getName());; | |||
| bill.updateTenantInfo(record); | |||
| bill.setStarttime(_bi.getStarttime()); | |||
| bill.setEndtime(_bi.getEndtime()); | |||
| bill.setIsPreview(_bi.getIsPreview()); | |||
| //bill.setManageFeeType(feeType.getCode()); | |||
| bill.setNeedPay(needPay.toPlainString()); | |||
| bill.setReceivePay(needPay.toPlainString()); | |||
| @@ -792,15 +791,15 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| } | |||
| //计算手续费 | |||
| BigDecimal servicePay = new BigDecimal(bill.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(10000), record.getDecimalSize(), BigDecimal.ROUND_HALF_UP); | |||
| bill.setServiceChargePay(servicePay.toPlainString()); | |||
| //BigDecimal servicePay = new BigDecimal(bill.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(10000), record.getDecimalSize(), BigDecimal.ROUND_HALF_UP); | |||
| //bill.setServiceChargePay(servicePay.toPlainString()); | |||
| //bill.setOwe(bill.getReceivePay() + bill.getServiceChargePay()); | |||
| //bill.setOwe(bill.getReceivePay()); | |||
| count++; | |||
| billList.add(bill); | |||
| } | |||
| if (billList.size() > 0 ) { | |||
| wxBillRentManageMapper.insertBills(record.getTenantId(),billList); | |||
| wxAllBillMapper.insertBills(record.getTenantId(),billList); | |||
| } | |||
| } | |||
| @@ -955,18 +954,19 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| //根据不同的科目生成不同的押金账单 | |||
| Map<Long,WxEnergyFees> feesMap = wxRentContract.getDepositEnergyFees(typeMap); | |||
| List<WxBillDeposit> insertList = new ArrayList<WxBillDeposit>(); | |||
| List<WxAllBill> insertList = new ArrayList<WxAllBill>(); | |||
| for (Iterator<Long> it = feesMap.keySet().iterator();it.hasNext();){ | |||
| Long energyFeesId = it.next(); | |||
| WxEnergyFees depositFee = feesMap.get(energyFeesId); | |||
| WxEnergyFees fees = typeMap.get(energyFeesId); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| WxBillDeposit wxBillDeposit = new WxBillDeposit(); | |||
| WxAllBill wxBillDeposit = new WxAllBill(); | |||
| wxBillDeposit.setId(idWorker.nextId()); | |||
| wxBillDeposit.setRentContractId(wxRentContract.getId()); | |||
| wxBillDeposit.setBillType(EnumBillAllType.RENT_DEPOSIT.getCode()); | |||
| if (null != fees) { | |||
| //wxBillDeposit.setContractDepoistDetail("合同押金项["+fees.getName()+"]"+depositFee.getPrice()+"元"+"/"+fees.getCalcuteUnitName()); | |||
| wxBillDeposit.setPriceDetail("合同押金项["+fees.getName()+"]"+depositFee.getPrice()+"元"+"/"+fees.getCalcuteUnitName()); | |||
| } | |||
| wxBillDeposit.setPay("0"); | |||
| //String needpay = wxRentContract.getDeposit(); | |||
| @@ -986,26 +986,26 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| instance.setTime(wxRentContract.getRentalStartDate()); | |||
| instance.add(Calendar.DAY_OF_MONTH, -1); | |||
| Date time = instance.getTime(); | |||
| wxBillDeposit.setReceiveDate(time); | |||
| //wxBillDeposit.setReceiveDate(time); | |||
| //账单开始时间 | |||
| instance.clear(); | |||
| instance.setTime(wxBillDeposit.getReceiveDate()); | |||
| instance.setTime(time); | |||
| instance.add(Calendar.DAY_OF_MONTH, 1); | |||
| wxBillDeposit.setStarttime(instance.getTime()); | |||
| //账单结束时间 | |||
| instance.clear(); | |||
| instance.setTime(wxBillDeposit.getReceiveDate()); | |||
| instance.setTime(time); | |||
| instance.add(dayType, wxRentContract.getLease()); | |||
| wxBillDeposit.setEndtime(instance.getTime()); | |||
| wxBillDeposit.setStatus(EnumBillStatus.WAIT_PAY.getCode()); | |||
| wxBillDeposit.setExpiredDay(0L); | |||
| wxBillDeposit.setReceiveDate(time); | |||
| //wxBillDeposit.setExpiredDay(0L); | |||
| //wxBillDeposit.setReceiveDate(time); | |||
| wxBillDeposit.updateTenantInfo(wxRentContract); | |||
| wxBillDeposit.setIsDel(0); | |||
| //wxBillDeposit.setIsDel(0); | |||
| wxBillDeposit.setMerchantId(wxRentContract.getMerchantId()); | |||
| if (null != user) { | |||
| wxBillDeposit.setUserId(user.getId()); | |||
| //wxBillDeposit.setUserId(user.getId()); | |||
| } | |||
| if (wxRentContract.shopIdsByRentInfo().size()==1) { | |||
| wxBillDeposit.setShopId(wxRentContract.shopIdsByRentInfo().get(0)); | |||
| @@ -1020,7 +1020,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| wxBillDeposit.setUpdateBy(user.getId()); | |||
| wxBillDeposit.setUpdateByName(user.getName()); | |||
| } | |||
| wxBillDeposit.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | |||
| //wxBillDeposit.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | |||
| wxBillDeposit.setRentShopType(wxRentContract.getRentShopType()); | |||
| if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { | |||
| String rentInfo = wxRentContract.getRentInfo(); | |||
| @@ -1042,7 +1042,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| try { | |||
| if (insertList.size() > 0 ) { | |||
| wxBillDepositMapper.insertBills(tenantEntity.getTenantId(),insertList); | |||
| wxAllBillMapper.insertBills(tenantEntity.getTenantId(),insertList); | |||
| } | |||
| } catch (Exception e) { | |||
| logger.error("添加押金账单失败,e:" + e.getMessage()); | |||
| @@ -1197,8 +1197,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| @Override | |||
| @Transactional(rollbackFor = {Exception.class}) | |||
| public List<WxBillRent> buildRent(MallUserInfo user,WxRentContract wxRentContract,Integer isPreview,boolean saveDb) { | |||
| List<WxBillRent> rentList = new ArrayList<>(); | |||
| public List<WxAllBill> buildRent(MallUserInfo user,WxRentContract wxRentContract,Integer isPreview,boolean saveDb) { | |||
| List<WxAllBill> rentList = new ArrayList<>(); | |||
| if (wxRentContract != null) { | |||
| int receivePeriod = wxRentContract.getReceivePeriod().intValue(); | |||
| Integer lease = wxRentContract.getLease(); | |||
| @@ -1219,7 +1219,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| public List<WxBillRent> buildRentMonth(MallUserInfo user, WxRentContract wxRentContract, int receivePeriod, Integer lease, Date rentalStartDate,Integer isPreview, boolean saveDb) { | |||
| public List<WxAllBill> buildRentMonth(MallUserInfo user, WxRentContract wxRentContract, int receivePeriod, Integer lease, Date rentalStartDate,Integer isPreview, boolean saveDb) { | |||
| int years = 0; | |||
| //计算租金每年的计费基数 | |||
| String[] priceArrs = WxRentContractHelper.calcuteRentPrice(wxRentContract); | |||
| @@ -1229,7 +1229,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| String[] operationManagerPriceArrs = WxRentContractHelper.calcuteOperatingManagementFee(wxRentContract); | |||
| int month = 12; | |||
| int billcount = 0; | |||
| List<WxBillRent> resultList = new ArrayList<>(); | |||
| List<WxAllBill> resultList = new ArrayList<WxAllBill>(); | |||
| years = priceArrs.length; | |||
| List<Date> yearList = new ArrayList<>(); | |||
| for (int i = 0; i < years; i++) { | |||
| @@ -1254,12 +1254,12 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| String shopInfoStr = getShopInfoStr(wxRentContract); | |||
| Map<String, Object> resultMap = buildRent(receivePeriod, priceArrs,bussinessManagerPriceArrs,operationManagerPriceArrs, yearList, wxRentContract.getReceivePeriodUnit(), wxRentContract, user, billcount, isPreview, shopInfoStr,saveDb); | |||
| List<WxBillRent> billRentList = (List<WxBillRent>)resultMap.get("billList"); | |||
| List<WxAllBill> billRentList = (List<WxAllBill>)resultMap.get("billList"); | |||
| resultList.addAll(billRentList); | |||
| return resultList; | |||
| } | |||
| public List<WxBillRent> buildRentJinmao(MallUserInfo user, WxRentContract wxRentContract, int receivePeriod, Integer lease, Date rentalStartDate, String price, Integer isPreview, boolean saveDb) { | |||
| public List<WxAllBill> buildRentJinmao(MallUserInfo user, WxRentContract wxRentContract, int receivePeriod, Integer lease, Date rentalStartDate, String price, Integer isPreview, boolean saveDb) { | |||
| int size = 0; | |||
| String[] priceArrs = null; | |||
| if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_AREA.getCode())){ | |||
| @@ -1329,7 +1329,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| // } | |||
| int billcount = 0; | |||
| List<WxBillRent> resultList = new ArrayList<>(); | |||
| List<WxAllBill> resultList = new ArrayList<WxAllBill>(); | |||
| List<Date> yearList = new ArrayList<>(); | |||
| for (int i = 0; i < size; i++) { | |||
| @@ -1354,7 +1354,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| String shopInfoStr = getShopInfoStr(wxRentContract); | |||
| Map<String, Object> resultMap = buildRent(receivePeriod, priceArrs,null,null, yearList, Calendar.MONTH, wxRentContract, user, billcount, isPreview, shopInfoStr,saveDb); | |||
| List<WxBillRent> billRentList = (List<WxBillRent>)resultMap.get("billList"); | |||
| List<WxAllBill> billRentList = (List<WxAllBill>)resultMap.get("billList"); | |||
| resultList.addAll(billRentList); | |||
| return resultList; | |||
| } | |||
| @@ -1505,8 +1505,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(wxRentContract); | |||
| SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); | |||
| Map<String,Object> resultMap = new HashedMap(); | |||
| List<WxBillRent> resultList = new ArrayList<>(); | |||
| List<WxBillRentManage> manageList = new ArrayList<WxBillRentManage>(); | |||
| List<WxAllBill> resultList = new ArrayList<WxAllBill>(); | |||
| List<WxAllBill> manageList = new ArrayList<WxAllBill>(); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| Date endDate = null;//每年的截止日期 | |||
| @@ -1519,7 +1519,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| billTimeVoList = initBillTimeList(wxRentContract.getRentalStartDate(),wxRentContract.getRentalEndDate(),wxRentContract.getAdjustPeriod(),dayType,receivePeriod); | |||
| }else{ | |||
| //预账单编辑账期,生成金额 | |||
| for (WxBillRent rent:wxRentContract.getPreviewBillRentList()) { | |||
| for (WxAllBill rent:wxRentContract.getPreviewBillRentList()) { | |||
| BillTimeVo billTimeVo = new BillTimeVo(); | |||
| billTimeVo.setStartDate(rent.getStarttime()); | |||
| billTimeVo.setEndDate(rent.getEndtime()); | |||
| @@ -1645,10 +1645,11 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| } | |||
| } | |||
| WxBillRent wxBillRent = new WxBillRent(); | |||
| WxAllBill wxBillRent = new WxAllBill(); | |||
| wxBillRent.setIsPreview(isPreview); | |||
| wxBillRent.setId(idWorker.nextId()); | |||
| wxBillRent.setRentContractId(wxRentContract.getId()); | |||
| wxBillRent.setBillType(EnumBillAllType.RENT.getCode()); | |||
| wxBillRent.setPay("0"); | |||
| wxBillRent.setStarttime(billTimeVo.getStartDate()); | |||
| wxBillRent.setEndtime(billTimeVo.getEndDate()); | |||
| @@ -1688,9 +1689,9 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| wxBillRent.setEnergyFeesId(EnumBillAllType.RENT.getEnergyFeesId()); | |||
| //计算手续费 | |||
| BigDecimal servicePay = new BigDecimal(wxBillRent.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())) | |||
| .divide(new BigDecimal(10000), wxRentContract.getDecimalSize(), BigDecimal.ROUND_HALF_UP); | |||
| wxBillRent.setServiceChargePay(servicePay.toPlainString()); | |||
| //BigDecimal servicePay = new BigDecimal(wxBillRent.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())) | |||
| // .divide(new BigDecimal(10000), wxRentContract.getDecimalSize(), BigDecimal.ROUND_HALF_UP); | |||
| //wxBillRent.setServiceChargePay(servicePay.toPlainString()); | |||
| //wxBillRent.setOwe(new BigDecimal(wxBillRent.getReceivePay()).add(new BigDecimal(wxBillRent.getServiceChargePay())).toPlainString()); | |||
| //wxBillRent.setOwe(new BigDecimal(wxBillRent.getReceivePay()).toPlainString()); | |||
| resultList.add(wxBillRent); | |||
| @@ -1708,9 +1709,9 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| //批量插入账单 | |||
| if(saveDb) { | |||
| wxBillRentMapper.insertBills(wxRentContract.getTenantId(),resultList); | |||
| wxAllBillMapper.insertBills(wxRentContract.getTenantId(),resultList); | |||
| if (manageList.size() > 0 ) { | |||
| wxBillRentManageMapper.insertBills(wxRentContract.getTenantId(),manageList); | |||
| wxAllBillMapper.insertBills(wxRentContract.getTenantId(),manageList); | |||
| } | |||
| } | |||
| resultMap.put("billcount",billcount); | |||
| @@ -1719,13 +1720,15 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| } | |||
| private WxBillRentManage setManageRent(Integer decimalSize,WxBillRent wxBillRent,EnumRentContractManageFeeType feeType,String needPay,Integer serviceChargeRate,int dayType,int receivePeriod) { | |||
| WxBillRentManage manage = new WxBillRentManage(); | |||
| private WxAllBill setManageRent(Integer decimalSize,WxAllBill wxBillRent,EnumRentContractManageFeeType feeType,String needPay,Integer serviceChargeRate,int dayType,int receivePeriod) { | |||
| WxAllBill manage = new WxAllBill(); | |||
| //manage.initByBillRent(wxBillRent); | |||
| if (feeType.getCode().intValue() == EnumRentContractManageFeeType.RENT_BUSSINESS_MANAGE_FEE.getCode().intValue()){ | |||
| manage.setEnergyFeesId(EnumBillAllType.RENT_BUSSINESS_MANAGE.getEnergyFeesId()); | |||
| manage.setBillType(EnumBillAllType.RENT_BUSSINESS_MANAGE.getCode()); | |||
| }else if (feeType.getCode().intValue() == EnumRentContractManageFeeType.RENT_OPERATING_MANAGE_FEE.getCode().intValue()) { | |||
| manage.setEnergyFeesId(EnumBillAllType.RENT_OPERATION_MANAGE.getEnergyFeesId()); | |||
| manage.setBillType(EnumBillAllType.RENT_OPERATION_MANAGE.getCode()); | |||
| } | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| wxBillRent.setId(idWorker.nextId()); | |||
| @@ -1735,8 +1738,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| //manage.setOwe(needPay); | |||
| //setManageExpiredDay(manage,dayType,receivePeriod); | |||
| //计算手续费 | |||
| BigDecimal servicePay = new BigDecimal(needPay).multiply(new BigDecimal(serviceChargeRate)).divide(new BigDecimal(10000), decimalSize, BigDecimal.ROUND_HALF_UP); | |||
| manage.setServiceChargePay(servicePay.toPlainString()); | |||
| //BigDecimal servicePay = new BigDecimal(needPay).multiply(new BigDecimal(serviceChargeRate)).divide(new BigDecimal(10000), decimalSize, BigDecimal.ROUND_HALF_UP); | |||
| //manage.setServiceChargePay(servicePay.toPlainString()); | |||
| //manage.setOwe(new BigDecimal(needPay).add(new BigDecimal(manage.getServiceChargePay())).toPlainString()); | |||
| //manage.setOwe(new BigDecimal(needPay).toPlainString()); | |||
| return manage; | |||
| @@ -1883,7 +1886,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| wxPropertyContractMapper.endContract(wxPropertyContract); | |||
| //物业账单失效 | |||
| wxBillPropertyMapper.updateInvalidStatusByRent(wxRentContract); | |||
| wxAllBillMapper.updatePropertyBillInvalidStatusByRent(wxRentContract); | |||
| } | |||
| //租赁账单失效 | |||
| wxBillAllHelper.rentContractStop(wxRentContract,userInfo); | |||
| @@ -2076,22 +2079,22 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| record.getMerchantId() != null && | |||
| record.getReceivePeriod() != null ) { | |||
| //预览账单改为正式,并写入商户id | |||
| WxBillRent billRent = new WxBillRent(); | |||
| WxAllBill billRent = new WxAllBill(); | |||
| billRent.setRentContractId(id); | |||
| billRent.setIsPreview(EnumIsPreview.NO.getCode()); | |||
| billRent.setMerchantId(record.getMerchantId()); | |||
| billRent.updateTenantInfo(record); | |||
| wxBillRentMapper.updatePreviewStatus(billRent); | |||
| wxAllBillMapper.updatePreviewStatus(billRent); | |||
| // WxMerchant wxMerchant = new WxMerchant(); | |||
| // wxMerchant.setId(record.getMerchantId()); | |||
| // wxMerchant.updateTenantInfo(record); | |||
| //商业管理费,营业管理费 | |||
| WxBillRentManage billRentManage = new WxBillRentManage(); | |||
| WxAllBill billRentManage = new WxAllBill(); | |||
| billRentManage.setRentContractId(id); | |||
| billRentManage.setIsPreview(EnumIsPreview.NO.getCode()); | |||
| billRentManage.updateTenantInfo(record); | |||
| wxBillRentManageMapper.updatePreviewStatus(billRentManage); | |||
| wxAllBillMapper.updatePreviewStatus(billRentManage); | |||
| if(new BigDecimal(record.getDeposit()).compareTo(new BigDecimal(0)) > 0) { | |||
| //押金 | |||
| @@ -3116,7 +3119,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| @Override | |||
| public WxRentContract getByBill(WxBillRent billRent) { | |||
| public WxRentContract getByBill(WxAllBill billRent) { | |||
| return wxRentContractMapper.getByBill(billRent); | |||
| } | |||
| @@ -3489,15 +3492,15 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| @Override | |||
| public void deletePrewBill(WxRentContract record) { | |||
| //删除预账单,重新生成 | |||
| wxBillRentMapper.deleteBillByContract(record); | |||
| wxAllBillMapper.deleteBillByContract(record); | |||
| //删除商业管理费账单 | |||
| WxBillRentManage wxBillRentManage = new WxBillRentManage(); | |||
| wxBillRentManage.setRentContractId(record.getId()); | |||
| //WxAllBill wxBillRentManage = new WxAllBill(); | |||
| //wxBillRentManage.setRentContractId(record.getId()); | |||
| //wxBillRentManage.setManageFeeType(EnumRentContractManageFeeType.RENT_BUSSINESS_MANAGE_FEE.getCode()); | |||
| wxBillRentManage.updateTenantInfo(record); | |||
| wxBillRentManageMapper.deletePreviewBill(wxBillRentManage); | |||
| //wxBillRentManage.updateTenantInfo(record); | |||
| //wxAllBillMapper.deletePreviewBill(wxBillRentManage); | |||
| //删除营业管理费账单 | |||
| //wxBillRentManage.setManageFeeType(EnumRentContractManageFeeType.RENT_OPERATING_MANAGE_FEE.getCode()); | |||
| wxBillRentManageMapper.deletePreviewBill(wxBillRentManage); | |||
| //wxBillRentManageMapper.deletePreviewBill(wxBillRentManage); | |||
| } | |||
| } | |||
| @@ -3,7 +3,7 @@ package com.iformall.service.impl; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxBillProperty; | |||
| import com.iformall.domain.po.WxAllBill; | |||
| import com.iformall.domain.po.WxFlowRecord; | |||
| import com.iformall.domain.po.WxPropertyContract; | |||
| import com.iformall.domain.po.WxRentContract; | |||
| @@ -80,7 +80,7 @@ public class WxRentPropertyContractServiceImpl implements WxRentPropertyContract | |||
| if (null != propertyId) { | |||
| WxPropertyContract propertyContract = wxPropertyContractMapper.selectById(propertyId); | |||
| if (propertyContract != null) { | |||
| List<WxBillProperty> wxBillPropertyPreview = wxPropertyContractService.getWxBillPropertyPreview(propertyContract,propertyContract.getId()); | |||
| List<WxAllBill> wxBillPropertyPreview = wxPropertyContractService.getWxBillPropertyPreview(propertyContract,propertyContract.getId()); | |||
| propertyContract.setPreviewBillRentList(wxBillPropertyPreview); | |||
| data.put("property", propertyContract); | |||
| } | |||
| @@ -202,6 +202,10 @@ | |||
| delete from wx_all_bill where rent_contract_id = #{id} | |||
| </delete> | |||
| <delete id="deleteBillByPropertyContract" parameterType="com.iformall.domain.po.WxPropertyContract"> | |||
| delete from wx_all_bill where property_contract_id = #{id} | |||
| </delete> | |||
| <delete id="deletePreviewBill" parameterType="com.iformall.domain.po.WxAllBill"> | |||
| delete from wx_all_bill where rent_contract_id = #{rentContractId} | |||
| <if test=" null != isPreview "> and is_preview = #{isPreview}</if> | |||
| @@ -214,7 +218,12 @@ | |||
| <update id="updatePreviewStatus" parameterType="com.iformall.domain.po.WxAllBill"> | |||
| update wx_all_bill set is_preview = #{isPreview},merchant_id = #{merchantId},need_pay = receive_pay | |||
| where rent_contract_id = #{rentContractId} | |||
| <if test=" null != rentContractId"> | |||
| where rent_contract_id = #{rentContractId} | |||
| </if> | |||
| <if test=" null != propertyContractId"> | |||
| where property_contract_id = #{propertyContractId} | |||
| </if> | |||
| </update> | |||
| <insert id="insertBills" parameterType="HashMap"> | |||
| @@ -242,6 +251,12 @@ | |||
| <delete id = "deleteEnergyReadingBills" parameterType="HashMap"> | |||
| delete from wx_all_bill where energy_reading_calcuteId = #{energyReadingCalcuteId} and tenant_id = #{tenantId} and status = 2 and pay <= 0 and IFNULL(`set_off`,'0') <= 0 and IFNULL(`return_pay`,'0') <= 0 | |||
| </delete> | |||
| <update id="updatePropertyBillInvalidStatusByRent" parameterType="com.iformall.domain.po.WxRentContract"> | |||
| update wx_all_bill set status = 6 where property_contract_id in | |||
| (select id from wx_property_contract where rent_contract_id = #{id}) | |||
| and status != 3 | |||
| </update> | |||
| </mapper> | |||