|
@@ -545,22 +545,9 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
|
|
cmPayShop.setPayTime(DateUtils.getDateTime());
|
|
cmPayShop.setPayTime(DateUtils.getDateTime());
|
|
cmPayShop.setStatus("1");
|
|
cmPayShop.setStatus("1");
|
|
cmPayShopDao.update(cmPayShop);
|
|
cmPayShopDao.update(cmPayShop);
|
|
- if (cmPayShop.getBalancePayFee() != null && cmPayShop.getBalancePayFee() > 0D) {
|
|
|
|
- //如果使用了余额付款 往余额记录表里面写入记录的cm_rebate_record
|
|
|
|
- CmRebateRecord r = new CmRebateRecord();
|
|
|
|
- r.setType("2");
|
|
|
|
- r.setShopId(cmPayShop.getShopID());
|
|
|
|
- r.setPayShopID(cmPayShop.getId());
|
|
|
|
- r.setShopOrderId(StringUtil.join(records.stream().map(CmPayShopRecord::getShopOrderID).toArray(), ","));
|
|
|
|
- r.setRebateAmount(cmPayShop.getBalancePayFee());
|
|
|
|
- r.setOperatTime(DateUtils.formatDateTime(new Date()));
|
|
|
|
- cmRebateRecordDao.insert(r);
|
|
|
|
- //扣除供应商余额
|
|
|
|
- newCmShopDao.updateRebateAmount(cmPayShop.getBalancePayFee(), Integer.valueOf(cmPayShop.getShopID()));
|
|
|
|
- }
|
|
|
|
- }else {
|
|
|
|
|
|
+ } else {
|
|
//付第三方与付供应商差价
|
|
//付第三方与付供应商差价
|
|
- records.forEach(record->{
|
|
|
|
|
|
+ records.forEach(record -> {
|
|
record.setStatus("1");
|
|
record.setStatus("1");
|
|
record.setPayTime(DateUtils.formatDateTime(new Date()));
|
|
record.setPayTime(DateUtils.formatDateTime(new Date()));
|
|
record.setPayType(cmPayShop.getPayType());
|
|
record.setPayType(cmPayShop.getPayType());
|
|
@@ -572,6 +559,19 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
|
|
cmPayShop.setStatus("1");
|
|
cmPayShop.setStatus("1");
|
|
cmPayShopDao.update(cmPayShop);
|
|
cmPayShopDao.update(cmPayShop);
|
|
}
|
|
}
|
|
|
|
+ if (cmPayShop.getBalancePayFee() != null && cmPayShop.getBalancePayFee() > 0D) {
|
|
|
|
+ //如果使用了余额付款 往余额记录表里面写入记录的cm_rebate_record
|
|
|
|
+ CmRebateRecord r = new CmRebateRecord();
|
|
|
|
+ r.setType("2");
|
|
|
|
+ r.setShopId(cmPayShop.getShopID());
|
|
|
|
+ r.setPayShopID(cmPayShop.getId());
|
|
|
|
+ r.setShopOrderId(StringUtil.join(records.stream().map(CmPayShopRecord::getShopOrderID).toArray(), ","));
|
|
|
|
+ r.setRebateAmount(cmPayShop.getBalancePayFee());
|
|
|
|
+ r.setOperatTime(DateUtils.formatDateTime(new Date()));
|
|
|
|
+ cmRebateRecordDao.insert(r);
|
|
|
|
+ //扣除供应商余额
|
|
|
|
+ newCmShopDao.updateRebateAmount(cmPayShop.getBalancePayFee(), Integer.valueOf(cmPayShop.getShopID()));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -614,6 +614,14 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
|
|
cmPayShopDao.update(maxIdpayShop);
|
|
cmPayShopDao.update(maxIdpayShop);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if (cmPayShop.getPaymentType() == 2) {
|
|
|
|
+ //供应商差价付款
|
|
|
|
+ NewShopOrder shopOrder = newShopOrderDao.findByShopOrderID(shopOrderID);
|
|
|
|
+ if (shopOrder != null) {
|
|
|
|
+ BigDecimal differencePrice = MathUtil.sub(shopOrder.getDifferencePrice(), cmPayShop.getTotalAmount());
|
|
|
|
+ newShopOrderDao.updateByDifferencePrice(1, differencePrice, shopOrderID);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
cmPayShop.setDelFlag("1");
|
|
cmPayShop.setDelFlag("1");
|
|
newShopOrderDao.outPaying(cmPayShop.getId());
|
|
newShopOrderDao.outPaying(cmPayShop.getId());
|
|
@@ -795,7 +803,6 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
|
|
payShop.setWipePayment(0d);
|
|
payShop.setWipePayment(0d);
|
|
payShop.setApplicant(currentUser.getId());
|
|
payShop.setApplicant(currentUser.getId());
|
|
payShop.setApplyTime(time);
|
|
payShop.setApplyTime(time);
|
|
- payShop.setPayTime(time);
|
|
|
|
payShop.setStatus("0");
|
|
payShop.setStatus("0");
|
|
payShop.setDelFlag("0");
|
|
payShop.setDelFlag("0");
|
|
if (payShopOther.getPayShopId() == null) {
|
|
if (payShopOther.getPayShopId() == null) {
|
|
@@ -830,7 +837,16 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
|
|
NewShopOrder shopOrder = newShopOrderDao.findByShopOrderID(shopOrderId);
|
|
NewShopOrder shopOrder = newShopOrderDao.findByShopOrderID(shopOrderId);
|
|
BigDecimal waitPayShop = BigDecimal.ZERO;
|
|
BigDecimal waitPayShop = BigDecimal.ZERO;
|
|
if (shopOrder != null) {
|
|
if (shopOrder != null) {
|
|
|
|
+ payShopDifference.setPayStatus(shopOrder.getPayStatus());
|
|
waitPayShop = MathUtil.sub(shopOrder.getShouldPayShopAmount(), shopOrder.getPayedShopAmount());
|
|
waitPayShop = MathUtil.sub(shopOrder.getShouldPayShopAmount(), shopOrder.getPayedShopAmount());
|
|
|
|
+ NewCmShop shop = newCmShopDao.get(shopOrder.getShopID().toString());
|
|
|
|
+ payShopDifference.setBankAccount(shop.getBankAccount());
|
|
|
|
+ payShopDifference.setBankAccountName(shop.getBankAccountName());
|
|
|
|
+ payShopDifference.setBankName(shop.getBankName());
|
|
|
|
+ double ableRebateAmount = shop.getAbleRebateAmount() == null ? 0D : shop.getAbleRebateAmount();
|
|
|
|
+ payShopDifference.setAbleRebateAmount(BigDecimal.valueOf(ableRebateAmount));
|
|
|
|
+ double rebateAmount = shop.getRebateAmount() == null ? 0D : shop.getRebateAmount();
|
|
|
|
+ payShopDifference.setRebateAmount(BigDecimal.valueOf(rebateAmount));
|
|
}
|
|
}
|
|
payShopDifference.setWaitPayShop(waitPayShop);
|
|
payShopDifference.setWaitPayShop(waitPayShop);
|
|
return payShopDifference;
|
|
return payShopDifference;
|
|
@@ -838,6 +854,10 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
|
|
|
|
|
|
@Transactional(readOnly = false)
|
|
@Transactional(readOnly = false)
|
|
public void saveDifferencePrice(ChangePayShopDifference payShopDifference) throws Exception {
|
|
public void saveDifferencePrice(ChangePayShopDifference payShopDifference) throws Exception {
|
|
|
|
+ User currentUser = UserUtils.getUser();
|
|
|
|
+ String time = DateUtils.getDateTime();
|
|
|
|
+ //补差价金额
|
|
|
|
+ BigDecimal differencePrice = payShopDifference.getDifferencePrice();
|
|
String[] remarkImages = payShopDifference.getRemarkImages();
|
|
String[] remarkImages = payShopDifference.getRemarkImages();
|
|
if (remarkImages != null && remarkImages.length > 0) {
|
|
if (remarkImages != null && remarkImages.length > 0) {
|
|
StringBuilder remarkImage = new StringBuilder();
|
|
StringBuilder remarkImage = new StringBuilder();
|
|
@@ -851,6 +871,55 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
|
|
}
|
|
}
|
|
Integer shopOrderId = payShopDifference.getShopOrderId();
|
|
Integer shopOrderId = payShopDifference.getShopOrderId();
|
|
NewShopOrder shopOrder = newShopOrderDao.findByShopOrderID(shopOrderId);
|
|
NewShopOrder shopOrder = newShopOrderDao.findByShopOrderID(shopOrderId);
|
|
|
|
+ payShopDifference.setPayStatus(shopOrder.getPayStatus());
|
|
|
|
+ if ("3".equals(shopOrder.getPayStatus()) && 1 == payShopDifference.getType()) {
|
|
|
|
+ //已付款且少付情况下,保存付第三方付款记录
|
|
|
|
+ BigDecimal totalAmount = MathUtil.add(payShopDifference.getTransferPayFee(), payShopDifference.getBalancePayFee());
|
|
|
|
+ if (MathUtil.compare(totalAmount, differencePrice) != 0) {
|
|
|
|
+ throw new Exception("付款金额异常");
|
|
|
|
+ }
|
|
|
|
+ CmPayShop payShop = new CmPayShop();
|
|
|
|
+ payShop.setShopID(shopOrder.getShopID().toString());
|
|
|
|
+ payShop.setName(payShopDifference.getName());
|
|
|
|
+ payShop.setBankAccountName(payShopDifference.getBankAccountName());
|
|
|
|
+ payShop.setBankAccount(payShopDifference.getBankAccount());
|
|
|
|
+ payShop.setBankName(payShopDifference.getBankName());
|
|
|
|
+ payShop.setType(payShopDifference.getType().toString());
|
|
|
|
+ payShop.setTotalAmount(differencePrice.doubleValue());
|
|
|
|
+ if (MathUtil.compare(payShopDifference.getBalancePayFee(), 0) > 0) {
|
|
|
|
+ payShop.setBalancePayFee(payShopDifference.getBalancePayFee().doubleValue());
|
|
|
|
+ }
|
|
|
|
+ if (MathUtil.compare(payShopDifference.getTransferPayFee(), 0) > 0) {
|
|
|
|
+ payShop.setTransferPayFee(payShopDifference.getTransferPayFee().doubleValue());
|
|
|
|
+ }
|
|
|
|
+ payShop.setWipePayment(0d);
|
|
|
|
+ payShop.setApplicant(currentUser.getId());
|
|
|
|
+ payShop.setApplyTime(time);
|
|
|
|
+ payShop.setStatus("0");
|
|
|
|
+ payShop.setDelFlag("0");
|
|
|
|
+ cmPayShopDao.insert(payShop);
|
|
|
|
+
|
|
|
|
+ CmPayShopRecord payShopRecord = new CmPayShopRecord();
|
|
|
|
+ payShopRecord.setShopID(shopOrder.getShopID().toString());
|
|
|
|
+ payShopRecord.setShopOrderID(payShopDifference.getShopOrderId().toString());
|
|
|
|
+ payShopRecord.setShopOrderNo(shopOrder.getOrderNo());
|
|
|
|
+ payShopRecord.setPayAmount(differencePrice.doubleValue());
|
|
|
|
+ payShopRecord.setWipePayment(0d);
|
|
|
|
+ payShopRecord.setPaymentType(2);
|
|
|
|
+ payShopRecord.setPayShopID(payShop.getId());
|
|
|
|
+ payShopRecord.setStatus("0");
|
|
|
|
+ payShopRecord.setDelFlag("0");
|
|
|
|
+ cmPayShopRecordDao.insert(payShopRecord);
|
|
|
|
+ payShopDifference.setPayShopId(Integer.valueOf(payShop.getId()));
|
|
|
|
+
|
|
|
|
+ //使用欠款抵扣
|
|
|
|
+ if (MathUtil.compare(payShopDifference.getBalancePayFee(), 0) > 0) {
|
|
|
|
+ NewCmShop shop = newCmShopDao.get(shopOrder.getShopID().toString());
|
|
|
|
+ BigDecimal ableRebateAmount = MathUtil.sub(shop.getAbleRebateAmount(), payShopDifference.getBalancePayFee());
|
|
|
|
+ shop.setAbleRebateAmount(ableRebateAmount.doubleValue());
|
|
|
|
+ newCmShopDao.updateAbleRebateAmount(shop);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
//查询之前是否有差价退款过
|
|
//查询之前是否有差价退款过
|
|
Integer refundShopId = cmRefundShopRecordDao.findByRefundType(shopOrderId);
|
|
Integer refundShopId = cmRefundShopRecordDao.findByRefundType(shopOrderId);
|
|
if (refundShopId != null && refundShopId > 0) {
|
|
if (refundShopId != null && refundShopId > 0) {
|
|
@@ -861,8 +930,6 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
|
|
|
|
|
|
//待付供应商金额
|
|
//待付供应商金额
|
|
BigDecimal waitPayShop = MathUtil.sub(shopOrder.getShouldPayShopAmount(), shopOrder.getPayedShopAmount());
|
|
BigDecimal waitPayShop = MathUtil.sub(shopOrder.getShouldPayShopAmount(), shopOrder.getPayedShopAmount());
|
|
- //补差价金额
|
|
|
|
- BigDecimal differencePrice = payShopDifference.getDifferencePrice();
|
|
|
|
if (payShopDifference.getType() == 2 && MathUtil.compare(differencePrice, waitPayShop) > 0) {
|
|
if (payShopDifference.getType() == 2 && MathUtil.compare(differencePrice, waitPayShop) > 0) {
|
|
//多付且差价大于待付金额,会发生供应商退款操作
|
|
//多付且差价大于待付金额,会发生供应商退款操作
|
|
BigDecimal waitRefund = MathUtil.sub(differencePrice, waitPayShop);
|
|
BigDecimal waitRefund = MathUtil.sub(differencePrice, waitPayShop);
|
|
@@ -881,8 +948,6 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
|
|
}
|
|
}
|
|
if (MathUtil.compare(waitRefund, MathUtil.add(refundAmount, refundBalanceAmount)) == 0) {
|
|
if (MathUtil.compare(waitRefund, MathUtil.add(refundAmount, refundBalanceAmount)) == 0) {
|
|
CmRefundShop refundShop = new CmRefundShop();
|
|
CmRefundShop refundShop = new CmRefundShop();
|
|
- String time = DateUtils.formatDateTime(new Date());
|
|
|
|
- User currentUser = UserUtils.getUser();
|
|
|
|
refundShop.setShopID(shopOrder.getShopID().toString());
|
|
refundShop.setShopID(shopOrder.getShopID().toString());
|
|
refundShop.setOperator(currentUser.getId());
|
|
refundShop.setOperator(currentUser.getId());
|
|
refundShop.setOperatTime(time);
|
|
refundShop.setOperatTime(time);
|
|
@@ -924,6 +989,10 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
|
|
}
|
|
}
|
|
payShopDifference.setModifyUserId(Integer.parseInt(UserUtils.getUser().getId()));
|
|
payShopDifference.setModifyUserId(Integer.parseInt(UserUtils.getUser().getId()));
|
|
cmPayShopRecordDao.insertDifference(payShopDifference);
|
|
cmPayShopRecordDao.insertDifference(payShopDifference);
|
|
|
|
+ if ("3".equals(shopOrder.getPayStatus()) && 1 == payShopDifference.getType()) {
|
|
|
|
+ //多次少付供应商,应加上差价
|
|
|
|
+ differencePrice = MathUtil.add(shopOrder.getDifferencePrice(), differencePrice);
|
|
|
|
+ }
|
|
newShopOrderDao.updateByDifferencePrice(payShopDifference.getType(), differencePrice, shopOrderId);
|
|
newShopOrderDao.updateByDifferencePrice(payShopDifference.getType(), differencePrice, shopOrderId);
|
|
}
|
|
}
|
|
|
|
|