cashier-client/src/main/resources/mapper/ShopUserDutyMapper.xml

239 lines
11 KiB
XML

<?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.chaozhanggui.system.cashierservice.dao.ShopUserDutyMapper">
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.ShopUserDuty">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="user_id" jdbcType="INTEGER" property="userId"/>
<result column="login_time" jdbcType="TIMESTAMP" property="loginTime"/>
<result column="order_num" jdbcType="INTEGER" property="orderNum"/>
<result column="amount" jdbcType="VARCHAR" property="amount"/>
<result column="login_out_time" jdbcType="TIMESTAMP" property="loginOutTime"/>
<result column="user_name" jdbcType="VARCHAR" property="userName"/>
<result column="status" jdbcType="VARCHAR" property="status"/>
<result column="income_amount" jdbcType="DECIMAL" property="incomeAmount"/>
<result column="shop_id" jdbcType="INTEGER" property="shopId"/>
<result column="token_id" jdbcType="INTEGER" property="tokenId"/>
<result column="petty_cash" jdbcType="DECIMAL" property="pettyCash"/>
<result column="cash_amount" jdbcType="DECIMAL" property="cashAmount"/>
<result column="hand_amount" jdbcType="DECIMAL" property="handAmount"/>
<result column="return_amount" jdbcType="DECIMAL" property="returnAmount"/>
<result column="equipment" jdbcType="VARCHAR" property="equipment"/>
<result column="trade_day" jdbcType="VARCHAR" property="tradeDay"/>
<result column="type" jdbcType="VARCHAR" property="type"/>
</resultMap>
<sql id="Base_Column_List">
id, user_id, login_time, order_num, amount, login_out_time, user_name, status, income_amount,
shop_id, petty_cash, cash_amount, hand_amount, equipment,return_amount,token_id,trade_day,type
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tb_shop_user_duty
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByTokenId" resultType="com.chaozhanggui.system.cashierservice.entity.ShopUserDuty">
select * from tb_shop_user_duty where token_id = #{tokenId}
</select>
<select id="selectByShopId" resultType="com.chaozhanggui.system.cashierservice.entity.ShopUserDuty">
select * from tb_shop_user_duty where shop_id = #{shopId}
</select>
<select id="selectSumAmount" resultType="java.math.BigDecimal">
select ifnull(sum(amount),0) from tb_shop_user_duty where shop_id = #{shopId}
</select>
<select id="selectByTokenIdAndTradeDay"
resultMap="BaseResultMap">
select * from tb_shop_user_duty where shop_id = #{shopId} and trade_day = #{day} and token_id = #{tokenId};
</select>
<select id="selectByShopIdAndTrade"
resultType="com.chaozhanggui.system.cashierservice.entity.ShopUserDuty">
select * from tb_shop_user_duty where trade_day = #{day} and shop_id = #{shopId} and status = '0'
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tb_shop_user_duty
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.ShopUserDuty"
useGeneratedKeys="true" keyProperty="id">
insert into tb_shop_user_duty (id, user_id, login_time,
order_num, amount, login_out_time,
user_name, status, income_amount,
shop_id, petty_cash, cash_amount,
hand_amount, equipment,return_amount,token_id,trade_day,type)
values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{loginTime,jdbcType=TIMESTAMP},
#{orderNum,jdbcType=INTEGER}, #{amount,jdbcType=VARCHAR}, #{loginOutTime,jdbcType=TIMESTAMP},
#{userName,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{incomeAmount,jdbcType=DECIMAL},
#{shopId,jdbcType=INTEGER}, #{pettyCash,jdbcType=DECIMAL}, #{cashAmount,jdbcType=DECIMAL},
#{handAmount,jdbcType=DECIMAL}, #{equipment,jdbcType=VARCHAR}, #{returnAmount,jdbcType=DECIMAL},#{tokenId,jdbcType=INTEGER},#{tradeDay,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.ShopUserDuty">
insert into tb_shop_user_duty
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="userId != null">
user_id,
</if>
<if test="loginTime != null">
login_time,
</if>
<if test="orderNum != null">
order_num,
</if>
<if test="amount != null">
amount,
</if>
<if test="loginOutTime != null">
login_out_time,
</if>
<if test="userName != null">
user_name,
</if>
<if test="status != null">
status,
</if>
<if test="incomeAmount != null">
income_amount,
</if>
<if test="shopId != null">
shop_id,
</if>
<if test="pettyCash != null">
petty_cash,
</if>
<if test="cashAmount != null">
cash_amount,
</if>
<if test="handAmount != null">
hand_amount,
</if>
<if test="equipment != null">
equipment,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="userId != null">
#{userId,jdbcType=INTEGER},
</if>
<if test="loginTime != null">
#{loginTime,jdbcType=TIMESTAMP},
</if>
<if test="orderNum != null">
#{orderNum,jdbcType=INTEGER},
</if>
<if test="amount != null">
#{amount,jdbcType=VARCHAR},
</if>
<if test="loginOutTime != null">
#{loginOutTime,jdbcType=TIMESTAMP},
</if>
<if test="userName != null">
#{userName,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
<if test="incomeAmount != null">
#{incomeAmount,jdbcType=DECIMAL},
</if>
<if test="shopId != null">
#{shopId,jdbcType=INTEGER},
</if>
<if test="pettyCash != null">
#{pettyCash,jdbcType=DECIMAL},
</if>
<if test="cashAmount != null">
#{cashAmount,jdbcType=DECIMAL},
</if>
<if test="handAmount != null">
#{handAmount,jdbcType=DECIMAL},
</if>
<if test="equipment != null">
#{equipment,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.ShopUserDuty">
update tb_shop_user_duty
<set>
<if test="userId != null">
user_id = #{userId,jdbcType=INTEGER},
</if>
<if test="loginTime != null">
login_time = #{loginTime,jdbcType=TIMESTAMP},
</if>
<if test="orderNum != null">
order_num = #{orderNum,jdbcType=INTEGER},
</if>
<if test="amount != null">
amount = #{amount,jdbcType=DECIMAL},
</if>
<if test="loginOutTime != null">
login_out_time = #{loginOutTime,jdbcType=TIMESTAMP},
</if>
<if test="userName != null">
user_name = #{userName,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=VARCHAR},
</if>
<if test="incomeAmount != null">
income_amount = #{incomeAmount,jdbcType=DECIMAL},
</if>
<if test="shopId != null">
shop_id = #{shopId,jdbcType=INTEGER},
</if>
<if test="pettyCash != null">
petty_cash = #{pettyCash,jdbcType=DECIMAL},
</if>
<if test="cashAmount != null">
cash_amount = #{cashAmount,jdbcType=DECIMAL},
</if>
<if test="handAmount != null">
hand_amount = #{handAmount,jdbcType=DECIMAL},
</if>
<if test="equipment != null">
equipment = #{equipment,jdbcType=VARCHAR},
</if>
<if test="returnAmount != null">
return_amount = #{returnAmount,jdbcType=DECIMAL},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.ShopUserDuty">
update tb_shop_user_duty
set user_id = #{userId,jdbcType=INTEGER},
login_time = #{loginTime,jdbcType=TIMESTAMP},
order_num = #{orderNum,jdbcType=INTEGER},
amount = #{amount,jdbcType=VARCHAR},
login_out_time = #{loginOutTime,jdbcType=TIMESTAMP},
user_name = #{userName,jdbcType=VARCHAR},
status = #{status,jdbcType=VARCHAR},
income_amount = #{incomeAmount,jdbcType=DECIMAL},
shop_id = #{shopId,jdbcType=INTEGER},
petty_cash = #{pettyCash,jdbcType=DECIMAL},
cash_amount = #{cashAmount,jdbcType=DECIMAL},
hand_amount = #{handAmount,jdbcType=DECIMAL},
equipment = #{equipment,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateStatusByTokenId">
update tb_shop_user_duty set status = '1' , login_out_time = now(),user_id = #{staffId} where shop_id = #{shopId} and trade_day = #{day} and status = '0'
</update>
<update id="updateStatusById">
update tb_shop_user_duty set status = '1' , login_out_time = now(),user_id = #{staffId} where id = #{id}
</update>
<select id="selectByShopIdAndDay" resultMap="BaseResultMap">
select * from tb_shop_user_duty where trade_day = #{day} and shop_id = #{shopId} order by id desc limit 1
</select>
<select id="selectByShopIdAndStatus"
resultType="com.chaozhanggui.system.cashierservice.entity.ShopUserDuty">
select * from tb_shop_user_duty where status = #{status} and shop_id = #{shopId} order by id desc limit 1
</select>
</mapper>