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.
1602 lines
62 KiB
1602 lines
62 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_by_name" jdbcType="VARCHAR" property="createByName" />
|
|
<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_by_name" jdbcType="VARCHAR" property="updateByName" />
|
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
|
<result column="user_id" jdbcType="VARCHAR" property="userId" />
|
|
<result column="user_name" jdbcType="VARCHAR" property="userName" />
|
|
<result column="shop_id" jdbcType="VARCHAR" property="shopId" />
|
|
<result column="shop_name" jdbcType="VARCHAR" property="shopName" />
|
|
<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="debt_deduction_amount" jdbcType="DECIMAL" property="debtDeductionAmount" />
|
|
<result column="sale_deduction_amount" jdbcType="DECIMAL" property="saleDeductionAmount" />
|
|
<result column="balance_deduction_amount" jdbcType="DECIMAL" property="balanceDeductionAmount" />
|
|
<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="pay_type" jdbcType="VARCHAR" property="payType" />
|
|
<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" />
|
|
<result column="sale_name" jdbcType="VARCHAR" property="saleName" />
|
|
<result column="remark" jdbcType="VARCHAR" property="remark" />
|
|
<result column="other_expense" jdbcType="VARCHAR" property="otherExpense" />
|
|
<result column="trans_company" jdbcType="VARCHAR" property="transCompany" />
|
|
<result column="company_name" jdbcType="VARCHAR" property="companyName" />
|
|
<result column="company_phone" jdbcType="VARCHAR" property="companyPhone" />
|
|
<result column="product_count" jdbcType="INTEGER" property="productCount" />
|
|
<result column="create_by_phone" jdbcType="VARCHAR" property="createByPhone" />
|
|
<result column="mode_of_service" jdbcType="VARCHAR" property="modeOfService" />
|
|
|
|
<result column="ai_flag" jdbcType="INTEGER" property="aiFlag" />
|
|
<result column="ai_result" jdbcType="VARCHAR" property="aiResult" />
|
|
<result column="ai_not_recognition" jdbcType="VARCHAR" property="aiNotRecognition" />
|
|
<result column="print_count" jdbcType="INTEGER" property="printCount" />
|
|
<result column="distribution_flag" jdbcType="VARCHAR" property="distributionFlag" />
|
|
</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_by_name, create_time, del_flag, update_by, update_by_name, update_time, user_id, user_name, shop_id, shop_name, total_amount, discount,
|
|
discount_amount, real_amount, debt_deduction_amount, sale_deduction_amount, balance_deduction_amount, already_earn, no_earn, pay_status,pay_type, status, other_expense, transport_type, share_address, receive_address, province, city, area,
|
|
trans_company, company_name, product_count, remark, sale_name, company_phone, create_by_phone,mode_of_service,ai_flag,ai_result,ai_not_recognition,print_count,distribution_flag
|
|
|
|
</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_by_name, create_time,
|
|
del_flag, update_by,update_by_name, update_time,
|
|
user_id,user_name, shop_id,shop_name, total_amount,
|
|
discount, discount_amount, real_amount, debt_deduction_amount, sale_deduction_amount, balance_deduction_amount,
|
|
already_earn, no_earn, pay_status,pay_type,
|
|
status, transport_type, share_address,
|
|
receive_address, province, city,
|
|
area,sale_name,remark,other_expense,trans_company,company_name,company_phone,product_count,create_by_phone,mode_of_service,ai_flag,ai_result,ai_not_recognition,print_count,distribution_flag)
|
|
values (#{id,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR},#{createByName,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
|
|
#{delFlag,jdbcType=INTEGER}, #{updateBy,jdbcType=VARCHAR},#{updateByName,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
|
|
#{userId,jdbcType=VARCHAR},#{userName,jdbcType=VARCHAR}, #{shopId,jdbcType=VARCHAR},#{shopName,jdbcType=VARCHAR}, #{totalAmount,jdbcType=DECIMAL},
|
|
#{discount,jdbcType=DECIMAL}, #{discountAmount,jdbcType=DECIMAL}, #{realAmount,jdbcType=DECIMAL},
|
|
#{debtDeductionAmount,jdbcType=DECIMAL}, #{saleDeductionAmount,jdbcType=DECIMAL},#{balanceDeductionAmount,jdbcType=DECIMAL},
|
|
#{alreadyEarn,jdbcType=DECIMAL}, #{noEarn,jdbcType=DECIMAL}, #{payStatus,jdbcType=VARCHAR}, #{payType,jdbcType=VARCHAR},
|
|
#{status,jdbcType=VARCHAR}, #{transportType,jdbcType=VARCHAR}, #{shareAddress,jdbcType=VARCHAR},
|
|
#{receiveAddress,jdbcType=VARCHAR}, #{province,jdbcType=VARCHAR}, #{city,jdbcType=VARCHAR},
|
|
#{area,jdbcType=VARCHAR}, #{saleName,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR},
|
|
#{otherExpense,jdbcType=VARCHAR},#{transCompany,jdbcType=VARCHAR},#{companyName,jdbcType=VARCHAR},#{companyPhone,jdbcType=VARCHAR},
|
|
#{productCount,jdbcType=INTEGER},#{createByPhone,jdbcType=VARCHAR},#{modeOfService,jdbcType=VARCHAR},
|
|
#{aiFlag,jdbcType=VARCHAR},#{aiResult,jdbcType=VARCHAR},#{aiNotRecognition,jdbcType=VARCHAR},#{printCount,jdbcType=INTEGER},#{distributionFlag,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="userName != null">
|
|
user_name,
|
|
</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="debtDeductionAmount != null">
|
|
debt_deduction_amount,
|
|
</if>
|
|
<if test="saleDeductionAmount != null">
|
|
sale_deduction_amount,
|
|
</if>
|
|
<if test="balanceDeductionAmount != null">
|
|
balance_deduction_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="payType != null">
|
|
pay_type,
|
|
</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>
|
|
<if test="otherExpense != null">
|
|
other_expense,
|
|
</if>
|
|
<if test="transCompany != null">
|
|
trans_company,
|
|
</if>
|
|
<if test="companyName != null">
|
|
company_name,
|
|
</if>
|
|
<if test="companyPhone != null">
|
|
company_phone,
|
|
</if>
|
|
<if test="productCount != null">
|
|
product_count,
|
|
</if>
|
|
<if test="createByPhone != null">
|
|
create_by_phone,
|
|
</if>
|
|
<if test="modeOfService != null">
|
|
mode_of_service,
|
|
</if>
|
|
<if test="aiFlag != null">
|
|
ai_flag,
|
|
</if>
|
|
<if test="aiResult != null">
|
|
ai_result,
|
|
</if>
|
|
<if test="aiNotRecognition != null">
|
|
ai_not_recognition,
|
|
</if>
|
|
<if test="printCount != null">
|
|
print_count,
|
|
</if>
|
|
<if test="distributionFlag != null">
|
|
distribution_flag,
|
|
</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="userName != null">
|
|
#{userName,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="debtDeductionAmount != null">
|
|
#{debtDeductionAmount,jdbcType=DECIMAL},
|
|
</if>
|
|
<if test="saleDeductionAmount != null">
|
|
#{saleDeductionAmount,jdbcType=DECIMAL},
|
|
</if>
|
|
<if test="balanceDeductionAmount != null">
|
|
#{balanceDeductionAmount,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>
|
|
<if test="otherExpense != null">
|
|
#{otherExpense,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="transCompany != null">
|
|
#{transCompany,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="companyName != null">
|
|
#{companyName,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="companyPhone != null">
|
|
#{companyPhone,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="productCount != null">
|
|
#{productCount,jdbcType=INTEGER},
|
|
</if>
|
|
<if test="createByPhone != null">
|
|
#{createByPhone,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="modeOfService != null">
|
|
#{modeOfService,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="aiFlag != null">
|
|
#{aiFlag,jdbcType=INTEGER},
|
|
</if>
|
|
<if test="aiResult != null">
|
|
#{aiResult,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="aiNotRecognition != null">
|
|
#{aiNotRecognition,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="printCount != null">
|
|
#{printCount,jdbcType=INTEGER},
|
|
</if>
|
|
<if test="distributionFlag != null">
|
|
#{distributionFlag,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.userName != null">
|
|
user_name = #{record.userName,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.debtDeductionAmount != null">
|
|
debt_deduction_amount = #{record.debtDeductionAmount,jdbcType=DECIMAL},
|
|
</if>
|
|
<if test="record.saleDeductionAmount != null">
|
|
sale_deduction_amount = #{record.saleDeductionAmount,jdbcType=DECIMAL},
|
|
</if>
|
|
<if test="record.balanceDeductionAmount != null">
|
|
balance_deduction_amount = #{record.balanceDeductionAmount,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.payType != null">
|
|
pay_type = #{record.payType,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>
|
|
<if test="record.otherExpense != null">
|
|
other_expense = #{record.otherExpense,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="record.transCompany != null">
|
|
trans_company = #{record.transCompany,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="record.companyName != null">
|
|
company_name = #{record.companyName,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="record.companyPhone != null">
|
|
company_phone = #{record.companyPhone,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="record.productCount != null">
|
|
product_count = #{record.productCount,jdbcType=INTEGER},
|
|
</if>
|
|
<if test="record.createByPhone != null">
|
|
create_by_phone = #{record.createByPhone,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="record.modeOfService != null">
|
|
mode_of_service = #{record.modeOfService,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="record.aiFlag != null">
|
|
ai_flag = #{record.aiFlag,jdbcType=INTEGER},
|
|
</if>
|
|
<if test="record.aiResult != null">
|
|
ai_result = #{record.aiResult,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="record.aiNotRecognition != null">
|
|
ai_not_recognition = #{record.aiNotRecognition,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="record.printCount != null">
|
|
print_count = #{record.printCount,jdbcType=INTEGER},
|
|
</if>
|
|
<if test="record.distributionFlag != null">
|
|
distribution_flag = #{record.distributionFlag,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},
|
|
user_name = #{record.userName,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},
|
|
debt_deduction_amount = #{record.debtDeductionAmount,jdbcType=DECIMAL},
|
|
sale_deduction_amount = #{record.saleDeductionAmount,jdbcType=DECIMAL},
|
|
balance_deduction_amount = #{record.balanceDeductionAmount,jdbcType=DECIMAL},
|
|
already_earn = #{record.alreadyEarn,jdbcType=DECIMAL},
|
|
no_earn = #{record.noEarn,jdbcType=DECIMAL},
|
|
pay_status = #{record.payStatus,jdbcType=VARCHAR},
|
|
pay_type = #{record.payType,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},
|
|
other_expense = #{record.otherExpense,jdbcType=VARCHAR},
|
|
trans_company = #{record.transCompany,jdbcType=VARCHAR},
|
|
company_name = #{record.companyName,jdbcType=VARCHAR},
|
|
company_phone = #{record.companyPhone,jdbcType=VARCHAR},
|
|
product_count = #{record.productCount,jdbcType=INTEGER},
|
|
create_by_phone = #{record.createByPhone,jdbcType=VARCHAR},
|
|
mode_of_service = #{record.modeOfService,jdbcType=VARCHAR},
|
|
ai_flag = #{record.aiFlag,jdbcType=INTEGER},
|
|
ai_result = #{record.aiResult,jdbcType=VARCHAR},
|
|
ai_not_recognition = #{record.aiNotRecognition,jdbcType=VARCHAR},
|
|
print_count = #{record.printCount,jdbcType=INTEGER},
|
|
distribution_flag = #{record.distributionFlag,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="userName != null">
|
|
user_name = #{userName,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="debtDeductionAmount != null">
|
|
debt_deduction_amount = #{debtDeductionAmount,jdbcType=DECIMAL},
|
|
</if>
|
|
<if test="saleDeductionAmount != null">
|
|
sale_deduction_amount = #{saleDeductionAmount,jdbcType=DECIMAL},
|
|
</if>
|
|
<if test="balanceDeductionAmount != null">
|
|
balance_deduction_amount = #{balanceDeductionAmount,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="payType != null">
|
|
pay_type = #{payType,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>
|
|
<if test="otherExpense != null">
|
|
other_expense = #{otherExpense,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="transCompany != null">
|
|
trans_company = #{transCompany,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="companyName != null">
|
|
company_name = #{companyName,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="companyPhone != null">
|
|
company_phone = #{companyPhone,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="productCount != null">
|
|
product_count = #{productCount,jdbcType=INTEGER},
|
|
</if>
|
|
<if test="createByPhone != null">
|
|
create_by_phone = #{createByPhone,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="modeOfService != null">
|
|
mode_of_service = #{modeOfService,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="aiFlag != null">
|
|
ai_flag = #{aiFlag,jdbcType=INTEGER},
|
|
</if>
|
|
<if test="aiResult != null">
|
|
ai_result = #{aiResult,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="aiNotRecognition != null">
|
|
ai_not_recognition = #{aiNotRecognition,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="printCount != null">
|
|
print_count = #{printCount,jdbcType=INTEGER},
|
|
</if>
|
|
<if test="distributionFlag != null">
|
|
distribution_flag = #{distributionFlag,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},
|
|
user_name = #{userName,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},
|
|
debt_deduction_amount = #{debtDeductionAmount,jdbcType=DECIMAL},
|
|
sale_deduction_amount = #{saleDeductionAmount,jdbcType=DECIMAL},
|
|
balance_deduction_amount = #{balanceDeductionAmount,jdbcType=DECIMAL},
|
|
already_earn = #{alreadyEarn,jdbcType=DECIMAL},
|
|
no_earn = #{noEarn,jdbcType=DECIMAL},
|
|
pay_status = #{payStatus,jdbcType=VARCHAR},
|
|
pay_type = #{payType,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},
|
|
other_expense = #{otherExpense,jdbcType=VARCHAR},
|
|
trans_company = #{transCompany,jdbcType=VARCHAR},
|
|
company_name = #{companyName,jdbcType=VARCHAR},
|
|
company_phone = #{companyPhone,jdbcType=VARCHAR},
|
|
product_count = #{productCount,jdbcType=INTEGER},
|
|
create_by_phone = #{createByPhone,jdbcType=VARCHAR},
|
|
mode_of_service = #{modeOfService,jdbcType=VARCHAR},
|
|
ai_flag = #{aiFlag,jdbcType=INTEGER},
|
|
ai_result = #{aiResult,jdbcType=VARCHAR},
|
|
ai_not_recognition = #{aiNotRecognition,jdbcType=VARCHAR},
|
|
print_count = #{printCount,jdbcType=INTEGER},
|
|
distribution_flag = #{distributionFlag,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(total_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 >= #{startDate,jdbcType=TIMESTAMP}
|
|
and create_time <= #{endDate,jdbcType=TIMESTAMP}
|
|
and shop_id = #{shopId,jdbcType=VARCHAR}
|
|
group by DATE_FORMAT(create_time, '%Y-%m-%d')
|
|
</select>
|
|
|
|
<!--获取当前的销售单-->
|
|
<select id="getSaleId" parameterType="java.lang.String" resultType="java.lang.String">
|
|
select
|
|
sale_id
|
|
from t_sale
|
|
where sale_id = #{id,jdbcType=VARCHAR}
|
|
</select>
|
|
|
|
<select id="getSaleListByProductId" resultMap="BaseResultMap">
|
|
select
|
|
ts.id,ts.create_by,ts.create_by_name,ts.create_time,ts.del_flag,ts.update_by,ts.update_by_name,ts.update_time,ts.user_id,ts.user_name,
|
|
ts.shop_id,ts.shop_name,ts.total_amount,ts.discount,ts.discount_amount,ts.real_amount,ts.debt_deduction_amount,ts.sale_deduction_amount,ts.balance_deduction_amount ,ts.already_earn,ts.no_earn,ts.pay_status,
|
|
ts.pay_type,ts.status,ts.other_expense,ts.transport_type,ts.share_address,ts.receive_address,ts.province,ts.city,ts.area,
|
|
ts.trans_company,ts.company_name,ts.product_count,ts.remark,ts.sale_name,ts.company_phone,ts.create_by_phone,ts.mode_of_service,
|
|
ts.ai_flag,ts.ai_result,ts.ai_not_recognition,ts.print_count,ts.distribution_flag,
|
|
ss.return_sale_product_count,ss.return_sale_amount
|
|
from
|
|
t_sale ts
|
|
left join (
|
|
select
|
|
sale_id,
|
|
sum( trs.product_count ) as return_sale_product_count,
|
|
sum( trs.total_amount ) as return_sale_amount
|
|
from
|
|
t_return_sale trs
|
|
where
|
|
trs.sale_id in ( select sale_id from t_sale_detail where product_id = #{productId} )
|
|
group by
|
|
trs.sale_id
|
|
) ss on ts.id = ss.sale_id
|
|
where
|
|
ts.id in ( select sale_id from t_sale_detail where product_id = #{productId} )
|
|
and ts.status not in ( '2', '6', '7' )
|
|
order by
|
|
ts.create_time desc
|
|
</select>
|
|
|
|
<select id="getSalesRankingByShopId" resultType="cc.hiver.mall.pojo.vo.SalesRankingVo">
|
|
SELECT
|
|
create_by,create_by_name,count(*) as totalCount,sum( total_amount ) as totalPrice
|
|
FROM
|
|
t_sale
|
|
<where>
|
|
and shop_id = #{salesRankingQueryCriteria.shopId}
|
|
<!--不包含挂单及待配货的-->
|
|
and status = '4'
|
|
<!--时间查询-->
|
|
<if test='salesRankingQueryCriteria.startTime!=null'>
|
|
and create_time BETWEEN #{salesRankingQueryCriteria.startTime} AND #{salesRankingQueryCriteria.endTime}
|
|
</if>
|
|
</where>
|
|
GROUP BY
|
|
create_by,create_by_name
|
|
order by totalPrice desc
|
|
</select>
|
|
|
|
<select id="getShopMonthData" parameterType="cc.hiver.mall.pojo.vo.SaleMonthQueryVo" resultType="cc.hiver.mall.pojo.vo.SaleMonthVo">
|
|
SELECT
|
|
DATE_FORMAT( create_time, '%Y-%m-%d' ) as day,
|
|
count(*) as totalCount,
|
|
sum( real_amount ) as price
|
|
FROM
|
|
t_sale
|
|
WHERE
|
|
shop_id = #{searchVo.shopId}
|
|
and status !='2'
|
|
and status !='6'
|
|
and status !='7'
|
|
and create_time between #{searchVo.startDate} and #{searchVo.endDate}
|
|
GROUP BY
|
|
DATE_FORMAT( create_time, '%Y-%m-%d' )
|
|
ORDER BY
|
|
DATE_FORMAT( create_time, '%Y-%m-%d' ) DESC
|
|
</select>
|
|
|
|
<select id="queryPage" parameterType="cc.hiver.mall.pojo.vo.SaleVO" resultType="cc.hiver.mall.entity.Sale">
|
|
SELECT
|
|
ts.id,ts.create_by,ts.create_by_name,ts.create_time,ts.del_flag,ts.update_by,ts.update_by_name,ts.update_time,ts.user_id,ts.user_name,
|
|
ts.shop_id,ts.shop_name,ts.total_amount,ts.discount,ts.discount_amount,ts.real_amount,ts.debt_deduction_amount,
|
|
ts.sale_deduction_amount,ts.balance_deduction_amount ,ts.already_earn,ts.no_earn,ts.pay_status,ts.pay_type,ts.status,
|
|
ts.other_expense,ts.transport_type,ts.share_address,ts.receive_address,ts.province,ts.city,ts.area,
|
|
ts.trans_company,ts.company_name,ts.product_count,ts.remark,ts.sale_name,ts.company_phone,ts.create_by_phone,ts.mode_of_service,
|
|
ts.ai_flag,ts.ai_result,ts.ai_not_recognition,ts.print_count,ts.distribution_flag,
|
|
trs.return_sale_total_amount ,trs.return_sale_product_count,
|
|
tdr.last_debt_amount
|
|
FROM
|
|
t_sale ts
|
|
left join (
|
|
select n.sale_id,sum(n.total_amount) as return_sale_total_amount ,sum(n.product_count) as return_sale_product_count from t_sale m left join t_return_sale n on m.id = n.sale_id group by n.sale_id
|
|
) trs on ts.id = trs.sale_id
|
|
left join (select sale_id,last_debt_amount from t_dealings_record where dealings_type = '0') tdr ON ts.id = tdr.sale_id
|
|
<where>
|
|
and ts.shop_id = #{saleVO.shopId}
|
|
<if test='saleVO.payStatus!=null'>
|
|
and ts.pay_status = #{saleVO.payStatus}
|
|
</if>
|
|
<if test='saleVO.payType!=null'>
|
|
and ts.pay_type = #{saleVO.payType}
|
|
</if>
|
|
|
|
<if test='saleVO.fromWhere!=null and saleVO.fromWhere.trim() neq ""'>
|
|
<!--哪个列表:
|
|
0:销售单:查询不是6待配货、7挂单的;
|
|
1:统计、客户拿货:查询不是2已作废、6待配货、7挂单的;
|
|
2:需要根据前台传递的status查询列表:6:待配货列表;7挂单列表-->
|
|
<if test='saleVO.fromWhere=="0"'>
|
|
and ts.status not in ('2','6','7')
|
|
</if>
|
|
<if test='saleVO.fromWhere=="1"'>
|
|
and ts.status not in ('2','6','7')
|
|
<!--开单仅退货的销售单,不记入查询-->
|
|
and ts.id in (select sale_id from t_sale_detail tsd
|
|
where tsd.shop_id = #{saleVO.shopId}
|
|
<if test='saleVO.startTime!=null'>
|
|
and tsd.create_time BETWEEN #{saleVO.startTime} AND #{saleVO.endTime}
|
|
</if>
|
|
)
|
|
</if>
|
|
<if test='saleVO.fromWhere=="2" and saleVO.status != null '>
|
|
and ts.status = #{saleVO.status}
|
|
</if>
|
|
</if>
|
|
<if test='saleVO.fromWhere == null or saleVO.fromWhere eq ""'>
|
|
and ts.status not in ('6','7')
|
|
</if>
|
|
|
|
<if test='saleVO.delFlag!=null and saleVO.delFlag.trim() neq ""'>
|
|
and ts.del_flag = #{saleVO.delFlag}
|
|
</if>
|
|
<if test='saleVO.status != null and saleVO.status.trim() neq ""'>
|
|
and ts.status = #{saleVO.status}
|
|
</if>
|
|
<if test='saleVO.transportType!=null' >
|
|
and ts.transport_type = #{saleVO.transportType}
|
|
</if>
|
|
<if test='saleVO.userId!=null'>
|
|
and ts.user_id = #{saleVO.userId}
|
|
</if>
|
|
<!--时间查询-->
|
|
<if test='saleVO.startTime!=null'>
|
|
and ts.create_time BETWEEN #{saleVO.startTime} AND #{saleVO.endTime}
|
|
</if>
|
|
<if test='saleVO.distributionFlag!=null'>
|
|
and ts.distribution_flag = #{saleVO.distributionFlag}
|
|
</if>
|
|
<if test='saleVO.searchStr!=null'>
|
|
and (ts.user_name like concat('%',#{saleVO.searchStr},'%')
|
|
or ts.create_by_name like concat('%',#{saleVO.searchStr},'%')
|
|
or ts.id like concat('%',#{saleVO.searchStr},'%'))
|
|
</if>
|
|
</where>
|
|
<if test='saleVO.timeOrder != null'>
|
|
<choose>
|
|
<when test='saleVO.timeOrder == "0"'>
|
|
order by ts.create_time desc
|
|
</when>
|
|
<when test='saleVO.timeOrder == "1"'>
|
|
order by ts.create_time asc
|
|
</when>
|
|
<!-- 可以在这里添加更多的when分支来处理其他情况 -->
|
|
<otherwise>
|
|
order by ts.create_time desc <!-- 默认降序 -->
|
|
</otherwise>
|
|
</choose>
|
|
</if>
|
|
<if test='saleVO.timeOrder == null'>
|
|
order by ts.create_time desc <!-- 默认情况 -->
|
|
</if>
|
|
</select>
|
|
|
|
<select id="getCustomerBuyProductLog" resultType="cc.hiver.mall.pojo.vo.CustomerBuyProductLogVo">
|
|
SELECT
|
|
product_id,product_name,product_sn,
|
|
MAX(create_time) AS latest_create_time
|
|
FROM
|
|
t_sale_detail
|
|
WHERE
|
|
shop_id = #{salePageQuery.shopId}
|
|
and sale_id IN ( SELECT id FROM t_sale WHERE status not in ('2','6','7')
|
|
|
|
<if test='salePageQuery.userId !=null and salePageQuery.userId !=null'>
|
|
and user_id = #{salePageQuery.userId}
|
|
</if>
|
|
<if test='salePageQuery.createBy !=null and salePageQuery.createBy !=null'>
|
|
and create_by = #{salePageQuery.createBy}
|
|
</if>
|
|
)
|
|
<if test='salePageQuery.startDate !=null and salePageQuery.endDate !=null'>
|
|
and create_time BETWEEN #{salePageQuery.startDate} AND #{salePageQuery.endDate}
|
|
</if>
|
|
GROUP BY
|
|
product_id, product_name,product_sn
|
|
order by latest_create_time desc
|
|
</select>
|
|
|
|
<select id="getCustomerBuyProductLogDetailLog" resultType="cc.hiver.mall.pojo.vo.CustomerBuyProductDetailLogVo">
|
|
SELECT
|
|
create_time,sale_id, product_id,attribute_list, discount_amount as real_price,product_count,purchase_price
|
|
FROM
|
|
t_sale_detail
|
|
WHERE
|
|
shop_id = #{shopId}
|
|
and sale_id in ( SELECT id FROM t_sale WHERE status not in ('2','6','7')
|
|
<if test='userId !=null and userId !=null'>
|
|
and user_id = #{userId}
|
|
</if>
|
|
<if test='createBy !=null and createBy !=null'>
|
|
and create_by = #{createBy}
|
|
</if>
|
|
)
|
|
<if test='startTime !=null and endTime !=null'>
|
|
and create_time BETWEEN #{startTime} AND #{endTime}
|
|
</if>
|
|
and product_id in
|
|
<foreach close=")" collection="productIds" item="listItem" open="(" separator=",">
|
|
#{listItem}
|
|
</foreach>
|
|
</select>
|
|
|
|
<select id="getByUserId" resultType="cc.hiver.mall.pojo.vo.CustomerBuySaleVo">
|
|
SELECT
|
|
id,create_time,product_count
|
|
FROM t_sale
|
|
WHERE
|
|
user_id = #{userId}
|
|
and status not in ('2','6','7')
|
|
</select>
|
|
|
|
<select id="getByCreUserId" resultType="cc.hiver.mall.pojo.vo.CustomerBuySaleVo">
|
|
SELECT
|
|
id,create_time,product_count
|
|
FROM t_sale
|
|
WHERE
|
|
create_by = #{createBy}
|
|
and status not in ('2','6','7')
|
|
</select>
|
|
|
|
<select id="queryTotalAlreadyEarnDetail" resultType="cc.hiver.mall.pojo.vo.TotalAlreadyEarnDetailVo">
|
|
select (CASE WHEN pay_type is NULL THEN 5 ELSE pay_type END) as pay_type,IFNULL(Sum(already_earn),0.00) as pay_amount
|
|
from t_sale
|
|
where shop_id = #{shopId}
|
|
and status not in ('2','6','7')
|
|
and create_time BETWEEN #{startTime} AND #{endTime}
|
|
group by pay_type
|
|
</select>
|
|
|
|
<select id="queryTotalAmountByCategory" resultType="cc.hiver.mall.pojo.vo.CategoryNumberVo">
|
|
select IFNULL(sum(discount_amount * product_count),0.00) as totalAmount,IFNULL(sum(product_count),0.00) as totalJCount from t_sale_detail where category_id in
|
|
<foreach close=")" collection="ids" item="listItem" open="(" separator=",">
|
|
#{listItem}
|
|
</foreach>
|
|
and sale_id in (
|
|
SELECT
|
|
id
|
|
FROM
|
|
t_sale ts
|
|
WHERE
|
|
ts.del_flag = '0'
|
|
AND ts.shop_id = #{shopId}
|
|
AND ts.STATUS NOT IN ( '2', '6', '7' )
|
|
AND ts.create_time BETWEEN #{startTime} AND #{endTime})
|
|
</select>
|
|
|
|
<select id="queryTotalProfitByCategory" resultType="java.math.BigDecimal">
|
|
select IFNULL(sum(ss.product_count * tt.purchase_price),0.00) from t_sale_detail ss
|
|
LEFT JOIN t_product tt on ss.product_id = tt.id where ss.category_id in
|
|
<foreach close=")" collection="ids" item="listItem" open="(" separator=",">
|
|
#{listItem}
|
|
</foreach>
|
|
and ss.sale_id in (
|
|
SELECT
|
|
id
|
|
FROM
|
|
t_sale ts
|
|
WHERE
|
|
ts.del_flag = '0'
|
|
AND ts.shop_id = #{shopId}
|
|
AND ts.STATUS NOT IN ( '2', '6', '7' )
|
|
AND ts.create_time BETWEEN #{startTime} AND #{endTime})
|
|
</select>
|
|
|
|
<select id="queryTotalPurchaseByCategory" resultType="cc.hiver.mall.pojo.vo.CategoryNumberVo">
|
|
select IFNULL(sum(purchase_price * product_count),0.00) as purchasingCost,IFNULL(sum(product_count),0.00) as purchasingCount
|
|
from t_purchase_detail where category_id in
|
|
<foreach close=")" collection="ids" item="listItem" open="(" separator=",">
|
|
#{listItem}
|
|
</foreach>
|
|
and purchase_id IN
|
|
(select id from t_purchase where del_flag = '0' and in_storage_status = 1
|
|
and shop_id = #{shopId}
|
|
and create_time BETWEEN #{startTime} AND #{endTime})
|
|
</select>
|
|
|
|
<select id="queryTotalReturnByCategory" resultType="cc.hiver.mall.pojo.vo.CategoryNumberVo">
|
|
select IFNULL(sum(discount_amount * product_count),0.00) as returnTotalAmount,IFNULL(sum(product_count),0.00) as returnTotalCount
|
|
from t_return_detail where category_id in
|
|
<foreach close=")" collection="ids" item="listItem" open="(" separator=",">
|
|
#{listItem}
|
|
</foreach>
|
|
and sale_id in
|
|
(SELECT
|
|
id
|
|
FROM
|
|
t_sale ts
|
|
WHERE
|
|
ts.del_flag = '0'
|
|
AND ts.shop_id = #{shopId}
|
|
AND ts.STATUS NOT IN ( '2', '6', '7' )
|
|
AND ts.create_time BETWEEN #{startTime} AND #{endTime})
|
|
</select>
|
|
|
|
<select id="querySaleReturnCost" resultType="java.math.BigDecimal">
|
|
select IFNULL(sum(tt.purchase_price * dd.product_count),0.00)
|
|
from t_return_detail dd left join t_product tt on dd.product_id = tt.id where dd.category_id in
|
|
<foreach close=")" collection="ids" item="listItem" open="(" separator=",">
|
|
#{listItem}
|
|
</foreach>
|
|
and dd.sale_id in
|
|
(SELECT
|
|
id
|
|
FROM
|
|
t_sale ts
|
|
WHERE
|
|
ts.del_flag = '0'
|
|
AND ts.shop_id = #{shopId}
|
|
AND ts.STATUS NOT IN ( '2', '6', '7' )
|
|
AND ts.create_time BETWEEN #{startTime} AND #{endTime})
|
|
</select>
|
|
|
|
|
|
<select id="queryTotalAlreadyEarn" resultType="java.math.BigDecimal">
|
|
select IFNULL(Sum(already_earn),0.00) as totalAlreadyEarn
|
|
from t_sale
|
|
where shop_id = #{shopId}
|
|
and status not in ('2','6','7')
|
|
and create_time BETWEEN #{startTime} AND #{endTime}
|
|
</select>
|
|
|
|
<select id="getSupplierBuyProductLog" resultType="cc.hiver.mall.pojo.vo.SupplierBuyProductLogVo">
|
|
SELECT
|
|
t.product_id,t.product_name,t.product_sn
|
|
FROM
|
|
t_purchase_detail t
|
|
WHERE
|
|
t.shop_id = #{salePageQuery.shopId}
|
|
and t.del_flag != 1
|
|
AND purchase_id IN ( SELECT id FROM t_purchase WHERE del_flag = 0 and in_storage_status = 1 and supplier_id = #{salePageQuery.supplierId}
|
|
<if test='salePageQuery.startDate !=null and salePageQuery.endDate !=null'>
|
|
and create_time BETWEEN #{salePageQuery.startDate} AND #{salePageQuery.endDate}
|
|
</if>
|
|
)
|
|
GROUP BY
|
|
product_id, product_name,product_sn
|
|
order by product_name desc
|
|
</select>
|
|
|
|
<select id="getSupplierBuyProductLogDetailLog" resultType="cc.hiver.mall.pojo.vo.SupplierBuyProductDetailLogVo">
|
|
SELECT
|
|
t.create_time, t.purchase_id, t.product_id, s.attribute_list, t.purchase_price, s.product_count
|
|
FROM
|
|
t_purchase_detail t
|
|
LEFT JOIN t_stock_log s ON t.purchase_id = s.order_id
|
|
AND t.product_id = s.product_id
|
|
WHERE
|
|
t.shop_id = #{shopId}
|
|
and t.del_flag != 1
|
|
AND t.purchase_id IN ( SELECT id FROM t_purchase WHERE del_flag = 0 and in_storage_status = 1 and supplier_id = #{supplierId} )
|
|
and t.product_id in
|
|
<foreach close=")" collection="productIds" item="listItem" open="(" separator=",">
|
|
#{listItem}
|
|
</foreach>
|
|
</select>
|
|
|
|
<select id="getBySupplierId" resultType="cc.hiver.mall.pojo.vo.SupplierBuyPurchaseVo">
|
|
SELECT
|
|
id,create_time
|
|
FROM t_purchase
|
|
WHERE
|
|
supplier_id = #{supplierId}
|
|
</select>
|
|
|
|
<select id="getSaleByCompanyId" resultType="cc.hiver.mall.pojo.vo.SaleNoWorkerVO">
|
|
SELECT
|
|
t.id as sale_id,t.shop_name,concat(m.region,m.shop_area_title,m.shop_address) as shop_address,t.create_by_name,t.create_by_phone,t.create_time,t.user_name,s.phone as user_phone,t.receive_address,t.province,t.city,t.area
|
|
FROM t_sale t left join t_customer s
|
|
on t.user_id = s.id
|
|
left join t_shop m
|
|
on t.shop_id = m.id
|
|
WHERE
|
|
t.trans_company = #{salePageQuery.companyId}
|
|
<if test='salePageQuery.status !=null and salePageQuery.status != ""'>
|
|
and t.status = #{salePageQuery.status}
|
|
</if>
|
|
<if test='salePageQuery.transportType !=null and salePageQuery.transportType != ""'>
|
|
and t.transport_type = #{salePageQuery.transportType}
|
|
</if>
|
|
<if test='salePageQuery.modeOfService !=null and salePageQuery.modeOfService != ""'>
|
|
and t.mode_of_service = #{salePageQuery.modeOfService}
|
|
</if>
|
|
<if test='salePageQuery.startDate !=null and salePageQuery.endDate !=null'>
|
|
and t.create_time BETWEEN #{salePageQuery.startDate} AND #{salePageQuery.endDate}
|
|
</if>
|
|
|
|
</select>
|
|
|
|
|
|
<update id="companyGetSale" >
|
|
update t_sale
|
|
set
|
|
status = '4'
|
|
where id = #{saleId,jdbcType=VARCHAR}
|
|
</update>
|
|
|
|
<update id="updateAiMsg" >
|
|
update t_sale
|
|
set
|
|
remark = #{aiMsg,jdbcType=VARCHAR}
|
|
where id = #{saleId,jdbcType=VARCHAR}
|
|
</update>
|
|
|
|
<update id="updateAiFlag" >
|
|
update t_sale
|
|
set
|
|
ai_flag = #{status,jdbcType=INTEGER}
|
|
where id = #{id,jdbcType=VARCHAR}
|
|
</update>
|
|
|
|
<update id="updateStatus" >
|
|
update t_sale
|
|
set
|
|
status = #{status,jdbcType=INTEGER}
|
|
where id = #{id,jdbcType=VARCHAR}
|
|
</update>
|
|
|
|
<select id="getCustomerBill" resultType="cc.hiver.mall.bill.vo.CustomerBillSaleVo">
|
|
select
|
|
ts.id as sale_id,
|
|
ts.create_by_name,
|
|
ts.create_time,
|
|
ts.total_amount,
|
|
ts.debt_deduction_amount,
|
|
ts.sale_deduction_amount,
|
|
ts.balance_deduction_amount,
|
|
ts.real_amount,
|
|
ts.already_earn,
|
|
trs.return_sale_total_amount ,
|
|
tdr.amount,
|
|
tdr.balance_due,
|
|
tdr.dealings_type
|
|
from
|
|
t_sale ts
|
|
left join (
|
|
select
|
|
n.sale_id,
|
|
sum( n.total_amount ) as return_sale_total_amount
|
|
from
|
|
t_sale m
|
|
left join t_return_sale n on m.id = n.sale_id
|
|
group by
|
|
n.sale_id
|
|
) trs on ts.id = trs.sale_id
|
|
left join t_dealings_record tdr on ts.id = tdr.sale_id and tdr.shop_id = #{customerBillQueryVo.shopId}
|
|
WHERE
|
|
ts.user_id = #{customerBillQueryVo.customerId}
|
|
and ts.shop_id = #{customerBillQueryVo.shopId}
|
|
<!--订单状态不为:2:已作废;分享页提交订单:6:待配货;挂单页提交订单:7:挂单-->
|
|
and ts.status not in ('6', '7' )
|
|
<if test='customerBillQueryVo.startDate !=null and customerBillQueryVo.endDate !=null'>
|
|
and ts.create_time BETWEEN #{customerBillQueryVo.startDate} AND #{customerBillQueryVo.endDate}
|
|
</if>
|
|
order by ts.create_time asc
|
|
</select>
|
|
|
|
<select id="getArrearsAndTotalSale" resultType="cc.hiver.mall.bill.vo.ArrearsVo">
|
|
select
|
|
sum(ts.no_earn) as arrears,
|
|
sum(ts.total_amount) as total_sale,
|
|
sum(ts.product_count) as sale_product_count
|
|
from
|
|
t_sale ts
|
|
WHERE
|
|
ts.del_flag = '0'
|
|
and ts.user_id = #{customerBillQueryVo.customerId}
|
|
and ts.shop_id = #{customerBillQueryVo.shopId}
|
|
<!--订单状态不为:2:已作废;分享页提交订单:6:待配货;挂单页提交订单:7:挂单-->
|
|
and ts.status not in ( '2', '6', '7' )
|
|
<if test='customerBillQueryVo.startDate !=null and customerBillQueryVo.endDate !=null'>
|
|
and ts.create_time BETWEEN #{customerBillQueryVo.startDate} AND #{customerBillQueryVo.endDate}
|
|
</if>
|
|
order by ts.create_time desc
|
|
</select>
|
|
|
|
<select id="totalAmountDetail" resultType="cc.hiver.mall.pojo.vo.TotalAmountDetailVo">
|
|
select
|
|
id as sale_id,
|
|
create_by,
|
|
create_by_name,
|
|
user_id,
|
|
user_name,
|
|
create_time as sale_date,
|
|
total_amount,
|
|
cb.total_cost,
|
|
total_amount -cb.total_cost as profit
|
|
from
|
|
t_sale ts
|
|
left join
|
|
(select tsd.sale_id, IFNULL(sum(pd.purchase_price * tsd.product_count),0.00) as total_cost from t_sale_detail tsd JOIN t_product pd ON tsd.product_id = pd.id
|
|
where tsd.shop_id = #{salePageQuery.shopId} group by tsd.sale_id) cb
|
|
on ts.id = cb.sale_id
|
|
WHERE
|
|
ts.del_flag ='0'
|
|
<!--开单仅退货的销售单,不记入查询-->
|
|
and ts.id in (select sale_id from t_sale_detail tsd
|
|
where tsd.shop_id = #{salePageQuery.shopId}
|
|
<if test='salePageQuery.startDate !=null and salePageQuery.endDate !=null'>
|
|
and tsd.create_time BETWEEN #{salePageQuery.startDate} AND #{salePageQuery.endDate}
|
|
</if>
|
|
)
|
|
<!--订单状态不为:2:已作废;分享页提交订单:6:待配货;挂单页提交订单:7:挂单-->
|
|
and ts.shop_id = #{salePageQuery.shopId}
|
|
and ts.status = '4'
|
|
<if test='salePageQuery.createByName !=null and salePageQuery.createByName !=""'>
|
|
and ts.create_by_name like concat('%',#{salePageQuery.createByName},'%')
|
|
</if>
|
|
<!--按客户查询-->
|
|
<if test='salePageQuery.createBy !=null and salePageQuery.createBy !=""'>
|
|
and ts.create_by = #{salePageQuery.createBy}
|
|
</if>
|
|
<!--按商品查询-->
|
|
<if test='salePageQuery.productId !=null and salePageQuery.productId !=""'>
|
|
and ts.product_id = #{salePageQuery.productId}
|
|
</if>
|
|
<if test='salePageQuery.userName !=null and salePageQuery.userName !=""'>
|
|
and ts.user_name like concat('%',#{salePageQuery.userName},'%')
|
|
</if>
|
|
<if test='salePageQuery.startDate !=null and salePageQuery.endDate !=null'>
|
|
and ts.create_time BETWEEN #{salePageQuery.startDate} AND #{salePageQuery.endDate}
|
|
</if>
|
|
order by ts.create_time desc
|
|
</select>
|
|
|
|
<select id="totalAlreadyEarnDetail" resultType="cc.hiver.mall.pojo.vo.TotalAlreadyEarnDetailDayVo">
|
|
select
|
|
date(create_time) as payment_day,
|
|
sum(case when pay_type = '0' then already_earn else 0 end) as xianjin,
|
|
sum(case when pay_type = '1' then already_earn else 0 end) as weixin,
|
|
sum(case when pay_type = '2' then already_earn else 0 end) as zhifubao,
|
|
sum(case when pay_type = '3' then already_earn else 0 end) as yihangzhuanzhang,
|
|
sum(case when pay_type = '4' then already_earn else 0 end) as shouhuanma,
|
|
sum(case when pay_type = '5' then already_earn else 0 end) as yuliu_one,
|
|
sum(case when pay_type = '6' then already_earn else 0 end) as yuliu_two,
|
|
sum(case when pay_type = '7' then already_earn else 0 end) as yuliu_three
|
|
from
|
|
t_sale
|
|
WHERE
|
|
del_flag ='0'
|
|
<!--订单状态不为:2:已作废;分享页提交订单:6:待配货;挂单页提交订单:7:挂单-->
|
|
and shop_id = #{salePageQuery.shopId}
|
|
and status not in ( '2', '6', '7' )
|
|
<if test='salePageQuery.createByName !=null and salePageQuery.createByName !=""'>
|
|
and create_by_name like concat('%',#{salePageQuery.createByName},'%')
|
|
</if>
|
|
<if test='salePageQuery.userName !=null and salePageQuery.userName !=""'>
|
|
and user_name like concat('%',#{salePageQuery.userName},'%')
|
|
</if>
|
|
<if test='salePageQuery.startDate !=null and salePageQuery.endDate !=null'>
|
|
and create_time BETWEEN #{salePageQuery.startDate} AND #{salePageQuery.endDate}
|
|
</if>
|
|
group by payment_day
|
|
order by payment_day desc
|
|
</select>
|
|
|
|
<select id="customerSaleDetail" resultType="cc.hiver.mall.pojo.vo.CustomerSaleDetailVo">
|
|
SELECT
|
|
ts.user_id,
|
|
ts.user_name,
|
|
sum(ts.product_count) as product_count,
|
|
sum(ts.total_amount) as real_amount,
|
|
sum(cb.total_cost) as total_cost,
|
|
sum(ts.total_amount - cb.total_cost) as profit
|
|
FROM
|
|
t_sale ts
|
|
left join
|
|
(select tsd.sale_id, IFNULL(sum(pd.purchase_price * tsd.product_count),0.00) as total_cost from t_sale_detail tsd JOIN t_product pd ON tsd.product_id = pd.id
|
|
where tsd.shop_id = #{salePageQuery.shopId} group by tsd.sale_id) cb
|
|
on ts.id = cb.sale_id
|
|
WHERE
|
|
ts.del_flag ='0'
|
|
<!--开单仅退货的销售单,不记入查询-->
|
|
and ts.id in (select sale_id from t_sale_detail tsd
|
|
where tsd.shop_id = #{salePageQuery.shopId}
|
|
<if test='salePageQuery.startDate !=null and salePageQuery.endDate !=null'>
|
|
and tsd.create_time BETWEEN #{salePageQuery.startDate} AND #{salePageQuery.endDate}
|
|
</if>
|
|
)
|
|
<!--订单状态不为:2:已作废;分享页提交订单:6:待配货;挂单页提交订单:7:挂单-->
|
|
and ts.shop_id = #{salePageQuery.shopId}
|
|
and ts.status not in ( '2', '6', '7' )
|
|
<if test='salePageQuery.createByName !=null and salePageQuery.createByName !=""'>
|
|
and ts.create_by_name like concat('%',#{salePageQuery.createByName},'%')
|
|
</if>
|
|
<!--按客户查询-->
|
|
<if test='salePageQuery.createBy !=null and salePageQuery.createBy !=""'>
|
|
and ts.create_by = #{salePageQuery.createBy}
|
|
</if>
|
|
<!--按商品查询-->
|
|
<if test='salePageQuery.productId !=null and salePageQuery.productId !=""'>
|
|
and ts.product_id = #{salePageQuery.productId}
|
|
</if>
|
|
<if test='salePageQuery.userName !=null and salePageQuery.userName !=""'>
|
|
and ts.user_name like concat('%',#{salePageQuery.userName},'%')
|
|
</if>
|
|
<if test='salePageQuery.startDate !=null and salePageQuery.endDate !=null'>
|
|
and ts.create_time BETWEEN #{salePageQuery.startDate} AND #{salePageQuery.endDate}
|
|
</if>
|
|
group by user_id,user_name
|
|
order by real_amount desc
|
|
</select>
|
|
|
|
<select id="queryTotalJCount" resultType="java.lang.Integer">
|
|
select IFNULL(Sum(product_count),0) as productCount
|
|
from t_sale
|
|
where shop_id = #{shopId}
|
|
and status = '4'
|
|
and create_time BETWEEN #{startTime} AND #{endTime}
|
|
</select>
|
|
|
|
<select id="totalAmountDetailByCustomer" resultType="cc.hiver.mall.pojo.vo.TotalAmountDetailByCustomerVo">
|
|
WITH ProfitSummary AS (
|
|
SELECT
|
|
m.user_id,
|
|
m.user_name,
|
|
sum(m.profit) AS profit
|
|
FROM
|
|
(
|
|
select
|
|
id as sale_id,
|
|
create_by,
|
|
create_by_name,
|
|
user_id,
|
|
user_name,
|
|
create_time as sale_date,
|
|
total_amount,
|
|
cb.total_cost,
|
|
total_amount -cb.total_cost as profit
|
|
from
|
|
t_sale ts
|
|
left join
|
|
(select tsd.sale_id, IFNULL(sum(pd.purchase_price * tsd.product_count),0.00) as total_cost from t_sale_detail tsd
|
|
JOIN t_product pd ON tsd.product_id = pd.id
|
|
where tsd.shop_id = #{salePageQuery.shopId} group by tsd.sale_id) cb
|
|
on ts.id = cb.sale_id
|
|
WHERE
|
|
ts.del_flag ='0'
|
|
<!--开单仅退货的销售单,不记入查询-->
|
|
and ts.id in (select sale_id from t_sale_detail tsd
|
|
where tsd.shop_id = #{salePageQuery.shopId}
|
|
<if test='salePageQuery.startDate !=null and salePageQuery.endDate !=null'>
|
|
and tsd.create_time BETWEEN #{salePageQuery.startDate} AND #{salePageQuery.endDate}
|
|
</if>
|
|
)
|
|
<!--订单状态不为:2:已作废;分享页提交订单:6:待配货;挂单页提交订单:7:挂单-->
|
|
and ts.shop_id = #{salePageQuery.shopId}
|
|
and ts.status not in ( '2', '6', '7' )
|
|
<if test='salePageQuery.createByName !=null and salePageQuery.createByName !=""'>
|
|
and ts.create_by_name like concat('%',#{salePageQuery.createByName},'%')
|
|
</if>
|
|
<!--按客户查询-->
|
|
<if test='salePageQuery.createBy !=null and salePageQuery.createBy !=""'>
|
|
and ts.create_by = #{salePageQuery.createBy}
|
|
</if>
|
|
<!--按商品查询-->
|
|
<if test='salePageQuery.productId !=null and salePageQuery.productId !=""'>
|
|
and ts.product_id = #{salePageQuery.productId}
|
|
</if>
|
|
<if test='salePageQuery.userName !=null and salePageQuery.userName !=""'>
|
|
and ts.user_name like concat('%',#{salePageQuery.userName},'%')
|
|
</if>
|
|
<if test='salePageQuery.startDate !=null and salePageQuery.endDate !=null'>
|
|
and ts.create_time BETWEEN #{salePageQuery.startDate} AND #{salePageQuery.endDate}
|
|
</if>
|
|
) m
|
|
group by m.user_id,m.user_name
|
|
)
|
|
SELECT
|
|
user_id,
|
|
user_name,
|
|
profit,
|
|
ROUND((profit / SUM(profit) OVER ()) * 100.0, 2) AS profit_proportion
|
|
FROM
|
|
ProfitSummary
|
|
ORDER BY
|
|
profit DESC
|
|
</select>
|
|
|
|
<select id="totalAmountDetailByProduct" resultType="cc.hiver.mall.pojo.vo.TotalAmountDetailByProductVo">
|
|
WITH ProductProfitSummary AS (
|
|
SELECT
|
|
sd.product_id,
|
|
sd.product_name,
|
|
pd.product_sn,
|
|
SUM((sd.discount_amount - COALESCE(pd.purchase_price, 0)) * sd.product_count) AS profit
|
|
FROM
|
|
t_sale_detail sd
|
|
JOIN t_product pd ON sd.product_id = pd.id
|
|
WHERE
|
|
sd.shop_id = #{salePageQuery.shopId}
|
|
<if test='salePageQuery.startDate !=null and salePageQuery.endDate !=null'>
|
|
and sd.create_time BETWEEN #{salePageQuery.startDate} AND #{salePageQuery.endDate}
|
|
</if>
|
|
and sale_id in(
|
|
select id from t_sale ts where
|
|
ts.del_flag ='0'
|
|
<!--开单仅退货的销售单,不记入查询-->
|
|
and ts.id in (select sale_id from t_sale_detail tsd
|
|
where tsd.shop_id = #{salePageQuery.shopId}
|
|
<if test='salePageQuery.startDate !=null and salePageQuery.endDate !=null'>
|
|
and tsd.create_time BETWEEN #{salePageQuery.startDate} AND #{salePageQuery.endDate}
|
|
</if>
|
|
)
|
|
<!--订单状态不为:2:已作废;分享页提交订单:6:待配货;挂单页提交订单:7:挂单-->
|
|
and ts.shop_id = #{salePageQuery.shopId}
|
|
and ts.status not in ( '2', '6', '7' )
|
|
<if test='salePageQuery.createByName !=null and salePageQuery.createByName !=""'>
|
|
and ts.create_by_name like concat('%',#{salePageQuery.createByName},'%')
|
|
</if>
|
|
<!--按客户查询-->
|
|
<if test='salePageQuery.createBy !=null and salePageQuery.createBy !=""'>
|
|
and ts.create_by = #{salePageQuery.createBy}
|
|
</if>
|
|
<!--按商品查询-->
|
|
<if test='salePageQuery.productId !=null and salePageQuery.productId !=""'>
|
|
and ts.product_id = #{salePageQuery.productId}
|
|
</if>
|
|
<if test='salePageQuery.userName !=null and salePageQuery.userName !=""'>
|
|
and ts.user_name like concat('%',#{salePageQuery.userName},'%')
|
|
</if>
|
|
<if test='salePageQuery.startDate !=null and salePageQuery.endDate !=null'>
|
|
and ts.create_time BETWEEN #{salePageQuery.startDate} AND #{salePageQuery.endDate}
|
|
</if>
|
|
)
|
|
GROUP BY
|
|
sd.product_id, sd.product_name
|
|
)
|
|
SELECT
|
|
product_id,
|
|
product_name,
|
|
product_sn,
|
|
profit,
|
|
ROUND((profit / SUM(profit) OVER ()) * 100.0, 2) AS profit_proportion
|
|
FROM
|
|
ProductProfitSummary
|
|
ORDER BY
|
|
profit DESC
|
|
</select>
|
|
|
|
<select id="buyCount" resultType="cc.hiver.mall.pojo.vo.BuyCountVo">
|
|
SELECT
|
|
count( aa.id ) as buy_count,
|
|
dd.product_id
|
|
FROM
|
|
t_sale aa,(
|
|
SELECT
|
|
sale_id,
|
|
product_id
|
|
FROM
|
|
t_sale_detail
|
|
WHERE
|
|
product_id IN
|
|
<foreach item="item" index="index" collection="productIdList" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
GROUP BY
|
|
sale_id,
|
|
product_id
|
|
) dd
|
|
WHERE
|
|
aa.id = dd.sale_id
|
|
AND aa.user_id = #{customerId}
|
|
AND aa.STATUS = 4
|
|
GROUP BY
|
|
dd.product_id
|
|
</select>
|
|
|
|
<select id="getSalePrice" resultType="cc.hiver.mall.pojo.vo.CustomerDataVo">
|
|
SELECT
|
|
sum( total_amount ) as sale_price
|
|
FROM
|
|
t_sale
|
|
WHERE
|
|
user_id = #{customerPageQuery.customerId}
|
|
AND del_flag = 0
|
|
AND STATUS = 4
|
|
<if test='customerPageQuery.startDate !=null and customerPageQuery.endDate !=null'>
|
|
and create_time BETWEEN #{customerPageQuery.startDate} AND #{customerPageQuery.endDate}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="getSaleCount" resultType="cc.hiver.mall.pojo.vo.ProductDataVo">
|
|
SELECT
|
|
sum( dd.product_count ) as product_count,
|
|
dd.product_id
|
|
FROM
|
|
t_sale_detail dd
|
|
JOIN t_sale tt ON dd.sale_id = tt.id
|
|
WHERE
|
|
tt.user_id = #{customerPageQuery.customerId}
|
|
AND tt.del_flag = 0
|
|
AND tt.STATUS = 4
|
|
<if test='customerPageQuery.startDate !=null and customerPageQuery.endDate !=null'>
|
|
and tt.create_time BETWEEN #{customerPageQuery.startDate} AND #{customerPageQuery.endDate}
|
|
</if>
|
|
GROUP BY
|
|
dd.product_id
|
|
</select>
|
|
|
|
<update id="updateDistributionFlag" >
|
|
update t_sale
|
|
set
|
|
distribution_flag = #{distributionFlag,jdbcType=VARCHAR}
|
|
where id = #{saleId,jdbcType=VARCHAR}
|
|
</update>
|
|
|
|
<update id="updatePrintCount" >
|
|
update t_sale
|
|
set
|
|
print_count = COALESCE(print_count, 0) + 1
|
|
where id = #{saleId,jdbcType=VARCHAR}
|
|
</update>
|
|
</mapper>
|