Explorar el Código

fix

release_toaliyun_real
winter hace 1 año
padre
commit
2c66e03ba8
Se han modificado 11 ficheros con 252 adiciones y 49 borrados
  1. +25
    -2
      mallinkAdmin/src/main/java/com/iformall/controller/market/WxFinanceController.java
  2. +1
    -0
      mallinkService/src/main/java/com/iformall/domain/dto/FinanceReceiveCalcuteDTO.java
  3. +6
    -1
      mallinkService/src/main/java/com/iformall/domain/po/WxAllBill.java
  4. +4
    -0
      mallinkService/src/main/java/com/iformall/mapper/WxAllBillMapper.java
  5. +3
    -0
      mallinkService/src/main/java/com/iformall/service/WxAllBillService.java
  6. +6
    -1
      mallinkService/src/main/java/com/iformall/service/WxFinanceService.java
  7. +0
    -4
      mallinkService/src/main/java/com/iformall/service/helper/WxBillAllHelper.java
  8. +12
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxAllBillServiceImpl.java
  9. +178
    -41
      mallinkService/src/main/java/com/iformall/service/impl/WxFinanceServiceImpl.java
  10. +3
    -0
      mallinkService/src/main/java/com/iformall/utils/Constant.java
  11. +14
    -0
      mallinkService/src/main/resources/mapper/WxAllBillMapper.xml

+ 25
- 2
mallinkAdmin/src/main/java/com/iformall/controller/market/WxFinanceController.java Ver fichero

@@ -22,6 +22,7 @@ import com.iformall.domain.po.WxFlowModel;
import com.iformall.domain.po.WxShop; import com.iformall.domain.po.WxShop;
import com.iformall.domain.po.base.BaseEntity; import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.FinanceAdvanceBillVo;
import com.iformall.domain.vo.FinanceBillSetoffSum; import com.iformall.domain.vo.FinanceBillSetoffSum;
import com.iformall.domain.vo.WxFinanceReceiveBillSum; import com.iformall.domain.vo.WxFinanceReceiveBillSum;
import com.iformall.domain.vo.WxFinanceReceiveCountVo; import com.iformall.domain.vo.WxFinanceReceiveCountVo;
@@ -281,14 +282,36 @@ public class WxFinanceController extends BaseController {
return new ResultData(); return new ResultData();
} }
//查询铺位预收总计
//押金总计
@GetMapping("getMerchantDeposit")
public ResultData getMerchantDeposit(@ModelAttribute WxShop record) {
record.updateTenantInfo(getTenantInfo());
if (null == record.getId()) {
return new ResultData(Result.ERROR,"请选择房源");
}
BigDecimal sum = wxFinanceService.getBillDepositSum(record);
return new ResultData(sum);
}
//预收总计
@GetMapping("getMerchantAdvance") @GetMapping("getMerchantAdvance")
public ResultData getMerchantAdvance(@ModelAttribute WxShop record) { public ResultData getMerchantAdvance(@ModelAttribute WxShop record) {
record.updateTenantInfo(getTenantInfo()); record.updateTenantInfo(getTenantInfo());
if (null == record.getId()) { if (null == record.getId()) {
return new ResultData(Result.ERROR,"请选择房源"); return new ResultData(Result.ERROR,"请选择房源");
} }
FinanceBillSetoffSum sum = wxFinanceService.getBillSetoffSum(record);
BigDecimal sum = wxFinanceService.getBillSetoffSum(record);
return new ResultData(sum);
}
@GetMapping("getMerchantAdvanceDepositList")
public ResultData getMerchantAdvanceDepositList(@ModelAttribute WxShop record) {
record.updateTenantInfo(getTenantInfo());
if (null == record.getId()) {
return new ResultData(Result.ERROR,"请选择房源");
}
//FinanceBillSetoffSum sum
List<FinanceAdvanceBillVo> sum = wxFinanceService.getMerchantAdvanceDepositList(record);
return new ResultData(sum); return new ResultData(sum);
} }


+ 1
- 0
mallinkService/src/main/java/com/iformall/domain/dto/FinanceReceiveCalcuteDTO.java Ver fichero

@@ -17,4 +17,5 @@ public class FinanceReceiveCalcuteDTO extends TenantEntity{
private BigDecimal totalSetoff; private BigDecimal totalSetoff;
private BigDecimal totalRemainPay; private BigDecimal totalRemainPay;
private BigDecimal totalCut; private BigDecimal totalCut;
private BigDecimal totalNeedPay;
} }

+ 6
- 1
mallinkService/src/main/java/com/iformall/domain/po/WxAllBill.java Ver fichero

