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.

445 lines
17 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.PurchaseMapper">
<resultMap id="BaseResultMap" type="cc.hiver.mall.entity.Purchase">
<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_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="supplier_id" jdbcType="VARCHAR" property="supplierId" />
<result column="supplier_name" jdbcType="VARCHAR" property="supplierName" />
<result column="shop_id" jdbcType="VARCHAR" property="shopId" />
<result column="total_amount" jdbcType="DECIMAL" property="totalAmount" />
<result column="should_pay" jdbcType="DECIMAL" property="shouldPay" />
<result column="already_pay" jdbcType="DECIMAL" property="alreadyPay" />
<result column="no_pay" jdbcType="DECIMAL" property="noPay" />
<result column="other_pay" jdbcType="DECIMAL" property="otherPay" />
<result column="in_storage_status" jdbcType="INTEGER" property="inStorageStatus" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
</resultMap>
<resultMap id="DebtResultMap" type="cc.hiver.mall.pojo.dto.DebtSupplier">
<result column="supplier_id" jdbcType="VARCHAR" property="supplierId" />
<result column="consignee_name" jdbcType="VARCHAR" property="consigneeName" />
<result column="no_pay" jdbcType="DECIMAL" property="noPay" />
</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_time, supplier_id,supplier_name, shop_id,
total_amount, should_pay, already_pay, no_pay,other_pay, in_storage_status,remark
</sql>
<select id="selectByExample" parameterType="cc.hiver.mall.entity.PurchaseExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from t_purchase
<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_purchase
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from t_purchase
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="cc.hiver.mall.entity.PurchaseExample">
delete from t_purchase
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="cc.hiver.mall.entity.Purchase">
insert into t_purchase (id, create_by, create_by_name, create_time,
del_flag, update_by, update_time,
supplier_id,supplier_name, shop_id, total_amount,
should_pay, already_pay, no_pay,other_pay, in_storage_status,remark
)
values (#{id,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createByName,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{delFlag,jdbcType=INTEGER}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
#{supplierId,jdbcType=VARCHAR},#{supplierName,jdbcType=VARCHAR}, #{shopId,jdbcType=VARCHAR}, #{totalAmount,jdbcType=DECIMAL},
#{shouldPay,jdbcType=DECIMAL}, #{alreadyPay,jdbcType=DECIMAL}, #{noPay,jdbcType=DECIMAL}, #{otherPay,jdbcType=DECIMAL}, #{inStorageStatus,jdbcType=INTEGER},
#{remark,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="cc.hiver.mall.entity.Purchase">
insert into t_purchase
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="createByName != null">
create_by_name,
</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="supplierId != null">
supplier_id,
</if>
<if test="supplierName != null">
supplier_name,
</if>
<if test="shopId != null">
shop_id,
</if>
<if test="totalAmount != null">
total_amount,
</if>
<if test="shouldPay != null">
should_pay,
</if>
<if test="alreadyPay != null">
already_pay,
</if>
<if test="noPay != null">
no_pay,
</if>
<if test="noPay != null">
other_pay,
</if>
<if test="inStorageStatus != null">
in_storage_status,
</if>
<if test="remark != null">
remark,
</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="createByName != null">
#{createByName,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="supplierId != null">
#{supplierId,jdbcType=VARCHAR},
</if>
<if test="supplierName != null">
#{supplierName,jdbcType=VARCHAR},
</if>
<if test="shopId != null">
#{shopId,jdbcType=VARCHAR},
</if>
<if test="totalAmount != null">
#{totalAmount,jdbcType=DECIMAL},
</if>
<if test="shouldPay != null">
#{shouldPay,jdbcType=DECIMAL},
</if>
<if test="alreadyPay != null">
#{alreadyPay,jdbcType=DECIMAL},
</if>
<if test="noPay != null">
#{noPay,jdbcType=DECIMAL},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="cc.hiver.mall.entity.PurchaseExample" resultType="java.lang.Long">
select count(*) from t_purchase
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update t_purchase
<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.createByName != null">
create_by_name = #{record.createByName,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.supplierId != null">
supplier_id = #{record.supplierId,jdbcType=VARCHAR},
</if>
<if test="record.supplierName != null">
supplier_name = #{record.supplierName,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.shouldPay != null">
should_pay = #{record.shouldPay,jdbcType=DECIMAL},
</if>
<if test="record.alreadyPay != null">
already_pay = #{record.alreadyPay,jdbcType=DECIMAL},
</if>
<if test="record.noPay != null">
no_pay = #{record.noPay,jdbcType=DECIMAL},
</if>
<if test="record.otherpay != null">
other_pay = #{record.otherpay,jdbcType=DECIMAL},
</if>
<if test="record.inStorageStatus != null">
in_storage_status = #{record.inStorageStatus,jdbcType=INTEGER},
</if>
<if test="record.remark != null">
remark = #{record.remark,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update t_purchase
set id = #{record.id,jdbcType=VARCHAR},
create_by = #{record.createBy,jdbcType=VARCHAR},
create_by_name = #{record.createByName,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},
supplier_id = #{record.supplierId,jdbcType=VARCHAR},
supplier_name = #{record.supplierName,jdbcType=VARCHAR},
shop_id = #{record.shopId,jdbcType=VARCHAR},
total_amount = #{record.totalAmount,jdbcType=DECIMAL},
should_pay = #{record.shouldPay,jdbcType=DECIMAL},
already_pay = #{record.alreadyPay,jdbcType=DECIMAL},
no_pay = #{record.noPay,jdbcType=DECIMAL},
other_pay = #{record.otherPay,jdbcType=DECIMAL},
in_storage_status = #{record.inStorageStatus,jdbcType=INTEGER},
remark = #{record.remark,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="cc.hiver.mall.entity.Purchase">
update t_purchase
<set>
<if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR},
</if>
<if test="createByName != null">
create_by_name = #{createByName,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="supplierId != null">
supplier_id = #{supplierId,jdbcType=VARCHAR},
</if>
<if test="supplierName != null">
supplier_name = #{supplierName,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="shouldPay != null">
should_pay = #{shouldPay,jdbcType=DECIMAL},
</if>
<if test="alreadyPay != null">
already_pay = #{alreadyPay,jdbcType=DECIMAL},
</if>
<if test="noPay != null">
no_pay = #{noPay,jdbcType=DECIMAL},
</if>
<if test="otherPay != null">
other_pay = #{otherPay,jdbcType=DECIMAL},
</if>
<if test="inStorageStatus != null">
in_storage_status = #{inStorageStatus,jdbcType=INTEGER},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="cc.hiver.mall.entity.Purchase">
update t_purchase
set create_by = #{createBy,jdbcType=VARCHAR},
create_by_name = #{createByName,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
del_flag = #{delFlag,jdbcType=INTEGER},
update_by = #{updateBy,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=TIMESTAMP},
supplier_id = #{supplierId,jdbcType=VARCHAR},
supplier_name = #{supplierName,jdbcType=VARCHAR},
shop_id = #{shopId,jdbcType=VARCHAR},
total_amount = #{totalAmount,jdbcType=DECIMAL},
should_pay = #{shouldPay,jdbcType=DECIMAL},
already_pay = #{alreadyPay,jdbcType=DECIMAL},
no_pay = #{noPay,jdbcType=DECIMAL},
other_pay = #{otherPay,jdbcType=DECIMAL},
in_storage_status = #{inStorageStatus,jdbcType=INTEGER},
remark = #{remark,jdbcType=INTEGER}
where id = #{id,jdbcType=VARCHAR}
</update>
2 years ago
<select id="selectDebtByShopId" resultMap="DebtResultMap">
select a.supplier_id,a.supplier_name,sum(a.no_pay) no_pay
from t_purchase a
where 1=1
and no_pay > 0
2 years ago
and shop_id = #{queryParams.shopId}
group by a.supplier_id,a.supplier_name
order by no_pay desc
</select>
2 years ago
<select id="getPurchaseList" parameterType="cc.hiver.mall.pojo.query.PurchasePageQuery" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_purchase
2 years ago
where shop_id = #{queryParams.shopId}
<if test="queryParams.startDate != null and queryParams.startDate != '' and queryParams.endDate != null and queryParams.endDate != ''">
and create_time BETWEEN #{queryParams.startDate} AND #{queryParams.endDate}
</if>
<if test="queryParams.searchStr != null and queryParams.searchStr != ''">
and (id in(
select purchase_id from t_purchase_detail
where product_id in (
select id from t_product
2 years ago
where product_name like concat('%',#{queryParams.searchStr},'%')
or product_sn like concat('%',#{queryParams.searchStr},'%')
)
group by purchase_id
)
2 years ago
or supplier_name like concat('%',#{queryParams.searchStr},'%')
)
</if>
2 years ago
order by create_time desc
</select>
<select id="getPurchaseListByProductId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from t_purchase
where id in (select purchase_id from t_purchase_detail where product_id =#{productId})
</select>
2 years ago
<select id="getPurchasingCost" resultType="java.math.BigDecimal">
select
IFNULL(sum(should_pay),0.00) as purchasingCost
from t_purchase
where shop_id = #{shopId}
and create_time BETWEEN #{startTime} AND #{endTime}
</select>
</mapper>