|
@@ -225,6 +225,8 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
|
|
|
} else if (so.getDifferenceType() != null && so.getDifferenceType() == 2) {
|
|
|
totalAmount = MathUtil.sub(totalAmount, so.getDifferencePrice()).doubleValue();
|
|
|
}
|
|
|
+
|
|
|
+ totalAmount -= so.getShopOtherFee();
|
|
|
List<NewOrderProduct> orderProductList = newOrderProductDao.findByShopOrderID(so.getShopOrderID());
|
|
|
/*
|
|
|
1. 若发生退货,数量要减去已退货和已取消的数量
|
|
@@ -234,6 +236,7 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
|
|
|
Integer returnNum = 0;
|
|
|
// 平台服务费
|
|
|
Double allServeAmount = 0d;
|
|
|
+ Double brokerage = 0d;
|
|
|
for (NewOrderProduct p : orderProductList) {
|
|
|
returnNum = newOrderProductDao.CountReturnedPurchaseProduct(so.getShopOrderID(), p.getOrderProductID());
|
|
|
returnNum = returnNum == null ? 0 : returnNum;
|
|
@@ -250,7 +253,11 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
|
|
|
}
|
|
|
// 付采美总金额
|
|
|
allServeAmount = MathUtil.add(allServeAmount, MathUtil.mul(p.getNum(), p.getCmCostPrice())).doubleValue();
|
|
|
+ // 子订单利润
|
|
|
+
|
|
|
+ brokerage = MathUtil.add(brokerage, MathUtil.mul(p.getBrokerage(),p.getNum())).doubleValue();
|
|
|
}
|
|
|
+ so.setBrokerage(brokerage);
|
|
|
so.setAllServeAmount(allServeAmount);
|
|
|
so.setNewOrderProducts(orderProductList);
|
|
|
so.setWaitPayShop((so.getShouldPayShopAmount() == null ? 0D : so.getShouldPayShopAmount()) - (so.getPayedShopAmount() == null ? 0D : so.getPayedShopAmount()));
|
|
@@ -319,20 +326,19 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
|
|
|
}
|
|
|
//若成本下降太多导致部分收款的钱,已经大于成本重新计算佣金
|
|
|
if ("0".equals(newOrder.getOnlinePayFlag()) && so.getShopReceiptStatus() == 2) {
|
|
|
- double mum = so.getProductAmount();
|
|
|
+ // double mum = so.getProductAmount();
|
|
|
System.out.println(so.getReceiptTotalFee());
|
|
|
System.out.println(so.getShouldPayShopAmount());
|
|
|
BigDecimal getShouldPayShopAmount = MathUtil.sub(so.getShouldPayShopAmount(), so.getDifferencePrice());
|
|
|
- if (so.getReceiptTotalFee() > Double.valueOf(getShouldPayShopAmount.toString())) {
|
|
|
+ /*if (so.getReceiptTotalFee() > Double.valueOf(getShouldPayShopAmount.toString())) {
|
|
|
//子订单佣金
|
|
|
-
|
|
|
mum -= so.getShopOtherFee() + Double.valueOf(getShouldPayShopAmount.toString());
|
|
|
// 子订单佣金减供应商运费
|
|
|
- mum -= so.getShopPostFee();
|
|
|
+ mum -= null == so.getShopPostFee()?0:so.getShopPostFee();
|
|
|
so.setBrokerage(mum);
|
|
|
} else {
|
|
|
so.setBrokerage(null);
|
|
|
- }
|
|
|
+ }*/
|
|
|
} else {
|
|
|
so.setBrokerage(null);
|
|
|
}
|
|
@@ -386,6 +392,7 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
|
|
|
/* 退货数量 */
|
|
|
Integer count = 0;
|
|
|
Double allServeAmount = 0d;
|
|
|
+ Double brokerage = 0d;
|
|
|
for (NewOrderProduct p : orderProductList) {
|
|
|
count = newOrderProductDao.CountReturnedPurchaseProduct(so.getShopOrderID(), p.getOrderProductID());
|
|
|
count = count == null ? 0 : count;
|
|
@@ -401,7 +408,9 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
|
|
|
}
|
|
|
// 付采美总金额
|
|
|
allServeAmount = MathUtil.add(allServeAmount, MathUtil.mul(p.getNum(), p.getCmCostPrice())).doubleValue();
|
|
|
+ brokerage = MathUtil.add(brokerage, MathUtil.mul(p.getBrokerage(),p.getNum())).doubleValue();
|
|
|
}
|
|
|
+ so.setBrokerage(brokerage);
|
|
|
so.setAllServeAmount(allServeAmount);
|
|
|
if (so.getShopPostFee() == null) so.setShopPostFee(0D);
|
|
|
if (so.getShopTaxFee() == null) so.setShopTaxFee(0D);
|
|
@@ -1046,7 +1055,8 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
|
|
|
BigDecimal waitPayShop = BigDecimal.ZERO;
|
|
|
if (shopOrder != null) {
|
|
|
payShopDifference.setPayStatus(shopOrder.getPayStatus());
|
|
|
- waitPayShop = MathUtil.sub(shopOrder.getShouldPayShopAmount(), shopOrder.getDifferencePrice());
|
|
|
+ Double paShopAmount = newShopOrderDao.findByPayShopID(shopOrderId);
|
|
|
+ waitPayShop = MathUtil.sub(MathUtil.sub(shopOrder.getShouldPayShopAmount(), shopOrder.getDifferencePrice()), paShopAmount);
|
|
|
NewCmShop shop = newCmShopDao.get(shopOrder.getShopID().toString());
|
|
|
payShopDifference.setBankAccount(shop.getBankAccount());
|
|
|
payShopDifference.setBankAccountName(shop.getBankAccountName());
|
|
@@ -1144,7 +1154,7 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
|
|
|
// List<Integer> payWay= newShopOrderDao.payWay(shopOrderId);
|
|
|
// if(payWay==1 && shopOrder.getShopReceiptStatus()==2) {
|
|
|
if (payShopDifference.getType() == 2 && MathUtil.compare(differencePrice, waitPayShop) > 0) {
|
|
|
- //多付且差价大于待付金额,会发生供应商退款操作
|
|
|
+ //成本降低且差价大于待付金额,会发生供应商退款操作
|
|
|
BigDecimal waitRefund = MathUtil.sub(differencePrice, waitPayShop);
|
|
|
String refundWay = payShopDifference.getRefundWay();
|
|
|
BigDecimal refundAmount = payShopDifference.getRefundAmount();
|