Przeglądaj źródła

子订单部分退款显示

huangzhiguo 1 rok temu
rodzic
commit
d49e31e8de

+ 24 - 3
src/main/java/com/caimei/modules/order/service/CmPayShopService.java

@@ -274,6 +274,7 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                  */
 
                 Integer returnNum = 0;
+                Double returnNumAmount = 0d;
                 // 平台服务费
                 Double allServeAmount = 0d;
                 Double brokerage = 0d;
@@ -294,11 +295,28 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                     // 付采美总金额
                     allServeAmount = MathUtil.add(allServeAmount, MathUtil.mul(p.getNum(), p.getCmCostPrice())).doubleValue();
                     // 子订单利润
-                    if (p.getProductType() == 0) {
-                        brokerage = MathUtil.add(brokerage, MathUtil.mul(p.getBrokerage(), p.getNum())).doubleValue();
+                    if (p.getReturnedNum().equals(p.getNum())) {
+                        if (p.getProductType() == 0) {
+                            brokerage = MathUtil.add(brokerage, MathUtil.mul(p.getBrokerage(), p.getNum())).doubleValue();
+                        } else {
+                            brokerage = MathUtil.add(brokerage, 0).doubleValue();
+                        }
+                    } else if (p.getReturnedNum() < p.getNum()) {
+                        if (p.getProductType() == 0) {
+                            brokerage = MathUtil.add(brokerage, MathUtil.mul(p.getBrokerage(), MathUtil.sub(p.getNum(), p.getReturnedNum()))).doubleValue();
+                        } else {
+                            brokerage = MathUtil.add(brokerage, 0).doubleValue();
+                        }
                     } else {
-                        brokerage = MathUtil.add(brokerage, 0).doubleValue();
+                        if (p.getProductType() == 0) {
+                            brokerage = MathUtil.add(brokerage, MathUtil.mul(p.getBrokerage(), p.getNum())).doubleValue();
+                        } else {
+                            brokerage = MathUtil.add(brokerage, 0).doubleValue();
+                        }
                     }
+                    allServeAmount = MathUtil.sub(allServeAmount, MathUtil.mul(returnNum, p.getCmCostPrice())).doubleValue();
+                    // 应退的成本
+                    returnNumAmount = MathUtil.mul(returnNum, p.getCostPrice()).doubleValue();
                 }
                 so.setBrokerage(brokerage);
                 so.setAllServeAmount(allServeAmount);
@@ -311,6 +329,9 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                     BigDecimal waitPayShop = MathUtil.sub(so.getWaitPayShop(), so.getDifferencePrice());
                     so.setWaitPayShop(waitPayShop.doubleValue());
                 }
+                so.setWaitPayShop(MathUtil.sub(so.getWaitPayShop(), returnNumAmount).doubleValue());
+                so.setShopProductAmount(MathUtil.sub(so.getShopProductAmount(), returnNumAmount).doubleValue());
+                so.setShouldPayShopAmount(MathUtil.sub(so.getShouldPayShopAmount(), returnNumAmount).doubleValue());
 
                 //统计该子订单的主的收款金额和收款状态
                 NewOrder newOrder = newOrderDao.get(so.getOrderID().toString());

+ 1 - 1
src/main/webapp/WEB-INF/views/modules/order/cmPayShopForm.jsp

@@ -692,7 +692,7 @@
                                     0.00
                                 </c:if>
                             </td>
-                            <td><fmt:formatNumber value="${p.cmCostPrice}" type="number" pattern="#,##0.00"/></td>
+                            <td><fmt:formatNumber value="${p.returnedNum == p.returnedNum ? 0.00 : p.cmCostPrice}" type="number" pattern="#,##0.00"/></td>
                             <td class="p-taxes">${(p.includedTax ne '' and p.includedTax eq 0 and p.invoiceType eq 3)?'---':empty p.supplierTaxRate?0.0:p.supplierTaxRate}${(p.includedTax ne '' and p.includedTax eq 0 and p.invoiceType eq 3)?'':'%'}</td>
                             <td class="p-taxes">${(p.includedTax ne '' and (p.includedTax eq 1 or (p.includedTax eq 0 and p.invoiceType eq 3)))?'---': empty p.singleShouldPayTotalTax ?0.00:p.singleShouldPayTotalTax}</td>
                             <td class="p-taxes-t"><c:choose>