Browse Source

收款bugfix

huangzhiguo 1 year ago
parent
commit
8acd19644a

+ 6 - 1
src/main/java/com/caimei/modules/order/service/CmPayShopService.java

@@ -225,7 +225,9 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                 } else if (so.getDifferenceType() != null && so.getDifferenceType() == 2) {
                     totalAmount = MathUtil.sub(totalAmount, so.getDifferencePrice()).doubleValue();
                 }
-
+                // 子订单已收金额
+                Double receiptAmount = cmReceiptOrderRelationDao.findReceiptByShopOrderId(so.getShopOrderID().toString());
+                so.setReceiptAmount(MathUtil.add(so.getReceiptAmount(), receiptAmount).doubleValue());
                 totalAmount -= so.getShopOtherFee();
                 List<NewOrderProduct> orderProductList = newOrderProductDao.findByShopOrderID(so.getShopOrderID());
                 /*
@@ -388,6 +390,9 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                 } else {
                     so.setWaitPayShop(cmPayShopRecord.getPayAmount());
                 }
+                // 子订单已收金额
+                Double receiptAmount = cmReceiptOrderRelationDao.findReceiptByShopOrderId(so.getShopOrderID().toString());
+                so.setReceiptAmount(MathUtil.add(so.getReceiptAmount(), receiptAmount).doubleValue());
                 List<NewOrderProduct> orderProductList = newOrderProductDao.findByShopOrderID(so.getShopOrderID());
                 /* 退货数量 */
                 Integer count = 0;

+ 4 - 85
src/main/resources/mappings/modules/order/CmPayShopMapper.xml

@@ -57,7 +57,7 @@
 		limit 1
 	</select>
 	<select id="findList" resultType="CmPayShop">
