huangzhiguo 1 år sedan
förälder
incheckning
f04ae00817

+ 2 - 0
src/main/java/com/caimei/modules/order/dao/NewShopOrderDao.java

@@ -26,6 +26,8 @@ public interface NewShopOrderDao extends CrudDao<NewShopOrder> {
 
     NewShopOrder findByShopOrderID(@Param("shopOrderID") Integer shopOrderID);
 
+    Double findByPayShopID(@Param("shopOrderID") Integer shopOrderID);
+
     List<NewShopOrder> findListByOrderID(@Param("orderID") Integer orderID);
 
     List<String> findCommercialCode(@Param("orderID") Integer orderID);

+ 1 - 1
src/main/java/com/caimei/modules/order/entity/ChangePayShopDifference.java

@@ -33,7 +33,7 @@ public class ChangePayShopDifference implements Serializable {
     private BigDecimal differencePrice;
 
     /**
-     * 差价类型:1 少付;2 多付
+     * 差价类型:1 成本上升;2 成本降低
      */
     private Integer type;
 

+ 8 - 0
src/main/java/com/caimei/modules/order/entity/NewOrderProduct.java

@@ -46,6 +46,7 @@ public class NewOrderProduct extends DataEntity<NewOrderProduct> {
     private Double singleOtherFee;//   decimal(20,6) comment '单个应付第三方金额',
     private Double singleCmFee;//   decimal(20,6) comment '单个应付采美金额',
     private Double shouldPayFee;//   decimal(20,6) comment '应付金额',
+    private Double brokerage;   // 利润
     //private String commentFlag;//        national char(1) comment '是否已评论:1是,空或0未评论',
 //    private Double price0;//   float(10,2),
 //    private Double price1;//   float comment '普通会员价',
@@ -428,6 +429,13 @@ public class NewOrderProduct extends DataEntity<NewOrderProduct> {
         this.shouldPayFee = shouldPayFee;
     }
 
+    public Double getBrokerage() {
+        return brokerage;
+    }
+
+    public void setBrokerage(Double brokerage) {
+        this.brokerage = brokerage;
+    }
 //    public String getCommentFlag() {
 //        return commentFlag;
 //    }

+ 17 - 7
src/main/java/com/caimei/modules/order/service/CmPayShopService.java

@@ -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();

+ 1 - 0
src/main/resources/mappings/modules/order/OrderProductMapper.xml

@@ -559,6 +559,7 @@
                cop.totalAddedValueTax      AS totalAddedValueTax,
                cs.organizeId      AS organizeId,
                cs.unit as productUnit,
+               (cop.discountPrice - cop.costPrice - cop.cmCostPrice) as brokerage,
                cop.costPrice               AS costPrice,
                ifnull(cop.organizeCostPrice, 0)       AS organizeCostPrice,
                ifnull(cop.cmCostPrice, 0)             AS cmCostPrice,

+ 8 - 0
src/main/resources/mappings/modules/order/ShopOrderMapper.xml

@@ -225,6 +225,14 @@
         where a.shopOrderID = #{shopOrderID}
     </select>
 
+    <select id="findByPayShopID" resultType="java.lang.Double">
+        SELECT SUM(cpsr.payAmount)
+        FROM cm_pay_shop cps
+        LEFT JOIN cm_pay_shop_record cpsr ON cpsr.payShopID = cps.id
+        WHERE cpsr.delFlag = 0
+          AND cps.delFlag = 0
+          AND cpsr.shopOrderId = #{shopOrderID}
+    </select>
     <select id="findList" resultType="newShopOrder">
         SELECT
         <include refid="shopOrderColumns"/>

+ 2 - 2
src/main/webapp/WEB-INF/views/modules/order/cmPayShopCheck.jsp

@@ -495,8 +495,8 @@
                     <th colspan="3">单价</th>
                     <th colspan="3">机构税率 / 单税费 / 总税费</th>
                     <th>总价</th>
-                    <th>佣金(单)</th>
-                    <th>佣金(总)</th>
+                    <th>利润(单)</th>
+                    <th>利润(总)</th>
                     <th colspan="3">供应商税率 / 单税费 / 总税费</th>
                     <th>成本(单)</th>
                     <th>成本(总)</th>

+ 2 - 2
src/main/webapp/WEB-INF/views/modules/order/cmPayShopDetail.jsp

@@ -505,7 +505,7 @@
                         <td colspan="3" class="supplier-fee">
                             <div><span class="nowrap">
                             <c:if test="${s.differenceType ne 1 && s.differenceType ne 2}">
-                                应付:<fmt:formatNumber value="${s.shouldPayShopAmount}" type="number" pattern="#,##0.00"/>
+                                应付:<fmt:formatNumber value="${s.shouldPayShopAmount-s.shopOtherFee}" type="number" pattern="#,##0.00"/>
                             </c:if>
 							<c:if test="${s.differenceType eq 1 && s.differencePrice > 0}">
                                 <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount+s.differencePrice}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已补差价:${s.differencePrice})</font>
@@ -516,7 +516,7 @@
 							,</span>
                                 <span class="nowrap">已付:${s.payedShopAmount},</span></div>
                             <div><span class="nowrap">待付:<input type="number"
-                                                                value="<fmt:formatNumber value="${s.waitPayShop}" pattern="0.00"/>"
+                                                                value="<fmt:formatNumber value="${s.waitPayShop-s.shopOtherFee}" pattern="0.00"/>"
                                                                 class="need-to-pay" data-type="${s.differenceType}"
                                                                 data-difference="${s.differencePrice}"
                                                                 data-pay="${s.shouldPayShopAmount}"

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

@@ -587,7 +587,7 @@
                         <td colspan="3" class="supplier-fee">
                             <div><span class="nowrap">
                             <c:if test="${s.differenceType ne 1 && s.differenceType ne 2}">
-                                应付:<fmt:formatNumber value="${s.shouldPayShopAmount}" type="number" pattern="#,##0.00"/>
+                                应付:<fmt:formatNumber value="${s.shouldPayShopAmount-s.shopOtherFee}" type="number" pattern="#,##0.00"/>
                             </c:if>
 							<c:if test="${s.differenceType eq 1 && s.differencePrice > 0}">
                                 <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount+s.differencePrice}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已补差价:${s.differencePrice})</font>
