winter 11 месяцев назад
Родитель
Сommit
dc6c0bafd2
3 измененных файлов: 107 добавлений и 123 удалений
  1. +16
    -7
      mallinkAdmin/src/main/java/com/iformall/controller/contract/WxAgileContractController.java
  2. +2
    -4
      mallinkService/src/main/java/com/iformall/service/WxAgileContractService.java
  3. +89
    -112
      mallinkService/src/main/java/com/iformall/service/impl/WxAgileContractServiceImpl.java

+ 16
- 7
mallinkAdmin/src/main/java/com/iformall/controller/contract/WxAgileContractController.java Просмотреть файл

@@ -212,19 +212,22 @@ public class WxAgileContractController extends WxContractBaseController {
wxRentContract.updateTenantInfo(user);
//如果是修改
WxRentContract oldRentContract = null;
boolean isValidEdit = false;
if (null != wxRentContract.getId()) {
WxRentContract r = wxAgileContractService.selectById(wxRentContract.getId());
if (r.getStatus().intValue() == EnumRentContractStatus.DRAFT.getCode().intValue() ||
r.getStatus().intValue() == EnumRentContractStatus.UNWRITE.getCode().intValue()) {
}else if(isValidContract(r)){
oldRentContract = wxAgileContractService.selectById(wxRentContract.getId());
if (oldRentContract.getStatus().intValue() == EnumRentContractStatus.DRAFT.getCode().intValue() ||
oldRentContract.getStatus().intValue() == EnumRentContractStatus.UNWRITE.getCode().intValue()) {
}else if(isValidContract(oldRentContract)){
isValidEdit = true;
//如果当前合同存在影子合同,则不让修改,直接修改影子合同即可
WxRentContract rc = wxAgileContractService.findYingZiContract(r.getId(), r);
WxRentContract rc = wxAgileContractService.findYingZiContract(oldRentContract.getId(), oldRentContract);
if (null != rc) {
return new ResultData(Result.ERROR,"已存在影子合同,请直接修改影子合同");
}
//把源合同的款项设置复制过来
//wxAgileContractService.copyContractFees(r, user);
wxRentContract.setOrginId(r.getId());
wxRentContract.setOrginId(oldRentContract.getId());
wxRentContract.setId(null);
}else {
return new ResultData(Result.ERROR,"该状态不允许修改");
@@ -236,7 +239,13 @@ public class WxAgileContractController extends WxContractBaseController {
}catch(Exception e) {
return new ResultData(Result.ERROR,e.getMessage());
}
return wxAgileContractService.saveOrUpdate(wxRentContract, user);
ResultData result = wxAgileContractService.saveOrUpdate(wxRentContract, user);
//如果是有效的合同编辑,则复制其他设置到影子合同
if (result.code == Result.SUCCESS && null != oldRentContract && isValidEdit) {
wxAgileContractService.copyContractConfig(wxRentContract.getId(), oldRentContract, user, false);
}
return result;
}
private void handleSaveData(WxRentContract wxRentContract) {


+ 2
- 4
mallinkService/src/main/java/com/iformall/service/WxAgileContractService.java Просмотреть файл

@@ -80,15 +80,13 @@ public interface WxAgileContractService {
PageInfo<WxContractCustomers> getContractCustomersList(WxContractCustomers record, Integer pageIndex, Integer pageSize);
void copyContractConfig(Long destId,WxRentContract orgContract,MallUserInfo user,boolean isReBuildUnDeposit);
void renewalAgile(WxRentContract wxRentContract,MallUserInfo user);
void transfer(WxRentContract wxRentContract,MallUserInfo user);
List<WxRentContractYearsVo> getRentContractYears(WxRentContract rentContract);
//void copyContractFees(Long oriContractId,WxRentContract destcontract,MallUserInfo user);
//void endContractDespoitBill(WxRentContract wxRentContract,MallUserInfo user);
//void endContractUnDespositBill(WxRentContractAgileUnDeposit unDeposit,MallUserInfo user);
//void endContractRenevueBill(WxRentContractAgileRenevue renevue);
void deleteContract(Long id,TenantEntity tenantEntity);
}

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

@@ -1073,21 +1073,19 @@ public class WxAgileContractServiceImpl implements WxAgileContractService {
return pageInfo;
}
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
@Override
@Transactional(rollbackFor = {Exception.class})
public void renewalAgile(WxRentContract rentContract,MallUserInfo user) {
public void copyContractConfig(Long destId,WxRentContract orgContract,MallUserInfo user,boolean isReBuildUnDeposit) {
final IdWorker idWorker = IdWorker.get();
Long newContractId = idWorker.nextId();
//拷贝
WxContractShop csq = new WxContractShop();
csq.updateTenantInfo(rentContract);
csq.setContractId(rentContract.getId());
csq.updateTenantInfo(user);
csq.setContractId(orgContract.getId());
List<WxContractShop> csqlist = wxContractShopMapper.findList(csq);
if (null != csqlist && csqlist.size() > 0 ){
for ( int i = 0 ; i< csqlist.size() ; i ++) {
WxContractShop cs = csqlist.get(i);
cs.setId(idWorker.nextId());
cs.setContractId(newContractId);
cs.setContractId(destId);
cs.setCreateDate(new Date());
cs.setUpdateDate(new Date());
wxContractShopMapper.insert(cs);
@@ -1095,29 +1093,29 @@ public class WxAgileContractServiceImpl implements WxAgileContractService {
}
WxRentContractAgileDeposit cadq = new WxRentContractAgileDeposit();
cadq.updateTenantInfo(rentContract);
cadq.setRentContractId(rentContract.getId());
cadq.updateTenantInfo(user);
cadq.setRentContractId(orgContract.getId());
List<WxRentContractAgileDeposit> depositList = wxRentContractAgileDepositMapper.findList(cadq);
if (null != depositList && depositList.size() > 0 ){
for ( int i = 0 ; i< depositList.size() ; i ++) {
WxRentContractAgileDeposit rad = depositList.get(i);
Long oldId = rad.getId();
rad.setId(idWorker.nextId());
rad.setRentContractId(newContractId);
rad.setRentContractId(destId);
rad.setCreatetime(new Date());
rad.setUpdatetime(new Date());
wxRentContractAgileDepositMapper.insert(rad);
WxRentContractAgileDepositShop radsq = new WxRentContractAgileDepositShop();
radsq.updateTenantInfo(rentContract);
radsq.setRentContractId(rentContract.getId());
radsq.updateTenantInfo(user);
radsq.setRentContractId(orgContract.getId());
radsq.setRentDepositId(oldId);
List<WxRentContractAgileDepositShop> dslist = wxRentContractAgileDepositShopMapper.findList(radsq);
if (null != dslist && dslist.size() > 0 ){
for ( int j = 0 ; j< dslist.size() ; j ++) {
WxRentContractAgileDepositShop ds = dslist.get(j);
ds.setId(idWorker.nextId());
ds.setRentContractId(newContractId);
ds.setRentContractId(destId);
ds.setRentDepositId(rad.getId());
ds.setCreatetime(new Date());
ds.setUpdatetime(new Date());
@@ -1128,40 +1126,65 @@ public class WxAgileContractServiceImpl implements WxAgileContractService {
}
WxRentContractAgileUnDeposit raudq = new WxRentContractAgileUnDeposit();
raudq.updateTenantInfo(rentContract);
raudq.setRentContractId(rentContract.getId());
raudq.updateTenantInfo(user);
raudq.setRentContractId(orgContract.getId());
List<WxRentContractAgileUnDeposit> undepositList = wxRentContractAgileUnDepositMapper.findList(raudq);
if (null != undepositList && undepositList.size() > 0 ) {
for ( int i = 0 ; i< undepositList.size() ; i ++) {
WxRentContractAgileUnDeposit raud = undepositList.get(i);
Long oraudid = raud.getId();
raud.setId(idWorker.nextId());
raud.setRentContractId(newContractId);
raud.setRentContractId(destId);
raud.setCreatetime(new Date());
raud.setUpdatetime(new Date());
wxRentContractAgileUnDepositMapper.insert(raud);
if (raud.getSettingMethod().intValue() == EnumRentContractAgilSettingMethod.BY_CONTRACT.getCode().intValue()) {
WxRentContractAgileUnDepositItem item = generateUnDepositItem(idWorker,rentContract,raud.getId(),raud.getFeesId(),null);
wxRentContractAgileUnDepositItemMapper.insert(item);
}else {
List<Long> shopIdList = rentContract.shopIdsByRentInfo();
for (int j = 0 ; j < shopIdList.size(); j++ ){
WxRentContractAgileUnDepositItem item = generateUnDepositItem(idWorker,rentContract,raud.getId(),raud.getFeesId(),shopIdList.get(j));
//是否设置一个默认的
if (isReBuildUnDeposit) {
if (raud.getSettingMethod().intValue() == EnumRentContractAgilSettingMethod.BY_CONTRACT.getCode().intValue()) {
WxRentContractAgileUnDepositItem item = generateUnDepositItem(idWorker,orgContract,raud.getId(),raud.getFeesId(),null);
wxRentContractAgileUnDepositItemMapper.insert(item);
}else {
List<Long> shopIdList = orgContract.shopIdsByRentInfo();
for (int j = 0 ; j < shopIdList.size(); j++ ){
WxRentContractAgileUnDepositItem item = generateUnDepositItem(idWorker,orgContract,raud.getId(),raud.getFeesId(),shopIdList.get(j));
wxRentContractAgileUnDepositItemMapper.insert(item);
}
}
}else {
WxRentContractAgileUnDepositItem udiq = new WxRentContractAgileUnDepositItem();
udiq.updateTenantInfo(user);
udiq.setUnDepositId(oraudid);
udiq.setRentContractId(orgContract.getId());
List<WxRentContractAgileUnDepositItem> udiqList = wxRentContractAgileUnDepositItemMapper.findList(udiq);
if (null != udiqList && udiqList.size() > 0 ) {
for (int j = 0 ; j < udiqList.size(); j++) {
WxRentContractAgileUnDepositItem udi = udiqList.get(j);
udi.setId(idWorker.nextId());
udi.setRentContractId(destId);
udi.setUnDepositId(raud.getId());
udi.setCreatetime(new Date());
udi.setUpdatetime(new Date());
wxRentContractAgileUnDepositItemMapper.insert(udi);
}
}
}
}
}
WxRentContractAgileRenevue rq = new WxRentContractAgileRenevue();
rq.updateTenantInfo(rentContract);
rq.setRentContractId(rentContract.getId());
rq.updateTenantInfo(user);
rq.setRentContractId(orgContract.getId());
List<WxRentContractAgileRenevue> renevueList = wxRentContractAgileRenevueMapper.findList(rq);
Long oldRenevueId = null;
Long renevueId = null;
if (null != renevueList && renevueList.size() > 0 ) {
for (int i = 0 ; i < renevueList.size() ; i++) {
WxRentContractAgileRenevue ar = renevueList.get(i);
ar.setRentContractId(newContractId);
oldRenevueId = ar.getId();
ar.setRentContractId(destId);
ar.setId(idWorker.nextId());
ar.setCreatetime(new Date());
ar.setUpdatetime(new Date());
@@ -1169,18 +1192,40 @@ public class WxAgileContractServiceImpl implements WxAgileContractService {
renevueId = ar.getId();
}
}
if (null != renevueId) {
WxRentContractAgileRenevueItem ari = generateRenevueItem(idWorker, rentContract, newContractId, renevueId);
wxRentContractAgileRenevueItemMapper.insert(ari);
if (isReBuildUnDeposit) {
if (null != renevueId) {
WxRentContractAgileRenevueItem ari = generateRenevueItem(idWorker, orgContract, destId, renevueId);
wxRentContractAgileRenevueItemMapper.insert(ari);
}
}else {
if (null != oldRenevueId && null != renevueId) {
WxRentContractAgileRenevueItem riq = new WxRentContractAgileRenevueItem();
riq.updateTenantInfo(user);
riq.setRenevueId(oldRenevueId);
riq.setRentContractId(orgContract.getId());;
List<WxRentContractAgileRenevueItem> riqList = wxRentContractAgileRenevueItemMapper.findList(riq);
if (null != riqList && riqList.size() > 0 ) {
for (int i = 0 ; i < riqList.size() ; i ++) {
WxRentContractAgileRenevueItem ri = riqList.get(i);
ri.setRentContractId(destId);
ri.setRenevueId(renevueId);
ri.setId(idWorker.nextId());
ri.setCreatetime(new Date());
ri.setUpdatetime(new Date());
wxRentContractAgileRenevueItemMapper.insert(ri);
}
}
}
}
WxRentContractAgileRenevueFees fq = new WxRentContractAgileRenevueFees();
fq.updateTenantInfo(rentContract);
fq.setRentContractId(rentContract.getId());
fq.updateTenantInfo(user);
fq.setRentContractId(orgContract.getId());
List<WxRentContractAgileRenevueFees> renevueFeesList = wxRentContractAgileRenevueFeesMapper.findList(fq);
if (null != renevueFeesList && renevueFeesList.size() > 0 && null != renevueId ) {
for (int i = 0 ; i < renevueFeesList.size() ; i++) {
WxRentContractAgileRenevueFees arf = renevueFeesList.get(i);
arf.setRentContractId(newContractId);
arf.setRentContractId(destId);
arf.setAgileRenevueId(renevueId);
arf.setId(idWorker.nextId());
arf.setCreatetime(new Date());
@@ -1190,13 +1235,13 @@ public class WxAgileContractServiceImpl implements WxAgileContractService {
}
WxRentContractRevenueJump crjq = new WxRentContractRevenueJump();
crjq.updateTenantInfo(rentContract);
crjq.setRentContractId(rentContract.getId());
crjq.updateTenantInfo(user);
crjq.setRentContractId(orgContract.getId());
List<WxRentContractRevenueJump> jumpList = wxRentContractRevenueJumpMapper.findList(crjq);
if ( null != jumpList && jumpList.size() > 0 ) {
for (int i = 0 ; i < jumpList.size(); i++) {
WxRentContractRevenueJump rj = jumpList.get(i);
rj.setRentContractId(newContractId);
rj.setRentContractId(destId);
rj.setId(idWorker.nextId());
rj.setCreateTime(new Date());
rj.setUpdateTime(new Date());
@@ -1204,6 +1249,13 @@ public class WxAgileContractServiceImpl implements WxAgileContractService {
}
}
}
@Override
@Transactional(rollbackFor = {Exception.class})
public void renewalAgile(WxRentContract rentContract,MallUserInfo user) {
final IdWorker idWorker = IdWorker.get();
Long newContractId = idWorker.nextId();
rentContract.setId(newContractId);
rentContract.setCreatetime(new Date());
rentContract.setCreateBy(user.getId());
@@ -1217,6 +1269,8 @@ public class WxAgileContractServiceImpl implements WxAgileContractService {
int[] array = DateUtils.getDiff(rentContract.getRentalStartDate(),rentContract.getRentalEndDate());
rentContract.setLease(array[0]);
wxRentContractMapper.insert(rentContract);
copyContractConfig(newContractId, rentContract, user, true);
}
private WxRentContractAgileRenevueItem generateRenevueItem(IdWorker idWorker,WxRentContract rentContract,Long newContractId,Long renevueId) {
@@ -1361,81 +1415,4 @@ public class WxAgileContractServiceImpl implements WxAgileContractService {
brDel.setIsPreview(EnumYesOrNo.YES.getCode());
wxAllBillMapper.deletePreviewBill(brDel);
}

// @Transactional(rollbackFor = {Exception.class})
// @Override
// public void copyContractFees(Long oriContractId,WxRentContract destcontract,MallUserInfo user) {
//
// //原来所有的非押金,扣点都默认设置为按合同,然后时间设置为合同开始时间和结束时间,单价为0
// WxRentContractAgileUnDeposit udq = new WxRentContractAgileUnDeposit();
// udq.updateTenantInfo(destcontract);
// udq.setRentContractId(oriContractId);
// List<WxRentContractAgileUnDeposit> udList = wxRentContractAgileUnDepositMapper.findList(udq);
// final IdWorker idWorker = IdWorker.get();
// if (null != udList && udList.size() > 0 ) {
// for (int i = 0 ; i < udList.size(); i++ ) {
// WxRentContractAgileUnDeposit ud = udList.get(i);
// WxRentContractAgileUnDepositItem udi = generateUnDepositItem(idWorker, destcontract, ud.getId(), ud.getFeesId(), null);
// }
// }
// WxRentContractAgileRenevue arq = new WxRentContractAgileRenevue();
// arq.updateTenantInfo(wxRentContract);
// arq.setRentContractId(wxRentContract.getId());
// List<WxRentContractAgileRenevue> arList = wxRentContractAgileRenevueMapper.findList(arq);
// if (null != arList && arList.size() > 0 ) {
// for (int i = 0 ; i < arList.size(); i++ ) {
// WxRentContractAgileRenevue ud = arList.get(i);
// WxRentContractAgileRenevueItem arid = new WxRentContractAgileRenevueItem();
// arid.updateTenantInfo(wxRentContract);
// arid.setRentContractId(wxRentContract.getId());
// arid.setRenevueId(ud.getId());
// wxRentContractAgileRenevueItemMapper.deleteByRenevue(arid);
// generateRenevueItem(idWorker, wxRentContract, wxRentContract.getId(), ud.getId());
// }
// }
// }

// @Override
// public void endContractDespoitBill(WxRentContract wxRentContract, MallUserInfo user) {
// //当前时间之后的未处理过的账单,全部删除,之前的账单,还有以后已经处理过的账单,不处理。需财务手工处理这些账单
// WxAllBill bq = new WxAllBill();
// bq.updateTenantInfo(wxRentContract);
// bq.setRentContractId(wxRentContract.getId());
// bq.setShopEndtime(new Date());
// List<Long> feesIds = new ArrayList<Long>();
// for (int i = 0 ; i < wxRentContract.getContractDepositList().size(); i++) {
// WxRentContractAgileDeposit deposit = wxRentContract.getContractDepositList().get(i);
// if (!feesIds.contains(deposit.getFeesId())) {
// feesIds.add(deposit.getFeesId());
// }
// }
// bq.setEnergyFeesIds(feesIds);
// bq.setRentContractAgileFeesType(EnumRentContractAgileFeesType.DEPOSIT.getCode());
// wxAllBillMapper.deleteNoNeedPayBill(bq);
// }
//
// @Override
// public void endContractUnDespositBill(WxRentContractAgileUnDeposit unDeposit, MallUserInfo user) {
// WxAllBill bq = new WxAllBill();
// bq.updateTenantInfo(unDeposit);
// bq.setRentContractId(unDeposit.getRentContractId());
// bq.setShopEndtime(new Date());
// bq.setEnergyFeesId(unDeposit.getFeesId());
// bq.setRentContractAgileFeesType(EnumRentContractAgileFeesType.UN_DEPOSIT.getCode());
// wxAllBillMapper.deleteNoNeedPayBill(bq);
// }
//
// @Transactional(rollbackFor = {Exception.class})
// @Override
// public void endContractRenevueBill(WxRentContractAgileRenevue renevue) {
// WxAllBill bq = new WxAllBill();
// bq.updateTenantInfo(renevue);
// bq.setRentContractId(renevue.getRentContractId());
// bq.setShopEndtime(new Date());
// bq.setExtraCreateFrom(EnumBillExtraCreateFrom.RNET_REVENUE_SALES.getCode());
// wxAllBillMapper.deleteNoNeedPayBill(bq);
// bq.setExtraCreateFrom(EnumBillExtraCreateFrom.RNET_TIAODIAN_HUISUAN.getCode());
// wxAllBillMapper.deleteNoNeedPayBill(bq);
// }
}

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