| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229 |
- <?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="shop_name" jdbcType="VARCHAR" property="shopName"/>
- <result column="channel_id" jdbcType="BIGINT" property="channelId"/>
- <result column="channel_name" jdbcType="VARCHAR" property="channelName"/>
- <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_status" jdbcType="VARCHAR" property="dvyStatus"/>
- <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"/>
- <result column="user_mobile" jdbcType="VARCHAR" property="userMobile"/>
- <result column="receiver" jdbcType="VARCHAR" property="receiver"/>
- <result column="shop_name" jdbcType="VARCHAR" property="shopName"/>
- </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"/>
- <result column="dvy_type" property="dvyType"/>
- <result column="comm_sts" property="commSts"/>
- <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="shop_name" jdbcType="VARCHAR" property="shopName"/>
- <result column="channel_id" jdbcType="BIGINT" property="channelId"/>
- <result column="channel_name" jdbcType="VARCHAR" property="channelName"/>
- <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="hb_order_status" jdbcType="VARCHAR" property="hbOrderStatus"/>
- <result column="dvy_status" jdbcType="VARCHAR" property="dvyStatus"/>
- <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="receiver" jdbcType="VARCHAR" property="receiver"/>
- <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.dvy_time < #{lessThanUpdateTime}
- </select>
- <select id="selectCancelOrders" resultMap="orderAndOrderItemMap">
- select o.*,oi.*,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
- where o.hb_order_status = #{orderStatus} and o.create_time < #{lessThanUpdateTime}
- </select>
- <update id="cancelOrders">
- update tz_order set `hb_order_status`=60,close_type = 1,cancel_reason = #{cancelReason}, cancel_time = NOW(),update_time=NOW(),close_type=4 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 dvy_type=3 and
- order_number in
- <foreach collection="orderNumbers" item="orderNumber" separator="," open="(" close=")">
- #{orderNumber}
- </foreach>
- </update>
- <update id="updateByToPaySuccessDelivery">
- update tz_order set `hb_order_status` = 1,is_payed =1,update_time=NOW(),pay_time=NOW(),pay_type =#{payType} where dvy_type=1 and
- 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.* ,o.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,temp.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.hbOrderStatus != null">
- and o.hb_order_status = #{orderParam.hbOrderStatus}
- </if>
- <!-- <if test="orderParam.payType != null">-->
- <!-- and o.pay_type = #{orderParam.payType}-->
- <!-- </if>-->
- <if test="orderParam.dvyType != null">
- and o.dvy_type = #{orderParam.dvyType}
- </if>
- <if test="orderParam.channelId != null">
- and o.channel_id = #{orderParam.channelId}
- </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="deliverList" resultMap="BaseResultMap">
- SELECT a.*,b.receiver,b.mobile user_mobile,c.shop_name FROM tz_order a
- LEFT JOIN tz_user_addr_order b on a.addr_order_id=b.addr_order_id
- LEFT JOIN tz_shop_detail c on a.shop_id=c.shop_id
- <where>
- <if test="orderParam.orderNumber != null and orderParam.orderNumber != ''">
- and a.order_number = #{orderParam.orderNumber}
- </if>
- <if test="orderParam.channelIdList != null and !orderParam.channelIdList.isEmpty()">
- and a.channel_id in
- <foreach collection="orderParam.channelIdList" item="channelId" open="(" close=")" separator=",">
- #{channelId}
- </foreach>
- </if>
- <if test="orderParam.dvyType != null and orderParam.dvyType != ''">
- and a.dvy_type = #{orderParam.dvyType}
- </if>
- <if test="orderParam.shopId != null">
- and a.shop_id = #{orderParam.shopId}
- </if>
- <if test="orderParam.startTime != null">
- and a.create_time > #{orderParam.startTime}
- </if>
- <if test="orderParam.endTime != null">
- and a.create_time < #{orderParam.endTime}
- </if>
- <if test="orderParam.refundStatus != null and orderParam.refundStatus != 0">
- and a.refund_status = #{orderParam.refundStatus}
- </if>
- <if test="orderParam.receiver != null">
- and b.receiver LIKE concat("%",#{orderParam.receiver},"%")
- </if>
- <if test="orderParam.userMobile != null">
- and b.mobile LIKE concat("%",#{orderParam.userMobile},"%")
- </if>
- <if test="orderParam.orderStatus != null and orderParam.orderStatus != ''">
- <if test="orderParam.orderStatus == 'all'">
- AND a.hb_order_status in (0, 1,20,30,40,50,60,70,80)
- </if>
- <if test="orderParam.orderStatus == 'paddingPay'">
- AND a.hb_order_status in (0)
- </if>
- <if test="orderParam.orderStatus == 'paddingShipped'">
- AND a.hb_order_status in (1)
- </if>
- <if test="orderParam.orderStatus == 'paddingReceived'">
- AND a.hb_order_status in (20,30,40,70)
- </if>
- <if test="orderParam.orderStatus == 'completed'">
- AND a.hb_order_status in (80)
- </if>
- <if test="orderParam.orderStatus == 'cancel'">
- AND a.hb_order_status in (50,60)
- </if>
- </if>
- </where>
- order by a.create_time desc,a.order_id desc
- LIMIT #{adapter.begin} , #{adapter.size}
- </select>
- <select id="deliverListCount" resultType="integer">
- SELECT count(1) FROM tz_order a
- LEFT JOIN tz_user_addr_order b on a.addr_order_id=b.addr_order_id
- LEFT JOIN tz_shop_detail c on a.shop_id=c.shop_id
- <where>
- <if test="orderParam.orderNumber != null and orderParam.orderNumber != ''">
- and a.order_number = #{orderParam.orderNumber}
- </if>
- <if test="orderParam.channelIdList != null and !orderParam.channelIdList.isEmpty()">
- and a.channel_id in
- <foreach collection="orderParam.channelIdList" item="channelId" open="(" close=")" separator=",">
- #{channelId}
- </foreach>
- </if>
- <if test="orderParam.dvyType != null and orderParam.dvyType != ''">
- and a.dvy_type = #{orderParam.dvyType}
- </if>
- <if test="orderParam.shopId != null">
- and a.shop_id = #{orderParam.shopId}
- </if>
- <if test="orderParam.startTime != null">
- and a.create_time > #{orderParam.startTime}
- </if>
- <if test="orderParam.endTime != null">
- and a.create_time < #{orderParam.endTime}
- </if>
- <if test="orderParam.refundStatus != null and orderParam.refundStatus != 0">
- and a.refund_status = #{orderParam.refundStatus}
- </if>
- <if test="orderParam.receiver != null">
- and b.receiver LIKE concat("%",#{orderParam.receiver},"%")
- </if>
- <if test="orderParam.userMobile != null">
- and b.mobile LIKE concat("%",#{orderParam.userMobile},"%")
- </if>
- <if test="orderParam.orderStatus != null and orderParam.orderStatus != ''">
- <if test="orderParam.orderStatus == 'all'">
- AND a.hb_order_status in (0, 1,20,30,40,50,60,70,80)
- </if>
- <if test="orderParam.orderStatus == 'paddingPay'">
- AND a.hb_order_status in (0)
- </if>
- <if test="orderParam.orderStatus == 'paddingShipped'">
- AND a.hb_order_status in (1)
- </if>
- <if test="orderParam.orderStatus == 'paddingReceived'">
- AND a.hb_order_status in (20,30,40,70)
- </if>
- <if test="orderParam.orderStatus == 'completed'">
- AND a.hb_order_status in (80)
- </if>
- <if test="orderParam.orderStatus == 'cancel'">
- AND a.hb_order_status in (50,60)
- </if>
- </if>
- </where>
- </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>
- o.delete_status = 0
- <if test="orderParam.orderNumber != null and orderParam.orderNumber != ''">
- and o.order_number = #{orderParam.orderNumber}
- </if>
- <if test="orderParam.hbOrderStatus != null">
- and o.hb_order_status = #{orderParam.hbOrderStatus}
- </if>
- <if test="orderParam.shopId != null">
- and o.shop_id = #{orderParam.shopId}
- </if>
- <if test="orderParam.channelId != null">
- and o.channel_id = #{orderParam.channelId}
- </if>
- <if test="orderParam.dvyType != null">
- and o.dvy_type = #{orderParam.dvyType}
- </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,
- o.dvy_type,
- o.comm_sts,
- (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.dvy_type,
- temp.comm_sts,
- 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
- <choose>
- <when test="20 == status">
- temp.hb_order_status IN (1,20,30,40,50,70)
- </when>
- <otherwise>
- temp.hb_order_status = #{status}
- </otherwise>
- </choose>
- </if>
- <if test="dvyType != null">
- AND temp.dvy_type = #{dvyType}
- </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 = 1 THEN o.order_id ELSE NULL END ) AS payed,
- COUNT( CASE WHEN o.hb_order_status in (1,20,30,40,50,70) 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 = 80 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,temp.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,o.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>
- <select id="statusCount" resultType="integer">
- SELECT count(a.order_id) FROM `tz_order` a
- LEFT JOIN tz_user_addr_order b on a.addr_order_id=b.addr_order_id
- LEFT JOIN tz_shop_detail c on a.shop_id=c.shop_id
- <where>
- hb_order_status in
- <foreach collection="status" item="status" separator="," open="(" close=")">
- #{status}
- </foreach>
- <if test="orderParam.orderNumber != null and orderParam.orderNumber != ''">
- and a.order_number = #{orderParam.orderNumber}
- </if>
- <if test="orderParam.channelIdList != null and !orderParam.channelIdList.isEmpty()">
- and a.channel_id in
- <foreach collection="orderParam.channelIdList" item="channelId" open="(" close=")" separator=",">
- #{channelId}
- </foreach>
- </if>
- <if test="orderParam.dvyType != null and orderParam.dvyType != ''">
- and a.dvy_type = #{orderParam.dvyType}
- </if>
- <if test="orderParam.shopId != null">
- and a.shop_id = #{orderParam.shopId}
- </if>
- <if test="orderParam.startTime != null">
- and a.create_time > #{orderParam.startTime}
- </if>
- <if test="orderParam.endTime != null">
- and a.create_time < #{orderParam.endTime}
- </if>
- <if test="orderParam.refundStatus != null and orderParam.refundStatus != 0">
- and a.refund_status = #{orderParam.refundStatus}
- </if>
- <if test="orderParam.receiver != null">
- and b.receiver LIKE concat("%",#{orderParam.receiver},"%")
- </if>
- <if test="orderParam.userMobile != null">
- and b.mobile LIKE concat("%",#{orderParam.userMobile},"%")
- </if>
- <if test="orderParam.orderStatus != null and orderParam.orderStatus != ''">
- <if test="orderParam.orderStatus == 'all'">
- AND a.hb_order_status in (0, 1,20,30,40,50,60,70,80)
- </if>
- <if test="orderParam.orderStatus == 'paddingPay'">
- AND a.hb_order_status in (0)
- </if>
- <if test="orderParam.orderStatus == 'paddingShipped'">
- AND a.hb_order_status in (1)
- </if>
- <if test="orderParam.orderStatus == 'paddingReceived'">
- AND a.hb_order_status in (20,30,40,70)
- </if>
- <if test="orderParam.orderStatus == 'completed'">
- AND a.hb_order_status in (80)
- </if>
- <if test="orderParam.orderStatus == 'cancel'">
- AND a.hb_order_status in (50,60)
- </if>
- </if>
- </where>
- </select>
- <select id="selectOrderCount" resultType="com.yami.shop.bean.param.OrderCountParam">
- SELECT
- count(1) as allCount,
- count(case when hb_order_status = 0 then 1 end) as payedCount,
- count(case when hb_order_status = 20 then 1 end) as readyCount,
- count(case when hb_order_status = 30 then 1 end) as deliveryCount,
- count(case when hb_order_status = 40 then 1 end) as shippingCount,
- count(case when hb_order_status = 50 then 1 end) as cancelAuditCount,
- count(case when hb_order_status = 60 then 1 end) as canceledCount,
- count(case when hb_order_status = 70 then 1 end) as arrivedCount,
- count(case when hb_order_status = 80 then 1 end) as completedCount
- FROM tz_order
- <where>
- delete_status = 0
- <if test="orderParam.orderNumber != null and orderParam.orderNumber != ''">
- and o.order_number = #{orderParam.orderNumber}
- </if>
- <if test="orderParam.hbOrderStatus != null">
- and o.hb_order_status = #{orderParam.hbOrderStatus}
- </if>
- <if test="orderParam.dvyType != null">
- and o.dvy_type = #{orderParam.dvyType}
- </if>
- <if test="orderParam.channelId != null">
- and o.channel_id = #{orderParam.channelId}
- </if>
- <if test="orderParam.shopId != null">
- and o.shop_id = #{orderParam.shopId}
- </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.refundStatus == 0">
- and o.refund_status IS NULL
- </if>
- </where>
- </select>
- <select id="deliveryOrder" resultMap="BaseResultMap">
- SELECT o.*, sd.shop_name,ch.channel_name
- FROM tz_order o
- LEFT JOIN tz_shop_detail sd ON o.shop_id = sd.shop_id
- LEFT JOIN tz_channel ch ON o.channel_id = ch.id
- join tz_user_addr_order uao ON o.addr_order_id = uao.addr_order_id
- <where>
- o.delete_status = 0 AND o.dvy_type = #{orderParam.dvyType}
- <if test="orderParam.orderNumber != null and orderParam.orderNumber != ''">
- AND o.order_number LIKE concat('%', #{orderParam.orderNumber}, '%')
- </if>
- <if test="orderParam.mobile != null and orderParam.mobile != ''">
- AND uao.mobile LIKE concat('%', #{orderParam.mobile}, '%')
- </if>
- <if test="orderParam.receiver != null and orderParam.receiver != ''">
- AND uao.receiver LIKE concat('%', #{orderParam.receiver}, '%')
- </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.channelId != null">
- AND o.channel_id = #{orderParam.channelId}
- </if>
- <if test="orderParam.shopId != null">
- AND o.shopId = #{orderParam.shopId}
- </if>
- <if test="orderParam.hbOrderStatus != null">
- <if test="orderParam.hbOrderStatus == 0">
- AND o.hb_order_status = 0
- </if>
- <if test="orderParam.hbOrderStatus == 20">
- AND o.hb_order_status = 20
- </if>
- <if test="orderParam.hbOrderStatus == 70">
- AND o.hb_order_status in (30,40,70)
- </if>
- <if test="orderParam.hbOrderStatus == 80">
- AND o.hb_order_status = 80
- </if>
- <if test="orderParam.hbOrderStatus == 60">
- AND o.hb_order_status in (50, 60)
- </if>
- </if>
- </where>
- ORDER BY o.create_time DESC
- </select>
- <select id="findList" resultMap="BaseResultMap">
- SELECT a.*,b.receiver,b.mobile user_mobile,c.shop_name,d.channel_name FROM tz_order a
- LEFT JOIN tz_user_addr_order b on a.addr_order_id=b.addr_order_id
- LEFT JOIN tz_shop_detail c on a.shop_id=c.shop_id
- LEFT JOIN tz_channel d on a.channel_id=d.id
- <where>
- <if test="orderParam.orderNumber != null and orderParam.orderNumber != ''">
- and a.order_number = #{orderParam.orderNumber}
- </if>
- <if test="orderParam.channelIdList != null and !orderParam.channelIdList.isEmpty()">
- and a.channel_id in
- <foreach collection="orderParam.channelIdList" item="channelId" open="(" close=")" separator=",">
- #{channelId}
- </foreach>
- </if>
- <if test="orderParam.dvyType != null and orderParam.dvyType != ''">
- and a.dvy_type = #{orderParam.dvyType}
- </if>
- <if test="orderParam.shopId != null">
- and a.shop_id = #{orderParam.shopId}
- </if>
- <if test="orderParam.startTime != null">
- and a.create_time > #{orderParam.startTime}
- </if>
- <if test="orderParam.endTime != null">
- and a.create_time < #{orderParam.endTime}
- </if>
- <if test="orderParam.refundStatus != null and orderParam.refundStatus != 0">
- and a.refund_status = #{orderParam.refundStatus}
- </if>
- <if test="orderParam.receiver != null">
- and b.receiver LIKE concat("%",#{orderParam.receiver},"%")
- </if>
- <if test="orderParam.userMobile != null">
- and b.mobile LIKE concat("%",#{orderParam.userMobile},"%")
- </if>
- <if test="orderParam.orderStatus != null and orderParam.orderStatus != ''">
- <if test="orderParam.orderStatus == 'all'">
- AND a.hb_order_status in (0, 1,20,30,40,50,60,70,80)
- </if>
- <if test="orderParam.orderStatus == 'paddingPay'">
- AND a.hb_order_status in (0)
- </if>
- <if test="orderParam.orderStatus == 'paddingShipped'">
- AND a.hb_order_status in (1)
- </if>
- <if test="orderParam.orderStatus == 'paddingReceived'">
- AND a.hb_order_status in (20,30,40,70)
- </if>
- <if test="orderParam.orderStatus == 'completed'">
- AND a.hb_order_status in (80)
- </if>
- <if test="orderParam.orderStatus == 'cancel'">
- AND a.hb_order_status in (50,60)
- </if>
- </if>
- </where>
- order by a.create_time desc,a.order_id desc
- </select>
- </mapper>
|