123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- <?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.modules.order.dao.CmPayShopDao">
- <sql id="cmPayShopColumns">
- a.id AS "id",
- a.shopID AS "shopID",
- a.name AS "name",
- a.bankAccountName AS "bankAccountName",
- a.bankAccount AS "bankAccount",
- a.bankName AS "bankName",
- a.type AS "type",
- a.totalAmount AS "totalAmount",
- a.balancePayFee AS "balancePayFee",
- a.transferPayFee AS "transferPayFee",
- a.payType AS "payType",
- a.wipePayment AS "wipePayment",
- a.wipeRemarks AS "wipeRemarks",
- a.wipeRemarkImages AS "wipeRemarkImages",
- a.applicant AS "applicant",
- a.applyTime AS "applyTime",
- a.wipeTime AS "wipeTime",
- a.reviewer AS "reviewer",
- a.reviewTime AS "reviewTime",
- a.payTime AS "payTime",
- a.status AS "status",
- a.reason AS "reason",
- a.delFlag AS "delFlag"
- </sql>
- <sql id="cmPayShopJoins">
- </sql>
- <select id="get" resultType="CmPayShop">
- SELECT
- <include refid="cmPayShopColumns"/>,
- u1.name AS applicantName,
- u2.name AS reviewerName,
- s.name AS shopName,
- s.ableRebateAmount AS ableRebateAmount,
- s.rebateAmount AS rebateAmount,
- (SELECT paymentType FROM cm_pay_shop_record WHERE payShopID = a.id LIMIT 1) AS paymentType
- FROM cm_pay_shop a
- <include refid="cmPayShopJoins"/>
- left join shop s on s.shopID = a.shopID
- left join sys_user u1 on u1.id = a.applicant
- left join sys_user u2 on u2.id = a.reviewer
- WHERE a.id = #{id}
- </select>
- <select id="getPayShopByShopOrderId" resultType="com.caimei.modules.order.entity.CmPayShop">
- SELECT
- <include refid="cmPayShopColumns"/>
- FROM cm_pay_shop a
- left join cm_pay_shop_record cpsr on a.id = cpsr.payShopID
- <include refid="cmPayShopJoins"/>
- left join shop s on s.shopID = a.shopID
- left join sys_user u1 on u1.id = a.applicant
- left join sys_user u2 on u2.id = a.reviewer
- where cpsr.shopOrderID=#{shopOrderID}
- and a.delFlag = '0'
- order by a.id desc
- limit 1
- </select>
- <select id="findList" resultType="CmPayShop">
- 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>
- <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>
- and a.delFlag = '0'
- and (so.organizeID!=4 or so.organizeID is null)
- and a.shopID != 998
- </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>
- </select>
- <select id="findAllList" resultType="CmPayShop">
- SELECT
- <include refid="cmPayShopColumns"/>
- FROM cm_pay_shop a
- <include refid="cmPayShopJoins"/>
- <where>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
- <select id="priceNum" resultType="com.caimei.modules.product.entity.Product">
- SELECT cso.shopOrderID,cop.orderProductID,cop.taxRate,cop.discountPrice as price,cop.costPrice as costPrice FROM cm_order co
- LEFT JOIN cm_order_product cop ON co.orderID = cop.orderID
- LEFT JOIN cm_shop_order cso ON cop.shopOrderNo = cso.shopOrderNo
- LEFT JOIN product p ON cop.productID = p.productID WHERE co.orderNo = #{orderNo}
- </select>
- <insert id="insert" parameterType="CmPayShop" keyProperty="id" useGeneratedKeys="true">
- 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>
- <update id="update">
- UPDATE cm_pay_shop SET
- shopID = #{shopID},
- name = #{name},
- bankAccountName = #{bankAccountName},
- bankAccount = #{bankAccount},
- bankName = #{bankName},
- type = #{type},
- totalAmount = #{totalAmount},
- balancePayFee = #{balancePayFee},
- transferPayFee = #{transferPayFee},
- payType = #{payType},
- wipePayment = #{wipePayment},
- wipeRemarks = #{wipeRemarks},
- wipeRemarkImages = #{wipeRemarkImages},
- wipeTime = #{wipeTime},
- applicant = #{applicant},
- applyTime = #{applyTime},
- reviewer = #{reviewer},
- reviewTime = #{reviewTime},
- payTime = #{payTime},
- status = #{status},
- reason = #{reason},
- delFlag = #{delFlag}
- WHERE id = #{id}
- </update>
- <delete id="delete">
- DELETE FROM cm_pay_shop
- WHERE id = #{id}
- </delete>
- <select id="orderList" parameterType="string" resultType="com.caimei.modules.order.entity.NewShopOrder">
- SELECT DISTINCT so.shopOrderID, so.shopOrderNo, so.orderNo, so.orderID, bou.name AS buyer ,so.organizeID,c.name AS clubName
- FROM `cm_pay_shop_record` psr
- LEFT JOIN cm_shop_order so ON so.shopOrderID = psr.shopOrderID
- LEFT JOIN bp_order_userinfo bou ON so.orderId = bou.orderId
- LEFT JOIN club c ON c.userID = so.userID
- WHERE psr.payShopID = #{id}
- AND psr.delFlag = '0'
- </select>
- <select id="hasReapply" resultType="integer">
- select id from cm_pay_shop_record where shopOrderID in
- <foreach collection="shopOrderIds" open="(" close=")" item="shopOrderId" separator=",">
- #{shopOrderId}
- </foreach>
- and payShopID > #{id}
- </select>
- <select id="findPayOnlineStatus" resultType="java.lang.Integer">
- select status from cm_pay_online_switch where id=1
- </select>
- <select id="getShopOrderIdsList" resultType="java.lang.Integer">
- SELECT DISTINCT shopOrderID FROM cm_pay_shop_record WHERE payShopID = #{payShopID} AND delFlag = '0'
- </select>
- <update id="savePayOnlineStatus">
- update cm_pay_online_switch set
- status=#{status},
- sysUserId=#{userId},
- updateTime=NOW()
- where id=1
- </update>
- <select id="getDiscernReceipts" resultType="com.caimei.modules.order.entity.CmDiscernReceipt">
- SELECT
- cdr.id,
- cdr.payType,
- cdr.receiptType,
- cdr.receiptAmount,
- cdr.receiptDate,
- f.bankAccount as bankNameType
- FROM
- cm_discern_receipt cdr
- LEFT JOIN cm_receipt_order_relation cror ON cdr.id = cror.receiptID
- LEFT JOIN cm_offline_collection f ON cdr.payType = f.type
- WHERE
- cror.relationType = 1
- AND cror.delFlag = 0
- AND cror.orderID = #{shopOrderId}
- AND cdr.receiptType = 5
- AND cdr.receiptStatus = 2
- ORDER BY
- receiptDate DESC
- </select>
- </mapper>
|