|
@@ -150,7 +150,7 @@
|
|
|
cdr.payType,
|
|
|
cdr.receiptType,
|
|
|
cdr.receiptStatus,
|
|
|
- cdr.receiptAmount,
|
|
|
+ IFNULL(cdr.receiptAmount,0) AS receiptAmount,
|
|
|
cdr.smsContent,
|
|
|
cdr.smsMd5Code,
|
|
|
cdr.receiptDate,
|
|
@@ -323,8 +323,7 @@
|
|
|
LEFT JOIN cm_receipt_order_relation cror ON svipr.id = cror.vipRecordId
|
|
|
LEFT JOIN club c ON svipr.userId = c.clubID
|
|
|
LEFT JOIN cm_svip_package svipp ON svipp.id = svipr.packageId
|
|
|
- WHERE cror.receiptID = #{receiptId}
|
|
|
- LIMIT 1
|
|
|
+ WHERE cror.receiptID = #{receiptId} LIMIT 1
|
|
|
</select>
|
|
|
<select id="getReceiptCouponInfo" resultType="com.caimei365.manager.entity.caimei.ReceiptCouponInfo">
|
|
|
SELECT c.name AS clubName,
|
|
@@ -341,5 +340,182 @@
|
|
|
LEFT JOIN cm_coupon cc ON ccb.couponId = cc.id
|
|
|
WHERE receiptID = #{receiptId}
|
|
|
</select>
|
|
|
-
|
|
|
+ <select id="getOrderIdsByReceiptId" resultType="java.lang.Integer">
|
|
|
+ SELECT cror.orderID FROM cm_receipt_order_relation cror
|
|
|
+ WHERE cror.receiptID = #{receiptId} and cror.delFlag = '0' and cror.relationType = '2'
|
|
|
+ </select>
|
|
|
+ <select id="getShopOrderIdsByReceiptId" resultType="java.lang.Integer">
|
|
|
+ SELECT cror.orderID FROM cm_receipt_order_relation cror
|
|
|
+ WHERE cror.receiptID = #{receiptId} and cror.delFlag = '0' and cror.relationType = '1'
|
|
|
+ </select>
|
|
|
+ <select id="getOrderReceiptCount" resultType="java.lang.Integer">
|
|
|
+ SELECT IFNULL(COUNT(cror.receiptID), 0)
|
|
|
+ FROM cm_receipt_order_relation cror
|
|
|
+ JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
|
|
|
+ WHERE cror.orderID = #{orderId} and cror.receiptID != #{receiptId}
|
|
|
+ AND cror.relationType = '2' AND cror.delFlag = '0'
|
|
|
+ AND cdr.receiptStatus = '3' AND cdr.delFlag = '0'
|
|
|
+ </select>
|
|
|
+ <select id="getShopOrderReceiptCount" resultType="java.lang.Integer">
|
|
|
+ SELECT IFNULL(COUNT(cror.receiptID), 0)
|
|
|
+ FROM cm_receipt_order_relation cror
|
|
|
+ JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
|
|
|
+ WHERE cror.orderID IN
|
|
|
+ (SELECT cso2.shopOrderID
|
|
|
+ FROM cm_shop_order cso1
|
|
|
+ LEFT JOIN cm_shop_order cso2 ON cso2.orderID = cso1.orderID
|
|
|
+ WHERE cso1.shopOrderID = #{shopOrderId} and cso2.shopOrderID != #{shopOrderId})
|
|
|
+ AND cror.orderID != #{shopOrderId}
|
|
|
+ AND cdr.receiptStatus = '2' AND cdr.delFlag = '0'
|
|
|
+ AND cror.relationType = '1' AND cror.delFlag = '0'
|
|
|
+ </select>
|
|
|
+ <select id="getOrderByOrderId" resultType="com.caimei365.manager.entity.caimei.CmOrder">
|
|
|
+ SELECT
|
|
|
+ orderID AS orderId,
|
|
|
+ shopOrderIds,
|
|
|
+ orderSource,
|
|
|
+ orderNo,
|
|
|
+ organizeID AS organizeId,
|
|
|
+ userID AS userId,
|
|
|
+ clubID AS clubId,
|
|
|
+ buyUserID AS buyUserId,
|
|
|
+ orderTime AS orderTime,
|
|
|
+ updateDate AS updateDate,
|
|
|
+ delFlag,
|
|
|
+ userBeans,
|
|
|
+ orderType,
|
|
|
+ orderSubmitType,
|
|
|
+ confirmFlag,
|
|
|
+ onlinePayFlag,
|
|
|
+ splitFlag,
|
|
|
+ payFlag,
|
|
|
+ receiptStatus,
|
|
|
+ payStatus,
|
|
|
+ zeroCostFlag,
|
|
|
+ sendOutStatus,
|
|
|
+ refundType,
|
|
|
+ affirmPaymentFlag,
|
|
|
+ productCount,
|
|
|
+ presentCount,
|
|
|
+ promotionalGiftsCount,
|
|
|
+ hasActProduct,
|
|
|
+ promotionFullReduction,
|
|
|
+ secondHandOrderFlag,
|
|
|
+ invoiceFlag,
|
|
|
+ freePostFlag AS postageFlag,
|
|
|
+ freight AS postage,
|
|
|
+ productTotalFee,
|
|
|
+ orderTotalFee,
|
|
|
+ payTotalFee,
|
|
|
+ payableAmount,
|
|
|
+ IFNULL(balancePayFee, 0) AS balancePayFee,
|
|
|
+ discountFee,
|
|
|
+ status,
|
|
|
+ paySuccessCounter,
|
|
|
+ confirmTime,
|
|
|
+ payTime,
|
|
|
+ rebateFlag,
|
|
|
+ clauseID AS clauseId,
|
|
|
+ clauseName
|
|
|
+ FROM cm_order
|
|
|
+ WHERE orderID = #{orderId}
|
|
|
+ </select>
|
|
|
+ <select id="countDepositOrderProduct" resultType="java.lang.Integer">
|
|
|
+ SELECT IFNULL(COUNT(productID), 0) FROM cm_order_product WHERE orderID = #{orderId} AND productID = '6060'
|
|
|
+ </select>
|
|
|
+ <select id="getShopOrderById" resultType="com.caimei365.manager.entity.caimei.CmShopOrder">
|
|
|
+ SELECT
|
|
|
+ shopOrderID AS shopOrderId,
|
|
|
+ shopOrderNo,
|
|
|
+ orderID AS orderId,
|
|
|
+ orderNo,
|
|
|
+ shopID AS shopId,
|
|
|
+ note,
|
|
|
+ userID AS userId,
|
|
|
+ clubID AS clubId,
|
|
|
+ spID AS spId,
|
|
|
+ orderPromotionsId,
|
|
|
+ promotionFullReduction,
|
|
|
+ brokerage,
|
|
|
+ canRefundAmount,
|
|
|
+ itemCount,
|
|
|
+ totalAmount,
|
|
|
+ productAmount,
|
|
|
+ needPayAmount,
|
|
|
+ shopProductAmount,
|
|
|
+ shopPostFee,
|
|
|
+ shopTaxFee,
|
|
|
+ shouldPayShopAmount,
|
|
|
+ payedShopAmount,
|
|
|
+ outStoreNum,
|
|
|
+ IFNULL(presentNum,0) AS presentNum,
|
|
|
+ orderTime,
|
|
|
+ orderSubmitType,
|
|
|
+ payStatus,
|
|
|
+ sendOutStatus,
|
|
|
+ splitFlag
|
|
|
+ FROM cm_shop_order
|
|
|
+ WHERE shopOrderID = #{shopOrderId} AND delFlag = '0'
|
|
|
+ </select>
|
|
|
+ <update id="updateOrderStatus">
|
|
|
+ UPDATE cm_order SET
|
|
|
+ status = #{status}
|
|
|
+ <if test="receiptStatus != null and receiptStatus != ''">
|
|
|
+ ,receiptStatus = #{receiptStatus}
|
|
|
+ </if>
|
|
|
+ <if test="payStatus != null and payStatus != ''">
|
|
|
+ ,payStatus = #{payStatus}
|
|
|
+ </if>
|
|
|
+ ,updateDate = #{updateDate}
|
|
|
+ WHERE orderID = #{orderId}
|
|
|
+ </update>
|
|
|
+ <update id="updateReduceUserMoney">
|
|
|
+ UPDATE user SET userMoney=(userMoney-#{money}), ableUserMoney = (ableUserMoney-#{money})
|
|
|
+ WHERE userID = #{userId}
|
|
|
+ </update>
|
|
|
+ <update id="updateShopOrderStatus">
|
|
|
+ UPDATE cm_shop_order SET payStatus = #{payStatus}
|
|
|
+ WHERE shopOrderID = #{shopOrderId}
|
|
|
+ </update>
|
|
|
+ <insert id="insertBalanceRecord">
|
|
|
+ INSERT INTO cm_user_balance_record (userId, type, balanceType, addDate, amount, orderId, receiptId, remark, delFlag)
|
|
|
+ VALUES (#{userId}, #{type}, #{balanceType}, #{addDate}, #{amount}, #{orderId}, #{receiptId}, #{remark}, #{delFlag})
|
|
|
+ </insert>
|
|
|
+ <update id="updateBalanceRecord">
|
|
|
+ UPDATE cm_user_balance_record SET remark = #{remark}, delFlag = #{delFlag}
|
|
|
+ WHERE userId = #{userId} AND orderId = #{orderId} and receiptId = #{receiptId}
|
|
|
+ </update>
|
|
|
+ <select id="getRebateRecordByReceiptId" resultType="com.caimei365.manager.entity.caimei.RebateRecord">
|
|
|
+ SELECT a.id,
|
|
|
+ a.shopId,
|
|
|
+ a.receiptID AS receiptId,
|
|
|
+ a.shopOrderId,
|
|
|
+ a.rebateAmount
|
|
|
+ FROM cm_rebate_record a
|
|
|
+ WHERE a.receiptID = #{receiptId} and a.delFlag = '0'
|
|
|
+ </select>
|
|
|
+ <select id="getShopByShopId" resultType="com.caimei365.manager.entity.caimei.CmShop">
|
|
|
+ SELECT userID AS userId, shopID AS shopId, NAME, sname AS shortName, linkMan, contractMobile, ableRebateAmount, rebateAmount,
|
|
|
+ contractEmail, contractEmail AS email, provinceID AS proviceId, cityID AS cityId, townID AS townId,
|
|
|
+ address, socialCreditCode, businessLicenseImage AS businessLicense, firstShopType, secondShopType,
|
|
|
+ mainpro AS mainProduct, productDesc AS mainProductDesc,legalPerson,registeredCapital,fax AS faxNumber,
|
|
|
+ nature AS companyNature, turnover, medicalPracticeLicenseImg1 AS medicalPracticeLicense, info AS shopDesc,
|
|
|
+ businessScope, logo, ADDTIME, STATUS, contractPhone, validFlag, website, wxOfficialAccount, wxApplets
|
|
|
+ FROM shop WHERE shopID = #{shopId}
|
|
|
+ </select>
|
|
|
+ <update id="updateShopAbleRebateAmount">
|
|
|
+ UPDATE shop SET ableRebateAmount = #{ableRebateAmount}, rebateAmount = #{rebateAmount} WHERE shopID = #{shopId}
|
|
|
+ </update>
|
|
|
+ <update id="deleteRebateRecord">
|
|
|
+ UPDATE cm_rebate_record SET delFlag = '1' WHERE receiptID = #{receiptId}
|
|
|
+ </update>
|
|
|
+ <update id="cancelReceipt">
|
|
|
+ UPDATE cm_discern_receipt SET
|
|
|
+ receiptStatus = #{receiptStatus},
|
|
|
+ cancelReason = #{cancelReason},
|
|
|
+ cancelDate = #{cancelDate},
|
|
|
+ cancelUserPermissionID = #{cancelUserPermissionId},
|
|
|
+ delFlag = #{delFlag}
|
|
|
+ WHERE id = #{id}
|
|
|
+ </update>
|
|
|
</mapper>
|