123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.caimei.mapper.PayOrderMapper">
- <select id="getPayOnLineSwitch" resultType="java.lang.Integer">
- select status from cm_pay_online_switch where id=1
- </select>
- <select id="getDiscernReceipt" resultType="com.caimei.model.vo.DiscernReceiptVo">
- SELECT
- cdr.*,
- cror.associateAmount
- FROM
- cm_receipt_order_relation cror
- LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
- WHERE
- (
- cror.orderID = #{orderId}
- AND cror.relationType = '2'
- OR
- cror.orderID = #{shopOrderIds}
- AND cror.relationType = '1'
- )
- AND cror.delFlag = '0'
- AND cdr.delFlag = '0'
- AND cdr.payType != '16'
- AND cdr.receiptStatus IN(2,3)
- ORDER BY
- cdr.receiptDate DESC
- </select>
- <update id="updateSelective">
- update cm_order
- <set>
- <if test="status != null">
- `status` = #{status},
- </if>
- <if test="receiptStatus != null">
- receiptStatus = #{receiptStatus},
- </if>
- <if test="payStatus != null">
- payStatus = #{payStatus},
- </if>
- <if test="sendOutStatus != null">
- sendOutStatus = #{sendOutStatus},
- </if>
- <if test="refundType != null">
- refundType = #{refundType},
- </if>
- <if test="paySuccessCounter != null">
- paySuccessCounter = #{paySuccessCounter},
- </if>
- <if test="payFlag != null">
- payFlag = #{payFlag,jdbcType=CHAR},
- </if>
- <if test="onlinePayFlag != null">
- onlinePayFlag = #{onlinePayFlag},
- </if>
- </set>
- where orderID = #{orderID,jdbcType=BIGINT}
- </update>
- <insert id="insertDiscernReceipt" keyColumn="id" keyProperty="id" useGeneratedKeys="true" parameterType="com.caimei.model.po.CmDiscernReceiptPo">
- INSERT INTO `cm_discern_receipt` (
- `payWay`, `payType`, `receiptType`,
- `receiptStatus`, `smsContent`, `smsMd5Code`,
- `orderFlag`, `receiptAmount`, `handlingFee`,
- `confirmType`, `confirmUserPermissionID`,
- `reviewUserPermissionID`, `cancelUserPermissionID`,
- `transactionNum`, `bankID`, `bankCode`,
- `kuaiQianPayTypeID`, `kuaiQianPayerID`,
- `rePayFlag`, `actualAmount`, `formData`,
- `problem`, `noOrderReason`, `reviewReason`,
- `cancelReason`, `receiptDate`, `confirmDate`,
- `reviewDate`, `cancelDate`, `updateDate`,
- `delFlag`
- )
- VALUES
- (
- #{payWay}, #{payType}, #{receiptType},
- #{receiptStatus}, #{smsContent}, #{smsMd5Code},
- #{orderFlag}, #{receiptAmount}, #{handlingFee},
- #{confirmType}, #{confirmUserPermissionID},
- #{reviewUserPermissionID}, #{cancelUserPermissionID},
- #{transactionNum}, #{bankID}, #{bankCode},
- #{kuaiQianPayTypeID}, #{kuaiQianPayerID},
- #{rePayFlag}, #{actualAmount}, #{formData},
- #{problem}, #{noOrderReason}, #{reviewReason},
- #{cancelReason}, #{receiptDate}, #{confirmDate},
- #{reviewDate}, #{cancelDate}, #{updateDate},
- #{delFlag}
- )
- </insert>
- <insert id="insertOrderRelation" keyColumn="id" keyProperty="id" useGeneratedKeys="true" parameterType="com.caimei.model.po.CmReceiptOrderRelationPo">
- INSERT INTO `cm_receipt_order_relation` (
- `relationType`, `receiptID`, `associateAmount`,
- `orderID`, `delFlag`, mbOrderId, orderRequestNo,
- splitStatus
- )
- VALUES
- (
- #{relationType}, #{receiptID}, #{associateAmount},
- #{orderID}, #{delFlag},#{mbOrderId},#{orderRequestNo},
- #{splitStatus}
- )
- </insert>
- <select id="findAllOrderProduct" resultType="com.caimei.model.vo.OrderProductVo">
- SELECT
- orderProductID AS orderProductId,
- orderID AS orderId,
- shopOrderID AS shopOrderId,
- shopID AS shopId,
- productID AS productId,
- organizeProductID AS organizeProductId,
- organizeID AS organizeId,
- num,
- presentNum,
- outStoreType,
- productNo,
- price,
- normalPrice,
- costPrice,
- price1,
- totalAmount,
- totalFee,
- shouldPayFee,
- discount,
- discountPrice,
- includedTax,
- invoiceType,
- taxRate,
- totalAddedValueTax,
- notOutStore,
- name,
- productUnit,
- productImage,
- productType,
- orderPromotionsId
- FROM
- cm_order_product
- WHERE
- orderID = #{orderId}
- ORDER BY
- shopID ASC,
- productID ASC
- </select>
- <select id="findUnallocatedAccount" resultType="com.caimei.model.po.CmReceiptOrderRelationPo">
- SELECT
- cror.id,
- cror.relationType,
- cror.receiptID,
- cror.orderID,
- cror.mbOrderId,
- cror.orderRequestNo,
- cror.splitStatus,
- cror.associateAmount
- FROM
- cm_receipt_order_relation cror
- LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
- LEFT JOIN cm_order co ON cror.orderID = co.orderID
- WHERE
- cror.relationType = 2
- AND cdr.payWay = 1
- AND cror.delFlag = 0
- AND cror.mbOrderId IS NOT NULL
- AND cror.splitStatus = 0
- AND cdr.receiptDate <![CDATA[ <= ]]> #{currentTime}
- AND co.orderType = 2
- </select>
- <insert id="insertSplitAccount" keyColumn="id" keyProperty="id" parameterType="com.caimei.model.vo.SplitAccountVo" useGeneratedKeys="true">
- INSERT INTO `cm_split_account` (
- `orderId`, `productId`, `orderProductId`,
- `shopId`, `type`, `subUserNo`, `splitAccount`,
- `mbOrderId`, `orderRequestNo`,
- `payStatus`, `productType`, splitTime
- )
- VALUES
- (
- #{orderId}, #{productId}, #{orderProductId},
- #{shopId}, #{type}, #{subUserNo}, #{splitAccount},
- #{mbOrderId}, #{orderRequestNo},
- #{payStatus}, #{productType}, NOW()
- )
- </insert>
- <select id="findPaidAmount" resultType="java.math.BigDecimal">
- SELECT
- SUM(splitAccount)
- FROM
- cm_split_account
- WHERE
- orderProductId = #{orderProductId}
- AND payStatus = 1
- AND productType = 1
- </select>
- <select id="findCommercialCode" resultType="string">
- SELECT commercialCode FROM shop WHERE shopID = #{shopId}
- </select>
- <select id="findShipping" resultType="java.math.BigDecimal">
- SELECT
- SUM(splitAccount)
- FROM
- cm_split_account
- WHERE
- orderId = #{orderId}
- AND shopId = #{shopId}
- AND productType = 2
- AND payStatus = 1
- </select>
- <update id="updateBySplitStatus">
- UPDATE cm_receipt_order_relation SET splitStatus = 1 WHERE mbOrderId = #{mbOrderId}
- </update>
- <select id="findByMbOrderId" resultType="com.caimei.model.vo.SplitAccountVo">
- SELECT
- orderId,
- productId,
- orderProductId,
- shopId,
- type,
- subUserNo,
- SUM(splitAccount) AS "splitAccount",
- mbOrderId,
- orderRequestNo,
- payStatus,
- productType
- FROM
- cm_split_account
- WHERE
- TYPE = 4
- AND payStatus = 1
- AND splitAccount > 0
- AND mbOrderId = #{mbOrderId}
- GROUP BY
- shopID
- </select>
- <select id="findPaidShop" resultType="java.math.BigDecimal">
- SELECT
- SUM(payAmount)
- FROM
- cm_pay_shop_record
- WHERE
- STATUS = 1
- AND delFlag = 0
- AND shopOrderID = #{shopOrderId}
- </select>
- <update id="updateShopOrderByPayStatus">
- UPDATE
- cm_shop_order
- SET
- payStatus = #{payStatus},
- payedShopAmount = #{paidShop}
- WHERE
- shopOrderID = #{shopOrderId}
- </update>
- <insert id="insertPayShop" useGeneratedKeys="true" keyProperty="id" keyColumn="id" parameterType="com.caimei.model.po.CmPayShopPo">
- INSERT INTO `cm_pay_shop` (
- `shopID`, `name`, `bankAccountName`,
- `bankAccount`, `bankName`, `type`,
- `totalAmount`, `balancePayFee`,
- `transferPayFee`, `payType`, `wipePayment`,
- `wipeRemarks`, `wipeRemarkImages`,
- `wipeTime`, `applicant`, `applyTime`,
- `reviewer`, `reviewTime`, `payTime`,
- `status`, `reason`, `delFlag`
- )
- VALUES
- (
- #{shopID}, #{name}, #{bankAccountName},
- #{bankAccount}, #{bankName}, #{type},
- #{totalAmount}, #{balancePayFee},
- #{transferPayFee}, #{payType}, #{wipePayment},
- #{wipeRemarks}, #{wipeRemarkImages},
- #{wipeTime}, #{applicant}, #{applyTime},
- #{reviewer}, #{reviewTime}, #{payTime},
- #{status}, #{reason}, #{delFlag}
- )
- </insert>
- <insert id="insertPayShopRecord">
- INSERT INTO `cm_pay_shop_record` (
- `shopID`, `shopOrderID`, `shopOrderNo`,
- `payAmount`, `wipePayment`, `payType`,
- `payTime`, `payShopID`,
- `status`, `delFlag`
- )
- VALUES
- (
- #{shopID}, #{shopOrderID}, #{shopOrderNo},
- #{payAmount}, #{wipePayment}, #{payType},
- #{payTime}, #{payShopID},
- #{status}, #{delFlag}
- )
- </insert>
- <update id="updateOrderByPayStatus">
- UPDATE
- cm_order
- SET
- payStatus = #{payStatus}
- WHERE
- orderID = #{orderId}
- </update>
- </mapper>
|