-		(SELECT
+		SELECT
 			<include refid="cmPayShopColumns"/>,
 		u1.name AS applicantName,
 		u2.name AS reviewerName,
@@ -70,12 +70,7 @@
 		LEFT JOIN cm_pay_shop_record psr ON psr.payShopID = a.id
 		LEFT JOIN cm_shop_order so ON so.shopOrderID = psr.shopOrderID
 		<where>
-			so.shopOrderId IN( SELECT DISTINCT cror.shopOrderId
-					FROM cm_discern_receipt cdr
-					LEFT JOIN cm_receipt_order_relation cror ON cdr.id=cror.receiptID
-					WHERE cdr.payway = 2
-				)
-			AND (a.shopId = 1161 OR s.AccountOwnership = 0 OR so.splitCode = 'E1807059160')
+			(a.shopId = 1161 OR s.AccountOwnership = 0 OR so.splitCode = 'E1807059160' or so.ordertype = 2)
 			and a.delFlag = '0'
 			and (so.organizeID!=4 or so.organizeID is null)
 			and a.shopID != 998
@@ -129,91 +124,15 @@
 			</if>
 		</where>
 		GROUP BY a.id
-		<!--<choose>
+		<choose>
 			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
 				ORDER BY ${page.orderBy}
 			</when>
 			<otherwise>
 				ORDER BY a.id desc
 			</otherwise>
-		</choose>-->)
-		union
-		(SELECT
-		<include refid="cmPayShopColumns"/>,
-		u1.name AS applicantName,
-		u2.name AS reviewerName,
-		s.name AS shopName,
-		(SELECT paymentType FROM cm_pay_shop_record WHERE payShopID = a.id LIMIT 1) AS paymentType
-		FROM cm_pay_shop a
-		left join sys_user u1 on u1.id = a.applicant
-		left join sys_user u2 on u2.id = a.reviewer
-		left join shop s on s.shopID = a.shopID
-		LEFT JOIN cm_pay_shop_record psr ON psr.payShopID = a.id
-		LEFT JOIN cm_shop_order so ON so.shopOrderID = psr.shopOrderID
-		<where>
-			so.ordertype = 2
-			and a.delFlag = '0'
-			and (so.organizeID!=4 or so.organizeID is null)
-			and a.shopID != 998
-			<if test="id != null and id != ''">
-				and a.id = #{id}
-			</if>
-			<if test="shopName != null and shopName != ''">
-				and s.name like concat('%', #{shopName}, '%')
-			</if>
-			<if test="name != null and name != ''">
-				AND a.name LIKE
-				<if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
-				<if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
-				<if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
-			</if>
-			<if test="startTime != null and startTime != ''">
-				AND a.applyTime <![CDATA[  >=  ]]> #{startTime}
-			</if>
-			<if test="endTime != null and endTime != ''">
-				AND a.applyTime <![CDATA[   <=  ]]> #{endTime}
-			</if>
-			<if test="startTime2 != null and startTime2 != ''">
-				AND a.payTime <![CDATA[  >=  ]]> #{startTime2}
-			</if>
-			<if test="endTime2 != null and endTime2 != ''">
-				AND a.payTime <![CDATA[   <=  ]]> #{endTime2}
-			</if>
-			<if test="status != null and status != ''">
-				AND a.status = #{status}
-			</if>
-			<if test="shopOrderNo != null and shopOrderNo != ''">
-				AND a.id in (select cpsr.payShopID from cm_pay_shop_record cpsr where cpsr.shopOrderNo like concat('%',#{shopOrderNo},'%'))
-			</if>
-			<if test="shopOrderID != null and shopOrderID != ''">
-				AND a.id in (SELECT cpsr.payShopID FROM cm_pay_shop_record cpsr WHERE cpsr.shopOrderID=#{shopOrderID})
-			</if>
-			<if test="orderID != null and orderID != ''">
-				AND a.id in (SELECT cpsr.payShopID FROM cm_pay_shop_record  cpsr LEFT JOIN cm_shop_order so ON so.shopOrderID=cpsr.shopOrderID WHERE so.orderID=#{orderID})
-			</if>
-			<if test='organizeID != null and organizeID != "" and organizeID != "9999"'>
-				AND a.id in (SELECT cpsr.payShopID FROM cm_pay_shop_record  cpsr LEFT JOIN cm_shop_order so ON so.shopOrderID=cpsr.shopOrderID WHERE so.organizeID = #{organizeID})
-			</if>
-			<if test='organizeID == "9999"'>
-				AND a.id IN (SELECT cpsr.payShopID FROM cm_pay_shop_record  cpsr LEFT JOIN cm_shop_order so ON so.shopOrderID=cpsr.shopOrderID WHERE so.orderType = 2)
-			</if>
-			<if test="orderNo != null and orderNo != ''">
-				AND a.id in (SELECT cpsr.payShopID FROM cm_pay_shop_record  cpsr LEFT JOIN cm_shop_order so ON so.shopOrderID=cpsr.shopOrderID WHERE so.orderNo LIKE CONCAT('%',#{orderNo},'%'))
-			</if>
-			<if test="paymentType != null">
-				AND a.id IN(SELECT payShopID FROM cm_pay_shop_record WHERE paymentType = #{paymentType} AND delFlag = 0)
-			</if>
+		</choose>
 
-		</where>
-		GROUP BY a.id
-		<!--<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-				ORDER BY a.id desc
-			</otherwise>
-		</choose>-->) ORDER BY id DESC
 	</select>
 
 	<select id="findAllList" resultType="CmPayShop">

+ 3 - 88
src/main/resources/mappings/modules/order/ShopOrderMapper.xml

@@ -701,90 +701,6 @@
     </update>
 
     <select id="findPayOrderList" resultType="newShopOrder">
-        (select<include refid="shopOrderColumns"/>,
-        co.payTotalFee AS payTotalFee,
-
-        bou.name AS buyer,
-        s.name AS shopName,
-        c.name AS clubName,
-        cdr.payWay AS payWay
-        from cm_shop_order a
-        left join cm_pay_shop_record cpsr on a.shopOrderID = cpsr.shopOrderID
-        left join bp_order_userinfo bou on bou.orderId = a.orderID
-        left join cm_order co on co.orderID = a.orderID
-        LEFT JOIN cm_receipt_order_relation cror ON cror.orderId = co.orderId
-        LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
-        left join shop s on s.shopID = a.shopID
-        LEFT JOIN club c ON c.userID = a.userID
-        <where>
-            a.shopOrderId IN( SELECT DISTINCT cror.shopOrderId
-                FROM cm_discern_receipt cdr
-                LEFT JOIN cm_receipt_order_relation cror ON cdr.id=cror.receiptID
-                WHERE cdr.payway = 2
-            )
-            AND (s.shopId = 1161 OR s.AccountOwnership = 0 OR a.splitCode = 'E1807059160')
-            <if test="startTime != null and startTime != ''">
-                AND (a.orderTime &gt; #{startTime} OR a.orderTime = #{startTime})
-            </if>
-            <if test="endTime != null and endTime != ''">
-                AND (a.orderTime &lt; #{endTime} OR a.orderTime = #{endTime})
-            </if>
-            <if test="orderID != null and orderID != ''">
-                AND a.orderID = #{orderID}
-            </if>
-            <if test="organizeID != null and organizeID != 9999">
-                AND co.organizeID = #{organizeID}
-            </if>
-            <if test="organizeID == 9999 ">
-                AND co.orderType = 2
-            </if>
-            <if test="orderNo != null and orderNo != ''">
-                AND a.orderNo like concat('%', #{orderNo} ,'%')
-            </if>
-            <if test="ps != null and ps.length>0 ">
-                AND a.payStatus in
-                <foreach item="item" index="index" collection="ps" open="(" close=")" separator=",">
-                    #{item}
-                </foreach>
-            </if>
-            <if test="shopName != null and shopName != ''">
-                AND s.name like concat('%', #{shopName} ,'%')
-            </if>
-            <if test="buyer != null and buyer != ''">
-                AND bou.name like concat('%', #{buyer} ,'%')
-            </if>
-            <if test="clubName != null and clubName != ''">
-                AND c.name like concat('%', #{clubName} ,'%')
-            </if>
-            <if test="shopOrderID != null and shopOrderID != ''">
-                AND a.shopOrderID = #{shopOrderID}
-            </if>
-            <if test="shopOrderNo != null and shopOrderNo != ''">
-                AND a.shopOrderNo like concat('%', #{shopOrderNo} ,'%')
-            </if>
-            and (co.confirmFlag = '1' or co.confirmFlag = '2')
-            <if test="operatingMode != null and operatingMode == '1'.toString()">
-                and a.payStatus != 3 and co.status NOT IN (6,7)
-            </if>
-            <if test="operatingMode != null and operatingMode == '2'.toString()">
-                and a.payStatus != 1 and co.status != 6
-            </if>
-            <if test="operatingMode != null and operatingMode == '3'.toString()">
-                and a.payStatus = 3 and co.status NOT IN (6,7)
-            </if>
-            and co.delFlag = 0
-            -- and not (co.secondHandOrderFlag=1 AND co.rebateFlag=1)
-            and a.delFlag = 0
-            and (a.organizeID!=4 or a.organizeID is null)
-            and a.shopID != 998
-            and co.orderID not in (
-            SELECT orderID FROM cm_order_product WHERE productID IN
-            (6060, 6061, 6062, 6063, 6064, 6065, 6066, 6067, 6068, 6069) GROUP BY orderID
-            )
-        </where>
-        group by a.shopOrderID)
-        union
-        (
         select<include refid="shopOrderColumns"/>,
         co.payTotalFee AS payTotalFee,
 
@@ -801,7 +717,7 @@
         left join shop s on s.shopID = a.shopID
         LEFT JOIN club c ON c.userID = a.userID
         <where>
-            a.ordertype = 2
+            (s.shopId = 1161 OR s.AccountOwnership = 0 OR a.splitCode = 'E1807059160' or a.ordertype = 2)
             <if test="startTime != null and startTime != ''">
                 AND (a.orderTime &gt; #{startTime} OR a.orderTime = #{startTime})
             </if>
@@ -841,7 +757,6 @@
             <if test="shopOrderNo != null and shopOrderNo != ''">
                 AND a.shopOrderNo like concat('%', #{shopOrderNo} ,'%')
             </if>
-            and (co.confirmFlag = '1' or co.confirmFlag = '2')
             <if test="operatingMode != null and operatingMode == '1'.toString()">
                 and a.payStatus != 3 and co.status NOT IN (6,7)
             </if>
@@ -851,6 +766,7 @@
             <if test="operatingMode != null and operatingMode == '3'.toString()">
                 and a.payStatus = 3 and co.status NOT IN (6,7)
             </if>
+            and a.shopStatus != 0
             and co.delFlag = 0
             -- and not (co.secondHandOrderFlag=1 AND co.rebateFlag=1)
             and a.delFlag = 0
@@ -862,8 +778,7 @@
             )
         </where>
         group by a.shopOrderID
-        )
-        ORDER BY shopOrderID DESC
+        ORDER BY a.shopOrderID DESC
     </select>
 
     <select id="payThirdParties" resultType="newShopOrder">

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

@@ -467,9 +467,9 @@
                                 <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount-s.differencePrice}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已退差价:${s.differencePrice})</font>
                             </c:if>
 							,</span>
-                            <span class="nowrap">已付:${s.payedShopAmount},</span></div>
+                            <span class="nowrap">已付:${s.payedShopAmount-s.shopOtherFee},</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}"
@@ -539,11 +539,11 @@
                                 value="${((empty p.touchPrice?p.discountPrice:p.touchPrice) + p.addedValueTax)*(p.num+p.presentNum-p.returnedNum)}"
                                 type="number" pattern="#,##0.00"/></td>
                         <td><fmt:formatNumber
-                                value="${(empty p.touchPrice?p.discountPrice:p.touchPrice) + p.addedValueTax - p.costPrice - p.singleShouldPayTotalTax}"
+                                value="${p.oldDiscountPrice - p.costPrice - p.cmCostPrice - p.organizeCostPrice}"
                                 pattern="#,##0.00"/></td>
 
                         <td class="payCm"><fmt:formatNumber
-                                value="${((empty p.touchPrice?p.discountPrice:p.touchPrice) + p.addedValueTax - p.costPrice - p.singleShouldPayTotalTax) * (p.num + p.presentNum - p.returnedNum)}"
+                                value="${(p.oldDiscountPrice - p.costPrice - p.cmCostPrice - p.organizeCostPrice) * (p.num + p.presentNum - p.returnedNum)}"
                                 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>

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

@@ -596,7 +596,7 @@
                                 <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount-s.differencePrice}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已退差价:${s.differencePrice})</font>
                             </c:if>
 							,</span>
-                                <span class="nowrap">已付:${s.payedShopAmount},</span></div>
+                                <span class="nowrap">已付:${s.payedShopAmount-s.shopOtherFee},</span></div>
                             <div><span class="nowrap">待付:<input type="number"
                                                                 value="<fmt:formatNumber value="${s.waitPayShop-s.shopOtherFee}" pattern="0.00"/>"
                                                                 class="need-to-pay" data-type="${s.differenceType}"

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

@@ -268,7 +268,7 @@
 							</c:if>
 						</c:if></td>
 					<td colspan="3" class="taxes"><fmt:formatNumber value="${s.shopTaxFee}" type="number" pattern="#,##0.00"/></td>
-					<td class="supplier-fee"><font color="#E15616"><fmt:formatNumber value="${s.shouldPayShopAmount}" type="number" pattern="#,##0.00"/></font></td>
+					<td class="supplier-fee"><font color="#E15616"><fmt:formatNumber value="${s.shouldPayShopAmount-s.shopOtherFee}" type="number" pattern="#,##0.00"/></font></td>
 						<input type="hidden" class="payedShopAmount" value="${s.payedShopAmount}">
 						<input type="hidden" class="productAmount" value="${s.productAmount}">
 						<input type="hidden" class="costType" value="${s.costType}">

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

@@ -219,7 +219,7 @@
 							<c:if test="${s.payStatus == 3}"><font color="green">已付款</font></c:if>
 						</td>
 						<td colspan="3" class="supplier-fee">
-							<div>应付:${s.shouldPayShopAmount}, 已付:${s.payedShopAmount}
+							<div>应付:${s.shouldPayShopAmount-s.shopOtherFee}, 已付:${s.payedShopAmount}
 								<c:if test="${s.wipePayment > 0}"><font color="red">(付款抹平¥${s.wipePayment})</font></c:if>
 							</div>
 							<div>已退:${s.refundsAmount}<%--, 待退:<span class="need-refund"><fmt:formatNumber value="${s.payedShopAmount-s.refundsAmount-s.shouldPayShopAmount}" type="number" pattern="#,##0.00"/></span>--%></div>

+ 3 - 3
src/main/webapp/WEB-INF/views/modules/order/cmSettlementList.jsp

@@ -447,13 +447,13 @@
                                                                     pattern="#,##0.00"/></td>
                     <td class="supplier-fee">
                         <c:if test="${s.differenceType ne 1 && s.differenceType ne 2 }">
-                            <font color="#E15616"><fmt:formatNumber value="${s.shouldPayShopAmount}" type="number" pattern="#,##0.00"/></font>
+                            <font color="#E15616"><fmt:formatNumber value="${s.shouldPayShopAmount-s.shopOtherFee}" type="number" pattern="#,##0.00"/></font>
                         </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>
+                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount+s.differencePrice-s.shopOtherFee}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已补差价:${s.differencePrice})</font>
                         </c:if>
                         <c:if test="${s.differenceType eq 2 && s.differencePrice > 0}">
-                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount-s.differencePrice}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已退差价:${s.differencePrice})</font>
+                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount-s.differencePrice-s.shopOtherFee}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已退差价:${s.differencePrice})</font>
                         </c:if>
                     </td>
                     <input type="hidden" class="payedShopAmount" value="${s.payedShopAmount}">

+ 3 - 3
src/main/webapp/WEB-INF/views/modules/order/cmSplitAccountList.jsp

@@ -420,13 +420,13 @@
                                                                     pattern="#,##0.00"/></td>
                     <td class="supplier-fee">
                         <c:if test="${s.differenceType ne 1 && s.differenceType ne 2 }">
-                            <font color="#E15616"><fmt:formatNumber value="${s.shouldPayShopAmount}" type="number" pattern="#,##0.00"/></font>
+                            <font color="#E15616"><fmt:formatNumber value="${s.shouldPayShopAmount-s.shopOtherFee}" type="number" pattern="#,##0.00"/></font>
                         </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>
+                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount+s.differencePrice-s.shopOtherFee}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已补差价:${s.differencePrice})</font>
                         </c:if>
                         <c:if test="${s.differenceType eq 2 && s.differencePrice > 0}">
-                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount-s.differencePrice}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已退差价:${s.differencePrice})</font>
+                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount-s.differencePrice-s.shopOtherFee}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已退差价:${s.differencePrice})</font>
                         </c:if>
                     </td>
                     <input type="hidden" class="payedShopAmount" value="${s.payedShopAmount}">

