update customer package
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
<?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.imyeyu.api.modules.gao.mapper.GaoCustomerPackageItemMapper">
|
||||
<select id="selectByCustomerPackageId" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomerPackageItem">
|
||||
SELECT * FROM `gao_customer_package_item`
|
||||
WHERE `customer_package_id` = #{customerPackageId} AND `deleted_at` IS NULL
|
||||
ORDER BY `sort`, `created_at`
|
||||
</select>
|
||||
<select id="selectByCustomerPackageIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomerPackageItem">
|
||||
SELECT * FROM `gao_customer_package_item`
|
||||
WHERE `deleted_at` IS NULL
|
||||
<choose>
|
||||
<when test="customerPackageIdList != null and !customerPackageIdList.isEmpty()">
|
||||
AND `customer_package_id` IN <foreach collection="customerPackageIdList" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</when>
|
||||
<otherwise>AND FALSE</otherwise>
|
||||
</choose>
|
||||
ORDER BY `customer_package_id`, `sort`, `created_at`
|
||||
</select>
|
||||
<select id="selectForUpdate" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomerPackageItem">
|
||||
SELECT * FROM `gao_customer_package_item`
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL
|
||||
FOR UPDATE
|
||||
</select>
|
||||
<update id="updateReservedQuantity">
|
||||
UPDATE `gao_customer_package_item`
|
||||
SET `reserved_quantity` = `reserved_quantity` + #{delta}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL
|
||||
AND `reserved_quantity` + #{delta} >= 0
|
||||
AND `reserved_quantity` + `fulfilled_quantity` + #{delta} <= `total_quantity`
|
||||
</update>
|
||||
<update id="updateFulfilledQuantity">
|
||||
UPDATE `gao_customer_package_item`
|
||||
SET `fulfilled_quantity` = `fulfilled_quantity` + #{delta}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL
|
||||
AND `fulfilled_quantity` + #{delta} >= 0
|
||||
AND `reserved_quantity` + `fulfilled_quantity` + #{delta} <= `total_quantity`
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -1,11 +1,6 @@
|
||||
<?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.imyeyu.api.modules.gao.mapper.GaoCustomerPackageMapper">
|
||||
<select id="selectForUpdate" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomerPackage">
|
||||
SELECT * FROM `gao_customer_package`
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL
|
||||
FOR UPDATE
|
||||
</select>
|
||||
<select id="selectBySalesOrderId" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomerPackage">
|
||||
SELECT * FROM `gao_customer_package`
|
||||
WHERE `sales_order_id` = #{salesOrderId} AND `deleted_at` IS NULL
|
||||
@@ -15,18 +10,19 @@
|
||||
p.`deleted_at` IS NULL
|
||||
<if test="storeId != null and storeId != ''">AND p.`store_id` = #{storeId}</if>
|
||||
<if test="customerId != null and customerId != ''">AND p.`customer_id` = #{customerId}</if>
|
||||
<if test="status != null">AND p.`status` = #{status}</if>
|
||||
<if test="status != null">AND o.`status` = #{status}</if>
|
||||
<if test="keyword != null and keyword.trim() != ''">AND (p.`package_name_snapshot` LIKE CONCAT('%', #{keyword}, '%') OR c.`name` LIKE CONCAT('%', #{keyword}, '%') OR c.`code` LIKE CONCAT('%', #{keyword}, '%'))</if>
|
||||
</sql>
|
||||
<select id="countByQuery" resultType="long">
|
||||
SELECT COUNT(1) FROM `gao_customer_package` p
|
||||
LEFT JOIN `gao_customer` c ON c.`id` = p.`customer_id`
|
||||
INNER JOIN `gao_sales_order` o ON o.`id` = p.`sales_order_id` AND o.`store_id` = p.`store_id` AND o.`deleted_at` IS NULL
|
||||
WHERE <include refid="queryWhere"/>
|
||||
</select>
|
||||
<select id="selectByQuery" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomerPackage">
|
||||
SELECT p.* FROM `gao_customer_package` p
|
||||
LEFT JOIN `gao_customer` c ON c.`id` = p.`customer_id`
|
||||
LEFT JOIN `gao_sales_order` o ON o.`id` = p.`sales_order_id` AND o.`store_id` = p.`store_id` AND o.`deleted_at` IS NULL
|
||||
INNER JOIN `gao_sales_order` o ON o.`id` = p.`sales_order_id` AND o.`store_id` = p.`store_id` AND o.`deleted_at` IS NULL
|
||||
WHERE <include refid="queryWhere"/>
|
||||
ORDER BY o.`purchased_at` DESC, p.`created_at` DESC
|
||||
LIMIT #{offset}, #{limit}
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
<if test="storeId != null and storeId != ''">AND `store_id` = #{storeId}</if>
|
||||
<if test="salesOrderId != null and salesOrderId != ''">AND `sales_order_id` = #{salesOrderId}</if>
|
||||
<if test="customerId != null and customerId != ''">AND `customer_id` = #{customerId}</if>
|
||||
<if test="fulfillmentType != null">AND `fulfillment_type` = #{fulfillmentType}</if>
|
||||
<if test="status != null">AND `status` = #{status}</if>
|
||||
<if test="beginAt != null">AND `delivered_at` >= #{beginAt}</if>
|
||||
<if test="endAt != null">AND `delivered_at` <= #{endAt}</if>
|
||||
|
||||
@@ -11,6 +11,14 @@
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL
|
||||
FOR UPDATE
|
||||
</select>
|
||||
<select id="selectByIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoSalesOrder">
|
||||
SELECT * FROM `gao_sales_order`
|
||||
WHERE `id` IN
|
||||
<foreach collection="idList" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
<sql id="queryWhere">
|
||||
o.`deleted_at` IS NULL
|
||||
<if test="storeId != null and storeId != ''">AND o.`store_id` = #{storeId}</if>
|
||||
|
||||
Reference in New Issue
Block a user