| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- <?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.gree.mall.manager.commonmapper.OrderMapper">
- <select id="selectByQueryMsg" resultType="com.gree.mall.manager.bean.order.OrderDetailListBean">
- select
- o.order_id as orderId,
- od.goods_name as goodsName,
- CONCAT(od.goods_spec_name,'(',od.goods_spec_value,')') as goodsSpecValue,
- od.num as num,
- od.price as price,
- od.pay_amount as payAmount,
- od.work_order_type,
- o.rece_user_name as receUserName,
- o.rece_phone as recePhone,
- CONCAT(o.province,o.city,o.area,o.street,o.rece_address,o.house_no) as address,
- o.order_status as orderStatus,
- o.refund_flag as refundFlag,
- od.refund_amount as refundAmount,
- od.refund_num as refundNum,
- o.remark as remark,
- o.create_time as createTime,
- o.pay_time,
- o.user_name as userName,
- o.worker_name as workerName,
- o.buyer_msg as buyerMsg,
- o.remark as remark,
- o.websit_name as websitName,
- CONCAT( o.worker_name,'/',o.websit_name) as workerNameWithWebsitName,
- od.share_amount as shareAmount ,
- u.nick_name as nickName,
- u.mobile as mobile,
- o.promotion_group_id as promotionGroupId,
- GROUP_CONCAT(odr.worker_order_no) workerOrderNo,
- o.comment_goods as commentGoods,
- o.comment_service as commentService,
- o.comment_express as commentExpress,
- o.worker_phone,
- o.promotion_package_goods,
- gs.goods_code,
- o.is_add_corp
- from order_detail od
- join order_info o on od.order_id = o.order_id
- left join goods_spec gs on gs.goods_spec_id = od.goods_spec_id
- LEFT join `user` u on o.promotion_group_user_id=u.user_id
- LEFT JOIN order_request odr on odr.order_id=o.order_id
- <where>
- <if test="userId != null and userId != ''">
- and o.user_id=#{userId}
- </if>
- <if test="orderId != null and orderId != ''">
- and o.order_id like CONCAT('%',#{orderId},'%')
- </if>
- <if test="productName != null and productName != ''">
- and o.order_title like CONCAT('%',#{productName},'%')
- </if>
- <if test="userName != null and userName != ''">
- and (o.rece_user_name like CONCAT('%',#{userName},'%') or o.user_name like CONCAT('%',#{userName},'%') )
- </if>
- <if test="phone != null and phone != ''">
- and (o.phone like CONCAT('%',#{phone},'%') or o.rece_phone like CONCAT('%',#{phone},'%') or o.worker_phone like CONCAT('%',#{phone},'%'))
- </if>
- <if test="exchangeCode != null and exchangeCode != ''">
- and o.exchange_code like CONCAT('%',#{exchangeCode},'%')
- </if>
- <if test="orderStatus != null and orderStatus != ''">
- and o.order_status = #{orderStatus}
- </if>
- <if test="orderStatus != null and orderStatus=='DFH'">
- and od.refund_num = 0
- </if>
- <if test="startCreateTime != null and startCreateTime != '' and endCreateTime != null and endCreateTime != ''">
- and (o.create_time between #{startCreateTime} and #{endCreateTime})
- </if>
- <if test="startPayTime != null and startPayTime != '' and endPayTime != null and endPayTime != ''">
- and (o.pay_time between #{startPayTime} and #{endPayTime})
- </if>
- <if test="promotionGroupId != null and promotionGroupId != ''">
- and o.promotion_group_id=#{promotionGroupId}
- </if>
- <if test="promotionGroupUserId != null and promotionGroupUserId != ''">
- and o.promotion_group_user_id=#{promotionGroupUserId}
- </if>
- <if test="promotionFullPieceId != null and promotionFullPieceId !=''">
- and o.promotion_full_piece_id=#{promotionFullPieceId}
- </if>
- <if test="websitId != null and websitId !=''">
- and o.websit_id = #{websitId}
- </if>
- <if test="goodsId != null and goodsId !=''">
- and o.promotion_package_goods_id = #{goodsId}
- </if>
- <if test="companyWechatIds != null and companyWechatIds.size > 0">
- and o.company_wechat_id in
- <foreach item="item" index="index" collection="companyWechatIds" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="websitIds != null and websitIds.size > 0">
- and o.websit_id in
- <foreach item="item" index="index" collection="websitIds" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- GROUP BY od.order_detail_id
- order by o.create_time desc
- </select>
- <select id="abnormalDispatchOrder" resultType="com.gree.mall.manager.plus.entity.OrderInfo">
- SELECT DISTINCT * from (
- SELECT o.*
- from order_detail od
- LEFT JOIN order_info o on od.order_id=o.order_id
- LEFT JOIN order_request oq on oq.order_id=o.order_id
- WHERE o.work_order=1 and od.work_order_type='REPAIR' AND oq.order_request_id is NULL and (o.order_status='YFH' or o.order_status='OVER')
- UNION
- SELECT o.*
- from order_detail od
- LEFT JOIN order_info o on od.order_id=o.order_id
- LEFT JOIN order_request oq on oq.order_id=o.order_id
- WHERE o.work_order=1 and od.work_order_type='INSTALL' AND oq.order_request_id is NULL and o.order_status='OVER'
- ) a
- <where>
- <if test="userId != null and userId != ''">
- and user_id=#{userId}
- </if>
- <if test="orderId != null and orderId != ''">
- and order_id like CONCAT('%',#{orderId},'%')
- </if>
- <if test="productName != null and productName != ''">
- and order_title like CONCAT('%',#{productName},'%')
- </if>
- <if test="userName != null and userName != ''">
- and (rece_user_name like CONCAT('%',#{userName},'%') or user_name like CONCAT('%',#{userName},'%') )
- </if>
- <if test="phone != null and phone != ''">
- and (phone like CONCAT('%',#{phone},'%') or rece_phone like CONCAT('%',#{phone},'%') or worker_phone like CONCAT('%',#{phone},'%'))
- </if>
- <if test="exchangeCode != null and exchangeCode != ''">
- and exchange_code like CONCAT('%',#{exchangeCode},'%')
- </if>
- <if test="orderStatus != null and orderStatus != ''">
- and order_status = #{orderStatus}
- </if>
- <if test="startCreateTime != null and startCreateTime != '' and endCreateTime != null and endCreateTime != ''">
- and (create_time between #{startCreateTime} and #{endCreateTime})
- </if>
- <if test="startPayTime != null and startPayTime != '' and endPayTime != null and endPayTime != ''">
- and (pay_time between #{startPayTime} and #{endPayTime})
- </if>
- <if test="isNegative == '2'.toString()">
- and comment_express > 2 and comment_service > 2 and comment_goods > 2
- </if>
- <if test="isNegative == '0'.toString()">
- and comment_express = 0 and comment_service = 0 and comment_goods = 0
- </if>
- <if test="isNegative == '1'.toString()">
- and (comment_express > 0 and comment_service > 0 and comment_goods > 0
- and (
- comment_express < 3 or comment_service < 3 or comment_goods < 3
- )
- )
- </if>
- <if test="isNegative == '3'.toString()">
- and comment_express > 0 and comment_service > 0 and comment_goods > 0
- </if>
- <if test="companyWechatIds != null and companyWechatIds.size > 0">
- and company_wechat_id in
- <foreach item="item" index="index" collection="companyWechatIds" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="websitIds != null and websitIds.size > 0">
- and websit_id in
- <foreach item="item" index="index" collection="websitIds" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- order by create_time desc
- </select>
- <select id="orderDelivery" resultType="com.gree.mall.manager.bean.order.OrderDeliveryVO">
- SELECT
- ${ex.selected}
- FROM order_delivery a
- ${ex.query}
- <if test="companyWechatIds != null and companyWechatIds.size > 0">
- AND a.company_wechat_id IN
- <foreach item="item" index="index" collection="companyWechatIds" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="storageIds != null and storageIds.size > 0">
- AND a.storage_stock_id IN
- <foreach item="item" index="index" collection="storageIds" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="ex.orderBy == null or ex.orderBy ==''">
- ORDER BY a.create_time DESC
- </if>
- ${ex.orderBy}
- </select>
- <select id="statusCount" resultType="com.gree.mall.manager.bean.order.OrderStatusCountBean">
- SELECT
- SUM(IF(a.order_status = 'DQR', 1, 0)) AS 'dqr',
- SUM(IF(a.order_status = 'DJH', 1, 0)) AS 'djh',
- SUM(IF(a.order_status = 'JHZ', 1, 0)) AS 'jhz',
- SUM(IF(a.order_status = 'DFH', 1, 0)) AS 'dfh',
- SUM(IF(a.order_status = 'DPS', 1, 0)) AS 'dps',
- SUM(IF(a.order_status = 'PSDQ', 1, 0)) AS 'psdq',
- SUM(IF(a.order_status = 'PSZ', 1, 0)) AS 'psz',
- SUM(IF(a.order_status = 'DTK', 1, 0)) AS 'dtk'
- FROM
- order_info a
- WHERE
- a.order_status IN ('DQR', 'DJH', 'JHZ', 'DFH', 'DPS', 'PSDQ', 'PSZ', 'DTK')
- <if test="companyWechatIds != null and companyWechatIds.size > 0">
- AND a.company_wechat_id in
- <foreach item="item" index="index" collection="companyWechatIds" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="storageIds != null and storageIds.size > 0">
- AND a.pick_storage_id in
- <foreach item="item" index="index" collection="storageIds" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </select>
- </mapper>
|