Просмотр исходного кода

[租赁物业账单][修改][日期查询]

release_toaliyun_real
gongbiao 7 лет назад
Родитель
Сommit
36deff10c2
5 измененных файлов: 18 добавлений и 222 удалений
  1. +0
    -16
      mallinkAdmin/src/main/java/com/iformall/controller/WxMerchantController.java
  2. +0
    -7
      mallinkService/src/main/java/com/iformall/service/WxMerchantService.java
  3. +15
    -197
      mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java
  4. +2
    -1
      mallinkService/src/main/resources/mapper/WxBillPropertyMapper.xml
  5. +1
    -1
      mallinkService/src/main/resources/mapper/WxBillRentMapper.xml

+ 0
- 16
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")


+ 0
- 7
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删除实体


+ 15
- 197
mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java Просмотреть файл

@@ -197,18 +197,17 @@ public class WxMerchantServiceImpl implements WxMerchantService {
long merchantId = idWorker.nextId();
//保存商户商铺的关联
List<Long> 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<Long> 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<WxMerchantBUser> 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<WxMerchantShop> 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<Long> 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<WxMerchantBUser> bUsers = wxMerchant.getbUsers();

//删除之前的关联用户
WxMerchantBUser bUser = new WxMerchantBUser();
bUser.setMerchantId(wxMerchant.getId());
List<WxMerchantBUser> 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");


+ 2
- 1
mallinkService/src/main/resources/mapper/WxBillPropertyMapper.xml Просмотреть файл

@@ -72,7 +72,8 @@
<if test=" null != tenantId ">and br.`tenant_id` = #{tenantId}</if>
<if test=" null != status ">and br.`status` = #{status}</if>
<if test=" null != isDel ">and br.`is_del` = #{isDel}</if>
<if test=" null != starttime and null!=endtime ">and br.`receive_date` between #{starttime} and #{endtime}</if>
</where>
order by id desc
</select>


+ 1
- 1
mallinkService/src/main/resources/mapper/WxBillRentMapper.xml Просмотреть файл

@@ -79,7 +79,7 @@
<if test=" null != tenantId ">and br.`tenant_id` = #{tenantId}</if>
<if test=" null != status ">and br.`status` = #{status}</if>
<if test=" null != isDel ">and br.`is_del` = #{isDel}</if>
<if test=" null != starttime and null!=endtime ">and br.`receive_date` between #{starttime} and #{endtime}</if>
</where>
order by id desc
</select>


Загрузка…
Отмена
Сохранить