+ 3 - 3
src/main/webapp/WEB-INF/views/modules/order/paidShopOrderList.jsp

@@ -409,14 +409,14 @@
                                                                     pattern="#,##0.00"/></td>
                     <td class="supplier-fee">
                         <c:if test="${s.differenceType ne 1 && s.differenceType ne 2 }">
-                        <font color="#E15616"><fmt:formatNumber value="${s.shouldPayShopAmount}" type="number"
+                        <font color="#E15616"><fmt:formatNumber value="${s.shouldPayShopAmount-s.shopOtherFee}" type="number"
                                                                 pattern="#,##0.00"/></font>
                         </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>
+                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount+s.differencePrice-s.shopOtherFee}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已补差价:${s.differencePrice})</font>
                         </c:if>
                         <c:if test="${s.differenceType eq 2 && s.differencePrice > 0}">
-                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount-s.differencePrice}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已退差价:${s.differencePrice})</font>
+                            <font color="black"><fmt:formatNumber value="${s.shouldPayShopAmount-s.differencePrice-s.shopOtherFee}"/></font><font color="red">(原应付:${s.shouldPayShopAmount},已退差价:${s.differencePrice})</font>
                         </c:if>
                     </td>
                     <input type="hidden" class="payedShopAmount" value="${s.payedShopAmount}">