@@ -245,7 +245,10 @@ public class WxAllBill extends TenantEntity {
if (StringUtils.isBlank(returnPay)) { if (StringUtils.isBlank(returnPay)) {
returnPay = "0"; returnPay = "0";
} }
return new BigDecimal(pay).subtract(new BigDecimal(returnPay)).toPlainString();
if (StringUtils.isBlank(useMoney)) {
useMoney = "0";
}
return new BigDecimal(pay).subtract(new BigDecimal(returnPay)).subtract(new BigDecimal(useMoney)).toPlainString();
} }
@Excel(name = "备注", width = 20, orderNum = "9") @Excel(name = "备注", width = 20, orderNum = "9")
@@ -423,6 +426,8 @@ public class WxAllBill extends TenantEntity {
@TableField(exist = false) @TableField(exist = false)
public Integer advanceHasMoney; public Integer advanceHasMoney;
@TableField(exist = false) @TableField(exist = false)
private Integer depositHasMoney;
@TableField(exist = false)
private String energyFeesIdStr; private String energyFeesIdStr;
@TableField(exist = false) @TableField(exist = false)
private String cusLinkPerson; private String cusLinkPerson;


+ 4
- 0
mallinkService/src/main/java/com/iformall/mapper/WxAllBillMapper.java Ver fichero

@@ -8,6 +8,8 @@ import com.iformall.domain.vo.WxBillHotNotify;
import com.iformall.domain.vo.WxBillNotify; import com.iformall.domain.vo.WxBillNotify;
import com.iformall.domain.vo.WxBillSum; import com.iformall.domain.vo.WxBillSum;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List; import java.util.List;


/** /**
@@ -21,6 +23,8 @@ public interface WxAllBillMapper extends CommonMapper<WxAllBill, Long> {
List<Long> getShopIdList(WxAllBill record); List<Long> getShopIdList(WxAllBill record);
BigDecimal getMerchantAdvanceGroupSum(WxAllBill wxBillRent);
BigDecimal getMerchantDepositGroupSum(WxAllBill wxBillRent);
List<WxAllBill> getMerchantAdvanceGroupSumList(WxAllBill wxBillRent); List<WxAllBill> getMerchantAdvanceGroupSumList(WxAllBill wxBillRent);
List<WxBillNotify> getBillNotifyList(WxAllBill record); List<WxBillNotify> getBillNotifyList(WxAllBill record);


+ 3
- 0
mallinkService/src/main/java/com/iformall/service/WxAllBillService.java Ver fichero

@@ -18,6 +18,7 @@ import com.iformall.domain.vo.WxBillSum;
import com.iformall.enums.EnumBillAction; import com.iformall.enums.EnumBillAction;
import com.iformall.enums.EnumBillStatus; import com.iformall.enums.EnumBillStatus;


import java.math.BigDecimal;
import java.util.List; import java.util.List;


import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@@ -56,6 +57,8 @@ public interface WxAllBillService {
void completeBill(EnumBillStatus status,WxShop wxShop,MallUserInfo user); void completeBill(EnumBillStatus status,WxShop wxShop,MallUserInfo user);
BigDecimal getBillSetoffSum(WxAllBill wxBillRent);
BigDecimal getBillDepositSum(WxAllBill wxBillRent);
List<WxAllBill> getMerchantAdvanceGroupSumList(WxAllBill wxBillRent); List<WxAllBill> getMerchantAdvanceGroupSumList(WxAllBill wxBillRent);
List<WxAllBill> list(WxAllBill record); List<WxAllBill> list(WxAllBill record);


+ 6
- 1
mallinkService/src/main/java/com/iformall/service/WxFinanceService.java Ver fichero

@@ -1,5 +1,6 @@
package com.iformall.service; package com.iformall.service;


import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -25,6 +26,7 @@ import com.iformall.domain.po.WxFinanceReceivePayway;
import com.iformall.domain.po.WxFinanceReceiveSetoff; import com.iformall.domain.po.WxFinanceReceiveSetoff;
import com.iformall.domain.po.WxShop; import com.iformall.domain.po.WxShop;
import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.FinanceAdvanceBillVo;
import com.iformall.domain.vo.FinanceBillSetoffSum; import com.iformall.domain.vo.FinanceBillSetoffSum;
import com.iformall.domain.vo.WxFinanceReceiveBillSum; import com.iformall.domain.vo.WxFinanceReceiveBillSum;
import com.iformall.domain.vo.WxFinanceReceiveCountVo; import com.iformall.domain.vo.WxFinanceReceiveCountVo;
@@ -62,10 +64,13 @@ public interface WxFinanceService {
void updateReceiveStatus(WxFinanceReceive record); void updateReceiveStatus(WxFinanceReceive record);
//预收款 //预收款
List<WxAllBill> calcuetSetOff(FinanceSetOffDTO dto,MallUserInfo user); List<WxAllBill> calcuetSetOff(FinanceSetOffDTO dto,MallUserInfo user);
FinanceBillSetoffSum getBillSetoffSum(WxShop wxShop);
//List<WxFinanceReceive> getSetOffList(FinanceSetOffDTO dto,boolean isMerge); //List<WxFinanceReceive> getSetOffList(FinanceSetOffDTO dto,boolean isMerge);
PageInfo<WxFinanceReceiveSetoff> receiveSetoffListAsPage(WxFinanceReceive record, Integer pageIndex, Integer pageSize); PageInfo<WxFinanceReceiveSetoff> receiveSetoffListAsPage(WxFinanceReceive record, Integer pageIndex, Integer pageSize);
BigDecimal getBillSetoffSum(WxShop wxShop);
BigDecimal getBillDepositSum(WxShop wxShop);
List<FinanceAdvanceBillVo> getMerchantAdvanceDepositList(WxShop wxShop);
//增加临时费用 //增加临时费用
void createTempFees(WxAllBill record,MallUserInfo user); void createTempFees(WxAllBill record,MallUserInfo user);
void createTempToPay(WxAllBill record,MallUserInfo user); void createTempToPay(WxAllBill record,MallUserInfo user);


+ 0
- 4
mallinkService/src/main/java/com/iformall/service/helper/WxBillAllHelper.java Ver fichero

@@ -380,10 +380,6 @@ public class WxBillAllHelper {
wxAllBillService.completeBill(status,wxShop, user); wxAllBillService.completeBill(status,wxShop, user);
} }
public List<WxAllBill> getMerchantAdvanceGroupSumList(WxAllBill bill) {
return wxAllBillService.getMerchantAdvanceGroupSumList(bill);
}
/** /**
* 退租: * 退租:
* 账单开始时间>= 今天,并且账单是 WAIT_PAY,NOT_PAID,NOT_EXPIRED,BAD 变为INVALID,如果已付了款,需要退回 * 账单开始时间>= 今天,并且账单是 WAIT_PAY,NOT_PAID,NOT_EXPIRED,BAD 变为INVALID,如果已付了款,需要退回


+ 12
- 0
mallinkService/src/main/java/com/iformall/service/impl/WxAllBillServiceImpl.java Ver fichero

@@ -544,6 +544,18 @@ public class WxAllBillServiceImpl extends WxBillBaseService implements WxAllBill
} }
@Override
public BigDecimal getBillSetoffSum(WxAllBill record) {
updateQueryParam(record);
return wxAllBillMapper.getMerchantAdvanceGroupSum(record);
}
@Override
public BigDecimal getBillDepositSum(WxAllBill record) {
updateQueryParam(record);
return wxAllBillMapper.getMerchantDepositGroupSum(record);
}
@Override @Override
public List<WxAllBill> getMerchantAdvanceGroupSumList(WxAllBill record) { public List<WxAllBill> getMerchantAdvanceGroupSumList(WxAllBill record) {
updateQueryParam(record); updateQueryParam(record);


+ 178
- 41
mallinkService/src/main/java/com/iformall/service/impl/WxFinanceServiceImpl.java Ver fichero

@@ -241,10 +241,35 @@ public class WxFinanceServiceImpl implements WxFinanceService {
payway4.setCreateTime(new Date()); payway4.setCreateTime(new Date());
payway4.setUpdateTime(new Date()); payway4.setUpdateTime(new Date());
wxBillPayWayMapper.insert(payway4); wxBillPayWayMapper.insert(payway4);
WxBillPayWay payway5 = new WxBillPayWay();
payway5.updateTenantInfo(tenantInfo);
payway5.setId(Constant.bill_pay_way_deposit_setoff);
payway5.setName("押金抵扣");
payway5.setIsDel(EnumYesOrNo.NO.getCode());
payway5.setIsSystem(EnumYesOrNo.YES.getCode());
payway5.setCreateTime(new Date());
payway5.setUpdateTime(new Date());
wxBillPayWayMapper.insert(payway5);
} }


@Override @Override
public FinanceBillSetoffSum getBillSetoffSum(WxShop record) {
public BigDecimal getBillDepositSum(WxShop record) {
//取账单里面的
//查询预存账单
WxAllBill abq = new WxAllBill();
abq.updateTenantInfo(record);
abq.setShopId(record.getId());
abq.setDepositHasMoney(EnumYesOrNo.YES.getCode());
BigDecimal total = wxAllBillService.getBillDepositSum(abq);
if (null == total) {
total = new BigDecimal(0);
}
return total;
}
@Override
public BigDecimal getBillSetoffSum(WxShop record) {
//取账单里面的 //取账单里面的
//查询预存账单 //查询预存账单
WxAllBill abq = new WxAllBill(); WxAllBill abq = new WxAllBill();
@@ -252,10 +277,34 @@ public class WxFinanceServiceImpl implements WxFinanceService {
abq.setBillType(EnumBillAllType.ADVANCE.getCode()); abq.setBillType(EnumBillAllType.ADVANCE.getCode());
abq.setShopId(record.getId()); abq.setShopId(record.getId());
abq.setAdvanceHasMoney(EnumYesOrNo.YES.getCode()); abq.setAdvanceHasMoney(EnumYesOrNo.YES.getCode());
List<WxAllBill> advanceList = wxBillAllHelper.getMerchantAdvanceGroupSumList(abq);
BigDecimal total = new BigDecimal(0);
FinanceBillSetoffSum retMap = new FinanceBillSetoffSum();
List<FinanceAdvanceBillVo> bvolist = new ArrayList<FinanceAdvanceBillVo>();
BigDecimal total = wxAllBillService.getBillSetoffSum(abq);
if (null == total) {
total = new BigDecimal(0);
}
return total;
}
@Override
public List<FinanceAdvanceBillVo> getMerchantAdvanceDepositList(WxShop record) {
//取账单里面的
List<FinanceAdvanceBillVo> bvolist = new ArrayList<FinanceAdvanceBillVo>();
//查询所有押金
BigDecimal deposit = getBillDepositSum(record);
if (null != deposit && deposit.compareTo(new BigDecimal(0)) > 0 ) {
FinanceAdvanceBillVo v0 = new FinanceAdvanceBillVo();
v0.setFeesId(Constant.bill_all_deposit_id);
v0.setFeesName("押金总计");
v0.setRemain(deposit.toPlainString());
bvolist.add(v0);
}
//查询预存账单
WxAllBill abq = new WxAllBill();
abq.updateTenantInfo(record);
abq.setBillType(EnumBillAllType.ADVANCE.getCode());
abq.setShopId(record.getId());
abq.setAdvanceHasMoney(EnumYesOrNo.YES.getCode());
List<WxAllBill> advanceList = wxAllBillService.getMerchantAdvanceGroupSumList(abq);
if (null != advanceList && advanceList.size() > 0 ) { if (null != advanceList && advanceList.size() > 0 ) {
WxEnergyFees fat = new WxEnergyFees(); WxEnergyFees fat = new WxEnergyFees();
fat.updateTenantInfo(record); fat.updateTenantInfo(record);
@@ -271,13 +320,10 @@ public class WxFinanceServiceImpl implements WxFinanceService {
vo.setFeesName(wfat.getName()); vo.setFeesName(wfat.getName());
} }
} }
total = total.add(new BigDecimal(at.getRemain()));
bvolist.add(vo); bvolist.add(vo);
} }
} }
retMap.setTotal(total);
retMap.setAdvanceList(bvolist);
return retMap;
return bvolist;
} }
//根据预充值收款单来冲抵账单 //根据预充值收款单来冲抵账单
@@ -347,17 +393,10 @@ public class WxFinanceServiceImpl implements WxFinanceService {
if (null == dto.getBills() || dto.getBills().size() <= 0 || null == dto.getFeesId()) { if (null == dto.getBills() || dto.getBills().size() <= 0 || null == dto.getFeesId()) {
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请选择账单和抵扣科目"); throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请选择账单和抵扣科目");
} }
//查询预收科目可冲抵的科目
WxEnergyFeesSetoff fsq = new WxEnergyFeesSetoff();
fsq.updateTenantInfo(dto);
fsq.setAdvanceFeesId(dto.getFeesId());
List<Long> setOffFeesIds = wxEnergyService.getAdvanceSetoffFeesids(fsq);
if (null == setOffFeesIds || setOffFeesIds.size() <= 0 ) {
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"该科目未设置可冲抵科目");
}
//查询出账单可以抵扣的科目预收项
//如果是多个店铺的则不能冲抵
Long shopId = null; Long shopId = null;
List<Long> billIdList = new ArrayList<Long>();
for (int i = 0 ; i < dto.getBills().size() ; i ++) { for (int i = 0 ; i < dto.getBills().size() ; i ++) {
WxAllBill be = dto.getBills().get(i); WxAllBill be = dto.getBills().get(i);
if (null == shopId) { if (null == shopId) {
@@ -366,18 +405,57 @@ public class WxFinanceServiceImpl implements WxFinanceService {
if (shopId.longValue() != be.getShopId().longValue()) { if (shopId.longValue() != be.getShopId().longValue()) {
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"多个房源合并收款不能冲抵"); throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"多个房源合并收款不能冲抵");
} }
billIdList.add(be.getId());
} }
WxAllBill abq = new WxAllBill();
abq.updateTenantInfo(dto);
abq.setEnergyFeesId(dto.getFeesId());
abq.setBillType(EnumBillAllType.ADVANCE.getCode());
abq.setAdvanceHasMoney(EnumYesOrNo.YES.getCode());
abq.setSortColumns(SortField.Createtime_ASC);
//如果是多个店铺的则不能冲抵
abq.setShopId(shopId);;
List<WxAllBill> advanceList = wxAllBillService.list(abq);
if (null == advanceList || advanceList.size() <= 0 ) {
return null;
List<Long> setOffFeesIds = null;
List<WxAllBill> advanceList = null;
//如果是押金
if (dto.getFeesId().longValue() == Constant.bill_all_deposit_id.longValue()){
WxEnergyFees fq = new WxEnergyFees();
fq.updateTenantInfo(dto);
List<Integer> depositTypes = new ArrayList<Integer>();
depositTypes.add(EnumBillAllType.RENT_DEPOSIT.getCode());
depositTypes.add(EnumBillAllType.PROPERTY_DEPOSIT.getCode());
depositTypes.add(EnumBillAllType.OTHER_DEPOSIT.getCode());
fq.setBillTypeList(depositTypes);
setOffFeesIds = wxEnergyService.getFeesIdList(fq);
if (null == setOffFeesIds || setOffFeesIds.size() <= 0 ) {
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"未查询到押金科目");
}
//查询出账单可以抵扣的押金项
WxAllBill abq = new WxAllBill();
abq.updateTenantInfo(dto);
abq.setNotInIds(billIdList);
abq.setDepositHasMoney(EnumYesOrNo.YES.getCode());
abq.setSortColumns(SortField.Createtime_ASC);
abq.setShopId(shopId);;
advanceList = wxAllBillService.list(abq);
if (null == advanceList || advanceList.size() <= 0 ) {
return null;
}
}else {
//查询预收科目可冲抵的科目
WxEnergyFeesSetoff fsq = new WxEnergyFeesSetoff();
fsq.updateTenantInfo(dto);
fsq.setAdvanceFeesId(dto.getFeesId());
setOffFeesIds = wxEnergyService.getAdvanceSetoffFeesids(fsq);
if (null == setOffFeesIds || setOffFeesIds.size() <= 0 ) {
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"该科目未设置可冲抵科目");
}
//查询出账单可以抵扣的科目预收项
WxAllBill abq = new WxAllBill();
abq.updateTenantInfo(dto);
abq.setEnergyFeesId(dto.getFeesId());
abq.setBillType(EnumBillAllType.ADVANCE.getCode());
abq.setAdvanceHasMoney(EnumYesOrNo.YES.getCode());
abq.setSortColumns(SortField.Createtime_ASC);
abq.setShopId(shopId);;
advanceList = wxAllBillService.list(abq);
if (null == advanceList || advanceList.size() <= 0 ) {
return null;
}
} }
//账单排序 //账单排序
List<WxAllBill> bills = dto.getBills(); List<WxAllBill> bills = dto.getBills();
@@ -407,6 +485,7 @@ public class WxFinanceServiceImpl implements WxFinanceService {
retList.add(retb); retList.add(retb);
} }
} }
return retList; return retList;
} }
@@ -681,11 +760,7 @@ public class WxFinanceServiceImpl implements WxFinanceService {
} }
} }
//TODO 校验金额+减免是不是超过了应收费用
//冲抵总金额
//已冲抵总金额
BigDecimal setOffTotal = new BigDecimal(0); BigDecimal setOffTotal = new BigDecimal(0);
List<WxAllBill> bills = record.getBills(); List<WxAllBill> bills = record.getBills();
sortBills(bills); sortBills(bills);
@@ -702,6 +777,7 @@ public class WxFinanceServiceImpl implements WxFinanceService {
calcuteDto.setTotalRemainReceive(receiveTotal); calcuteDto.setTotalRemainReceive(receiveTotal);
calcuteDto.setTotalSetoff(setOffTotal); calcuteDto.setTotalSetoff(setOffTotal);
calcuteDto.setTotalCut(new BigDecimal(0)); calcuteDto.setTotalCut(new BigDecimal(0));
calcuteDto.setTotalNeedPay(new BigDecimal(0));
//建立子账单关联单 //建立子账单关联单
List<Long> shopIdList = new ArrayList<Long>(); List<Long> shopIdList = new ArrayList<Long>();
StringBuffer shopnumberSb = new StringBuffer(); StringBuffer shopnumberSb = new StringBuffer();
@@ -723,9 +799,17 @@ public class WxFinanceServiceImpl implements WxFinanceService {
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请收款或者冲抵"); throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请收款或者冲抵");
} }
BigDecimal allHandleMoney = receiveTotal.add(new BigDecimal(0));
if (null != calcuteDto.getTotalSetoff()) { if (null != calcuteDto.getTotalSetoff()) {
addreceive.setSetOffMoney(calcuteDto.getTotalSetoff().toPlainString()); addreceive.setSetOffMoney(calcuteDto.getTotalSetoff().toPlainString());
allHandleMoney.add(calcuteDto.getTotalSetoff());
}
//校验金额+冲抵是不是超过了应收费用
if (calcuteDto.getTotalNeedPay().compareTo(allHandleMoney) < 0 ){
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"实际收款和冲抵之和不能超过应收总金额");
} }
addreceive.setBillCusName(billCusSb.toString()); addreceive.setBillCusName(billCusSb.toString());
addreceive.setBillShopNumber(shopnumberSb.toString()); addreceive.setBillShopNumber(shopnumberSb.toString());
addreceive.setRemark(record.getRemark()); addreceive.setRemark(record.getRemark());
@@ -771,7 +855,10 @@ public class WxFinanceServiceImpl implements WxFinanceService {
//计算账单收款费用,更新账单收款 //计算账单收款费用,更新账单收款
BigDecimal b0 = new BigDecimal(0); BigDecimal b0 = new BigDecimal(0);
WxAllBill bill = wxBillAllHelper.getBillDetail(addreceive, be.getId()); WxAllBill bill = wxBillAllHelper.getBillDetail(addreceive, be.getId());
boolean billIsHandled = false;
BigDecimal billOldOweDecimal = new BigDecimal(bill.getOwe());
if (calcuteDto.getTotalRemainReceive().compareTo(b0) > 0) { if (calcuteDto.getTotalRemainReceive().compareTo(b0) > 0) {
billIsHandled = true;
noNeedCreate = false; noNeedCreate = false;
//有收款,就要更新账单的收款 //有收款,就要更新账单的收款
//更新账单收款信息 //更新账单收款信息
@@ -815,9 +902,7 @@ public class WxFinanceServiceImpl implements WxFinanceService {
if(StringUtils.isNotBlank(be.getCurrentSetOff())) { if(StringUtils.isNotBlank(be.getCurrentSetOff())) {
calcuteDto.setTotalSetoff(calcuteDto.getTotalSetoff().add(new BigDecimal(be.getCurrentSetOff()))); calcuteDto.setTotalSetoff(calcuteDto.getTotalSetoff().add(new BigDecimal(be.getCurrentSetOff())));
payDto.setSetOff(be.getCurrentSetOff()); payDto.setSetOff(be.getCurrentSetOff());
//创建一个冲抵收款单
createFinanceReceiveBill(addreceive,bill,be.getCurrentSetOff(),null,Constant.bill_pay_way_setoff);
//处理关联抵扣的预收单
//押金冲抵和预收冲抵要分开建收款单
createFinanceReceiveSetoff(addreceive,be,bill); createFinanceReceiveSetoff(addreceive,be,bill);
} }
//有减免 //有减免
@@ -829,11 +914,10 @@ public class WxFinanceServiceImpl implements WxFinanceService {
wxBillAllHelper.updatePay(payDto, user); wxBillAllHelper.updatePay(payDto, user);
}else if (StringUtils.isNotBlank(be.getCurrentSetOff())) { }else if (StringUtils.isNotBlank(be.getCurrentSetOff())) {
billIsHandled = true;
noNeedCreate = false; noNeedCreate = false;
calcuteDto.setTotalSetoff(calcuteDto.getTotalSetoff().add(new BigDecimal(be.getCurrentSetOff()))); calcuteDto.setTotalSetoff(calcuteDto.getTotalSetoff().add(new BigDecimal(be.getCurrentSetOff())));
//没收款,有冲抵,就要更新账单的冲抵,然后把对应的预充值使用金额更新,并进行关联 //没收款,有冲抵,就要更新账单的冲抵,然后把对应的预充值使用金额更新,并进行关联
//创建一个冲抵收款单
createFinanceReceiveBill(addreceive,bill,be.getCurrentSetOff(),null,Constant.bill_pay_way_setoff);
//处理预充关联 //处理预充关联
createFinanceReceiveSetoff(addreceive,be,bill); createFinanceReceiveSetoff(addreceive,be,bill);
@@ -856,6 +940,9 @@ public class WxFinanceServiceImpl implements WxFinanceService {
payDto.setRemark("收款单收款["+addreceive.getId()+"]冲抵"+addreceive.getRemark()); payDto.setRemark("收款单收款["+addreceive.getId()+"]冲抵"+addreceive.getRemark());
wxBillAllHelper.updatePay(payDto, user); wxBillAllHelper.updatePay(payDto, user);
} }
if (billIsHandled) {
calcuteDto.setTotalNeedPay(calcuteDto.getTotalNeedPay().add(billOldOweDecimal));
}
return noNeedCreate; return noNeedCreate;
} }
@@ -904,9 +991,30 @@ public class WxFinanceServiceImpl implements WxFinanceService {
} }
public void createFinanceReceiveSetoff(WxFinanceReceive addreceive,WxAllBill be,WxAllBill bill) { public void createFinanceReceiveSetoff(WxFinanceReceive addreceive,WxAllBill be,WxAllBill bill) {
BigDecimal advanceMoney = new BigDecimal(0);
BigDecimal depositMoney = new BigDecimal(0);
for (int j = 0 ; j < be.getSetOffDetailList().size(); j ++ ) { for (int j = 0 ; j < be.getSetOffDetailList().size(); j ++ ) {
FinanceSetOffDetailVo setoffdetail = be.getSetOffDetailList().get(j); FinanceSetOffDetailVo setoffdetail = be.getSetOffDetailList().get(j);
WxAllBill advance = wxAllBillService.getById(addreceive, setoffdetail.getAdvanceId()); WxAllBill advance = wxAllBillService.getById(addreceive, setoffdetail.getAdvanceId());
EnumBillAllType billType = EnumBillAllType.getEnum(advance.getBillType());
//如果是预冲
if (billType == EnumBillAllType.ADVANCE){
advanceMoney = advanceMoney.add(new BigDecimal(setoffdetail.getSetoff()));
}else {
//如果是押金
boolean isDeposit = false;
for (EnumBillAllType bt : EnumBillAllType.getDepositTypes()) {
if (bt == billType) {
isDeposit = true;
break;
}
}
if (isDeposit) {
depositMoney = depositMoney.add(new BigDecimal(setoffdetail.getSetoff()));
}
}
advance.setUseMoney(new BigDecimal(advance.getUseMoney()).add(new BigDecimal(setoffdetail.getSetoff())).toPlainString()); advance.setUseMoney(new BigDecimal(advance.getUseMoney()).add(new BigDecimal(setoffdetail.getSetoff())).toPlainString());
advance.setUpdatetime(new Date()); advance.setUpdatetime(new Date());
wxAllBillService.saveOrUpdate(advance, null); wxAllBillService.saveOrUpdate(advance, null);
@@ -926,6 +1034,14 @@ public class WxFinanceServiceImpl implements WxFinanceService {
rb.setCreateTime(new Date()); rb.setCreateTime(new Date());
rb.setUpdateTime(new Date()); rb.setUpdateTime(new Date());
wxFinanceReceiveSetoffMapper.insert(rb); wxFinanceReceiveSetoffMapper.insert(rb);
//创建一个冲抵收款单
if (advanceMoney.compareTo(new BigDecimal(0)) > 0 ) {
createFinanceReceiveBill(addreceive,bill,be.getCurrentSetOff(),null,Constant.bill_pay_way_setoff);
}
if (depositMoney.compareTo(new BigDecimal(0)) > 0 ) {
createFinanceReceiveBill(addreceive,bill,be.getCurrentSetOff(),null,Constant.bill_pay_way_deposit_setoff);
}
} }
} }
@@ -1002,6 +1118,7 @@ public class WxFinanceServiceImpl implements WxFinanceService {
FinanceReceiveCalcuteDTO calcuteDto = new FinanceReceiveCalcuteDTO(); FinanceReceiveCalcuteDTO calcuteDto = new FinanceReceiveCalcuteDTO();
calcuteDto.setTotalCut(new BigDecimal(0)); calcuteDto.setTotalCut(new BigDecimal(0));
calcuteDto.setTotalNeedPay(new BigDecimal(0));
//建立子账单关联单 //建立子账单关联单
List<Long> shopIdList = new ArrayList<Long>(); List<Long> shopIdList = new ArrayList<Long>();
StringBuffer shopnumberSb = new StringBuffer(); StringBuffer shopnumberSb = new StringBuffer();
@@ -1009,6 +1126,8 @@ public class WxFinanceServiceImpl implements WxFinanceService {
for (int i = 0 ; i < record.getBills().size(); i++) { for (int i = 0 ; i < record.getBills().size(); i++) {
WxAllBill be = record.getBills().get(i); WxAllBill be = record.getBills().get(i);
if(StringUtils.isNotBlank(be.getCurrentCut())) { if(StringUtils.isNotBlank(be.getCurrentCut())) {
WxAllBill bill = wxBillAllHelper.getBillDetail(record, be.getId());
calcuteDto.setTotalNeedPay(calcuteDto.getTotalNeedPay().add(new BigDecimal(bill.getOwe())));
WxBillPayDTO payDto = new WxBillPayDTO(); WxBillPayDTO payDto = new WxBillPayDTO();
payDto.updateTenantInfo(addreceive); payDto.updateTenantInfo(addreceive);
payDto.setId(be.getId()); payDto.setId(be.getId());
@@ -1031,6 +1150,11 @@ public class WxFinanceServiceImpl implements WxFinanceService {
if (isAllEmpity) { if (isAllEmpity) {
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请收款或者冲抵"); throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请收款或者冲抵");
} }
//校验减免是不是超过了应收费用
if (calcuteDto.getTotalNeedPay().compareTo(calcuteDto.getTotalCut()) < 0 ){
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"减免金额之和不能超过应收总金额");
}
addreceive.setBillCusName(billCusSb.toString()); addreceive.setBillCusName(billCusSb.toString());
addreceive.setBillShopNumber(shopnumberSb.toString()); addreceive.setBillShopNumber(shopnumberSb.toString());
addreceive.setRemark(record.getRemark()); addreceive.setRemark(record.getRemark());
@@ -1089,6 +1213,7 @@ public class WxFinanceServiceImpl implements WxFinanceService {
FinanceReceiveCalcuteDTO calcuteDto = new FinanceReceiveCalcuteDTO(); FinanceReceiveCalcuteDTO calcuteDto = new FinanceReceiveCalcuteDTO();
calcuteDto.setTotalRemainPay(payTotal); calcuteDto.setTotalRemainPay(payTotal);
calcuteDto.setTotalNeedPay(new BigDecimal(0));
//建立子账单关联单 //建立子账单关联单
List<Long> shopIdList = new ArrayList<Long>(); List<Long> shopIdList = new ArrayList<Long>();
StringBuffer shopnumberSb = new StringBuffer(); StringBuffer shopnumberSb = new StringBuffer();
@@ -1110,6 +1235,12 @@ public class WxFinanceServiceImpl implements WxFinanceService {
if (isAllEmpity) { if (isAllEmpity) {
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请付款"); throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"请付款");
} }
//校验金额+冲抵是不是超过了应收费用
if (calcuteDto.getTotalNeedPay().compareTo(payTotal) < 0 ){
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"实际付款之和不能超过应付总金额");
}
addreceive.setBillCusName(billCusSb.toString()); addreceive.setBillCusName(billCusSb.toString());
addreceive.setBillShopNumber(shopnumberSb.toString()); addreceive.setBillShopNumber(shopnumberSb.toString());
addreceive.setRemark(record.getRemark()); addreceive.setRemark(record.getRemark());
@@ -1155,8 +1286,11 @@ public class WxFinanceServiceImpl implements WxFinanceService {
//计算账单收款费用,更新账单收款 //计算账单收款费用,更新账单收款
BigDecimal b0 = new BigDecimal(0); BigDecimal b0 = new BigDecimal(0);
WxAllBill bill = wxBillAllHelper.getBillDetail(addreceive, be.getId()); WxAllBill bill = wxBillAllHelper.getBillDetail(addreceive, be.getId());
boolean billIsHandled = false;
BigDecimal billOldOweDecimal = new BigDecimal(bill.getRemainReturnPrice());
if (calcuteDto.getTotalRemainPay().compareTo(b0) > 0) { if (calcuteDto.getTotalRemainPay().compareTo(b0) > 0) {
noNeedCreate = false; noNeedCreate = false;
billIsHandled = true;
//有收款,就要更新账单的收款 //有收款,就要更新账单的收款
//更新账单收款信息 //更新账单收款信息
String money = ""; String money = "";
@@ -1195,8 +1329,11 @@ public class WxFinanceServiceImpl implements WxFinanceService {
bill.setCurrentReceive(money); bill.setCurrentReceive(money);
wxBillAllHelper.updatePayToMerchant(payDto, user); wxBillAllHelper.updatePayToMerchant(payDto, user);
} }
if (billIsHandled) {
calcuteDto.setTotalNeedPay(calcuteDto.getTotalNeedPay().add(billOldOweDecimal));
}
return noNeedCreate; return noNeedCreate;
} }


@@ -1279,7 +1416,7 @@ public class WxFinanceServiceImpl implements WxFinanceService {
@Override @Override
public void delteTemp(WxAllBill record,MallUserInfo user) { public void delteTemp(WxAllBill record,MallUserInfo user) {
WxAllBill bill = wxAllBillService.getById(record,record.getId()); WxAllBill bill = wxAllBillService.getById(record,record.getId());
if (bill.getCreateBy() != user.getId()) {
if (bill.getCreateBy().longValue() != user.getId().longValue()) {
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"只能删除自己创建的账单"); throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"只能删除自己创建的账单");
} }
if (bill.getCanEdit() == EnumYesOrNo.YES.getCode()) { if (bill.getCanEdit() == EnumYesOrNo.YES.getCode()) {


+ 3
- 0
mallinkService/src/main/java/com/iformall/utils/Constant.java Ver fichero

@@ -149,6 +149,9 @@ public class Constant {
public static final Long bill_pay_way_system = 2L; public static final Long bill_pay_way_system = 2L;
public static final Long bill_pay_way_setoff = 3L; public static final Long bill_pay_way_setoff = 3L;
public static final Long bill_pay_way_cut = 4L; public static final Long bill_pay_way_cut = 4L;
public static final Long bill_pay_way_deposit_setoff = 5L;
public static final Long bill_all_deposit_id = 99999999L;


} }

+ 14
- 0
mallinkService/src/main/resources/mapper/WxAllBillMapper.xml Ver fichero

@@ -84,6 +84,7 @@
<if test=" null != extraCreateFrom">and `extra_create_from` = #{extraCreateFrom}</if> <if test=" null != extraCreateFrom">and `extra_create_from` = #{extraCreateFrom}</if>
<if test=" null != noExtraCreateFrom">and `extra_create_from` is null</if> <if test=" null != noExtraCreateFrom">and `extra_create_from` is null</if>
<if test=" null != advanceHasMoney">and bill_type = 6 and IFNULL(`pay`,'0') -IFNULL(`return_pay`,'0') - IFNULL(`use_money`,'0') &gt; 0</if> <if test=" null != advanceHasMoney">and bill_type = 6 and IFNULL(`pay`,'0') -IFNULL(`return_pay`,'0') - IFNULL(`use_money`,'0') &gt; 0</if>
<if test=" null != depositHasMoney">and IFNULL(`pay`,'0') - IFNULL(`return_pay`,'0') - IFNULL(`use_money`,'0') &gt; 0 and bill_type in (13,21,5)</if>
<if test=" null != canEdit">and `can_edit` = #{canEdit}</if> <if test=" null != canEdit">and `can_edit` = #{canEdit}</if>
<if test=" null != month and '' != month"> <if test=" null != month and '' != month">
and date_format(starttime,'%Y-%m') &lt;= #{month} and date_format(endtime,'%Y-%m') &gt;= #{month} and date_format(starttime,'%Y-%m') &lt;= #{month} and date_format(endtime,'%Y-%m') &gt;= #{month}
@@ -217,6 +218,19 @@
<include refid="dynamicWhereConditions"/> <include refid="dynamicWhereConditions"/>
</select> </select>
<select id="getMerchantAdvanceGroupSum" parameterType="com.iformall.domain.po.WxAllBill" resultType="DECIMAL">
select sum(CAST(pay AS DECIMAL(20,2))) pay , sum(CAST(ifnull(use_money,'0') AS DECIMAL(20,2))) use_money
from wx_all_bill
<include refid="dynamicWhereConditions"/>
</select>
<select id="getMerchantDepositGroupSum" parameterType="com.iformall.domain.po.WxAllBill" resultType="DECIMAL">
select sum(CAST(pay AS DECIMAL(20,2))) pay , sum(CAST(ifnull(return_pay,'0') AS DECIMAL(20,2))) deposit_money
from wx_all_bill
<include refid="dynamicWhereConditions"/>
</select>
<select id="getMerchantAdvanceGroupSumList" parameterType="com.iformall.domain.po.WxAllBill" resultMap="BaseResultMap"> <select id="getMerchantAdvanceGroupSumList" parameterType="com.iformall.domain.po.WxAllBill" resultMap="BaseResultMap">
select energy_fees_id, sum(CAST(pay AS DECIMAL(20,2))) pay , sum(CAST(ifnull(use_money,'0') AS DECIMAL(20,2))) use_money select energy_fees_id, sum(CAST(pay AS DECIMAL(20,2))) pay , sum(CAST(ifnull(use_money,'0') AS DECIMAL(20,2))) use_money
from wx_all_bill from wx_all_bill


Cargando…
Cancelar
Guardar