| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751 |
- <?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.SkuMapper">
- <resultMap id="BaseResultMap" type="com.yami.shop.bean.model.Sku">
- <!--
- WARNING - @mbg.generated
- -->
- <id column="sku_id" jdbcType="BIGINT" property="skuId"/>
- <result column="prod_id" jdbcType="BIGINT" property="prodId"/>
- <result column="properties" jdbcType="VARCHAR" property="properties"/>
- <result column="ori_price" jdbcType="DECIMAL" property="oriPrice"/>
- <result column="price" jdbcType="DECIMAL" property="price"/>
- <result column="stocks" jdbcType="INTEGER" property="stocks"/>
- <result column="actual_stocks" jdbcType="INTEGER" property="actualStocks"/>
- <result column="status" jdbcType="TINYINT" property="status"/>
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
- <result column="rec_time" jdbcType="TIMESTAMP" property="recTime"/>
- <result column="party_code" jdbcType="VARCHAR" property="partyCode"/>
- <result column="model_id" jdbcType="VARCHAR" property="modelId"/>
- <result column="pic" jdbcType="VARCHAR" property="pic"/>
- <result column="sku_name" jdbcType="VARCHAR" property="skuName"/>
- <result column="is_delete" jdbcType="INTEGER" property="isDelete"/>
- </resultMap>
- <insert id="insertBatch">
- INSERT INTO `tz_sku` (
- `prod_id`,`properties`,`ori_price`,`price`,`stocks`,`actual_stocks`,
- `update_time`,`rec_time`,`party_code`,`model_id`, `pic`,
- `sku_name`,`prod_name`,`version`,`weight`,`volume`, `status`, `is_delete`, `sku_score`
- )
- VALUES
- <foreach collection="skuList" item="sku" separator=",">
- (
- #{prodId},#{sku.properties},#{sku.oriPrice},#{sku.price},#{sku.stocks},
- #{sku.actualStocks}, NOW(),NOW(),#{sku.partyCode},#{sku.modelId}, #{sku.pic},
- #{sku.skuName},#{sku.prodName},0,#{sku.weight},#{sku.volume}, #{sku.status},0, #{sku.skuScore}
- )
- </foreach>
- </insert>
- <select id="listByProdId" resultType="com.yami.shop.bean.model.Sku">
- select *
- from tz_sku
- where prod_id = #{prodId}
- and is_delete = 0
- </select>
- <select id="listByProdIdAndPlatform" resultType="com.yami.shop.bean.model.Sku">
- SELECT ts.sku_id,
- ts.prod_id,
- ts.sku_name,
- ts.prod_name,
- ts.ori_price,
- tcp.channel_prod_price AS price,
- ts.sku_score,
- ts.properties,
- ts.stocks,
- tss.shop_sku_stocks AS actual_stocks,
- ts.update_time,
- ts.rec_time,
- ts.party_code,
- ts.model_id,
- ts.pic,
- ts.version,
- ts.weight,
- ts.volume,
- ts.`status`,
- ts.is_delete,
- ts.weight_unit,
- ts.sku_code,
- ts.hb_spu_id,
- ts.hb_sku_id
- FROM tz_shop_sku AS tss
- LEFT JOIN tz_sku AS ts ON ts.sku_id = tss.sku_id
- LEFT JOIN tz_channel_prod AS tcp ON ts.sku_id = tcp.sku_id
- WHERE tss.spu_id = #{prodId}
- AND ts.is_delete = 0
- AND tcp.is_delete = 0
- AND ts.`status` = 1
- AND tss.shop_id = #{shopId}
- AND tcp.channel_id = #{channelId}
- </select>
- <select id="listBySukIdAndPlatformShop" resultType="com.yami.shop.bean.model.Sku">
- SELECT ts.sku_id,
- ts.prod_id,
- ts.sku_name,
- ts.prod_name,
- ts.ori_price,
- tcp.channel_prod_price AS price,
- ts.sku_score,
- ts.properties,
- ts.stocks,
- tss.shop_sku_stocks AS actual_stocks,
- ts.update_time,
- ts.rec_time,
- ts.party_code,
- ts.model_id,
- ts.pic,
- ts.version,
- ts.weight,
- ts.volume,
- ts.`status`,
- ts.is_delete,
- ts.weight_unit,
- ts.sku_code,
- ts.hb_spu_id,
- ts.hb_sku_id
- FROM tz_sku AS ts
- LEFT JOIN tz_shop_sku AS tss ON ts.sku_id = tss.sku_id
- LEFT JOIN tz_channel_prod AS tcp ON ts.sku_id = tcp.sku_id
- WHERE ts.sku_id = #{skuId}
- AND ts.is_delete = 0
- AND tcp.is_delete = 0
- AND ts.`status` = 1
- AND tss.shop_id = #{shopId}
- AND tcp.channel_id = #{channelId}
- LIMIT 1
- </select>
- <select id="listBySukIdAndPlatform" resultType="com.yami.shop.bean.model.Sku">
- SELECT ts.sku_id,
- ts.prod_id,
- ts.sku_name,
- ts.prod_name,
- ts.ori_price,
- tcp.channel_prod_price AS price,
- ts.sku_score,
- ts.properties,
- ts.stocks,
- tss.shop_sku_stocks AS actual_stocks,
- ts.update_time,
- ts.rec_time,
- ts.party_code,
- ts.model_id,
- ts.pic,
- ts.version,
- ts.weight,
- ts.volume,
- ts.`status`,
- ts.is_delete,
- ts.weight_unit,
- ts.sku_code,
- ts.hb_spu_id,
- ts.hb_sku_id
- FROM tz_sku AS ts
- LEFT JOIN tz_shop_sku AS tss ON ts.sku_id = tss.sku_id
- LEFT JOIN tz_channel_prod AS tcp ON ts.sku_id = tcp.sku_id
- WHERE ts.sku_id = #{skuId}
- AND ts.is_delete = 0
- AND tcp.is_delete = 0
- AND ts.`status` = 1
- AND tcp.channel_id = #{channelId} LIMIT 1
- </select>
- <select id="selectByHbSkuId" resultType="com.yami.shop.bean.model.Sku">
- select *
- from tz_sku
- where hb_sku_id = #{hbSkuId}
- and is_delete = 0
- </select>
- <update id="updateStocks" parameterType="com.yami.shop.bean.model.Sku">
- update tz_sku
- set stocks = stocks - #{sku.stocks},
- version = version + 1,
- update_time = NOW()
- where sku_id = #{sku.skuId}
- and #{sku.stocks} <= stocks
- </update>
- <update id="deleteByProdId">
- update tz_sku
- set is_delete = 1
- where prod_id = #{prodId}
- </update>
- <update id="returnStock">
- <foreach collection="skuCollect" item="changeStocks" index="skuId" separator=";">
- update tz_sku set stocks = stocks + #{changeStocks} where sku_id = #{skuId}
- </foreach>
- </update>
- <select id="buyTogetherOften" resultType="com.yami.shop.bean.vo.SkuBuyTogetherOftenVo">
- SELECT a.shop_id,b.sku_id, b.prod_id, b.prod_name, b.pic, c.channel_prod_price, d.shop_sku_stocks,IFNULL(e.basket_count,0) prodCount
- FROM tz_order_item a
- LEFT JOIN tz_sku b on a.sku_id = b.sku_id
- LEFT JOIN tz_channel_prod c on a.sku_id = c.sku_id and c.is_delete = 0
- LEFT JOIN tz_shop_sku d on a.sku_id = d.sku_id and d.is_delete = 0
- LEFT JOIN tz_basket e on a.prod_id=e.prod_id and a.sku_id=e.sku_id and a.shop_id=e.shop_id and e.user_id=#{userId}
- WHERE a.order_number in (SELECT a.order_number FROM tz_order_item a
- LEFT JOIN tz_order b on a.order_number=b.order_number
- WHERE a.prod_id = #{prodId} and a.shop_id = #{shopId} and b.channel_id=#{channelId})
- and a.prod_id!=#{prodId}
- and a.shop_id=#{shopId}
- and b.`status`=1
- and b.is_delete=0
- and d.sale_status=1
- and c.channel_id=#{channelId}
- and c.shop_id=#{shopId}
- GROUP BY a.sku_id
- ORDER BY a.rec_time desc, a.order_item_id desc
- </select>
- <select id="goodsTotalPrice" resultType="Double">
- SELECT (SELECT IFNULL(SUM(IFNULL(a.total,0)) ,0) goods_total_price FROM tz_order a
- LEFT JOIN tz_user e on a.user_id=e.user_id
- WHERE a.is_payed=1
- <if test="po.startTime != null and po.startTime != ''">
- and a.create_time>= #{po.startTime}
- </if>
- <if test="po.endTime != null and po.endTime != ''">
- and a.create_time<= #{po.endTime}
- </if>
- <if test="po.skuId != null or (po.skuName != null and po.skuName != '') or (po.spec != null and po.spec != '')">
- and a.order_number in(SELECT a.order_number FROM tz_order_item a LEFT JOIN tz_sku b on a.sku_id=b.sku_id
- <where>
- <if test="po.skuId != null">
- AND a.sku_id like concat('%',#{po.skuId} ,'%')
- </if>
- <if test="po.skuName != null and po.skuName != ''">
- AND a.sku_name like concat('%',#{po.skuName} ,'%')
- </if>
- <if test="po.spec != null and po.spec != ''">
- AND b.spec like concat('%',#{po.spec} ,'%')
- </if>
- </where>
- )
- </if>
- and a.channel_id in
- <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- <if test="po.userAttrType != null and po.userAttrType != 0">
- AND e.user_attr_type=#{po.userAttrType}
- </if>
- )
- -
- (SELECT IFNULL(SUM(a.sku_price * a.product_count),0)
- FROM `tz_order_refund_sku` a
- LEFT JOIN tz_order_refund b on a.order_refund_id=b.refund_id
- LEFT JOIN tz_order c on b.order_number=c.order_number
- LEFT JOIN tz_sku d on a.sku_id=d.sku_id
- LEFT JOIN tz_user e on b.user_id=e.user_id
- WHERE b.return_money_sts=70
- <if test="po.startTime != null and po.startTime != ''">
- and b.apply_time>= #{po.startTime}
- </if>
- <if test="po.endTime != null and po.endTime != ''">
- and b.apply_time<= #{po.endTime}
- </if>
- and c.channel_id in
- <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- <if test="po.skuId != null">
- AND a.sku_id like concat('%',#{po.skuId} ,'%')
- </if>
- <if test="po.skuName != null and po.skuName != ''">
- AND d.sku_name like concat('%',#{po.skuName} ,'%')
- </if>
- <if test="po.spec != null and po.spec != ''">
- AND d.spec like concat('%',#{po.spec} ,'%')
- </if>
- <if test="po.userAttrType != null and po.userAttrType != 0">
- AND e.user_attr_type=#{po.userAttrType}
- </if>
- ) goods_total_price
- </select>
- <select id="totalPoints" resultType="Double">
- SELECT TRUNCATE(((SELECT SUM(IFNULL(a.offset_points,0)) FROM tz_order a
- LEFT JOIN tz_user e on a.user_id=e.user_id
- WHERE a.is_payed=1
- <if test="po.startTime != null and po.startTime != ''">
- and a.create_time>= #{po.startTime}
- </if>
- <if test="po.endTime != null and po.endTime != ''">
- and a.create_time<= #{po.endTime}
- </if>
- and a.channel_id in
- <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- <if test="po.userAttrType != null and po.userAttrType != 0">
- AND e.user_attr_type=#{po.userAttrType}
- </if>
- <if test="po.skuId != null or (po.skuName != null and po.skuName != '') or (po.spec != null and po.spec != '')">
- and a.order_number in(SELECT a.order_number FROM tz_order_item a LEFT JOIN tz_sku b on a.sku_id=b.sku_id
- <where>
- <if test="po.skuId != null">
- AND a.sku_id like concat('%',#{po.skuId} ,'%')
- </if>
- <if test="po.skuName != null and po.skuName != ''">
- AND a.sku_name like concat('%',#{po.skuName} ,'%')
- </if>
- <if test="po.spec != null and po.spec != ''">
- AND b.spec like concat('%',#{po.spec} ,'%')
- </if>
- </where>
- )
- </if>
- )
- -
- (SELECT IFNULL(SUM( total_offset_points ),0) FROM (SELECT
- CASE
- WHEN refund_type=1 THEN total_offset_points
- ELSE total_offset_points
- END AS total_offset_points
- FROM tz_order_refund a
- LEFT JOIN tz_user e on a.user_id=e.user_id
- LEFT JOIN (SELECT SUM(tor.offset_points) total_offset_points ,tor.order_number
- FROM tz_order_refund tor
- LEFT JOIN tz_user e on tor.user_id=e.user_id
- WHERE tor.return_money_sts=70
- <if test="po.startTime != null and po.startTime != ''">
- and tor.apply_time>= #{po.startTime}
- </if>
- <if test="po.endTime != null and po.endTime != ''">
- and tor.apply_time<= #{po.endTime}
- </if>
- <if test="po.userAttrType != null and po.userAttrType != 0">
- AND e.user_attr_type=#{po.userAttrType}
- </if>
- and tor.order_number in(SELECT ao.order_number FROM tz_order_item ao
- LEFT JOIN tz_sku b on ao.sku_id=b.sku_id
- LEFT JOIN tz_order c on ao.order_number=c.order_number
- <where>
- c.channel_id in
- <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- <if test="po.skuId != null or (po.skuName != null and po.skuName != '') or (po.spec != null and po.spec != '')">
- <if test="po.skuId != null">
- AND ao.sku_id like concat('%',#{po.skuId} ,'%')
- </if>
- <if test="po.skuName != null and po.skuName != ''">
- AND ao.sku_name like concat('%',#{po.skuName} ,'%')
- </if>
- <if test="po.spec != null and po.spec != ''">
- AND b.spec like concat('%',#{po.spec} ,'%')
- </if>
- </if>
- </where>
- )
- GROUP BY tor.order_number) b on a.order_number=b.order_number
- WHERE return_money_sts=70
- <if test="po.startTime != null and po.startTime != ''">
- and apply_time >= #{po.startTime}
- </if>
- <if test="po.endTime != null and po.endTime != ''">
- and apply_time <= #{po.endTime}
- </if>
- <if test="po.userAttrType != null and po.userAttrType != 0">
- AND e.user_attr_type=#{po.userAttrType}
- </if>
- and a.order_number in(SELECT ao2.order_number FROM tz_order_item ao2
- LEFT JOIN tz_sku b on ao2.sku_id=b.sku_id
- LEFT JOIN tz_order c on ao2.order_number=c.order_number
- <where>
- c.channel_id in
- <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- <if test="po.skuId != null or (po.skuName != null and po.skuName != '') or (po.spec != null and po.spec != '')">
- <if test="po.skuId != null">
- AND ao2.sku_id like concat('%',#{po.skuId} ,'%')
- </if>
- <if test="po.skuName != null and po.skuName != ''">
- AND ao2.sku_name like concat('%',#{po.skuName} ,'%')
- </if>
- <if test="po.spec != null and po.spec != ''">
- AND b.spec like concat('%',#{po.spec} ,'%')
- </if>
- </if>
- </where>
- )
- GROUP BY a.order_number) a)) /100,2) total_offset_points
- </select>
- <select id="totalCash" resultType="Double">
- SELECT (SELECT SUM(IFNULL(a.actual_total,0)) FROM tz_order a
- LEFT JOIN tz_user e on a.user_id=e.user_id
- WHERE a.is_payed=1
- <if test="po.startTime != null and po.startTime != ''">
- and a.create_time>= #{po.startTime}
- </if>
- <if test="po.endTime != null and po.endTime != ''">
- and a.create_time<= #{po.endTime}
- </if>
- <if test="po.userAttrType != null and po.userAttrType != 0">
- AND e.user_attr_type=#{po.userAttrType}
- </if>
- and a.channel_id in
- <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- <if test="po.skuId != null or (po.skuName != null and po.skuName != '') or (po.spec != null and po.spec != '')">
- and a.order_number in(SELECT a.order_number FROM tz_order_item a LEFT JOIN tz_sku b on a.sku_id=b.sku_id
- <where>
- <if test="po.skuId != null">
- AND a.sku_id like concat('%',#{po.skuId} ,'%')
- </if>
- <if test="po.skuName != null and po.skuName != ''">
- AND a.sku_name like concat('%',#{po.skuName} ,'%')
- </if>
- <if test="po.spec != null and po.spec != ''">
- AND b.spec like concat('%',#{po.spec} ,'%')
- </if>
- </where>
- )
- </if>
- )
- -
- (SELECT IFNULL(SUM( a.refund_amount ),0) FROM tz_order_refund a
- LEFT JOIN tz_user e on a.user_id=e.user_id
- WHERE a.return_money_sts=70
- <if test="po.startTime != null and po.startTime != ''">
- and a.apply_time>= #{po.startTime}
- </if>
- <if test="po.endTime != null and po.endTime != ''">
- and a.apply_time<= #{po.endTime}
- </if>
- <if test="po.userAttrType != null and po.userAttrType != 0">
- AND e.user_attr_type=#{po.userAttrType}
- </if>
- and a.order_number in(SELECT a.order_number FROM tz_order_item a
- LEFT JOIN tz_sku b on a.sku_id=b.sku_id
- LEFT JOIN tz_order c on a.order_number=c.order_number
- <where>
- c.channel_id in
- <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- <if test="po.skuId != null or (po.skuName != null and po.skuName != '') or (po.spec != null and po.spec != '')">
- <if test="po.skuId != null">
- AND a.sku_id like concat('%',#{po.skuId} ,'%')
- </if>
- <if test="po.skuName != null and po.skuName != ''">
- AND a.sku_name like concat('%',#{po.skuName} ,'%')
- </if>
- <if test="po.spec != null and po.spec != ''">
- AND b.spec like concat('%',#{po.spec} ,'%')
- </if>
- </if>
- </where>
- )) cash
- </select>
- <select id="totalFreight" resultType="Double">
- SELECT (SELECT IFNULL(SUM(a.freight_amount),0) total_freight FROM tz_order a
- LEFT JOIN tz_user e on a.user_id=e.user_id
- WHERE a.is_payed=1
- <if test="po.startTime != null and po.startTime != ''">
- and a.create_time>= #{po.startTime}
- </if>
- <if test="po.endTime != null and po.endTime != ''">
- and a.create_time<= #{po.endTime}
- </if>
- <if test="po.userAttrType != null and po.userAttrType != 0">
- AND e.user_attr_type=#{po.userAttrType}
- </if>
- and a.channel_id in
- <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- <if test="po.skuId != null or (po.skuName != null and po.skuName != '') or (po.spec != null and po.spec != '')">
- and a.order_number in(SELECT a.order_number FROM tz_order_item a LEFT JOIN tz_sku b on a.sku_id=b.sku_id
- <where>
- <if test="po.skuId != null">
- AND a.sku_id like concat('%',#{po.skuId} ,'%')
- </if>
- <if test="po.skuName != null and po.skuName != ''">
- AND a.sku_name like concat('%',#{po.skuName} ,'%')
- </if>
- <if test="po.spec != null and po.spec != ''">
- AND b.spec like concat('%',#{po.spec} ,'%')
- </if>
- </where>
- )
- </if>
- )
- -
- (SELECT IFNULL(SUM(a.freight_amount),0)
- FROM `tz_order_refund` a
- LEFT JOIN tz_user e on a.user_id=e.user_id
- WHERE a.return_money_sts=70
- <if test="po.startTime != null and po.startTime != ''">
- and a.apply_time>= #{po.startTime}
- </if>
- <if test="po.endTime != null and po.endTime != ''">
- and a.apply_time<= #{po.endTime}
- </if>
- <if test="po.userAttrType != null and po.userAttrType != 0">
- AND e.user_attr_type=#{po.userAttrType}
- </if>
- and a.refund_type=1
- and a.order_number in(SELECT a.order_number FROM tz_order_item a
- LEFT JOIN tz_sku b on a.sku_id=b.sku_id
- LEFT JOIN tz_order c on a.order_number=c.order_number
- <where>
- c.channel_id in
- <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- <if test="po.skuId != null or (po.skuName != null and po.skuName != '') or (po.spec != null and po.spec != '')">
- <if test="po.skuId != null">
- AND a.sku_id like concat('%',#{po.skuId} ,'%')
- </if>
- <if test="po.skuName != null and po.skuName != ''">
- AND a.sku_name like concat('%',#{po.skuName} ,'%')
- </if>
- <if test="po.spec != null and po.spec != ''">
- AND b.spec like concat('%',#{po.spec} ,'%')
- </if>
- </if>
- </where>
- ))
- </select>
- <select id="skuStatisticsList" resultType="com.yami.shop.bean.vo.SkuStatisticsVo">
- SELECT a.prod_id,a.sku_id,a.sku_name,c.spec,TRUNCATE(IFNULL(SUM(a.price*a.prod_count)/SUM(a.prod_count),0),2)
- price,IFNULL(SUM(a.prod_count),0)-IFNULL(d.product_count,0) as prod_count,
- TRUNCATE(IFNULL(SUM(a.price*a.prod_count)/SUM(a.prod_count),0),2) *
- (IFNULL(SUM(a.prod_count),0)-IFNULL(d.product_count,0)) total
- FROM tz_order_item a
- LEFT JOIN tz_order b on a.order_number=b.order_number
- LEFT JOIN tz_sku c on a.sku_id=c.sku_id
- LEFT JOIN tz_user e on b.user_id=e.user_id
- LEFT JOIN (SELECT a.sku_id,SUM(a.product_count) product_count
- FROM `tz_order_refund_sku` a
- LEFT JOIN tz_order_refund b on a.order_refund_id=b.refund_id
- LEFT JOIN tz_order c on b.order_number=c.order_number
- LEFT JOIN tz_sku d on a.sku_id=d.sku_id
- LEFT JOIN tz_user e on b.user_id=e.user_id
- WHERE return_money_sts=70
- <if test="po.startTime != null and po.startTime != ''">
- and b.apply_time>= #{po.startTime}
- </if>
- <if test="po.endTime != null and po.endTime != ''">
- and b.apply_time<= #{po.endTime}
- </if>
- and c.channel_id in
- <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- <if test="po.skuId != null">
- AND a.sku_id like concat('%',#{po.skuId} ,'%')
- </if>
- <if test="po.skuName != null and po.skuName != ''">
- AND d.sku_name like concat('%',#{po.skuName} ,'%')
- </if>
- <if test="po.spec != null and po.spec != ''">
- AND d.spec like concat('%',#{po.spec} ,'%')
- </if>
- <if test="po.userAttrType != null and po.userAttrType != 0">
- AND e.user_attr_type=#{po.userAttrType}
- </if>
- GROUP BY a.sku_id) d on a.sku_id = d.sku_id
- WHERE b.is_payed=1
- <if test="po.startTime != null and po.startTime != ''">
- and a.rec_time>= #{po.startTime}
- </if>
- <if test="po.endTime != null and po.endTime != ''">
- and a.rec_time<= #{po.endTime}
- </if>
- and b.channel_id in
- <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- <if test="po.skuId != null">
- AND a.sku_id like concat('%',#{po.skuId} ,'%')
- </if>
- <if test="po.skuName != null and po.skuName != ''">
- AND a.sku_name like concat('%',#{po.skuName} ,'%')
- </if>
- <if test="po.spec != null and po.spec != ''">
- AND c.spec like concat('%',#{po.spec} ,'%')
- </if>
- <if test="po.userAttrType != null and po.userAttrType != 0">
- AND e.user_attr_type=#{po.userAttrType}
- </if>
- GROUP BY a.sku_id HAVING prod_count>0
- </select>
- <select id="skuStatisticsList2" resultType="com.yami.shop.bean.vo.SkuStatisticsVo">
- SELECT a.prod_id,a.sku_id,a.sku_name,c.spec,TRUNCATE(IFNULL(SUM(a.price*a.prod_count)/SUM(a.prod_count),0),2)
- price,IFNULL(SUM(a.prod_count),0)-IFNULL(d.product_count,0) as prod_count,
- TRUNCATE(IFNULL(SUM(a.price*a.prod_count)/SUM(a.prod_count),0),2) *
- (IFNULL(SUM(a.prod_count),0)-IFNULL(d.product_count,0)) total
- FROM tz_order_item a
- LEFT JOIN tz_order b on a.order_number=b.order_number
- LEFT JOIN tz_sku c on a.sku_id=c.sku_id
- LEFT JOIN tz_user e on b.user_id=e.user_id
- LEFT JOIN (SELECT a.sku_id,SUM(a.product_count) product_count
- FROM `tz_order_refund_sku` a
- LEFT JOIN tz_order_refund b on a.order_refund_id=b.refund_id
- LEFT JOIN tz_order c on b.order_number=c.order_number
- LEFT JOIN tz_sku d on a.sku_id=d.sku_id
- LEFT JOIN tz_user e on b.user_id=e.user_id
- WHERE return_money_sts=70
- <if test="po.startTime != null and po.startTime != ''">
- and b.apply_time>= #{po.startTime}
- </if>
- <if test="po.endTime != null and po.endTime != ''">
- and b.apply_time<= #{po.endTime}
- </if>
- and c.channel_id in
- <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- <if test="po.skuId != null">
- AND a.sku_id like concat('%',#{po.skuId} ,'%')
- </if>
- <if test="po.skuName != null and po.skuName != ''">
- AND d.sku_name like concat('%',#{po.skuName} ,'%')
- </if>
- <if test="po.spec != null and po.spec != ''">
- AND d.spec like concat('%',#{po.spec} ,'%')
- </if>
- <if test="po.userAttrType != null and po.userAttrType != 0">
- AND e.user_attr_type=#{po.userAttrType}
- </if>
- GROUP BY a.sku_id) d on a.sku_id = d.sku_id
- WHERE b.is_payed=1
- <if test="po.startTime != null and po.startTime != ''">
- and a.rec_time>= #{po.startTime}
- </if>
- <if test="po.endTime != null and po.endTime != ''">
- and a.rec_time<= #{po.endTime}
- </if>
- and b.channel_id in
- <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- <if test="po.skuId != null">
- AND a.sku_id like concat('%',#{po.skuId} ,'%')
- </if>
- <if test="po.skuName != null and po.skuName != ''">
- AND a.sku_name like concat('%',#{po.skuName} ,'%')
- </if>
- <if test="po.spec != null and po.spec != ''">
- AND c.spec like concat('%',#{po.spec} ,'%')
- </if>
- <if test="po.userAttrType != null and po.userAttrType != 0">
- AND e.user_attr_type=#{po.userAttrType}
- </if>
- GROUP BY a.sku_id HAVING prod_count>0
- </select>
- <select id="freightStatisticsList" resultType="com.yami.shop.bean.vo.FreightStatisticsVo">
- SELECT @row_number := @row_number + 1 AS sort,a.pay_time,CONCAT(b.receiver,' ',b.mobile) receiver,a.dvy_flow_id delivery_no,b.address to_address,a.freight_amount money,a.order_number order_no,
- CASE WHEN a.dvy_type=1 THEN '邮政'
- WHEN a.dvy_type=3 THEN '麦芽田-闪送'
- ELSE
- '其他'
- END delivery
- FROM (SELECT @row_number := 0) sort,
- tz_order a
- LEFT JOIN tz_user_addr_order b on a.addr_order_id =b.addr_order_id
- LEFT JOIN tz_user e on a.user_id=e.user_id
- WHERE a.is_payed=1 and a.hb_order_status not in(0,60)
- and a.channel_id in
- <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- <if test="po.delivery != null">
- and a.dvy_type=#{po.delivery}
- </if>
- <if test="po.receiver != null and po.receiver != ''">
- AND b.receiver like concat('%',#{po.receiver} ,'%')
- </if>
- <if test="po.mobile != null and po.mobile != ''">
- AND b.mobile like concat('%',#{po.mobile} ,'%')
- </if>
- <if test="po.deliveryNo != null and po.deliveryNo != ''">
- AND a.dvy_flow_id like concat('%',#{po.deliveryNo} ,'%')
- </if>
- <if test="po.toAddress != null and po.toAddress != ''">
- AND b.address like concat('%',#{po.toAddress} ,'%')
- </if>
- <if test="po.orderNo != null and po.orderNo != ''">
- AND a.order_number like concat('%',#{po.orderNo} ,'%')
- </if>
- <if test="po.userAttrType != null and po.userAttrType != 0">
- AND e.user_attr_type=#{po.userAttrType}
- </if>
- <if test="po.startTime != null and po.startTime != ''">
- and a.pay_time>= #{po.startTime}
- </if>
- <if test="po.endTime != null and po.endTime != ''">
- and a.pay_time<= #{po.endTime}
- </if>
- </select>
- <select id="freightStatisticsList2" resultType="com.yami.shop.bean.vo.FreightStatisticsVo">
- SELECT @row_number := @row_number + 1 AS sort,a.pay_time,CONCAT(b.receiver,' ',b.mobile) receiver,a.dvy_flow_id delivery_no,b.address to_address,a.freight_amount money,a.order_number order_no,
- CASE WHEN a.dvy_type=1 THEN '邮政'
- WHEN a.dvy_type=3 THEN '麦芽田-闪送'
- ELSE
- '其他'
- END delivery
- FROM (SELECT @row_number := 0) sort,
- tz_order a
- LEFT JOIN tz_user_addr_order b on a.addr_order_id =b.addr_order_id
- LEFT JOIN tz_user e on a.user_id=e.user_id
- WHERE a.is_payed=1 and a.hb_order_status not in(0,60)
- and a.channel_id in
- <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- <if test="po.delivery != null">
- and a.dvy_type=#{po.delivery}
- </if>
- <if test="po.receiver != null and po.receiver != ''">
- AND b.receiver like concat('%',#{po.receiver} ,'%')
- </if>
- <if test="po.mobile != null and po.mobile != ''">
- AND b.mobile like concat('%',#{po.mobile} ,'%')
- </if>
- <if test="po.deliveryNo != null and po.deliveryNo != ''">
- AND a.dvy_flow_id like concat('%',#{po.deliveryNo} ,'%')
- </if>
- <if test="po.toAddress != null and po.toAddress != ''">
- AND b.address like concat('%',#{po.toAddress} ,'%')
- </if>
- <if test="po.orderNo != null and po.orderNo != ''">
- AND a.order_number like concat('%',#{po.orderNo} ,'%')
- </if>
- <if test="po.userAttrType != null and po.userAttrType != 0">
- AND e.user_attr_type=#{po.userAttrType}
- </if>
- <if test="po.startTime != null and po.startTime != ''">
- and a.pay_time>= #{po.startTime}
- </if>
- <if test="po.endTime != null and po.endTime != ''">
- and a.pay_time<= #{po.endTime}
- </if>
- </select>
- </mapper>
|