You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

510 lines
19 KiB

<?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="cc.hiver.mall.dao.mapper.SaleMapper">
<resultMap id="BaseResultMap" type="cc.hiver.mall.entity.Sale">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="del_flag" jdbcType="INTEGER" property="delFlag" />
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="shop_id" jdbcType="VARCHAR" property="shopId" />
<result column="total_amount" jdbcType="DECIMAL" property="totalAmount" />
<result column="discount" jdbcType="DECIMAL" property="discount" />
<result column="discount_amount" jdbcType="DECIMAL" property="discountAmount" />
<result column="real_amount" jdbcType="DECIMAL" property="realAmount" />
<result column="already_earn" jdbcType="DECIMAL" property="alreadyEarn" />
<result column="no_earn" jdbcType="DECIMAL" property="noEarn" />
<result column="pay_status" jdbcType="VARCHAR" property="payStatus" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="transport_type" jdbcType="VARCHAR" property="transportType" />
<result column="share_address" jdbcType="VARCHAR" property="shareAddress" />
<result column="receive_address" jdbcType="VARCHAR" property="receiveAddress" />
<result column="province" jdbcType="VARCHAR" property="province" />
<result column="city" jdbcType="VARCHAR" property="city" />
<result column="area" jdbcType="VARCHAR" property="area" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, create_by, create_time, del_flag, update_by, update_time, user_id, shop_id, total_amount,
discount, discount_amount, real_amount, already_earn, no_earn, pay_status, status,
transport_type, share_address, receive_address, province, city, area
</sql>
<select id="selectByExample" parameterType="cc.hiver.mall.entity.SaleExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from t_sale
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from t_sale
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from t_sale
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="cc.hiver.mall.entity.SaleExample">
delete from t_sale
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="cc.hiver.mall.entity.Sale">
insert into t_sale (id, create_by, create_time,
del_flag, update_by, update_time,
user_id, shop_id, total_amount,
discount, discount_amount, real_amount,
already_earn, no_earn, pay_status,
status, transport_type, share_address,
receive_address, province, city,
area)
values (#{id,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{delFlag,jdbcType=INTEGER}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
#{userId,jdbcType=VARCHAR}, #{shopId,jdbcType=VARCHAR}, #{totalAmount,jdbcType=DECIMAL},
#{discount,jdbcType=DECIMAL}, #{discountAmount,jdbcType=DECIMAL}, #{realAmount,jdbcType=DECIMAL},
#{alreadyEarn,jdbcType=DECIMAL}, #{noEarn,jdbcType=DECIMAL}, #{payStatus,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR}, #{transportType,jdbcType=VARCHAR}, #{shareAddress,jdbcType=VARCHAR},
#{receiveAddress,jdbcType=VARCHAR}, #{province,jdbcType=VARCHAR}, #{city,jdbcType=VARCHAR},
#{area,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="cc.hiver.mall.entity.Sale">
insert into t_sale
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="delFlag != null">
del_flag,
</if>
<if test="updateBy != null">
update_by,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="userId != null">
user_id,
</if>
<if test="shopId != null">
shop_id,
</if>
<if test="totalAmount != null">
total_amount,
</if>
<if test="discount != null">
discount,
</if>
<if test="discountAmount != null">
discount_amount,
</if>
<if test="realAmount != null">
real_amount,
</if>
<if test="alreadyEarn != null">
already_earn,
</if>
<if test="noEarn != null">
no_earn,
</if>
<if test="payStatus != null">
pay_status,
</if>
<if test="status != null">
status,
</if>
<if test="transportType != null">
transport_type,
</if>
<if test="shareAddress != null">
share_address,
</if>
<if test="receiveAddress != null">
receive_address,
</if>
<if test="province != null">
province,
</if>
<if test="city != null">
city,
</if>
<if test="area != null">
area,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="delFlag != null">
#{delFlag,jdbcType=INTEGER},
</if>
<if test="updateBy != null">
#{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="userId != null">
#{userId,jdbcType=VARCHAR},
</if>
<if test="shopId != null">
#{shopId,jdbcType=VARCHAR},
</if>
<if test="totalAmount != null">
#{totalAmount,jdbcType=DECIMAL},
</if>
<if test="discount != null">
#{discount,jdbcType=DECIMAL},
</if>
<if test="discountAmount != null">
#{discountAmount,jdbcType=DECIMAL},
</if>
<if test="realAmount != null">
#{realAmount,jdbcType=DECIMAL},
</if>
<if test="alreadyEarn != null">
#{alreadyEarn,jdbcType=DECIMAL},
</if>
<if test="noEarn != null">
#{noEarn,jdbcType=DECIMAL},
</if>
<if test="payStatus != null">
#{payStatus,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
<if test="transportType != null">
#{transportType,jdbcType=VARCHAR},
</if>
<if test="shareAddress != null">
#{shareAddress,jdbcType=VARCHAR},
</if>
<if test="receiveAddress != null">
#{receiveAddress,jdbcType=VARCHAR},
</if>
<if test="province != null">
#{province,jdbcType=VARCHAR},
</if>
<if test="city != null">
#{city,jdbcType=VARCHAR},
</if>
<if test="area != null">
#{area,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="cc.hiver.mall.entity.SaleExample" resultType="java.lang.Long">
select count(*) from t_sale
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update t_sale
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.createBy != null">
create_by = #{record.createBy,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.delFlag != null">
del_flag = #{record.delFlag,jdbcType=INTEGER},
</if>
<if test="record.updateBy != null">
update_by = #{record.updateBy,jdbcType=VARCHAR},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=VARCHAR},
</if>
<if test="record.shopId != null">
shop_id = #{record.shopId,jdbcType=VARCHAR},
</if>
<if test="record.totalAmount != null">
total_amount = #{record.totalAmount,jdbcType=DECIMAL},
</if>
<if test="record.discount != null">
discount = #{record.discount,jdbcType=DECIMAL},
</if>
<if test="record.discountAmount != null">
discount_amount = #{record.discountAmount,jdbcType=DECIMAL},
</if>
<if test="record.realAmount != null">
real_amount = #{record.realAmount,jdbcType=DECIMAL},
</if>
<if test="record.alreadyEarn != null">
already_earn = #{record.alreadyEarn,jdbcType=DECIMAL},
</if>
<if test="record.noEarn != null">
no_earn = #{record.noEarn,jdbcType=DECIMAL},
</if>
<if test="record.payStatus != null">
pay_status = #{record.payStatus,jdbcType=VARCHAR},
</if>
<if test="record.status != null">
status = #{record.status,jdbcType=VARCHAR},
</if>
<if test="record.transportType != null">
transport_type = #{record.transportType,jdbcType=VARCHAR},
</if>
<if test="record.shareAddress != null">
share_address = #{record.shareAddress,jdbcType=VARCHAR},
</if>
<if test="record.receiveAddress != null">
receive_address = #{record.receiveAddress,jdbcType=VARCHAR},
</if>
<if test="record.province != null">
province = #{record.province,jdbcType=VARCHAR},
</if>
<if test="record.city != null">
city = #{record.city,jdbcType=VARCHAR},
</if>
<if test="record.area != null">
area = #{record.area,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update t_sale
set id = #{record.id,jdbcType=VARCHAR},
create_by = #{record.createBy,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
del_flag = #{record.delFlag,jdbcType=INTEGER},
update_by = #{record.updateBy,jdbcType=VARCHAR},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
user_id = #{record.userId,jdbcType=VARCHAR},
shop_id = #{record.shopId,jdbcType=VARCHAR},
total_amount = #{record.totalAmount,jdbcType=DECIMAL},
discount = #{record.discount,jdbcType=DECIMAL},
discount_amount = #{record.discountAmount,jdbcType=DECIMAL},
real_amount = #{record.realAmount,jdbcType=DECIMAL},
already_earn = #{record.alreadyEarn,jdbcType=DECIMAL},
no_earn = #{record.noEarn,jdbcType=DECIMAL},
pay_status = #{record.payStatus,jdbcType=VARCHAR},
status = #{record.status,jdbcType=VARCHAR},
transport_type = #{record.transportType,jdbcType=VARCHAR},
share_address = #{record.shareAddress,jdbcType=VARCHAR},
receive_address = #{record.receiveAddress,jdbcType=VARCHAR},
province = #{record.province,jdbcType=VARCHAR},
city = #{record.city,jdbcType=VARCHAR},
area = #{record.area,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="cc.hiver.mall.entity.Sale">
update t_sale
<set>
<if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="delFlag != null">
del_flag = #{delFlag,jdbcType=INTEGER},
</if>
<if test="updateBy != null">
update_by = #{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="userId != null">
user_id = #{userId,jdbcType=VARCHAR},
</if>
<if test="shopId != null">
shop_id = #{shopId,jdbcType=VARCHAR},
</if>
<if test="totalAmount != null">
total_amount = #{totalAmount,jdbcType=DECIMAL},
</if>
<if test="discount != null">
discount = #{discount,jdbcType=DECIMAL},
</if>
<if test="discountAmount != null">
discount_amount = #{discountAmount,jdbcType=DECIMAL},
</if>
<if test="realAmount != null">
real_amount = #{realAmount,jdbcType=DECIMAL},
</if>
<if test="alreadyEarn != null">
already_earn = #{alreadyEarn,jdbcType=DECIMAL},
</if>
<if test="noEarn != null">
no_earn = #{noEarn,jdbcType=DECIMAL},
</if>
<if test="payStatus != null">
pay_status = #{payStatus,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=VARCHAR},
</if>
<if test="transportType != null">
transport_type = #{transportType,jdbcType=VARCHAR},
</if>
<if test="shareAddress != null">
share_address = #{shareAddress,jdbcType=VARCHAR},
</if>
<if test="receiveAddress != null">
receive_address = #{receiveAddress,jdbcType=VARCHAR},
</if>
<if test="province != null">
province = #{province,jdbcType=VARCHAR},
</if>
<if test="city != null">
city = #{city,jdbcType=VARCHAR},
</if>
<if test="area != null">
area = #{area,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="cc.hiver.mall.entity.Sale">
update t_sale
set create_by = #{createBy,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
del_flag = #{delFlag,jdbcType=INTEGER},
update_by = #{updateBy,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=TIMESTAMP},
user_id = #{userId,jdbcType=VARCHAR},
shop_id = #{shopId,jdbcType=VARCHAR},
total_amount = #{totalAmount,jdbcType=DECIMAL},
discount = #{discount,jdbcType=DECIMAL},
discount_amount = #{discountAmount,jdbcType=DECIMAL},
real_amount = #{realAmount,jdbcType=DECIMAL},
already_earn = #{alreadyEarn,jdbcType=DECIMAL},
no_earn = #{noEarn,jdbcType=DECIMAL},
pay_status = #{payStatus,jdbcType=VARCHAR},
status = #{status,jdbcType=VARCHAR},
transport_type = #{transportType,jdbcType=VARCHAR},
share_address = #{shareAddress,jdbcType=VARCHAR},
receive_address = #{receiveAddress,jdbcType=VARCHAR},
province = #{province,jdbcType=VARCHAR},
city = #{city,jdbcType=VARCHAR},
area = #{area,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<select id="saleSumAndCount" parameterType="cc.hiver.mall.entity.SaleExample" resultType="cc.hiver.mall.pojo.vo.SaleAllVO">
select IFNULL(Sum(real_amount),0) as totalAmount,count(1) as totalCount,IFNULL(SUM(product_count),0) as totalJCount from t_sale
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<select id="saleMaxAmount" parameterType="cc.hiver.mall.entity.SaleExample" resultType="cc.hiver.mall.pojo.vo.SaleAllVO">
select max(IFNULL(t.real_amount,0)-IFNULL(t1.real_amount,0)) as oneHighPrice from t_sale t left join t_return_sale t1 on t.id =t1.sale_id
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<select id="saleSumProfit" parameterType="cc.hiver.mall.entity.SaleExample" resultType="cc.hiver.mall.pojo.vo.SaleAllVO">
select IFNULL(purchasePrice,0)* IFNULL(real_amount,0) as oneHighPrice from t_sale
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<select id="getShopRevenue" parameterType="cc.hiver.mall.pojo.vo.QueryShopRevenueVO" resultType="cc.hiver.mall.pojo.dto.ShopRevenue">
select DATE_FORMAT(create_time, '%Y-%m-%d') dt,sum(real_amount) real_amount
from t_sale
where 1=1
and create_time &gt;= #{startDate,jdbcType=TIMESTAMP}
and create_time &lt;= #{endDate,jdbcType=TIMESTAMP}
and shop_id = #{shopId,jdbcType=VARCHAR}
group by DATE_FORMAT(create_time, '%Y-%m-%d')
</select>
</mapper>