123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- <?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.hehe.dao.HeHeNewOrderDao">
- <sql id="columns">
- a.orderID AS orderID,
- a.orderNo AS orderNo,
- a.organizeID AS organizeID,
- a.userID AS userID,
- a.buyUserID AS buyUserID,
- a.shopOrderIDs AS shopOrderIDs,
- a.orderSubmitType AS orderSubmitType,
- a.orderType AS orderType,
- a.secondHandOrderFlag AS secondHandOrderFlag,
- a.status AS status,
- a.productTotalFee AS productTotalFee,
- a.orderTotalFee AS orderTotalFee,
- a.payTotalFee AS payTotalFee,
- a.payableAmount AS payableAmount,
- a.balancePayFee AS balancePayFee ,
- a.discountFee AS discountFee,
- a.spID AS spID,
- a.mainSpID AS mainSpID,
- a.note AS note,
- a.clubID AS clubID,
- a.clubScanTime AS clubScanTime,
- a.orderSource AS orderSource,
- a.orderTime AS orderTime,
- a.confirmTime AS confirmTime,
- a.productCount AS productCount,
- a.presentCount AS presentCount,
- a.confirmFlag AS confirmFlag,
- a.clauseID AS clauseID,
- a.clauseContent AS clauseContent,
- a.clauseName AS clauseName,
- a.updateDate AS updateDate,
- a.freePostFlag AS freePostFlag,
- a.freight AS freight,
- a.delFlag AS delFlag,
- a.onlinePayFlag AS onlinePayFlag,
- a.payTime AS payTime,
- a.splitFlag AS splitFlag,
- (select sum(cop.totalAddedValueTax) from cm_order_product cop where cop.orderID = a.orderID) AS totalAddedValueTax,
- a.preferential AS preferential,
- a.closeReason AS closeReason,
- a.receiptStatus as receiptStatus,
- a.payStatus as payStatus,
- a.sendOutStatus as sendOutStatus,
- a.refundType as refundType,
- a.postageOrderFlag AS postageOrderFlag,
- a.promotionFullReduction AS promotionFullReduction,
- a.promotionalGiftsCount AS promotionalGiftsCount,
- a.affirmPaymentFlag AS affirmPaymentFlag,
- a.rebateFlag AS rebateFlag,
- a.zeroCostFlag AS zeroCostFlag,
- a.couponAmount,
- a.reductionAmount,
- if(chcm.id is not null,1,0) as collageFlag,
- chc.status as collageStatus
- </sql>
- <select id="get" resultType="newOrder">
- SELECT <include refid="columns"/>
- FROM cm_order a
- LEFT JOIN cm_hehe_collage_member chcm on a.orderID = chcm.orderId
- LEFT JOIN cm_hehe_collage chc on chcm.collageId = chc.id
- WHERE a.orderID = #{id}
- </select>
- <resultMap id="orderDisplayList" type="com.caimei.modules.order.entity.NewOrder">
- <id column="orderID" property="orderID"/>
- <result column="orderNo" property="orderNo"/>
- <result column="organizeID" property="organizeID"/>
- <result column="orderType" property="orderType"/>
- <result column="shopName" property="shopName"/>
- <result column="receiver" property="receiver"/>
- <result column="buyer" property="buyer"/>
- <result column="orderSource" property="orderSource"/>
- <result column="orderTotalFee" property="orderTotalFee"/>
- <result column="orderTime" property="orderTime"/>
- <result column="productCount" property="productCount"/>
- <result column="alreadyReceipt" property="alreadyReceipt"/>
- <result column="unReceipt" property="unReceipt"/>
- <result column="payTotalFee" property="payTotalFee"/>
- <result column="status" property="status"/>
- <collection property="newShopOrders" ofType="com.caimei.modules.order.entity.NewShopOrder"
- select="loadShopOrders" column="orderNo" fetchType="eager">
- </collection>
- </resultMap>
- <select id="findList" resultMap="orderDisplayList" parameterType="com.caimei.modules.order.entity.NewOrder">
- SELECT DISTINCT
- co.orderID AS orderID,
- co.orderNo AS orderNo,
- co.organizeID AS organizeID,
- co.userID AS userID,
- co.orderType AS orderType,
- co.secondHandOrderFlag AS secondHandOrderFlag,
- co.onlinePayFlag AS onlinePayFlag,
- bou.shouHuoRen AS receiver,
- IFNULL(c.name,c.nickName) AS buyer,
- co.orderSource AS orderSource,
- co.orderTotalFee AS orderTotalFee,
- co.payableAmount AS payableAmount,
- co.orderTime AS orderTime,
- co.confirmTime AS confirmTime,
- co.payTotalFee AS payTotalFee,
- co.payStatus AS payStatus,
- co.refundType AS refundType,
- co.sendOutStatus AS sendOutStatus,
- co.receiptStatus AS receiptStatus,
- co.productCount AS productCount,
- (SELECT IFNULL(sum(cop.shouldPayFee),0) FROM cm_order_product cop WHERE cop.orderId=co.orderID) AS
- "shouldPayProduct",
- co.status AS status,
- co.splitFlag AS splitFlag,
- co.postageOrderFlag AS postageOrderFlag,
- (case when co.orderType = '0' then
- (select case status when 91 then '采美默认协销经理(官方账号)' else linkMan end from serviceprovider where serviceProviderID
- = co.spID)
- else
- ''
- end) AS spName,
- co.rebateFlag AS rebateFlag,
- if(chcm.id is not null,1,0) as collageFlag,
- chc.status as collageStatus
- FROM cm_order co
- LEFT JOIN bp_order_userinfo bou ON bou.orderId = co.orderID
- LEFT JOIN user u ON u.userID = co.userID
- LEFT JOIN cm_hehe_user c ON u.userID = c.userId
- LEFT JOIN cm_order_product cop ON co.orderID = cop.orderID
- LEFT JOIN product p ON cop.productID = p.productID
- LEFT JOIN cm_hehe_collage_member chcm on co.orderID = chcm.orderId
- LEFT JOIN cm_hehe_collage chc on chcm.collageId = chc.id
- <where>
- co.orderType = 2
- <if test="orderID != null and orderID != ''">
- AND co.orderID = #{orderID}
- </if>
- <if test="orderNo != null and orderNo != ''">
- AND co.orderNo = #{orderNo}
- </if>
- <if test="status != null and status != ''">
- <choose>
- <when test="status == '99'.toString()">
- AND co.status in (11,12,13,21,22,23,31,32,33)
- </when>
- <otherwise>
- AND co.status = #{status}
- </otherwise>
- </choose>
- </if>
- <if test="buyer != null and buyer != ''">
- AND (c.name LIKE concat('%',#{buyer},'%') or c.nickName LIKE concat('%',#{buyer},'%'))
- </if>
- <if test="orderTime != null and orderTime != ''">
- AND co.orderTime = #{orderTime}
- </if>
- <if test="sendOutStatus != null and sendOutStatus != ''">
- AND co.sendOutStatus = #{sendOutStatus}
- </if>
- <if test="startTime != null and startTime != ''">
- AND co.orderTime <![CDATA[ >= ]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND co.orderTime <![CDATA[ <= ]]> #{endTime}
- </if>
- <if test="receiver != null and receiver != ''">
- AND bou.shouHuoRen LIKE concat('%',#{receiver},'%')
- </if>
- <if test="receiptStatus != null and receiptStatus != ''">
- AND co.receiptStatus = #{receiptStatus}
- </if>
- <if test="payStatus != null and payStatus != ''">
- AND co.payStatus = #{payStatus}
- </if>
- <if test="sendOutStatus != null and sendOutStatus != ''">
- AND co.sendOutStatus = #{sendOutStatus}
- </if>
- <if test="returnedPurchaseStatus != null and returnedPurchaseStatus != ''">
- AND
- <if test="returnedPurchaseStatus == 1">
- exists
- </if>
- <if test="returnedPurchaseStatus == 0">
- not exists
- </if>
- (select 1 from cm_returned_purchase c3 where c3.status = '1' and c3.orderID = co.orderID and c3.delFlag = 0)
- </if>
- <if test="refundType != null and refundType != ''">
- AND
- <if test="refundType == 0">
- co.refundType is null
- </if>
- <if test="refundType == 1">
- co.refundType = '1'
- </if>
- <if test="refundType == 2">
- co.refundType = '2'
- </if>
- </if>
- <if test="orderRefundType != null and orderRefundType != ''">
- <if test="orderRefundType == 0">
- AND (select count(1) from cm_returned_purchase crp where co.orderID = crp.orderID and crp.delFlag = 0) = 0
- </if>
- <if test="orderRefundType == 1">
- AND (select count(1) from cm_returned_purchase crp where co.orderID = crp.orderID and crp.delFlag = 0) > 0
- </if>
- <if test="orderRefundType == 11">
- AND (select count(1) from cm_returned_purchase crp where co.orderID = crp.orderID and crp.status = 1 and crp.delFlag = 0) > 0
- </if>
- <if test="orderRefundType == 12">
- AND (select count(1) from cm_returned_purchase crp where co.orderID = crp.orderID and crp.status = 2 and crp.delFlag = 0
- <if test="startRefundTime != null and startRefundTime != ''">
- AND crp.confirmReturnTime <![CDATA[ >= ]]> #{startRefundTime}
- </if>
- <if test="endRefundTime != null and endRefundTime != ''">
- AND crp.confirmReturnTime <![CDATA[ <= ]]> #{endRefundTime}
- </if>
- ) > 0
- </if>
- <if test="orderRefundType == 13">
- AND (select count(1) from cm_returned_purchase crp where co.orderID = crp.orderID and crp.status = 3 and crp.delFlag = 0) > 0
- </if>
- </if>
- <if test="collageFlag != null">
- <if test="collageFlag == 1">
- and chcm.id is not null
- </if>
- <if test="collageFlag == 0">
- and chcm.id is null
- </if>
- </if>
- <if test="collageStatus != null">
- and chc.status = #{collageStatus}
- </if>
- AND co.delFlag = 0
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- ORDER BY co.orderID DESC, co.orderTime DESC
- </otherwise>
- </choose>
- </select>
- <select id="loadShopOrders" parameterType="string" resultType="NewShopOrder">
- SELECT
- cs.shopOrderID AS shopOrderID,
- cs.shopOrderNo AS shopOrderNo,
- cs.shopOrderNo AS shopOrderNo,
- cs.itemCount AS itemCount,
- cs.needPayAmount AS needPayAmount,
- s.name AS shopName,
- cs.shopID AS shopID
- FROM cm_shop_order cs
- LEFT JOIN shop s ON cs.shopID = s.shopID
- WHERE cs.orderNo = #{orderNo} AND cs.delFlag = 0
- </select>
- <select id="findHeUser" resultType="string">
- SELECT IFNULL(name,nickName) FROM cm_hehe_user WHERE userId = #{heUserId}
- </select>
- <select id="findOrderCouponRecord" resultType="com.caimei.modules.hehe.entity.CmHeheCouponOrderRecord">
- SELECT
- `id`,
- `orderId`,
- `receiveCouponId`,
- `couponType`,
- `couponAmount`,
- `touchPrice`,
- `createDate`
- FROM
- cm_hehe_coupon_order_record
- WHERE
- orderId = #{orderID}
- </select>
- <select id="findReductionTouchPrice" resultType="java.lang.Double">
- select touchPrice from cm_hehe_reduction_user where orderId = #{orderID}
- </select>
- </mapper>
|