123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586 |
- <?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.module.pay.dao.PayDao">
- <select id="findOrder" resultType="com.caimei.module.base.entity.vo.OrderVo">
- SELECT
- *
- FROM
- cm_order
- WHERE
- orderID = #{orderID}
- AND delFlag = '0'
- </select>
- <select id="getDiscernReceipt" resultType="com.caimei.module.base.entity.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" parameterType="com.caimei.module.base.entity.po.CmOrder">
- update cm_order
- <set>
- <if test="orderNo != null">
- orderNo = #{orderNo,jdbcType=VARCHAR},
- </if>
- <if test="userID != null">
- userID = #{userID,jdbcType=BIGINT},
- </if>
- <if test="buyUserID != null">
- buyUserID = #{buyUserID,jdbcType=INTEGER},
- </if>
- <if test="shopOrderIDs != null">
- shopOrderIDs = #{shopOrderIDs,jdbcType=VARCHAR},
- </if>
- <if test="orderSubmitType != null">
- orderSubmitType = #{orderSubmitType,jdbcType=INTEGER},
- </if>
- <if test="orderType != null">
- orderType = #{orderType,jdbcType=INTEGER},
- </if>
- <if test="hasActProduct != null">
- hasActProduct = #{hasActProduct,jdbcType=CHAR},
- </if>
- <if test="autoCloseTimeMills != null">
- autoCloseTimeMills = #{autoCloseTimeMills,jdbcType=DECIMAL},
- </if>
- <if test="status != null">
- `status` = #{status,jdbcType=CHAR},
- </if>
- <if test="receiptStatus != null">
- receiptStatus = #{receiptStatus,jdbcType=CHAR},
- </if>
- <if test="payStatus != null">
- payStatus = #{payStatus,jdbcType=CHAR},
- </if>
- <if test="sendOutStatus != null">
- sendOutStatus = #{sendOutStatus,jdbcType=CHAR},
- </if>
- <if test="refundType != null">
- refundType = #{refundType,jdbcType=CHAR},
- </if>
- <if test="paySuccessCounter != null">
- paySuccessCounter = #{paySuccessCounter},
- </if>
- <if test="payFlag != null">
- payFlag = #{payFlag,jdbcType=CHAR},
- </if>
- <if test="onlinePayFlag != null">
- onlinePayFlag = #{onlinePayFlag,jdbcType=CHAR},
- </if>
- <if test="productTotalFee != null">
- productTotalFee = #{productTotalFee,jdbcType=DECIMAL},
- </if>
- <if test="orderTotalFee != null">
- orderTotalFee = #{orderTotalFee,jdbcType=DECIMAL},
- </if>
- <if test="payTotalFee != null">
- payTotalFee = #{payTotalFee,jdbcType=DECIMAL},
- </if>
- <if test="payableAmount != null">
- payableAmount = #{payableAmount,jdbcType=DECIMAL},
- </if>
- <if test="balancePayFee != null">
- balancePayFee = #{balancePayFee,jdbcType=DECIMAL},
- </if>
- <if test="preferential != null">
- preferential = #{preferential,jdbcType=DECIMAL},
- </if>
- <if test="discountFee != null">
- discountFee = #{discountFee,jdbcType=DECIMAL},
- </if>
- <if test="spID != null">
- spID = #{spID,jdbcType=BIGINT},
- </if>
- <if test="mainSpID != null">
- mainSpID = #{mainSpID,jdbcType=BIGINT},
- </if>
- <if test="note != null">
- note = #{note,jdbcType=VARCHAR},
- </if>
- <if test="clubID != null">
- clubID = #{clubID,jdbcType=BIGINT},
- </if>
- <if test="clubScanTime != null">
- clubScanTime = #{clubScanTime,jdbcType=VARCHAR},
- </if>
- <if test="payWay != null">
- payWay = #{payWay,jdbcType=VARCHAR},
- </if>
- <if test="orderSource != null">
- orderSource = #{orderSource,jdbcType=CHAR},
- </if>
- <if test="closeTime != null">
- closeTime = #{closeTime,jdbcType=VARCHAR},
- </if>
- <if test="confirmTime != null">
- confirmTime = #{confirmTime,jdbcType=VARCHAR},
- </if>
- <if test="payTime != null">
- payTime = #{payTime,jdbcType=VARCHAR},
- </if>
- <if test="orderTime != null">
- orderTime = #{orderTime,jdbcType=VARCHAR},
- </if>
- <if test="productCount != null">
- productCount = #{productCount,jdbcType=INTEGER},
- </if>
- <if test="presentCount != null">
- presentCount = #{presentCount,jdbcType=INTEGER},
- </if>
- <if test="cooFreeFlag != null">
- cooFreeFlag = #{cooFreeFlag,jdbcType=CHAR},
- </if>
- <if test="cooFreeRate != null">
- cooFreeRate = #{cooFreeRate,jdbcType=INTEGER},
- </if>
- <if test="cooFreeAmount != null">
- cooFreeAmount = #{cooFreeAmount,jdbcType=DECIMAL},
- </if>
- <if test="invoiceFlag != null">
- invoiceFlag = #{invoiceFlag,jdbcType=CHAR},
- </if>
- <if test="confirmFlag != null">
- confirmFlag = #{confirmFlag,jdbcType=CHAR},
- </if>
- <if test="clauseID != null">
- clauseID = #{clauseID,jdbcType=BIGINT},
- </if>
- <if test="clauseContent != null">
- clauseContent = #{clauseContent,jdbcType=VARCHAR},
- </if>
- <if test="clauseName != null">
- clauseName = #{clauseName,jdbcType=VARCHAR},
- </if>
- <if test="updateDate != null">
- updateDate = #{updateDate,jdbcType=VARCHAR},
- </if>
- <if test="freePostFlag != null">
- freePostFlag = #{freePostFlag,jdbcType=CHAR},
- </if>
- <if test="freight != null">
- freight = #{freight,jdbcType=DECIMAL},
- </if>
- <if test="delFlag != null">
- delFlag = #{delFlag,jdbcType=CHAR},
- </if>
- <if test="freePostageTicketID != null">
- freePostageTicketID = #{freePostageTicketID,jdbcType=INTEGER},
- </if>
- <if test="splitFlag != null">
- splitFlag = #{splitFlag,jdbcType=CHAR},
- </if>
- <if test="closeReason != null">
- closeReason = #{closeReason,jdbcType=VARCHAR},
- </if>
- <if test="postageOrderFlag != null">
- postageOrderFlag = #{postageOrderFlag,jdbcType=CHAR},
- </if>
- </set>
- where orderID = #{orderID,jdbcType=BIGINT}
- </update>
- <insert id="insertDiscernReceipt" keyColumn="id" keyProperty="id" useGeneratedKeys="true"
- parameterType="com.caimei.module.base.entity.vo.DiscernReceiptVo">
- 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.module.base.entity.vo.OrderRelationVo">
- 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="findOrderPayLink" resultType="com.caimei.module.base.entity.vo.OrderPayLinkVo">
- SELECT
- *
- FROM
- cm_order_pay_link
- WHERE
- orderId = #{orderId}
- <if test="amount != null">
- AND unpaidAmount = #{amount}
- </if>
- AND delFlag = '0'
- AND payStatus = '0'
- ORDER BY id DESC LIMIT 1
- </select>
- <insert id="insertOrderPayLink">
- insert into cm_order_pay_link
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="orderId != null">
- orderId,
- </if>
- <if test="linkLogo != null">
- linkLogo,
- </if>
- <if test="unpaidAmount != null">
- unpaidAmount,
- </if>
- <if test="generateTime != null">
- generateTime,
- </if>
- <if test="effectiveTime != null">
- effectiveTime,
- </if>
- <if test="payStatus != null">
- payStatus,
- </if>
- <if test="payType != null">
- payType,
- </if>
- <if test="delFlag != null">
- delFlag,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="orderId != null">
- #{orderId,jdbcType=BIGINT},
- </if>
- <if test="linkLogo != null">
- #{linkLogo,jdbcType=VARCHAR},
- </if>
- <if test="unpaidAmount != null">
- #{unpaidAmount,jdbcType=DECIMAL},
- </if>
- <if test="generateTime != null">
- #{generateTime,jdbcType=TIMESTAMP},
- </if>
- <if test="effectiveTime != null">
- #{effectiveTime,jdbcType=TIMESTAMP},
- </if>
- <if test="payStatus != null">
- #{payStatus,jdbcType=CHAR},
- </if>
- <if test="payType != null">
- #{payType},
- </if>
- <if test="delFlag != null">
- #{delFlag,jdbcType=CHAR},
- </if>
- </trim>
- </insert>
- <update id="updateOrderPayLink">
- update cm_order_pay_link
- <set>
- <if test="orderId != null">
- orderId = #{orderId,jdbcType=BIGINT},
- </if>
- <if test="linkLogo != null">
- linkLogo = #{linkLogo,jdbcType=VARCHAR},
- </if>
- <if test="unpaidAmount != null">
- unpaidAmount = #{unpaidAmount,jdbcType=DECIMAL},
- </if>
- <if test="generateTime != null">
- generateTime = #{generateTime,jdbcType=TIMESTAMP},
- </if>
- <if test="effectiveTime != null">
- effectiveTime = #{effectiveTime,jdbcType=TIMESTAMP},
- </if>
- <if test="payStatus != null">
- payStatus = #{payStatus,jdbcType=CHAR},
- </if>
- <if test="payType != null">
- payType = #{payType},
- </if>
- <if test="delFlag != null">
- delFlag = #{delFlag,jdbcType=CHAR},
- </if>
- </set>
- where id = #{id,jdbcType=INTEGER}
- </update>
- <select id="getOrderPayLink" resultType="com.caimei.module.base.entity.vo.OrderPayLinkVo">
- SELECT
- *
- FROM
- cm_order_pay_link
- WHERE
- linkLogo = #{linkLogo}
- AND delFlag = '0'
- </select>
- <select id="fandAllOrderProduct" resultType="com.caimei.module.base.entity.vo.OrderProductVo">
- SELECT * FROM cm_order_product WHERE orderID = #{orderId} ORDER BY shopID ASC, productID ASC
- </select>
- <select id="findUser" resultType="com.caimei.module.base.entity.vo.UserVo">
- SELECT
- *
- FROM
- USER
- WHERE
- userID = #{userID}
- </select>
- <select id="getPayOnLineSwitch" resultType="java.lang.Integer">
- select status from cm_pay_online_switch where id=1
- </select>
- <update id="updateSeconHand">
- UPDATE
- cm_second_hand_detail
- SET
- payStatus = '2',
- payAmount = #{payAmount},
- payFormData = #{payFormData},
- payType = #{payType},
- payDate = NOW()
- WHERE
- productID = #{productID}
- </update>
- <insert id="insertSplitAccount" keyColumn="id" keyProperty="id" parameterType="com.caimei.module.base.entity.po.CmSplitAccount" 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>
- <update id="updateSplitAccountByPay">
- UPDATE cm_split_account SET payStatus = '1' WHERE mbOrderId = #{mbOrderId}
- </update>
- <update id="updateUserMoney">
- update user
- <set>
- <if test="userMoney != null">
- userMoney = #{userMoney},
- </if>
- <if test="ableUserMoney != null">
- ableUserMoney = #{ableUserMoney},
- </if>
- </set>
- where userID = #{userId}
- </update>
- <insert id="insertBalanceRecord">
- INSERT INTO `cm_user_balance_record` (
- `userId`, `type`, `balanceType`, `addDate`,
- `amount`, `orderId`, `receiptId`,
- `returnedId`, `withdrawalsId`, `remark`,
- `delFlag`
- )
- VALUES
- (
- #{userId}, #{type}, #{balanceType}, #{addDate},
- #{amount}, #{orderId}, #{receiptId},
- #{returnedId}, #{withdrawalsId}, #{remark},
- #{delFlag}
- )
- </insert>
- <select id="findCommercialCode" resultType="string">
- SELECT commercialCode FROM shop WHERE shopID = #{shopId}
- </select>
- <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="findShopOrder" resultType="com.caimei.module.base.entity.vo.ShopOrderVo">
- SELECT * FROM cm_shop_order WHERE orderID = #{orderId}
- </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>
- <select id="findUnallocatedAccount" resultType="com.caimei.module.base.entity.vo.OrderRelationVo">
- SELECT
- cror.*, cdr.payType
- 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.organizeID = 0
- AND co.orderType != 2
- </select>
- <select id="findByMbOrderId" resultType="com.caimei.module.base.entity.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>
- <insert id="insertPayShop" useGeneratedKeys="true" keyProperty="id" keyColumn="id" parameterType="com.caimei.module.base.entity.vo.PayShopVo">
- 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="updateBySplitStatus">
- UPDATE cm_receipt_order_relation SET splitStatus = 1 WHERE mbOrderId = #{mbOrderId}
- </update>
- <update id="updateShopOrderByPayStatus">
- UPDATE
- cm_shop_order
- SET
- payStatus = #{payStatus},
- payedShopAmount = #{paidShop}
- WHERE
- shopOrderID = #{shopOrderId}
- </update>
- <update id="updateOrderByPayStatus">
- UPDATE
- cm_order
- SET
- payStatus = #{payStatus}
- WHERE
- orderID = #{orderId}
- </update>
- </mapper>
|