123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825 |
- <?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.yami.shop.dao.OrderMapper">
- <resultMap id="BaseResultMap" type="com.yami.shop.bean.model.Order">
- <id column="order_id" jdbcType="BIGINT" property="orderId"/>
- <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
- <result column="prod_name" jdbcType="VARCHAR" property="prodName"/>
- <result column="user_id" jdbcType="VARCHAR" property="userId"/>
- <result column="order_number" jdbcType="VARCHAR" property="orderNumber"/>
- <result column="total" jdbcType="DECIMAL" property="total"/>
- <result column="actual_total" jdbcType="DECIMAL" property="actualTotal"/>
- <result column="pay_type" jdbcType="INTEGER" property="payType"/>
- <result column="remarks" jdbcType="VARCHAR" property="remarks"/>
- <result column="hb_order_status" jdbcType="INTEGER" property="hbOrderStatus"/>
- <result column="dvy_type" jdbcType="VARCHAR" property="dvyType"/>
- <result column="dvy_id" jdbcType="BIGINT" property="dvyId"/>
- <result column="dvy_flow_id" jdbcType="VARCHAR" property="dvyFlowId"/>
- <result column="freight_amount" jdbcType="DECIMAL" property="freightAmount"/>
- <result column="addr_order_id" jdbcType="BIGINT" property="addrOrderId"/>
- <result column="product_nums" jdbcType="INTEGER" property="productNums"/>
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
- <result column="pay_time" jdbcType="TIMESTAMP" property="payTime"/>
- <result column="dvy_time" jdbcType="TIMESTAMP" property="dvyTime"/>
- <result column="finally_time" jdbcType="TIMESTAMP" property="finallyTime"/>
- <result column="cancel_time" jdbcType="TIMESTAMP" property="cancelTime"/>
- <result column="is_payed" jdbcType="BIT" property="isPayed"/>
- <result column="delete_status" jdbcType="INTEGER" property="deleteStatus"/>
- <result column="refund_status" jdbcType="INTEGER" property="refundStatus"/>
- <result column="close_type" jdbcType="INTEGER" property="closeType"/>
- </resultMap>
- <resultMap id="MyOrderMap" type="com.yami.shop.bean.app.dto.MyOrderDto">
- <result column="order_number" jdbcType="VARCHAR" property="orderNumber"/>
- <result column="actual_total" jdbcType="DECIMAL" property="actualTotal"/>
- <result column="order_type" jdbcType="VARCHAR" property="orderType"/>
- <result column="refund_type" jdbcType="INTEGER" property="refundType"/>
- <result column="return_money_sts" jdbcType="INTEGER" property="returnMoneySts"/>
- <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
- <result column="shop_name" jdbcType="VARCHAR" property="shopName"/>
- <result column="latitude" property="latitude"/>
- <result column="longitude" property="longitude"/>
- <result column="create_time" property="createTime"/>
- <result column="hb_order_status" property="hbOrderStatus"/>
- <result column="hb_logistic_status" property="hbLogisticStatus"/>
- <result column="offset_points" property="offsetPoints"/>
- <result column="pay_time" property="payTime"/>
- <collection property="orderItemDtos" ofType="com.yami.shop.bean.app.dto.MyOrderItemDto">
- <result column="order_number" jdbcType="VARCHAR" property="orderNumber"/>
- <result column="pic" jdbcType="VARCHAR" property="pic"/>
- <result column="prod_id" jdbcType="BIGINT" property="prodId"/>
- <result column="prod_name" jdbcType="VARCHAR" property="prodName"/>
- <result column="prod_count" jdbcType="INTEGER" property="prodCount"/>
- <result column="use_score" jdbcType="INTEGER" property="useScore"/>
- <result column="price" jdbcType="DECIMAL" property="price"/>
- <result column="sku_name" jdbcType="VARCHAR" property="skuName"/>
- <result column="order_item_id" property="orderItemId"/>
- <result column="comm_sts" property="commSts"/>
- <result column="rec_time" property="recTime"/>
- </collection>
- </resultMap>
- <resultMap id="MyOrderItemMap" type="com.yami.shop.bean.app.dto.MyOrderItemDto">
- <result column="order_number" jdbcType="VARCHAR" property="orderNumber"/>
- <result column="pic" jdbcType="VARCHAR" property="pic"/>
- <result column="prod_id" jdbcType="BIGINT" property="prodId"/>
- <result column="prod_name" jdbcType="VARCHAR" property="prodName"/>
- <result column="prod_count" jdbcType="INTEGER" property="prodCount"/>
- <result column="use_score" jdbcType="INTEGER" property="useScore"/>
- <result column="price" jdbcType="DECIMAL" property="price"/>
- <result column="sku_name" jdbcType="VARCHAR" property="skuName"/>
- <result column="order_item_id" property="orderItemId"/>
- <result column="comm_sts" property="commSts"/>
- <result column="rec_time" property="recTime"/>
- </resultMap>
- <resultMap type="com.yami.shop.bean.model.Order" id="orderAndOrderItemMap">
- <id column="order_id" jdbcType="BIGINT" property="orderId"/>
- <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
- <result column="prod_name" jdbcType="VARCHAR" property="prodName"/>
- <result column="user_id" jdbcType="VARCHAR" property="userId"/>
- <result column="order_number" jdbcType="VARCHAR" property="orderNumber"/>
- <result column="total" jdbcType="DECIMAL" property="total"/>
- <result column="actual_total" jdbcType="DECIMAL" property="actualTotal"/>
- <result column="pay_type" jdbcType="INTEGER" property="payType"/>
- <result column="remarks" jdbcType="VARCHAR" property="remarks"/>
- <result column="dvy_type" jdbcType="VARCHAR" property="dvyType"/>
- <result column="dvy_id" jdbcType="BIGINT" property="dvyId"/>
- <result column="dvy_flow_id" jdbcType="VARCHAR" property="dvyFlowId"/>
- <result column="freight_amount" jdbcType="DECIMAL" property="freightAmount"/>
- <result column="platform_amount" jdbcType="DECIMAL" property="platformAmount"/>
- <result column="addr_order_id" jdbcType="BIGINT" property="addrOrderId"/>
- <result column="product_nums" jdbcType="INTEGER" property="productNums"/>
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
- <result column="pay_time" jdbcType="TIMESTAMP" property="payTime"/>
- <result column="dvy_time" jdbcType="TIMESTAMP" property="dvyTime"/>
- <result column="finally_time" jdbcType="TIMESTAMP" property="finallyTime"/>
- <result column="cancel_time" jdbcType="TIMESTAMP" property="cancelTime"/>
- <result column="is_payed" jdbcType="BIT" property="isPayed"/>
- <result column="hb_order_status" jdbcType="INTEGER" property="hbOrderStatus"/>
- <result column="delete_status" jdbcType="INTEGER" property="deleteStatus"/>
- <result column="refund_status" jdbcType="INTEGER" property="refundStatus"/>
- <result column="order_type" jdbcType="INTEGER" property="orderType"/>
- <result column="close_type" jdbcType="INTEGER" property="closeType"/>
- <collection property="orderItems" ofType="com.yami.shop.bean.model.OrderItem">
- <id column="order_item_id" jdbcType="BIGINT" property="orderItemId"/>
- <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
- <result column="order_number" jdbcType="VARCHAR" property="orderNumber"/>
- <result column="prod_id" jdbcType="BIGINT" property="prodId"/>
- <result column="sku_id" jdbcType="BIGINT" property="skuId"/>
- <result column="prod_count" jdbcType="INTEGER" property="prodCount"/>
- <result column="use_score" jdbcType="INTEGER" property="useScore"/>
- <result column="oi_prod_name" jdbcType="VARCHAR" property="prodName"/>
- <result column="pic" jdbcType="VARCHAR" property="pic"/>
- <result column="price" jdbcType="DECIMAL" property="price"/>
- <result column="user_id" jdbcType="VARCHAR" property="userId"/>
- <result column="product_total_amount" jdbcType="DECIMAL" property="productTotalAmount"/>
- <!--<result column="platform_amount" jdbcType="DECIMAL" property="platformAmount"/>-->
- <result column="rec_time" jdbcType="TIMESTAMP" property="recTime"/>
- <result column="comm_sts" jdbcType="INTEGER" property="commSts"/>
- <result column="distribution_card_no" property="distributionCardNo"/>
- <result column="basket_date" property="basketDate"/>
- <result column="share_reduce" property="shareReduce"/>
- <result column="distribution_amount" property="distributionAmount"/>
- <result column="distribution_parent_amount" property="distributionParentAmount"/>
- <result column="return_money_sts" property="returnMoneySts"/>
- <result column="oi_actual_total" property="actualTotal"/>
- </collection>
- </resultMap>
- <resultMap type="com.yami.shop.bean.model.Order" id="orderAndOrderItemAndUserAddrMap">
- <id column="order_id" jdbcType="BIGINT" property="orderId"/>
- <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
- <result column="order_prod_name" jdbcType="VARCHAR" property="prodName"/>
- <result column="user_id" jdbcType="VARCHAR" property="userId"/>
- <result column="order_number" jdbcType="VARCHAR" property="orderNumber"/>
- <result column="total" jdbcType="DECIMAL" property="total"/>
- <result column="actual_total" jdbcType="DECIMAL" property="actualTotal"/>
- <result column="pay_type" jdbcType="INTEGER" property="payType"/>
- <result column="remarks" jdbcType="VARCHAR" property="remarks"/>
- <result column="hb_order_status" jdbcType="INTEGER" property="hbOrderStatus"/>
- <result column="dvy_type" jdbcType="VARCHAR" property="dvyType"/>
- <result column="dvy_id" jdbcType="BIGINT" property="dvyId"/>
- <result column="nick_name" jdbcType="BIGINT" property="nickName"/>
- <result column="dvy_flow_id" jdbcType="VARCHAR" property="dvyFlowId"/>
- <result column="freight_amount" jdbcType="DECIMAL" property="freightAmount"/>
- <result column="order_type" jdbcType="INTEGER" property="orderType"/>
- <result column="addr_order_id" jdbcType="BIGINT" property="addrOrderId"/>
- <result column="product_nums" jdbcType="INTEGER" property="productNums"/>
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
- <result column="pay_time" jdbcType="TIMESTAMP" property="payTime"/>
- <result column="dvy_time" jdbcType="TIMESTAMP" property="dvyTime"/>
- <result column="finally_time" jdbcType="TIMESTAMP" property="finallyTime"/>
- <result column="cancel_time" jdbcType="TIMESTAMP" property="cancelTime"/>
- <result column="is_payed" jdbcType="BIT" property="isPayed"/>
- <result column="delete_status" jdbcType="INTEGER" property="deleteStatus"/>
- <result column="pay_score" jdbcType="INTEGER" property="score"/>
- <result column="refund_status" jdbcType="INTEGER" property="refundStatus"/>
- <result column="close_type" jdbcType="INTEGER" property="closeType"/>
- <result column="shop_name" jdbcType="VARCHAR" property="shopName"/>
- <result column="pay_score" jdbcType="INTEGER" property="payScore"/>
- <result column="user_mobile" jdbcType="VARCHAR" property="userMobile"/>
- <result column="qnh_order_id" jdbcType="VARCHAR" property="qnhOrderId"/>
- <result column="qnh_order_status" jdbcType="VARCHAR" property="qnhOrderStatus"/>
- <result column="dvy_status" jdbcType="INTEGER" property="dvyStatus"/>
- <association property="userAddrOrder" javaType="com.yami.shop.bean.model.UserAddrOrder">
- <id column="addr_order_id" jdbcType="BIGINT" property="addrOrderId"/>
- <result column="province" jdbcType="VARCHAR" property="province"/>
- <result column="city" jdbcType="VARCHAR" property="city"/>
- <result column="area" jdbcType="VARCHAR" property="area"/>
- <result column="addr" jdbcType="VARCHAR" property="addr"/>
- <result column="mobile" jdbcType="VARCHAR" property="mobile"/>
- <result column="receiver" jdbcType="VARCHAR" property="receiver"/>
- <result column="address" jdbcType="VARCHAR" property="address"/>
- <result column="address_name" jdbcType="VARCHAR" property="addressName"/>
- <result column="address_detail" jdbcType="VARCHAR" property="addrDetail"/>
- </association>
- <collection property="orderItems" ofType="com.yami.shop.bean.model.OrderItem">
- <id column="order_item_id" jdbcType="BIGINT" property="orderItemId"/>
- <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
- <result column="order_number" jdbcType="VARCHAR" property="orderNumber"/>
- <result column="prod_id" jdbcType="BIGINT" property="prodId"/>
- <!-- <result column="prod_name" jdbcType="BIGINT" property="prodName"/>-->
- <result column="sku_id" jdbcType="BIGINT" property="skuId"/>
- <result column="prod_count" jdbcType="INTEGER" property="prodCount"/>
- <result column="use_score" jdbcType="INTEGER" property="useScore"/>
- <result column="prod_name" jdbcType="VARCHAR" property="prodName"/>
- <result column="pic" jdbcType="VARCHAR" property="pic"/>
- <result column="price" jdbcType="DECIMAL" property="price"/>
- <result column="user_id" jdbcType="VARCHAR" property="userId"/>
- <result column="oi_actual_total" jdbcType="DECIMAL" property="actualTotal"/>
- <result column="product_total_amount" jdbcType="DECIMAL" property="productTotalAmount"/>
- <result column="rec_time" jdbcType="TIMESTAMP" property="recTime"/>
- <result column="comm_sts" jdbcType="INTEGER" property="commSts"/>
- <result column="item_status" jdbcType="INTEGER" property="status"/>
- <result column="distribution_card_no" property="distributionCardNo"/>
- <result column="basket_date" property="basketDate"/>
- <result column="share_reduce" property="shareReduce"/>
- <result column="platform_share_reduce" property="platformShareReduce"/>
- <result column="oi_return_money_sts" property="returnMoneySts"/>
- <result column="oi_status" property="status"/>
- </collection>
- </resultMap>
- <select id="getOrderByOrderNumber" resultType="com.yami.shop.bean.model.Order">
- select * from tz_order o where o.order_number = #{orderNumber}
- </select>
- <select id="listUnRefundOrderAndOrderItems" resultMap="orderAndOrderItemMap">
- select o.*,oi.*,tor.return_money_sts,oi.prod_name oi_prod_name,oi.actual_total as oi_actual_total from tz_order o
- join tz_order_item oi on o.order_number = oi.order_number
- left join tz_order_refund tor on tor.order_id = o.order_id
- where o.hb_order_status = #{orderStatus} and (refund_status IS NULL OR o.refund_status <> 1)
- and o.update_time < #{lessThanUpdateTime}
- </select>
- <update id="cancelOrders">
- update tz_order set `hb_order_status`=60,cancel_time = NOW(),update_time=NOW() where order_id in
- <foreach collection="orders" item="order" open="(" close=")" separator=",">
- #{order.orderId}
- </foreach>
- </update>
- <update id="receiptOrder">
- update tz_order set `hb_order_status`=80,finally_time = NOW(),update_time=NOW() where order_id in
- <foreach collection="orders" item="order" open="(" close=")" separator=",">
- #{order.orderId}
- </foreach>
- </update>
- <update id="updateByToPaySuccess">
- update tz_order set `hb_order_status` = 20,is_payed =1,update_time=NOW(),pay_time=NOW(),pay_type =#{payType} where
- order_number in
- <foreach collection="orderNumbers" item="orderNumber" separator="," open="(" close=")">
- #{orderNumber}
- </foreach>
- </update>
- <select id="listOrdersDetialByOrder" resultMap="orderAndOrderItemAndUserAddrMap">
- select o.*,oi.*,oi.prod_name as item_prod_name,o.prod_name as order_prod_name,uao.* ,oi.hb_order_status as oi_status
- from tz_order o
- left join tz_order_item oi on o.order_number = oi.order_number
- left join tz_user_addr_order uao on o.addr_order_id = uao.addr_order_id
- where o.order_id in (
- select * from (
- select o.order_id from tz_order o
- left join tz_shop_detail sd on o.shop_id = sd.shop_id
- where 1=1
- <if test="order.orderNumber != null and order.orderNumber != ''">
- and o.order_number like concat('%',#{order.orderNumber},'%')
- </if>
- <if test="order.hb_order_status != null">
- and o.hb_order_status = #{order.orderStatus}
- </if>
- <if test="order.shopId != null">
- and o.shop_id = #{order.shopId}
- </if>
- <if test="order.isPayed != null">
- and o.is_payed = #{order.isPayed}
- and o.hb_order_status != 60
- </if>
- <if test="startTime != null">
- and o.create_time > #{startTime}
- </if>
- <if test="endTime != null">
- and o.create_time < #{endTime}
- </if>
- <if test="order.shopName != null">
- and sd.shop_name like concat("%",#{order.shopName},"%")
- </if>
- ORDER BY o.create_time DESC
- )
- AS limittable) ORDER BY o.create_time DESC
- </select>
- <select id="getOrderCountByShopId" resultType="com.yami.shop.bean.param.OrderPayParam">
- SELECT SUM(actual_total) as payActualTotal,COUNT(DISTINCT user_id) as payUserCount,
- COUNT(*) as payOrderCount
- FROM tz_order o
- <where>
- <if test="shopId != null">
- and o.shop_id = #{shopId}
- </if>
- <if test="startTime != null">
- and o.pay_time >= #{startTime}
- </if>
- <if test="endTime != null">
- and o.pay_time <= #{endTime}
- </if>
- AND o.is_payed =1
- </where>
- </select>
- <select id="getPayOrderByTime" resultType="com.yami.shop.bean.param.OrderPayParam">
- SELECT dates, MAX(orderCount) AS payOrderCount,MAX(payActualTotal) as payActualTotal FROM(
- SELECT @cdate := DATE_ADD(@cdate,INTERVAL - 1 DAY) dates ,0 AS 'orderCount',0 AS 'payActualTotal'
- FROM (SELECT @cdate :=DATE_ADD(CURDATE(),INTERVAL + 1 DAY) FROM tz_user) t1
- <where>
- <if test="startTime != null">
- and @cdate >= #{startTime}
- </if>
- </where>
- UNION ALL
- SELECT DATE_FORMAT(o.pay_time, '%Y-%m-%d') AS dates,COUNT(*) AS orderCount,SUM(actual_total) AS payActualTotal
- FROM tz_order o
- <where>
- <if test="shopId != null">
- and o.shop_id = #{shopId}
- </if>
- <if test="startTime != null">
- and o.pay_time >= #{startTime}
- </if>
- <if test="endTime != null">
- and o.pay_time <= #{endTime}
- </if>
- AND o.is_payed =1
- </where>
- GROUP BY dates) _tmpAllTable GROUP BY dates
- ORDER BY dates
- </select>
- <select id="getActualTotalByHour" resultType="com.yami.shop.bean.param.OrderPayParam">
- SELECT DATE_FORMAT(o.pay_time, '%k') AS dates,SUM(actual_total) as payActualTotal
- FROM tz_order o
- <where>
- <if test="shopId != null">
- and o.shop_id = #{shopId}
- </if>
- <if test="startTime != null">
- and o.pay_time >= #{startTime}
- </if>
- <if test="endTime != null">
- and o.pay_time <= #{endTime}
- </if>
- AND o.is_payed =1
- </where>
- GROUP BY dates
- </select>
- <select id="getActualTotalByDay" resultType="com.yami.shop.bean.param.OrderPayParam">
- SELECT DATE_FORMAT(o.pay_time, '%Y-%m-%d') AS payDay,SUM(actual_total) as payActualTotal
- FROM tz_order o
- <where>
- <if test="shopId != null">
- and o.shop_id = #{shopId}
- </if>
- <if test="startTime != null">
- and o.pay_time >= #{startTime}
- </if>
- <if test="endTime != null">
- and o.pay_time <= #{endTime}
- </if>
- AND o.is_payed =1
- </where>
- GROUP BY payDay
- </select>
- <select id="listOrdersDetialByOrderParam" resultMap="orderAndOrderItemAndUserAddrMap">
- SELECT *,oi.prod_name as item_prod_name,oi.actual_total as oi_actual_total,IF(r.refund_type = 2,r.return_money_sts,IF(ar.refund_type = 1,ar.return_money_sts,NULL)) AS oi_return_money_sts,
- temp.prod_name as order_prod_name,oi.hb_order_status as oi_status, IF(os.pay_score IS NULL,0,os.pay_score) as pay_score
- FROM
- (
- SELECT o.*,sd.shop_name,uao.receiver,uao.mobile,u.user_mobile,u.nick_name FROM tz_order o
- LEFT JOIN tz_shop_detail sd ON o.shop_id = sd.shop_id
- LEFT JOIN tz_user_addr_order uao ON o.addr_order_id = uao.addr_order_id
- LEFT JOIN tz_user u on u.user_id=o.user_id
- <where>
- <!-- <if test="orderParam.type!=null and orderParam.type==1 and orderParam.content != null and orderParam.content != ''">-->
- <!-- and o.order_number = #{orderParam.content}-->
- <!-- </if>-->
- <if test="orderParam.orderNumber != null and orderParam.orderNumber != ''">
- and o.order_number = #{orderParam.orderNumber}
- </if>
- <!-- <if test="orderParam.type!=null and orderParam.type==2 and orderParam.orderNumber != null and orderParam.orderNumber != ''">-->
- <!-- and o.order_number = #{orderParam.orderNumber}-->
- <!-- </if>-->
- <!-- <if test="orderParam.type!=null and orderParam.type==4 and orderParam.content != null and orderParam.content != ''">-->
- <!-- and u.nick_name LIKE concat("%",#{orderParam.content},"%")-->
- <!-- </if>-->
- <!-- <if test="orderParam.type!=null and orderParam.type==5 and orderParam.content != null and orderParam.content != ''">-->
- <!-- and u.user_mobile LIKE concat("%",#{orderParam.content},"%")-->
- <!-- </if>-->
- <!-- <if test="orderParam.type!=null and orderParam.type==6 and orderParam.content != null and orderParam.content != ''">-->
- <!-- and u.dvy_flow_id = #{orderParam.content}-->
- <!-- </if>-->
- <if test="orderParam.hb_order_status != null">
- and o.hb_order_status = #{orderParam.hbOrderStatus}
- </if>
- <!-- <if test="orderParam.payType != null">-->
- <!-- and o.pay_type = #{orderParam.payType}-->
- <!-- </if>-->
- <if test="orderParam.shopId != null">
- and o.shop_id = #{orderParam.shopId}
- </if>
- <if test="orderParam.isPayed != null">
- and o.is_payed = #{orderParam.isPayed}
- and o.hb_order_status != 60
- </if>
- <if test="orderParam.startTime != null">
- and o.create_time > #{orderParam.startTime}
- </if>
- <if test="orderParam.endTime != null">
- and o.create_time < #{orderParam.endTime}
- </if>
- <if test="orderParam.orderType != null">
- and o.order_type = #{orderParam.orderType}
- </if>
- <if test="orderParam.orderType == null">
- and (o.order_type <![CDATA[ <> ]]> 3 OR o.order_type IS NULL)
- </if>
- <if test="orderParam.shopName != null">
- and sd.shop_name LIKE concat("%",#{orderParam.shopName},"%")
- </if>
- <if test="orderParam.refundStatus == 0">
- and o.refund_status IS NULL
- </if>
- <if test="orderParam.refundStatus != null and orderParam.refundStatus != 0">
- and o.refund_status = #{orderParam.refundStatus}
- </if>
- <if test="orderParam.prodName != null">
- and o.prod_name LIKE concat("%",#{orderParam.prodName},"%")
- </if>
- <!-- <if test="orderParam.type!=null and orderParam.type==2 and orderParam.content != null and orderParam.content != ''">-->
- <!-- and uao.receiver LIKE concat("%",#{orderParam.content},"%")-->
- <!-- </if>-->
- <!-- <if test="orderParam.type!=null and orderParam.type==3 and orderParam.content != null and orderParam.content != ''">-->
- <!-- and uao.mobile LIKE concat("%",#{orderParam.content},"%")-->
- <!-- </if>-->
- </where>
- ORDER BY o.create_time DESC
- LIMIT #{adapter.begin} , #{adapter.size}
- ) AS temp
- LEFT JOIN tz_order_item oi ON temp.order_number = oi.order_number
- <!--连接单个物品退款的退款信息-->
- LEFT JOIN tz_order_refund r ON r.order_item_id = oi.order_item_id AND r.refund_type = 2 AND r.return_money_sts > 0 AND r.return_money_sts < 6
- <!--连接整单退款的退款信息-->
- LEFT JOIN tz_order_refund ar ON ar.order_id = temp.order_id AND ar.refund_type = 1 AND ar.return_money_sts > 0 AND ar.return_money_sts < 6
- LEFT JOIN tz_order_settlement os ON temp.order_number = os.order_number
- ORDER BY temp.create_time DESC
- </select>
- <select id="countOrderDetial" resultType="long">
- SELECT count(0)
- FROM tz_order o
- LEFT JOIN tz_shop_detail sd ON o.shop_id = sd.shop_id
- JOIN tz_user_addr_order uao
- ON o.addr_order_id = uao.addr_order_id
- <where>
- <if test="orderParam.orderNumber != null and orderParam.orderNumber != ''">
- and o.order_number = #{orderParam.orderNumber}
- </if>
- <if test="orderParam.orderStatus != null">
- and o.hb_order_status = #{orderParam.orderStatus}
- </if>
- <if test="orderParam.shopId != null">
- and o.shop_id = #{orderParam.shopId}
- </if>
- <if test="orderParam.isPayed != null">
- and o.is_payed = #{orderParam.isPayed}
- and o.hb_order_status != 60
- </if>
- <if test="orderParam.startTime != null">
- and o.create_time > #{orderParam.startTime}
- </if>
- <if test="orderParam.endTime != null">
- and o.create_time < #{orderParam.endTime}
- </if>
- <if test="orderParam.orderType != null">
- and o.order_type = #{orderParam.orderType}
- </if>
- <if test="orderParam.orderType == null">
- and (o.order_type <![CDATA[ <> ]]> 3 OR o.order_type IS NULL)
- </if>
- <if test="orderParam.shopName != null">
- and sd.shop_name LIKE concat("%",#{orderParam.shopName},"%")
- </if>
- <if test="orderParam.refundStatus == 0">
- and o.refund_status IS NULL
- </if>
- <if test="orderParam.refundStatus != null and orderParam.refundStatus != 0">
- and o.refund_status = #{orderParam.refundStatus}
- </if>
- <if test="orderParam.prodName != null">
- and o.prod_name LIKE concat("%",#{orderParam.prodName},"%")
- </if>
- <if test="orderParam.receiver != null">
- and uao.receiver LIKE concat("%",#{orderParam.receiver},"%")
- </if>
- <if test="orderParam.mobile != null">
- and uao.mobile LIKE concat("%",#{orderParam.mobile},"%")
- </if>
- </where>
- </select>
- <select id="calculateUserInShopData" resultType="com.yami.shop.bean.distribution.UserShoppingDataDto">
- select
- count(o.order_number) as expense_number,
- ifnull(SUM(o.actual_total),0) as expense_amount
- from tz_order o
- where o.user_id=#{userId} and o.shop_id = #{shopId} and (o.hb_order_status = 45 or o.hb_order_status = 80)
- </select>
- <select id="listMyOrderByUserIdAndStatus" resultMap="MyOrderMap">
- SELECT
- o.order_type,o.actual_total,o.order_number,o.freight_amount,o.create_time,o.order_id,
- o.hb_order_status,
- o.hb_logistic_status,
- o.offset_points,
- o.pay_time,
- (SELECT r.refund_type FROM tz_order_refund r WHERE r.order_id =o.order_id ORDER BY r.update_time DESC LIMIT 0,1) AS refund_type,
- (SELECT r.return_money_sts FROM tz_order_refund r WHERE r.order_id =o.order_id ORDER BY r.update_time DESC LIMIT 0,1) AS return_money_sts,
- oi.pic,oi.price,oi.prod_name,oi.pic,oi.sku_name,ifnull(oi.use_score,0) as use_score,oi.prod_id,oi.rec_time,oi.prod_count,oi.order_item_id,oi.comm_sts,
- sd.shop_id,sd.shop_name,oi.actual_total as oi_actual_total,ad.longitude,ad.latitude
- FROM (
- SELECT temp.order_type,
- temp.hb_order_status,
- temp.hb_logistic_status,
- temp.offset_points,
- temp.pay_time,
- temp.order_id, temp.create_time, temp.freight_amount,temp.order_number,temp.actual_total,temp.shop_id,temp.addr_order_id FROM tz_order temp
- WHERE temp.user_id = #{userId} and temp.delete_status = 0
- <if test="status != null and status != 0">
- AND temp.hb_order_status = #{status}
- </if>
- ORDER BY temp.create_time DESC
- LIMIT #{adapter.begin} , #{adapter.size}
- )AS o
- JOIN tz_order_item oi ON o.order_number = oi.order_number
- left join tz_shop_detail sd on o.shop_id = sd.shop_id
- left join tz_order_refund tor on o.order_id = tor.order_id
- left join tz_user_addr_order ad on o.addr_order_id = ad.addr_order_id
- ORDER BY o.create_time DESC
- </select>
- <select id="countMyOrderByUserIdAndStatus" resultType="Long">
- SELECT count(*)
- FROM (
- SELECT count(*) FROM tz_order temp
- JOIN tz_order_item oi ON temp.order_number = oi.order_number
- WHERE temp.user_id = #{userId} and temp.delete_status = 0
- <if test="status != null and status != 0">
- AND temp.hb_order_status = #{status}
- </if>
- <if test="isComm != null">
- AND temp.hb_order_status = 80
- </if>
- <if test="isComm != null">
- AND oi.comm_sts = #{isComm}
- </if>
- group by temp.order_id
- )AS o
- </select>
- <update id="deleteOrders">
- UPDATE tz_order SET `delete_status`=2,update_time=NOW()
- WHERE order_id IN
- <foreach collection="orders" item="order" open="(" close=")" separator=",">
- #{order.orderId}
- </foreach>
- </update>
- <select id="getOrderCount" resultType="com.yami.shop.bean.app.dto.OrderCountData">
- SELECT
- COUNT(o.order_id) all_count,
- COUNT( CASE WHEN o.hb_order_status = 0 THEN o.order_id ELSE NULL END ) AS unPay,
- COUNT( CASE WHEN o.hb_order_status = 20 THEN o.order_id ELSE NULL END ) AS payed,
- COUNT( CASE WHEN o.hb_order_status = 30 THEN o.order_id ELSE NULL END ) AS consignment,
- COUNT( CASE WHEN o.hb_order_status = 40 THEN o.order_id ELSE NULL END ) AS confirm,
- COUNT( CASE WHEN o.hb_order_status = 50 THEN o.order_id ELSE NULL END ) AS success,
- COUNT( CASE WHEN o.hb_order_status = 60 THEN o.order_id ELSE NULL END ) AS `close`
- FROM tz_order o
- WHERE o.user_id =#{userId} AND o.delete_status = 0
- </select>
- <update id="cancelSeckillOrderByTime">
- UPDATE tz_order o JOIN (
- SELECT so.order_number FROM tz_seckill_order so JOIN
- tz_seckill s ON s.seckill_id = so.seckill_id
- AND (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(so.`create_time`))/60 > s.`max_cancel_time` and so.state = 0 ) t
- ON o.order_number = t.order_number
- SET o.`hb_order_status`=60,o.cancel_time = NOW(),o.update_time=NOW()
- </update>
- <update id="updateToWaitGroup">
- UPDATE tz_order SET hb_order_status = 7,update_time=NOW() WHERE order_number = #{orderNumber}
- </update>
- <update id="updateToWaitDelivery">
- UPDATE tz_order SET `hb_order_status` = 20, `update_time` = NOW()
- WHERE `order_number` IN
- (
- SELECT order_number FROM
- (SELECT o.`order_number` FROM tz_order o
- LEFT JOIN tz_group_order go ON go.`order_number` = o.`order_number`
- LEFT JOIN tz_group_team gt ON gt.`group_team_id` = go.`group_team_id`
- WHERE gt.`group_team_id` = #{groupTeamId}) temp
- )
- </update>
- <select id="getOrderByOrderNumberAndUserId" resultType="com.yami.shop.bean.model.Order">
- select o.* from tz_order o where o.order_number = #{orderNumber} and o.user_id = #{userId}
- </select>
- <select id="getOrderAndOrderItemByOrderNumber" resultMap="orderAndOrderItemMap">
- select o.*,oi.*,oi.prod_name oi_prod_name,oi.actual_total as oi_actual_total from tz_order o
- left join tz_order_item oi on o.order_number = oi.order_number
- where o.order_number = #{orderNumber}
- </select>
- <select id="hasBuySuccessProd" resultType="java.lang.Integer">
- select count(*) from tz_order_item oi
- join tz_order o on o.order_number = oi.order_number
- where o.user_id=#{userId} and o.hb_order_status = 50 and oi.prod_id = #{prodId}
- </select>
- <select id="listMyOrderByParams" resultMap="MyOrderMap">
- SELECT
- o.order_type,o.actual_total,
- oi.pic,oi.price,oi.prod_id,oi.prod_name,oi.sku_name,ifnull(oi.use_score,0) as use_score,oi.prod_count,oi.order_item_id,o.hb_order_status,o.order_number,oi.comm_sts,
- sd.shop_id,sd.shop_name
- FROM (
- SELECT temp.order_type, temp.create_time, temp.order_number,temp.actual_total,temp.hb_order_status,temp.shop_id,prod_name
- FROM tz_order temp
- WHERE temp.user_id = #{userId} and temp.delete_status = 0
- <if test="status != null and status != 0">
- AND temp.hb_order_status = #{status}
- </if>
- <if test="orderNumber != null and orderNumber != ''">
- AND temp.order_number LIKE CONCAT("%",#{orderNumber},"%")
- </if>
- <if test="orderType == 0">
- AND (temp.order_type = 0 or temp.order_type is null)
- </if>
- <if test="orderType != null and orderType !='' and orderType != 0">
- AND temp.order_type = #{orderType}
- </if>
- <if test="orderTimeStatus == 1 or orderTimeStatus == 2">
- AND temp.create_time >= #{preTime}
- </if>
- <if test="orderTimeStatus == 3">
- AND temp.create_time <= #{preTime}
- </if>
- <if test="orderName != null and orderName != ''">
- AND temp.prod_name LIKE concat('%',#{orderName},'%')
- </if>
- ORDER BY temp.create_time DESC
- LIMIT #{adapter.begin} , #{adapter.size}
- )AS o
- JOIN tz_order_item oi ON o.order_number = oi.order_number
- LEFT JOIN tz_shop_detail sd on o.shop_id = sd.shop_id
- ORDER BY o.create_time DESC
- </select>
- <select id="countMyOrderByParams" resultType="Long">
- SELECT COUNT(*) FROM(
- SELECT
- count(1)
- FROM tz_order o
- JOIN tz_order_item oi ON o.order_number = oi.order_number
- join tz_shop_detail sd on o.shop_id = sd.shop_id
- WHERE o.user_id = #{userId} and o.delete_status = 0
- <if test="status != null and status != 0">
- AND o.hb_order_status = #{status}
- </if>
- <if test="orderNumber != null and orderNumber != ''">
- AND o.order_number LIKE CONCAT("%",#{orderNumber},"%")
- </if>
- <if test="orderType == 0">
- AND (o.order_type = 0 or o.order_type is null)
- </if>
- <if test="orderType != null and orderType !='' and orderType != 0">
- AND o.order_type = #{orderType}
- </if>
- <if test="orderTimeStatus == 1 or orderTimeStatus == 2">
- AND o.create_time >= #{preTime}
- </if>
- <if test="orderTimeStatus == 3">
- AND o.create_time <= #{preTime}
- </if>
- <if test="orderName != null and orderName != ''">
- AND (o.prod_name LIKE concat('%',#{orderName},'%') OR oi.prod_name LIKE concat('%',#{orderName},'%'))
- </if>
- GROUP BY o.order_number
- ) AS temp
- </select>
- <select id="listOrdersDetialByOrderInfo" resultMap="orderAndOrderItemAndUserAddrMap">
- SELECT *,oi.prod_name,uao.address,uao.address_name,uao.addr_detail as item_prod_name,oi.actual_total as oi_actual_total,temp.prod_name as order_prod_name,oi.hb_order_status as oi_status
- FROM
- (
- SELECT o.*,sd.shop_name FROM tz_order o
- LEFT JOIN tz_shop_detail sd ON o.shop_id = sd.shop_id
- <where>
- <if test="orderParam.orderNumber != null and orderParam.orderNumber != ''">
- and o.order_number = #{orderParam.orderNumber}
- </if>
- <if test="orderParam.status != null">
- and o.hb_order_status = #{orderParam.status}
- </if>
- <if test="orderParam.shopId != null">
- and o.shop_id = #{orderParam.shopId}
- </if>
- <if test="orderParam.isPayed != null">
- and o.is_payed = #{orderParam.isPayed}
- and o.hb_order_status != 60
- </if>
- <if test="orderParam.startTime != null">
- and o.create_time > #{orderParam.startTime}
- </if>
- <if test="orderParam.endTime != null">
- and o.create_time < #{orderParam.endTime}
- </if>
- <if test="orderParam.orderType != null">
- and o.order_type = #{orderParam.orderType}
- </if>
- <if test="orderParam.orderType == null">
- and (o.order_type <![CDATA[ <> ]]> 3 OR o.order_type IS NULL)
- </if>
- <if test="orderParam.shopName != null">
- and sd.shop_name LIKE concat("%",#{orderParam.shopName},"%")
- </if>
- <if test="orderParam.refundStatus == 0">
- and o.refund_status IS NULL
- </if>
- <if test="orderParam.refundStatus != null and orderParam.refundStatus != 0">
- and o.refund_status = #{orderParam.refundStatus}
- </if>
- <if test="orderParam.prodName != null">
- and o.prod_name LIKE concat("%",#{orderParam.prodName},"%")
- </if>
- </where>
- ORDER BY o.create_time DESC
- ) AS temp
- LEFT JOIN tz_order_item oi
- ON temp.order_number = oi.order_number
- LEFT JOIN tz_user_addr_order uao
- ON temp.addr_order_id = uao.addr_order_id
- <where>
- <if test="orderParam.receiver != null">
- and uao.receiver LIKE concat("%",#{orderParam.receiver},"%")
- </if>
- <if test="orderParam.mobile != null">
- and uao.mobile LIKE concat("%",#{orderParam.mobile},"%")
- </if>
- </where>
- ORDER BY temp.create_time DESC
- </select>
- <select id="getOrderPayInfoByOrderNumber" resultMap="orderAndOrderItemMap">
- SELECT o.*,oi.prod_name as oi_prod_name,oi.actual_total as oi_actual_total,oi.use_score
- FROM tz_order o
- LEFT JOIN tz_order_item oi ON oi.order_number = o.order_number
- WHERE o.order_number IN
- <foreach collection="orderNumberList" item="orderNumber" separator="," open="(" close=")">
- #{orderNumber}
- </foreach>
- </select>
- <select id="getOrderDetailByOrderNumberAndShopId" resultMap="orderAndOrderItemAndUserAddrMap">
- SELECT o.*,oi.prod_name as item_prod_name,oi.*,uao.*,u.`nick_name`,u.user_mobile,oi.hb_order_status as oi_status, IF(o.refund_type = 1,
- o.rms,r.return_money_sts) AS oi_return_money_sts
- FROM (
- SELECT temp.*,tr.refund_type,tr.return_money_sts rms
- FROM tz_order temp
- LEFT JOIN tz_order_refund tr ON tr.order_id = temp.order_id AND tr.return_money_sts > 0 AND
- tr.return_money_sts < 6
- WHERE temp.order_number =#{orderNumber}
- <if test="shopId != null">
- and temp.shop_id =#{shopId}
- </if>
- ) as o
- LEFT JOIN tz_order_item oi ON oi.order_number = o.order_number
- LEFT JOIN tz_order_refund r ON r.order_item_id = oi.order_item_id AND r.return_money_sts > 0 AND r.return_money_sts < 6
- LEFT JOIN tz_user_addr_order uao ON o.addr_order_id = uao.addr_order_id
- LEFT JOIN tz_user u ON u.user_id = o.user_id
- </select>
- <select id="OrderCommentByUserIdAndStatus" resultMap="MyOrderMap">
- SELECT
- o.order_type,o.actual_total,o.hb_order_status,o.order_number,o.freight_amount,o.create_time,
- pc.rec_time,
- oi.pic,oi.price,oi.prod_name,oi.pic,oi.sku_name,oi.use_score,oi.prod_id,oi.rec_time,oi.prod_count,oi.order_item_id,oi.comm_sts,
- sd.shop_id,sd.shop_name,oi.actual_total as oi_actual_total
- FROM (
- SELECT DISTINCT temp.order_type, temp.create_time, temp.freight_amount,temp.order_number,temp.actual_total,temp.hb_order_status,temp.shop_id FROM tz_order temp
- JOIN tz_order_item toi ON temp.order_number = toi.order_number AND toi.comm_sts = #{isComm}
- WHERE temp.user_id = #{userId} and temp.delete_status = 0 AND temp.hb_order_status = 80
- ORDER BY temp.create_time DESC
- LIMIT #{adapter.begin} , #{adapter.size}
- )AS o
- JOIN tz_order_item oi ON o.order_number = oi.order_number AND oi.comm_sts = #{isComm}
- left JOIN tz_prod_comm pc ON pc.order_item_id = oi.order_item_id
- left join tz_shop_detail sd on o.shop_id = sd.shop_id
- ORDER BY o.create_time DESC
- </select>
- <select id="orderItemCommentByUserIdAndStatus" resultMap="MyOrderItemMap">
- SELECT
- pc.rec_time,oi.pic,oi.price,oi.prod_name,oi.order_number,oi.pic,oi.sku_name,oi.use_score,oi.prod_id,oi.rec_time,oi.prod_count,oi.order_item_id,oi.comm_sts,
- oi.actual_total as oi_actual_total
- FROM tz_order o
- left JOIN tz_order_item oi ON o.order_number = oi.order_number
- left JOIN tz_prod_comm pc ON pc.order_item_id = oi.order_item_id
- where oi.comm_sts = #{isComm} and o.user_id = #{userId}
- <if test="isComm == 1">
- AND o.hb_order_status = 80
- </if>
- ORDER BY pc.rec_time DESC
- LIMIT #{adapter.begin} , #{adapter.size}
- </select>
- <select id="countOrderItemComment" resultType="long">
- SELECT count(*)
- FROM tz_order o
- left JOIN tz_order_item oi ON o.order_number = oi.order_number
- where oi.comm_sts = #{isComm} and o.user_id = #{userId}
- <if test="isComm == 1">
- AND o.hb_order_status = 80
- </if>
- </select>
- </mapper>
|