javacodeadmin/ruoyi-system/src/main/resources/mapper/system/UserGroupBuyingMapper.xml

145 lines
6.4 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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.ruoyi.system.mapper.UserGroupBuyingMapper">
<resultMap type="UserGroupBuying" id="UserGroupBuyingResult">
<result property="id" column="id" />
<result property="orderid" column="orderid" />
<result property="uid" column="uid" />
<result property="money" column="money" />
<result property="status" column="status" />
<result property="deduction" column="deduction" />
<result property="uname" column="uname" />
<result property="paytime" column="paytime" />
<result property="transactionId" column="transaction_id" />
<result property="paytype" column="paytype" />
<result property="image" column="image" />
<result property="paystatus" column="paystatus" />
<result property="productId" column="product_id" />
<result property="createdAt" column="created_at" />
<result property="updatedAt" column="updated_at" />
<result property="ptorderid" column="ptorderid" />
</resultMap>
<sql id="selectUserGroupBuyingVo">
select id, orderid, uid, money, status, ptorderid,deduction, paystatus,image,uname, paytime, transaction_id, paytype, product_id, created_at, updated_at from user_group_buying
</sql>
<select id="selectUserGroupBuyingList" parameterType="UserGroupBuying" resultMap="UserGroupBuyingResult">
<include refid="selectUserGroupBuyingVo"/>
<where>
<if test="orderid != null and orderid != ''"> and orderid = #{orderid}</if>
<if test="status != null "> and status = #{status}</if>
<if test="uname != null and uname != ''"> and uname like concat('%', #{uname}, '%')</if>
<if test="paytype != null "> and paytype = #{paytype}</if>
<if test="ptorderid != null "> and ptorderid = #{ptorderid}</if>
<if test="paystatus != null "> and paystatus = #{paystatus}</if>
</where>
</select>
<select id="selectUserGroupBuyingById" parameterType="Long" resultMap="UserGroupBuyingResult">
<include refid="selectUserGroupBuyingVo"/>
where id = #{id}
</select>
<select id="selectUserGroupBuyingByptorderid" parameterType="String" resultMap="UserGroupBuyingResult">
<include refid="selectUserGroupBuyingVo"/>
where ptorderid = #{ptorderid}
</select>
<insert id="insertUserGroupBuying" parameterType="UserGroupBuying">
insert into user_group_buying
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="orderid != null">orderid,</if>
<if test="uid != null">uid,</if>
<if test="money != null">money,</if>
<if test="status != null">status,</if>
<if test="deduction != null">deduction,</if>
<if test="uname != null">uname,</if>
<if test="paytime != null">paytime,</if>
<if test="transactionId != null">transaction_id,</if>
<if test="paytype != null">paytype,</if>
<if test="productId != null">product_id,</if>
<if test="image != null">image,</if>
<if test="paystatus != null">paystatus,</if>
<if test="ptorderid != null">ptorderid,</if>
created_at,
updated_at
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="orderid != null">#{orderid},</if>
<if test="uid != null">#{uid},</if>
<if test="money != null">#{money},</if>
<if test="status != null">#{status},</if>
<if test="deduction != null">#{deduction},</if>
<if test="uname != null">#{uname},</if>
<if test="paytime != null">#{paytime},</if>
<if test="transactionId != null">#{transactionId},</if>
<if test="paytype != null">#{paytype},</if>
<if test="productId != null">#{productId},</if>
<if test="image != null">#{image},</if>
<if test="paystatus != null">#{paystatus},</if>
<if test="ptorderid != null">#{ptorderid},</if>
NOW(),
NOW()
</trim>
</insert>
<update id="updateUserGroupBuying" parameterType="UserGroupBuying">
update user_group_buying
<trim prefix="SET" suffixOverrides=",">
<if test="orderid != null">orderid = #{orderid},</if>
<if test="uid != null">uid = #{uid},</if>
<if test="image != null">image = #{image},</if>
<if test="money != null">money = #{money},</if>
<if test="status != null">status = #{status},</if>
<if test="deduction != null">deduction = #{deduction},</if>
<if test="uname != null">uname = #{uname},</if>
<if test="paytime != null">paytime = #{paytime},</if>
<if test="transactionId != null">transaction_id = #{transactionId},</if>
<if test="paytype != null">paytype = #{paytype},</if>
<if test="productId != null">product_id = #{productId},</if>
<if test="paystatus != null">paystatus = #{paystatus},</if>
<if test="ptorderid != null">ptorderid = #{ptorderid},</if>
updated_at = NOW(),
</trim>
where id = #{id}
</update>
<delete id="deleteUserGroupBuyingById" parameterType="Long">
delete from user_group_buying where id = #{id}
</delete>
<delete id="deleteUserGroupBuyingByIds" parameterType="String">
delete from user_group_buying where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<!-- 新增分组查询返回name和image为字符串数组 -->
<select id="selectGroupBuyingGroupByProductAndOrder" resultType="map">
SELECT
CONCAT('[', GROUP_CONCAT('"', uname, '"'), ']') AS name,
CONCAT('[', GROUP_CONCAT('"', image, '"'), ']') AS image,
product_id,
orderid
FROM
user_group_buying
WHERE
status = 1 and paystatus=1
<if test="productId != null">AND product_id = #{productId}</if>
GROUP BY
product_id, orderid
</select>
</mapper>