@@ -598,7 +598,7 @@
 							,</span>
                                 <span class="nowrap">已付:${s.payedShopAmount},</span></div>
                             <div><span class="nowrap">待付:<input type="number"
-                                                                value="<fmt:formatNumber value="${s.waitPayShop}" pattern="0.00"/>"
+                                                                value="<fmt:formatNumber value="${s.waitPayShop-s.shopOtherFee}" pattern="0.00"/>"
                                                                 class="need-to-pay" data-type="${s.differenceType}"
                                                                 data-difference="${s.differencePrice}"
                                                                 data-pay="${s.shouldPayShopAmount}"

+ 2 - 2
src/main/webapp/WEB-INF/views/modules/order/cmPayShopOtherCheck.jsp

@@ -507,8 +507,8 @@
                     <th colspan="3">单价</th>
                     <th colspan="3">机构税率 / 单税费 / 总税费</th>
                     <th>总价</th>
-                    <th>佣金(单)</th>
-                    <th>佣金(总)</th>
+                    <th>利润(单)</th>
+                    <th>利润(总)</th>
                     <th colspan="3">供应商税率 / 单税费 / 总税费</th>
                     <th>成本(单)</th>
                     <th>成本(总)</th>

+ 2 - 2
src/main/webapp/WEB-INF/views/modules/order/cmPayShopOtherPrintDetail.jsp

@@ -621,8 +621,8 @@
                     <th colspan="2">单价</th>
                     <th colspan="3">机构税率 / 单税费 / 总税费</th>
                     <th colspan="2">总价</th>
-                    <th>佣金(单)</th>
-                    <th>佣金(总)</th>
+                    <th>利润(单)</th>
+                    <th>利润(总)</th>
                     <th colspan="3">供应商税率 / 单税费 / 总税费</th>
                     <th>成本(单)</th>
                     <th>成本(总)</th>

+ 2 - 2
src/main/webapp/WEB-INF/views/modules/order/cmRefundShopDetail.jsp

@@ -234,8 +234,8 @@
                     <th colspan="3">单价</th>
                     <th colspan="3">机构税率 / 单税费 / 总税费</th>
                     <th>总价</th>
-                    <th>佣金(单)</th>
-                    <th>佣金(总)</th>
+                    <th>利润(单)</th>
+                    <th>利润(总)</th>
                     <th colspan="3">供应商税率 / 单税费 / 总税费</th>
                     <th>成本(单)</th>
                     <th>成本(总)</th>

+ 2 - 2
src/main/webapp/WEB-INF/views/modules/order/cmRefundShopForm.jsp

@@ -241,8 +241,8 @@
 						<th colspan="3">单价</th>
 						<th colspan="3">机构税率 / 单税费 / 总税费</th>
 						<th>总价</th>
-						<th>佣金(单)</th>
-						<th>佣金(总)</th>
+						<th>利润(单)</th>
+						<th>利润(总)</th>
 						<th colspan="3">供应商税率 / 单税费 / 总税费</th>
 						<th>成本(单)</th>
 						<th>成本(总)</th>

+ 2 - 2
src/main/webapp/WEB-INF/views/modules/order/cmSettlementForm.jsp

@@ -560,8 +560,8 @@
                         <th colspan="3">单价</th>
                         <th colspan="3">机构税率 / 单税费 / 总税费</th>
                         <th>总价</th>
-                        <th>佣金(单)</th>
-                        <th>佣金(总)</th>
+                        <th>利润(单)</th>
+                        <th>利润(总)</th>
                         <th colspan="3">供应商税率 / 单税费 / 总税费</th>
                         <th>成本(单)</th>
                         <th>成本(总)</th>

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

@@ -502,7 +502,7 @@
     }
 
     function showInfo() {
-        debugger
+        // debugger
         var type = $("input[name='type']:checked").val();
         var ShopReceiptStatus=$('#ShopReceiptStatus').val();
         console.log(ShopReceiptStatus)