|
@@ -21,6 +21,8 @@ import com.pj.api.wx.bo.PriceBO;
|
|
|
import com.pj.current.config.MyConfig;
|
|
|
import com.pj.current.config.PartConfig;
|
|
|
import com.pj.current.satoken.StpUserUtil;
|
|
|
+import com.pj.project.relation_business_car.RelationBusinessCar;
|
|
|
+import com.pj.project.relation_business_car.RelationBusinessCarService;
|
|
|
import com.pj.project.tb_business.TbBusiness;
|
|
|
import com.pj.project.tb_business.TbBusinessService;
|
|
|
import com.pj.project.tb_business_car.TbBusinessCar;
|
|
@@ -29,6 +31,8 @@ import com.pj.project.tb_business_item.TbBusinessItem;
|
|
|
import com.pj.project.tb_fee_details.statics.FeeTypeStatics;
|
|
|
import com.pj.project.tb_fee_statistics.TbFeeStatistics;
|
|
|
import com.pj.project.tb_fee_statistics.TbFeeStatisticsService;
|
|
|
+import com.pj.project.tb_goods.TbGoods;
|
|
|
+import com.pj.project.tb_goods.TbGoodsService;
|
|
|
import com.pj.project4sp.admin.SpAdmin;
|
|
|
import com.pj.project4sp.global.BusinessException;
|
|
|
import com.pj.project4sp.role.SpRole;
|
|
@@ -75,6 +79,10 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
|
|
|
SpRoleMapper spRoleMapper;
|
|
|
@Resource
|
|
|
TbFeeStatisticsService tbFeeStatisticsService;
|
|
|
+ @Resource
|
|
|
+ private RelationBusinessCarService relationBusinessCarService;
|
|
|
+ @Resource
|
|
|
+ private TbGoodsService tbGoodsService;
|
|
|
|
|
|
/**
|
|
|
* 增
|
|
@@ -146,6 +154,15 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
|
|
|
return list(qw);
|
|
|
}
|
|
|
|
|
|
+ public List<TbFeeDetails> getByBusinessCarIdAndCarNoAndFeeTypeAndPayDay(String businessCarId, String carNo, Integer feeType, String payDay){
|
|
|
+ QueryWrapper<TbFeeDetails> qw = new QueryWrapper<>();
|
|
|
+ qw.eq("business_car_id", businessCarId);
|
|
|
+ qw.eq("car_no", carNo);
|
|
|
+ qw.eq("fee_type", feeType);
|
|
|
+ qw.eq("pay_day", payDay);
|
|
|
+ return list(qw);
|
|
|
+ }
|
|
|
+
|
|
|
public TbFeeDetails findBuCarIdAndCarNoAndFeeTypeAndItemTypeName(String businessCarId, String carNo, Integer feeType, String itemTypeName){
|
|
|
QueryWrapper<TbFeeDetails> qw = new QueryWrapper<>();
|
|
|
qw.eq("business_car_id", businessCarId);
|
|
@@ -155,18 +172,29 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
|
|
|
return getOne(qw);
|
|
|
}
|
|
|
|
|
|
+ public List<TbFeeDetails> findByTransactionId(String transactionId){
|
|
|
+ QueryWrapper<TbFeeDetails> qw = new QueryWrapper<>();
|
|
|
+ qw.like("transaction_id", transactionId);
|
|
|
+ return list(qw);
|
|
|
+ }
|
|
|
|
|
|
- public void chargeParkFee(List<PriceBO> cars, String transactionId, String outTradeNo) {
|
|
|
+
|
|
|
+ public void chargeParkFee(List<PriceBO> cars, String transactionId, String outTradeNo, Date now) {
|
|
|
log.info("进入计算停车费:{}", JSONUtil.toJsonStr(cars));
|
|
|
+ List<TbFeeDetails> transList = this.findByTransactionId(transactionId);
|
|
|
+ if(transList.size() > 0){
|
|
|
+ log.error("========收费明细已生成==========:{}", transactionId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String payDay = DateUtil.format(now, "yyyy-MM-dd");
|
|
|
for (PriceBO bo1 : cars) {
|
|
|
if(bo1.getP().compareTo(BigDecimal.valueOf(0)) == 0){
|
|
|
continue;
|
|
|
}
|
|
|
TbBusinessCar car = tbBusinessCarService.getById(bo1.getId());
|
|
|
-
|
|
|
BigDecimal paidMoney = car.getMoney();
|
|
|
|
|
|
- List<TbFeeDetails> oldFeeList = getByBusinessCarIdAndCarNoAndFeeType(car.getId(), car.getCarNo(), TbFeeDetails.fee.PARK_FEE.getCode());
|
|
|
+ List<TbFeeDetails> oldFeeList = getByBusinessCarIdAndCarNoAndFeeTypeAndPayDay(car.getId(), car.getCarNo(), TbFeeDetails.fee.PARK_FEE.getCode(), payDay);
|
|
|
TbFeeDetails nightParkFee = new TbFeeDetails();
|
|
|
TbFeeDetails dayParkFee = new TbFeeDetails();
|
|
|
String transactionIdStr = "";
|
|
@@ -191,7 +219,7 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
|
|
|
if(nightFeeNum.compareTo(BigDecimal.valueOf(0)) > 0){
|
|
|
nightParkFee.setNum(nightFeeNum.intValue()).setItemTypeName("夜间停车")
|
|
|
.setUnitPrice(baseNightPrice).setItemPrice(baseNightPrice.multiply(nightFeeNum));
|
|
|
- setFee(nightParkFee, car, transactionIdStr, outTradeNoStr);
|
|
|
+ setFee(nightParkFee, car, transactionIdStr, outTradeNoStr, now);
|
|
|
saveOrUpdate(nightParkFee);
|
|
|
if(qr[1].compareTo(BigDecimal.valueOf(0)) == 0 && dayParkFee.getId() != null){
|
|
|
delete(Long.valueOf(dayParkFee.getId()));
|
|
@@ -199,15 +227,15 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
|
|
|
}
|
|
|
if(qr[1].compareTo(BigDecimal.valueOf(0)) > 0){
|
|
|
dayParkFee.setNum(1).setItemTypeName("白天停车").setUnitPrice(qr[1]).setItemPrice(qr[1]);
|
|
|
- setFee(dayParkFee, car, transactionIdStr, outTradeNoStr);
|
|
|
+ setFee(dayParkFee, car, transactionIdStr, outTradeNoStr, now);
|
|
|
saveOrUpdate(dayParkFee);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void setFee(TbFeeDetails parkFee, TbBusinessCar car, String transactionId, String outTradeNo){
|
|
|
- Date now = new Date();
|
|
|
+ private void setFee(TbFeeDetails parkFee, TbBusinessCar car, String transactionId, String outTradeNo, Date now){
|
|
|
+
|
|
|
String nowStr = DateUtil.format(now, "yyyy-MM-dd HH:mm:ss");
|
|
|
String toDay = DateUtil.format(now, "yyyy-MM-dd");
|
|
|
parkFee.setTaxRate(partConfig.getTaxRate());
|
|
@@ -224,6 +252,81 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
|
|
|
.setTransactionId(transactionId).setOutTradeNo(outTradeNo)
|
|
|
.setBusinessCarNo(car.getNo());
|
|
|
}
|
|
|
+ public void chargeBusinessFee(List<TbBusinessItem> items, String transactionId, String outTradeNo, Date now) {
|
|
|
+ List<TbFeeDetails> transList = this.findByTransactionId(transactionId);
|
|
|
+ if(transList.size() > 0){
|
|
|
+ log.error("========收费明细已生成==========:{}", transactionId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String nowStr = DateUtil.format(now, "yyyy-MM-dd HH:mm:ss");
|
|
|
+ String toDay = DateUtil.format(now, "yyyy-MM-dd");
|
|
|
+ for (TbBusinessItem item : items) {
|
|
|
+ Integer feeType = item.getPayType();
|
|
|
+ String itemType = item.getItemTypeName();
|
|
|
+ if (StrUtil.isNotEmpty(itemType)) {
|
|
|
+ if (itemType.contains("核酸")) {
|
|
|
+ feeType = TbFeeStatistics.FeeTypeEnum.NUCLEIC_FEE.getCode();
|
|
|
+ } else if (itemType.contains("消毒") || itemType.contains("消杀")) {
|
|
|
+ feeType = TbFeeStatistics.FeeTypeEnum.DISINFECT_FEE.getCode();
|
|
|
+ } else if (itemType.contains("装卸")) {
|
|
|
+ feeType = TbFeeStatistics.FeeTypeEnum.STEVEDORE_FEE.getCode();
|
|
|
+ } else if (StrUtil.equals(itemType, "特殊车辆") || StrUtil.equals(itemType, "汽车吊")) {
|
|
|
+ feeType = TbFeeStatistics.FeeTypeEnum.STEVEDORE_FEE.getCode();
|
|
|
+ } else if (itemType.contains("入场管理")) {
|
|
|
+ feeType = TbFeeStatistics.FeeTypeEnum.MANAGE_FEE.getCode();
|
|
|
+ } else if (StrUtil.equals(itemType, "充电打冷")) {
|
|
|
+ feeType = TbFeeStatistics.FeeTypeEnum.CHARGE_FEE.getCode();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Double taxRate = item.getTaxRate();
|
|
|
+ //添加此item的收费明细
|
|
|
+ TbBusiness business = tbBusinessService.getById(item.getBusinessId());
|
|
|
+ TbFeeDetails businessFeeDetail = new TbFeeDetails();
|
|
|
+ businessFeeDetail.setTaxRate(BigDecimal.valueOf(taxRate));
|
|
|
+ BigDecimal taxPrice = item.getTotal()
|
|
|
+ .divide(BigDecimal.valueOf(1).add(businessFeeDetail.getTaxRate()), 2, BigDecimal.ROUND_HALF_UP)
|
|
|
+ .multiply(businessFeeDetail.getTaxRate());
|
|
|
+ taxPrice = taxPrice.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal noTaxPrice = item.getTotal().subtract(taxPrice);
|
|
|
+ noTaxPrice = noTaxPrice.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+
|
|
|
+ String carNo = business.getCardNo();
|
|
|
+ if (StrUtil.isEmpty(business.getCardNo())) {
|
|
|
+ carNo = business.getChinaCarNo();
|
|
|
+ }
|
|
|
+ TbGoods businessCfg = tbGoodsService.getById(business.getGoodsId());
|
|
|
+ if((TbGoods.LeaveEnum.BUSINESS_MONEY.getCode()==businessCfg.getChinaCarLeave() || TbGoods.LeaveEnum.APART_BUSINESS.getCode()==businessCfg.getChinaCarLeave())
|
|
|
+ && TbGoods.LeaveEnum.BUSINESS_MONEY.getCode()!=businessCfg.getVietnamCarLeave() && TbGoods.LeaveEnum.APART_BUSINESS.getCode()!=businessCfg.getVietnamCarLeave()){
|
|
|
+ carNo = business.getChinaCarNo();
|
|
|
+ }
|
|
|
+ String businessCarIds = "";
|
|
|
+ String businessCarNos = "";
|
|
|
+ List<RelationBusinessCar> relation = relationBusinessCarService.findByBusinessId(item.getBusinessId());
|
|
|
+ for (RelationBusinessCar rela : relation) {
|
|
|
+ TbBusinessCar bt = tbBusinessCarService.getById(rela.getBusinessCarId());
|
|
|
+ if(StrUtil.contains(carNo, bt.getCarNo())){
|
|
|
+ businessCarIds += bt.getId() + ",";
|
|
|
+ businessCarNos += bt.getNo() + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ businessCarIds = StrUtil.sub(businessCarIds, 0, businessCarIds.length()-1);
|
|
|
+ businessCarNos = StrUtil.sub(businessCarNos, 0, businessCarNos.length()-1);
|
|
|
+ businessFeeDetail.setBusinessId(item.getBusinessId()).setBusinessNo(business.getNo())
|
|
|
+ .setBusinessItemNo(item.getNo()).setBusinessCarId(businessCarIds).setBusinessCarNo(businessCarNos)
|
|
|
+ .setCarNo(carNo)
|
|
|
+ .setItemPrice(item.getTotal()).setUnitPrice(item.getItemPrice()).setNoTaxPrice(noTaxPrice).setTaxPrice(taxPrice)
|
|
|
+ .setFeeType(feeType)
|
|
|
+ .setItemTypeId(item.getItemTypeId()).setItemTypeName(item.getItemTypeName())
|
|
|
+ .setItemId(item.getItemId()).setItemName(item.getItemName())
|
|
|
+ .setPayDay(toDay).setPayType(3).setCreateTime(now)
|
|
|
+ .setBusinessItemId(item.getId() + "")
|
|
|
+ .setPickCustomerName(item.getPickCustomerName())
|
|
|
+ .setIsSettle(1).setPayMode(1).setPayTime(nowStr).setWeight(business.getNetWeight())
|
|
|
+ .setTransactionId(transactionId).setOutTradeNo(outTradeNo)
|
|
|
+ .setNum(Integer.valueOf(item.getNum()));
|
|
|
+ this.saveOrUpdate(businessFeeDetail);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public String export(SoMap so) throws Exception{
|
|
|
Date now = new Date();
|
|
@@ -580,4 +683,8 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
|
|
|
ew.eq("business_no",businessNo);
|
|
|
return list(ew);
|
|
|
}
|
|
|
+
|
|
|
+ public List<TbFeeStatistics> getDayStatistics(String toDay) {
|
|
|
+ return tbFeeDetailsMapper.getDayStatistics(toDay);
|
|
|
+ }
|
|
|
}
|