diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/WxMerchantController.java b/mallinkAdmin/src/main/java/com/iformall/controller/WxMerchantController.java index 433198ebb..eb5586bd0 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/WxMerchantController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/WxMerchantController.java @@ -45,22 +45,6 @@ public class WxMerchantController extends BaseController { return new ResultData(page); } - @ApiOperation("新增接口") - @PostMapping("add") - public ResultData add(@RequestBody WxMerchant wxMerchant) { - logger.debug("[" + getIpAddr() + "] WxMerchantController::add"); - wxMerchant.setTenantId(getTenantId()); - wxMerchantService.saveOrUpdate(wxMerchant); - return new ResultData(); - } - - @ApiOperation("根据id更新接口") - @PostMapping("update") - public ResultData update(@RequestBody WxMerchant wxMerchant) { - logger.debug("[" + getIpAddr() + "] WxMerchantController::update"); - wxMerchantService.saveOrUpdate(wxMerchant); - return new ResultData(); - } @ApiOperation("ETCP商户列表") @GetMapping("etcplist") diff --git a/mallinkService/src/main/java/com/iformall/service/WxMerchantService.java b/mallinkService/src/main/java/com/iformall/service/WxMerchantService.java index 7478e9297..179d84da2 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxMerchantService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxMerchantService.java @@ -36,13 +36,6 @@ public interface WxMerchantService { * @return */ WxMerchant getById(Long id); - - /** - * 保存或更新实体 - * - * @param record - */ - void saveOrUpdate(WxMerchant record); /** * 根据Id删除实体 diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java index 12e200f5f..086a29189 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java @@ -197,18 +197,17 @@ public class WxMerchantServiceImpl implements WxMerchantService { long merchantId = idWorker.nextId(); //保存商户商铺的关联 List shopidlist = wxMerchant.getShopids(); - for (Long shopid : shopidlist) { + if(null!=shopidlist && !shopidlist.isEmpty()){ + Long shopid = shopidlist.get(0); WxMerchantShop wxMerchantShop = new WxMerchantShop(); - wxMerchantShop.setId(idWorker.nextId()); - wxMerchantShop.setMerchantId(merchantId); - wxMerchantShop.setShopId(shopid); - wxMerchantShop.setTenantId(wxMerchant.getTenantId()); - Date shopdate = new Date(); - wxMerchantShop.setUpdateDate(shopdate); - wxMerchantShop.setCreateDate(shopdate); wxMerchantShop.setIsDel(EnumDelStatus.NOT_DEL.getCode()); + long count = wxMerchantShopMapper.findList(wxMerchantShop).size(); + if(count>0){ + return new ResultData(ErrorCode.SHOP_IS_RENT); + } //更新商铺状态 WxShop wxShop = new WxShop(); + wxShop.setTenantId(wxMerchant.getTenantId()); wxShop.setId(shopid); //已出租 WxShop shop = wxShopMapper.selectByPrimaryKey(shopid); @@ -218,11 +217,17 @@ public class WxMerchantServiceImpl implements WxMerchantService { if (shop.getStatus().equals(EnumShopStatus.RENT.getCode())) { return new ResultData(ErrorCode.SHOP_IS_RENT); } + wxMerchantShop.setId(idWorker.nextId()); + wxMerchantShop.setMerchantId(merchantId); + wxMerchantShop.setTenantId(wxMerchant.getTenantId()); + Date shopdate = new Date(); + wxMerchantShop.setUpdateDate(shopdate); + wxMerchantShop.setCreateDate(shopdate); wxMerchantShopMapper.insertSelective(wxMerchantShop); wxShop.setStatus(EnumShopStatus.RENT.getCode()); wxShopMapper.updateByPrimaryKeySelective(wxShop); - } + wxMerchant.setId(merchantId); Date date = new Date(); wxMerchant.setStatus(EnumMerchantStatus.VALID.getCode()); @@ -288,7 +293,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { wxMerchantShop.setTenantId(wxMerchant.getTenantId()); wxMerchantShop.setShopId(shopid); wxMerchantShop.setIsDel(EnumDelStatus.NOT_DEL.getCode()); - long count = wxMerchantShopMapper.findList(wxMerchantShop).stream().filter(ms -> !ms.getMerchantId().equals(wxMerchant.getId())).count(); + long count = wxMerchantShopMapper.findList(wxMerchantShop).size(); if(count>0){ return new ResultData(ErrorCode.SHOP_IS_RENT); } @@ -410,193 +415,6 @@ public class WxMerchantServiceImpl implements WxMerchantService { } - @Transactional(rollbackFor = {Exception.class}) - @Override - public void saveOrUpdate(WxMerchant wxMerchant) { - - WxAppinfo wxAppinfo = new WxAppinfo(); - wxAppinfo.setTenantId(wxMerchant.getTenantId()); - wxAppinfo.setType(EnumAppType.B.getCode()); - wxAppinfo = wxAppinfoMapper.findList(wxAppinfo).get(0); - - final IdWorker idWorker = IdWorker.get(); - - if (wxMerchant.getId() == null) { - long merchantid = idWorker.nextId(); - wxMerchant.setId(merchantid); - Date date = new Date(); - wxMerchant.setStatus(EnumMerchantStatus.VALID.getCode()); - wxMerchant.setUpdateDate(date); - wxMerchant.setCreateDate(date); - wxMerchantMapper.insertSelective(wxMerchant); - - //保存商户商铺的关联 - List shopidlist = wxMerchant.getShopids(); - for (Long shopid : shopidlist) { - WxMerchantShop wxMerchantShop = new WxMerchantShop(); - wxMerchantShop.setId(idWorker.nextId()); - wxMerchantShop.setMerchantId(merchantid); - wxMerchantShop.setShopId(shopid); - wxMerchantShop.setTenantId(wxMerchant.getTenantId()); - Date shopdate = new Date(); - wxMerchantShop.setUpdateDate(shopdate); - wxMerchantShop.setCreateDate(shopdate); - wxMerchantShop.setIsDel(EnumDelStatus.NOT_DEL.getCode()); - wxMerchantShopMapper.insertSelective(wxMerchantShop); - - //更新商铺状态 - WxShop wxShop = new WxShop(); - wxShop.setId(shopid); - //已出租 - wxShop.setStatus(EnumShopStatus.RENT.getCode()); - wxShopMapper.updateByPrimaryKeySelective(wxShop); - } - - List bUsers = wxMerchant.getbUsers(); - - //保存商户关联用户 - for (WxMerchantBUser user : bUsers) { - long id = idWorker.nextId(); - user.setId(id); - user.setbUserId(id); - user.setMerchantId(merchantid); - user.setTenantId(wxMerchant.getTenantId()); - user.setAppId(wxAppinfo.getAppId()); - date = new Date(); - user.setCreateDate(date); - user.setUpdateDate(date); - user.setStatus(EnumMerchantBUserStatus.VALID.getCode()); - wxMerchantBUserMapper.insertSelective(user); - - } //添加商户的分账账户(不是必选) - if (wxMerchant.getAccountId() != null && wxMerchant.getAccountName() != null) { - WxProfitSharingReceiver receiver = new WxProfitSharingReceiver(); - receiver.setReceiverAccount(wxMerchant.getAccountId()); - receiver.setReceiverComments(wxMerchant.getName()); - receiver.setReceiverType(wxMerchant.getAccountTypeValue()); - receiver.setTrueName(wxMerchant.getAccountName()); - wxProfitSharingReceiverService.addReceiver(wxMerchant, receiver); - } - - //关联合同 - if (wxMerchant.getRentContractId() != null) { - WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(wxMerchant.getRentContractId()); - wxRentContract.setMerchantId(merchantid); - wxRentContract.setUpdatetime(new Date()); - wxRentContract.setStatus(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode()); - wxRentContractMapper.updateByPrimaryKeySelective(wxRentContract); - //创建账单 - buildRent(wxMerchant); - //创建押金 - buildDeposit(wxMerchant); - } - - } else { - - //更新商户 - Date date = new Date(); - wxMerchant.setUpdateDate(date); - wxMerchantMapper.updateByPrimaryKeySelective(wxMerchant); - - WxShop wxShopP = new WxShop(); - wxShopP.setId(wxMerchant.getShopids().get(0)); - - //删除当前商户关联的所有商铺然后再插入 - WxMerchantShop wxMerchantShopQuery = new WxMerchantShop(); - wxMerchantShopQuery.setTenantId(wxMerchant.getTenantId()); - wxMerchantShopQuery.setMerchantId(wxMerchant.getId()); - List wxMerchantShopList = wxMerchantShopMapper.findList(wxMerchantShopQuery); - for (WxMerchantShop merchantShop : wxMerchantShopList) { - merchantShop.setIsDel(EnumDelStatus.DEL.getCode()); - wxMerchantShopMapper.updateByPrimaryKeySelective(merchantShop); - - //更新商铺状态 - WxShop wxShop = new WxShop(); - wxShop.setId(merchantShop.getShopId()); - //未出租 - wxShop.setStatus(EnumShopStatus.NOT_RENT.getCode()); - wxShopMapper.updateByPrimaryKeySelective(wxShop); - } - - //保存商户商铺的关联 - List shopidlist = wxMerchant.getShopids(); - for (Long shopid : shopidlist) { - WxMerchantShop wxMerchantShop = new WxMerchantShop(); - wxMerchantShop.setId(idWorker.nextId()); - wxMerchantShop.setMerchantId(wxMerchant.getId()); - wxMerchantShop.setShopId(shopid); - wxMerchantShop.setTenantId(wxMerchant.getTenantId()); - Date shopdate = new Date(); - wxMerchantShop.setUpdateDate(shopdate); - wxMerchantShop.setCreateDate(shopdate); - wxMerchantShop.setRentalStartDate(wxMerchant.getRentalStartDate()); - wxMerchantShop.setRentalEndDate(wxMerchant.getRentalEndDate()); - wxMerchantShop.setIsDel(EnumDelStatus.NOT_DEL.getCode()); - wxMerchantShopMapper.insertSelective(wxMerchantShop); - - //更新商铺状态 - WxShop wxShop = new WxShop(); - wxShop.setId(shopid); - wxShop.setStatus(EnumShopStatus.RENT.getCode());//已出租 - wxShopMapper.updateByPrimaryKeySelective(wxShop); - } - - List bUsers = wxMerchant.getbUsers(); - - //删除之前的关联用户 - WxMerchantBUser bUser = new WxMerchantBUser(); - bUser.setMerchantId(wxMerchant.getId()); - List wxMerchantBUserMapperList = wxMerchantBUserMapper.findList(bUser); - for (WxMerchantBUser wxMerchantBUser : wxMerchantBUserMapperList) { - wxMerchantBUser.setStatus(EnumMerchantBUserStatus.INVALID.getCode()); - wxMerchantBUserMapper.updateByPrimaryKeySelective(wxMerchantBUser); - } - - - //保存商户关联用户 - for (WxMerchantBUser user : bUsers) { - if (user.getId() == null) {//没有id的新增 - long id = idWorker.nextId(); - user.setId(id); - user.setbUserId(id); - user.setMerchantId(wxMerchant.getId()); - user.setTenantId(wxMerchant.getTenantId()); - user.setAppId(wxAppinfo.getAppId()); - date = new Date(); - user.setCreateDate(date); - user.setUpdateDate(date); - user.setStatus(EnumMerchantBUserStatus.VALID.getCode()); - wxMerchantBUserMapper.insertSelective(user); - } else {//有id的更新 - user.setbUserId(user.getId()); - user.setMerchantId(wxMerchant.getId()); - user.setTenantId(wxMerchant.getTenantId()); - user.setAppId(wxAppinfo.getAppId()); - date = new Date(); - user.setUpdateDate(date); - user.setStatus(EnumMerchantBUserStatus.VALID.getCode()); - wxMerchantBUserMapper.updateByPrimaryKeySelective(user); - } - - } - - - //添加商户的分账账户(不是必选) - if (wxMerchant.getAccountId() != null && wxMerchant.getAccountName() != null - && !wxMerchant.getAccountId().isEmpty() && !wxMerchant.getAccountName().isEmpty()) { - WxProfitSharingReceiver receiver = new WxProfitSharingReceiver(); - receiver.setReceiverAccount(wxMerchant.getAccountId()); - receiver.setReceiverComments(wxMerchant.getName()); - receiver.setReceiverType(wxMerchant.getAccountTypeValue()); - receiver.setTrueName(wxMerchant.getAccountName()); - wxProfitSharingReceiverService.updateReceiver(wxMerchant, receiver); - } else { - wxProfitSharingReceiverService.delReceiver(wxMerchant); - } - } - - } - @Transactional(rollbackFor = {Exception.class}) public void buildDeposit(WxMerchant wxMerchant) { MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute("userSession"); diff --git a/mallinkService/src/main/resources/mapper/WxBillPropertyMapper.xml b/mallinkService/src/main/resources/mapper/WxBillPropertyMapper.xml index 4b0721e86..43b46b188 100644 --- a/mallinkService/src/main/resources/mapper/WxBillPropertyMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillPropertyMapper.xml @@ -72,7 +72,8 @@ and br.`tenant_id` = #{tenantId} and br.`status` = #{status} and br.`is_del` = #{isDel} - + and br.`receive_date` between #{starttime} and #{endtime} + order by id desc diff --git a/mallinkService/src/main/resources/mapper/WxBillRentMapper.xml b/mallinkService/src/main/resources/mapper/WxBillRentMapper.xml index d0b4231e3..3889d3493 100644 --- a/mallinkService/src/main/resources/mapper/WxBillRentMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillRentMapper.xml @@ -79,7 +79,7 @@ and br.`tenant_id` = #{tenantId} and br.`status` = #{status} and br.`is_del` = #{isDel} - + and br.`receive_date` between #{starttime} and #{endtime} order by id desc