| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- <?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.cyksj.mapper.OrderDonMapper">
- <update id="updateHasPaymentInterestRealGoods">
- update real_goods_interest_user
- set interest_status = 'hasPayment'
- where id in (select id
- from (select distinct ru.id
- from `real_goods_interest_user` ru
- left join `order_don` od on od.user_id = ru.user_id and od.goods_id = ru.goods_id
- where od.status not in ('close', 'noPayment')
- and ru.interest_status != 'hasPayment') s)
- </update>
- <update id="updateHasPaymentInterestRealGoodsPayTime">
- update real_goods_interest_user ru
- set ru.pay_time= (select if(pay_time is null,created_time,pay_time) from `order_don` od where od.user_id = ru.user_id and od.goods_id = ru.goods_id and od.status not in ('close','noPayment') order by money desc limit 1),
- ru.sku_id = (select sku_id from `order_don` od where od.user_id = ru.user_id and od.goods_id = ru.goods_id and od.status not in ('close','noPayment') order by money desc limit 1)
- where interest_status = 'hasPayment'
- and pay_time is null
- </update>
- <select id="exportOrderInfo" resultType="com.cyksj.model.excel.ExcelOrderDonInfo">
- SELECT o.order_no, o.real_name ,o.price,o.phone,o.source,o.pay_time ,u1.nickname as sharedName,u2.nickname as nickName
- from order_don o LEFT JOIN user u1 on o.shared_id = u1.id
- LEFT JOIN user u2 on o.user_id = u2.id
- where o.promotion_id = #{promotionId,jdbcType=BIGINT}
- and o.status = 'hasPayment'
- <if test="start != null and start != ''">
- and o.pay_time >= #{start,jdbcType=VARCHAR}
- </if>
- <if test="end != null and end != ''">
- and #{end,jdbcType=VARCHAR} >= o.pay_time
- </if>
- </select>
- <select id="getAppleOneOrderDons" resultType="com.cyksj.model.entity.OrderDon">
- select id,sku_id,user_id,money,is_distribute,`type` from `order_don`
- where sku_id in
- <foreach collection="skuIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- and status not in
- <foreach collection="noOrderStatus" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- and created_time between #{yesZeroDate} and #{thisZeroDate}
- </select>
- <select id="selectNoPaymentRealGoods" resultType="com.cyksj.model.entity.RealGoodsInterestUser">
- select s.*
- from (select od.id as orderId,
- od.user_id,
- gd.id as goods_id,
- od.sku_id,
- od.money,
- concat(od.user_id, gd.id) as groupBy,
- od.created_time as orderCreatedTime
- from `order_don` od
- left join `goods_don` gd on gd.id = od.goods_id
- left join `real_goods_interest_user` ru on ru.user_id = od.user_id
- and ru.goods_id = od.goods_id
- where gd.type = 2
- and od.status = 'close'
- and ru.id is null
- group by od.id, od.user_id, gd.id, od.sku_id, od.money, od.created_time) s
- where not EXISTS(
- select id from `order_don` where user_id = s.user_id and goods_id = s.goods_id and status !='close')
- </select>
- <select id="selectPlatBrokenLineMoney" resultType="com.cyksj.model.views.BrokenLineObjView">
- select min(curdate) as firstDate,
- max(curdate) as lastDate
- from (select cast(sum(od.money)/100 as decimal(10,2)) as curdateMoney,
- date_format(od.created_time,'%Y-%m-%d') curdate from order_don od
- where od.status not in ('noPayment','close','refund')
- group by od.goods_id,date_format(od.created_time,'%Y-%m-%d'))s
- where 1 = 1
- <if test="first != null">
- and curdate >= #{first}
- </if>
- <if test="end != null">
- and curdate < #{end}
- </if>
- </select>
- <select id="selectPersonDistributeBrokenLine" resultType="com.cyksj.model.views.BrokenLineObjView">
- select min(curdate) as firstDate,
- max(curdate) as lastDate
- from (select date_format(od.created_time,'%Y-%m-%d') curdate,
- count(od.id) curdateOrderCount
- from distribute_waiting_send_points dw
- left join order_don od on od.id = dw.order_id
- where dw.shared_id = #{userId}
- and od.is_distribute is true
- and dw.send_status not in ('not_exist', 'close')
- group by od.goods_id, date_format(od.created_time, '%Y-%m-%d'))s
- where 1 = 1
- <if test="first != null">
- and curdate >= #{first}
- </if>
- <if test="end != null">
- and curdate < #{end}
- </if>
- </select>
- <select id="selectChannelStatistics" resultType="com.cyksj.model.views.ChannelStatisticsView">
- select min(curdate) as firstDate,
- max(curdate) as lastDate
- from (select cast(sum(od.money)/100 as decimal(10,2)) as curdateMoney,
- date_format(od.created_time,'%Y-%m-%d') curdate from order_don od
- where od.status not in ('noPayment','close','refund')
- group by date_format(od.created_time,'%Y-%m-%d'))s
- where 1 = 1
- <if test="first != null">
- and curdate >= #{first}
- </if>
- <if test="end != null">
- and curdate < #{end}
- </if>
- </select>
- <select id="selectCouponCodeUserNum" resultType="java.lang.Integer">
- select count(distinct user_id) from order_don where ds_popularize_id = #{dsPopularizeId}
- and status not in
- <foreach collection="noOrderAllStatus" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </select>
- <select id="countPopularizeOrderDetail" resultType="com.cyksj.model.views.ChannelPopularizeView">
- select *
- from (select count(*) as orderCount, ifnull(sum(money),0) as orderMoney
- from order_don
- where popularize_id = #{popularizeId}
- <if test="startTime != null and startTime != ''">
- and created_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and created_time < #{endTime}
- </if>
- and status not in ('close', 'noPayment')) s1
- ,
- (select count(*) as refundCount, ifnull(sum(money),0) as refundMoney
- from order_don
- where popularize_id = #{popularizeId}
- <if test="startTime != null and startTime != ''">
- and created_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and created_time < #{endTime}
- </if>
- and status = 'refund')
- s2
- </select>
- <select id="selectThisMonthAppleOneMoney" resultType="java.math.BigDecimal">
- select cast(ifnull((sum(money),0) - ifnull(sum(refund_money),0))/100 as decimal(10,2)) from `order_don` where sku_id in
- <foreach collection="skuIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- and status not in ('close','noPayment') and created_time between #{startDate} and #{endDate}
- </select>
- <select id="selectThisMonthDistributeOrderMoney" resultType="java.math.BigDecimal">
- select cast((ifnull(sum(money),0) - ifnull(sum(refund_money),0))/100 as decimal(10,2)) from `order_don` where sku_id in
- <foreach collection="skuIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- and status not in ('close','noPayment') and is_distribute = 1
- and created_time between #{startDate} and #{endDate}
- </select>
- <select id="getOrderDetailByGoodsType" resultType="java.util.Map">
- select count(id) as orderNum,
- ifnull(sum(money),0) as money
- from order_don where goods_id in (select id from `goods_don` where type = #{type})
- and status not in
- <foreach collection="noOrderStatus" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- <if test="startDate != null">
- and created_time >= #{startDate}
- </if>
- <if test="endDate != null">
- and created_time < #{endDate}
- </if>
- </select>
- <select id="selectYhShopDistributeOrderDetail" resultType="java.util.Map">
- select count(*) as numOfDsOrder,
- ifnull(sum(money),0) as dsMoney
- from `order_don` where yhs_id > 0 and status not in ('close','noPayment','refund')
- <if test="startDate != null">
- and created_time >= #{startDate}
- </if>
- <if test="endDate != null">
- and created_time < #{endDate}
- </if>
- </select>
- </mapper>
|