<?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.webmanage.mapper.CartMapper">
|
|
<resultMap id="BaseResultMap" type="com.webmanage.entity.Cart">
|
<id column="id" property="id" jdbcType="BIGINT"/>
|
<result column="user_id" property="userId" jdbcType="VARCHAR"/>
|
<result column="unit_id" property="unitId" jdbcType="VARCHAR"/>
|
<result column="pricing_id" property="pricingId" jdbcType="BIGINT"/>
|
<result column="product_id" property="productId" jdbcType="VARCHAR"/>
|
<result column="product_name" property="productName" jdbcType="VARCHAR"/>
|
<result column="suite_name" property="suiteName" jdbcType="VARCHAR"/>
|
<result column="sales_form" property="salesForm" jdbcType="VARCHAR"/>
|
<result column="customer_type" property="customerType" jdbcType="VARCHAR"/>
|
<result column="account_limit" property="accountLimit" jdbcType="VARCHAR"/>
|
<result column="concurrent_nodes" property="concurrentNodes" jdbcType="VARCHAR"/>
|
<result column="price_type" property="priceType" jdbcType="VARCHAR"/>
|
<result column="price_unit" property="priceUnit" jdbcType="VARCHAR"/>
|
<result column="unit_price" property="unitPrice" jdbcType="DECIMAL"/>
|
<result column="quantity" property="quantity" jdbcType="INTEGER"/>
|
<result column="duration" property="duration" jdbcType="INTEGER"/>
|
<result column="total_price" property="totalPrice" jdbcType="DECIMAL"/>
|
<result column="provider_id" property="providerId" jdbcType="BIGINT"/>
|
<result column="provider_name" property="providerName" jdbcType="VARCHAR"/>
|
<result column="remarks" property="remarks" jdbcType="VARCHAR"/>
|
<result column="add_time" property="addTime" jdbcType="TIMESTAMP"/>
|
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
<result column="deleted" property="deleted" jdbcType="INTEGER"/>
|
</resultMap>
|
|
<sql id="Base_Column_List">
|
id, user_id, unit_id, pricing_id, product_id, product_name, suite_name, sales_form,
|
customer_type, account_limit, concurrent_nodes, price_type, price_unit, unit_price,
|
quantity, duration, total_price, provider_id, provider_name, remarks, add_time,
|
update_time, deleted
|
</sql>
|
|
<select id="selectByUserIdAndUnitId" resultMap="BaseResultMap">
|
SELECT <include refid="Base_Column_List"/>
|
FROM tb_cart
|
WHERE deleted = 0
|
AND user_id = #{userId}
|
<if test="unitId !=null and unitId != ''">
|
AND unit_id = #{unitId}
|
</if>
|
<if test="productId !=null and productId != ''">
|
AND product_id = #{productId}
|
</if>
|
ORDER BY add_time DESC
|
</select>
|
|
<select id="selectByUserIdUnitIdAndPricingId" resultMap="BaseResultMap">
|
SELECT <include refid="Base_Column_List"/>
|
FROM tb_cart
|
WHERE deleted = 0
|
AND user_id = #{userId}
|
<if test="unitId != '' and unitId != null">
|
AND unit_id = #{unitId}
|
</if>
|
AND pricing_id = #{pricingId}
|
AND product_id = #{productId}
|
LIMIT 1
|
</select>
|
|
<select id="countByUserIdAndUnitId" resultType="java.lang.Integer">
|
SELECT COUNT(*)
|
FROM tb_cart
|
WHERE deleted = 0
|
AND user_id = #{userId}
|
<if test="unitId != '' and unitId != null">
|
AND unit_id = #{unitId}
|
</if>
|
<if test="productId != '' and productId != null">
|
AND product_id = #{productId}
|
</if>
|
</select>
|
|
<select id="sumTotalAmountByUserIdAndUnitId" resultType="java.math.BigDecimal">
|
SELECT COALESCE(SUM(total_price), 0)
|
FROM tb_cart
|
WHERE deleted = 0
|
AND user_id = #{userId}
|
<if test="unitId != '' and unitId != null">
|
AND unit_id = #{unitId}
|
</if>
|
</select>
|
<delete id="deleteByCustomerCondition">
|
delete from tb_cart where id = #{id}
|
</delete>
|
|
</mapper>
|