add gao product
This commit is contained in:
@@ -27,13 +27,13 @@
|
||||
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` + `delivered_quantity` + #{delta} <= `total_quantity`
|
||||
AND `reserved_quantity` + `fulfilled_quantity` + #{delta} <= `total_quantity`
|
||||
</update>
|
||||
<update id="updateDeliveredQuantity">
|
||||
<update id="updateFulfilledQuantity">
|
||||
UPDATE `gao_customer_package_item`
|
||||
SET `delivered_quantity` = `delivered_quantity` + #{delta}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
SET `fulfilled_quantity` = `fulfilled_quantity` + #{delta}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL
|
||||
AND `delivered_quantity` + #{delta} >= 0
|
||||
AND `reserved_quantity` + `delivered_quantity` + #{delta} <= `total_quantity`
|
||||
AND `fulfilled_quantity` + #{delta} >= 0
|
||||
AND `reserved_quantity` + `fulfilled_quantity` + #{delta} <= `total_quantity`
|
||||
</update>
|
||||
</mapper>
|
||||
|
||||
@@ -1,24 +1,14 @@
|
||||
<?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="selectByRequestNo" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomerPackage">
|
||||
SELECT * FROM `gao_customer_package`
|
||||
WHERE `store_id` = #{storeId} AND `request_no` = #{requestNo}
|
||||
LIMIT 1
|
||||
</select>
|
||||
<select id="selectByRequestNoAnyStore" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomerPackage">
|
||||
SELECT * FROM `gao_customer_package`
|
||||
WHERE `request_no` = #{requestNo}
|
||||
LIMIT 1
|
||||
</select>
|
||||
<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="selectByPurchaseEventRecordId" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomerPackage">
|
||||
<select id="selectBySalesOrderId" resultType="com.imyeyu.api.modules.gao.entity.GaoCustomerPackage">
|
||||
SELECT * FROM `gao_customer_package`
|
||||
WHERE `purchase_event_record_id` = #{purchaseEventRecordId}
|
||||
WHERE `sales_order_id` = #{salesOrderId} AND `deleted_at` IS NULL
|
||||
LIMIT 1
|
||||
</select>
|
||||
<sql id="queryWhere">
|
||||
@@ -26,10 +16,6 @@
|
||||
<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="paymentStatus != null">AND p.`payment_status` = #{paymentStatus}</if>
|
||||
<if test="refundStatus != null">AND p.`refund_status` = #{refundStatus}</if>
|
||||
<if test="beginAt != null">AND p.`purchased_at` >= #{beginAt}</if>
|
||||
<if test="endAt != null">AND p.`purchased_at` <= #{endAt}</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">
|
||||
@@ -44,19 +30,4 @@
|
||||
ORDER BY p.`purchased_at` DESC, p.`created_at` DESC
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
<update id="updatePendingPaidAmountDelta">
|
||||
UPDATE `gao_customer_package`
|
||||
SET `pending_paid_amount` = `pending_paid_amount` + #{delta}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL AND `pending_paid_amount` + #{delta} >= 0
|
||||
</update>
|
||||
<update id="updatePaidAmountDelta">
|
||||
UPDATE `gao_customer_package`
|
||||
SET `paid_amount` = `paid_amount` + #{delta}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL AND `paid_amount` + #{delta} >= 0
|
||||
</update>
|
||||
<update id="updateStatusIf">
|
||||
UPDATE `gao_customer_package`
|
||||
SET `status` = #{toStatus}, `cancelled_at` = #{cancelledAt}, `cancel_operator_user_id` = #{cancelOperatorUserId}, `cancel_reason` = #{cancelReason}, `refund_status` = #{refundStatus}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id} AND `status` = #{fromStatus} AND `deleted_at` IS NULL
|
||||
</update>
|
||||
</mapper>
|
||||
|
||||
@@ -29,7 +29,9 @@
|
||||
f.`deleted_at` IS NULL
|
||||
<if test="storeId != null and storeId != ''">AND f.`store_id` = #{storeId}</if>
|
||||
<if test="customerPackageId != null and customerPackageId != ''">AND f.`biz_id` = #{customerPackageId}</if>
|
||||
<if test="salesOrderId != null and salesOrderId != ''">AND f.`biz_id` = #{salesOrderId}</if>
|
||||
<if test="customerId != null and customerId != ''">AND f.`customer_id` = #{customerId}</if>
|
||||
<if test="bizType != null">AND f.`biz_type` = #{bizType}</if>
|
||||
<if test="operationType != null">AND f.`operation_type` = #{operationType}</if>
|
||||
<if test="status != null">AND f.`status` = #{status}</if>
|
||||
<if test="beginAt != null">AND f.`occurred_at` >= #{beginAt}</if>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?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.GaoOrderFulfillmentItemMapper">
|
||||
<select id="selectByFulfillmentId" resultType="com.imyeyu.api.modules.gao.entity.GaoOrderFulfillmentItem">
|
||||
SELECT * FROM `gao_order_fulfillment_item`
|
||||
WHERE `fulfillment_id` = #{fulfillmentId}
|
||||
ORDER BY `created_at`
|
||||
</select>
|
||||
<select id="selectByFulfillmentIdForUpdate" resultType="com.imyeyu.api.modules.gao.entity.GaoOrderFulfillmentItem">
|
||||
SELECT * FROM `gao_order_fulfillment_item`
|
||||
WHERE `fulfillment_id` = #{fulfillmentId}
|
||||
ORDER BY `created_at`
|
||||
FOR UPDATE
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,57 @@
|
||||
<?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.GaoOrderFulfillmentMapper">
|
||||
<select id="selectByRequestNo" resultType="com.imyeyu.api.modules.gao.entity.GaoOrderFulfillment">
|
||||
SELECT * FROM `gao_order_fulfillment`
|
||||
WHERE `store_id` = #{storeId} AND `request_no` = #{requestNo}
|
||||
LIMIT 1
|
||||
</select>
|
||||
<select id="selectById" resultType="com.imyeyu.api.modules.gao.entity.GaoOrderFulfillment">
|
||||
SELECT * FROM `gao_order_fulfillment`
|
||||
WHERE `id` = #{id}
|
||||
</select>
|
||||
<select id="selectForUpdate" resultType="com.imyeyu.api.modules.gao.entity.GaoOrderFulfillment">
|
||||
SELECT * FROM `gao_order_fulfillment`
|
||||
WHERE `id` = #{id}
|
||||
FOR UPDATE
|
||||
</select>
|
||||
<select id="selectBySalesOrderId" resultType="com.imyeyu.api.modules.gao.entity.GaoOrderFulfillment">
|
||||
SELECT * FROM `gao_order_fulfillment`
|
||||
WHERE `sales_order_id` = #{salesOrderId}
|
||||
ORDER BY `created_at`
|
||||
</select>
|
||||
<select id="selectBySourceFulfillmentId" resultType="com.imyeyu.api.modules.gao.entity.GaoOrderFulfillment">
|
||||
SELECT * FROM `gao_order_fulfillment`
|
||||
WHERE `source_fulfillment_id` = #{sourceFulfillmentId}
|
||||
LIMIT 1
|
||||
</select>
|
||||
<select id="countPendingBySalesOrderId" resultType="long">
|
||||
SELECT COUNT(1) FROM `gao_order_fulfillment`
|
||||
WHERE `sales_order_id` = #{salesOrderId} AND `status` IN ('WAITING_STOCK', 'PENDING')
|
||||
</select>
|
||||
<sql id="queryWhere">
|
||||
1 = 1
|
||||
<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>
|
||||
</sql>
|
||||
<select id="countByQuery" resultType="long">
|
||||
SELECT COUNT(1) FROM `gao_order_fulfillment` WHERE <include refid="queryWhere"/>
|
||||
</select>
|
||||
<select id="selectByQuery" resultType="com.imyeyu.api.modules.gao.entity.GaoOrderFulfillment">
|
||||
SELECT * FROM `gao_order_fulfillment`
|
||||
WHERE <include refid="queryWhere"/>
|
||||
ORDER BY `delivered_at` DESC, `created_at` DESC
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
<update id="updateStatus">
|
||||
UPDATE `gao_order_fulfillment`
|
||||
SET `status` = #{status}, `verifier_user_id` = #{verifierUserId}, `verified_at` = #{verifiedAt},
|
||||
`reason` = #{reason}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -1,20 +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.GaoPackageDeliveryItemMapper">
|
||||
<select id="selectByDeliveryId" resultType="com.imyeyu.api.modules.gao.entity.GaoPackageDeliveryItem">
|
||||
SELECT * FROM `gao_package_delivery_item`
|
||||
WHERE `delivery_id` = #{deliveryId} AND `deleted_at` IS NULL
|
||||
ORDER BY `created_at`, `id`
|
||||
</select>
|
||||
<select id="selectByDeliveryIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoPackageDeliveryItem">
|
||||
SELECT * FROM `gao_package_delivery_item`
|
||||
WHERE `deleted_at` IS NULL
|
||||
<choose>
|
||||
<when test="deliveryIdList != null and !deliveryIdList.isEmpty()">
|
||||
AND `delivery_id` IN <foreach collection="deliveryIdList" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</when>
|
||||
<otherwise>AND FALSE</otherwise>
|
||||
</choose>
|
||||
ORDER BY `delivery_id`, `created_at`, `id`
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,55 +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.GaoPackageDeliveryMapper">
|
||||
<select id="selectByRequestNo" resultType="com.imyeyu.api.modules.gao.entity.GaoPackageDelivery">
|
||||
SELECT * FROM `gao_package_delivery`
|
||||
WHERE `store_id` = #{storeId} AND `request_no` = #{requestNo}
|
||||
LIMIT 1
|
||||
</select>
|
||||
<select id="selectForUpdate" resultType="com.imyeyu.api.modules.gao.entity.GaoPackageDelivery">
|
||||
SELECT * FROM `gao_package_delivery`
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL
|
||||
FOR UPDATE
|
||||
</select>
|
||||
<select id="selectRevokeBySourceDeliveryId" resultType="com.imyeyu.api.modules.gao.entity.GaoPackageDelivery">
|
||||
SELECT * FROM `gao_package_delivery`
|
||||
WHERE `source_delivery_id` = #{sourceDeliveryId} AND `deleted_at` IS NULL
|
||||
LIMIT 1
|
||||
</select>
|
||||
<select id="countPendingByCustomerPackageId" resultType="long">
|
||||
SELECT COUNT(1) FROM `gao_package_delivery`
|
||||
WHERE `customer_package_id` = #{customerPackageId} AND `status` = 'PENDING' AND `operation_type` = 'DELIVER' AND `deleted_at` IS NULL
|
||||
</select>
|
||||
<select id="countVerifiedByCustomerPackageId" resultType="long">
|
||||
SELECT COUNT(1) FROM `gao_package_delivery`
|
||||
WHERE `customer_package_id` = #{customerPackageId} AND `status` = 'VERIFIED' AND `operation_type` = 'DELIVER' AND `deleted_at` IS NULL
|
||||
</select>
|
||||
<select id="selectByCustomerPackageId" resultType="com.imyeyu.api.modules.gao.entity.GaoPackageDelivery">
|
||||
SELECT * FROM `gao_package_delivery`
|
||||
WHERE `customer_package_id` = #{customerPackageId} AND `deleted_at` IS NULL
|
||||
ORDER BY `delivered_at` DESC, `created_at` DESC
|
||||
</select>
|
||||
<sql id="queryWhere">
|
||||
d.`deleted_at` IS NULL
|
||||
<if test="storeId != null and storeId != ''">AND d.`store_id` = #{storeId}</if>
|
||||
<if test="customerPackageId != null and customerPackageId != ''">AND d.`customer_package_id` = #{customerPackageId}</if>
|
||||
<if test="customerId != null and customerId != ''">AND d.`customer_id` = #{customerId}</if>
|
||||
<if test="status != null">AND d.`status` = #{status}</if>
|
||||
<if test="operationType != null">AND d.`operation_type` = #{operationType}</if>
|
||||
<if test="beginAt != null">AND d.`delivered_at` >= #{beginAt}</if>
|
||||
<if test="endAt != null">AND d.`delivered_at` <= #{endAt}</if>
|
||||
</sql>
|
||||
<select id="countByQuery" resultType="long">
|
||||
SELECT COUNT(1) FROM `gao_package_delivery` d WHERE <include refid="queryWhere"/>
|
||||
</select>
|
||||
<select id="selectByQuery" resultType="com.imyeyu.api.modules.gao.entity.GaoPackageDelivery">
|
||||
SELECT d.* FROM `gao_package_delivery` d WHERE <include refid="queryWhere"/>
|
||||
ORDER BY d.`delivered_at` DESC, d.`created_at` DESC
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
<update id="updateStatusIf">
|
||||
UPDATE `gao_package_delivery`
|
||||
SET `status` = #{toStatus}, `verifier_user_id` = #{verifierUserId}, `verified_at` = #{verifiedAt}, `reason` = #{reason}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id} AND `status` = #{fromStatus} AND `deleted_at` IS NULL
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,63 @@
|
||||
<?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.GaoProductCategoryMapper">
|
||||
<select id="selectById" resultType="com.imyeyu.api.modules.gao.entity.GaoProductCategory">
|
||||
SELECT * FROM `gao_product_category`
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL
|
||||
</select>
|
||||
<select id="selectByIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoProductCategory">
|
||||
SELECT * FROM `gao_product_category`
|
||||
WHERE `deleted_at` IS NULL
|
||||
<if test="idList != null and !idList.isEmpty()">
|
||||
AND `id` IN
|
||||
<foreach collection="idList" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="idList == null or idList.isEmpty()">
|
||||
AND FALSE
|
||||
</if>
|
||||
</select>
|
||||
<update id="updateSort">
|
||||
UPDATE `gao_product_category`
|
||||
SET
|
||||
`sort` = CASE `id`
|
||||
<foreach collection="idList" item="id" index="sort" separator=" ">
|
||||
WHEN #{id} THEN #{sort}
|
||||
</foreach>
|
||||
END,
|
||||
`updated_at` = #{updatedAt}
|
||||
WHERE `deleted_at` IS NULL
|
||||
AND `id` IN
|
||||
<foreach collection="idList" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
<select id="countByQuery" resultType="long">
|
||||
SELECT COUNT(1) FROM `gao_product_category`
|
||||
WHERE `deleted_at` IS NULL
|
||||
<if test="storeId != null and storeId != ''">AND `store_id` = #{storeId}</if>
|
||||
<if test="status != null">AND `status` = #{status}</if>
|
||||
<if test="keyword != null and keyword.trim() != ''">AND `name` LIKE CONCAT('%', #{keyword}, '%')</if>
|
||||
</select>
|
||||
<select id="selectByQuery" resultType="com.imyeyu.api.modules.gao.entity.GaoProductCategory">
|
||||
SELECT * FROM `gao_product_category`
|
||||
WHERE `deleted_at` IS NULL
|
||||
<if test="storeId != null and storeId != ''">AND `store_id` = #{storeId}</if>
|
||||
<if test="status != null">AND `status` = #{status}</if>
|
||||
<if test="keyword != null and keyword.trim() != ''">AND `name` LIKE CONCAT('%', #{keyword}, '%')</if>
|
||||
ORDER BY `sort`, `name`, `created_at`
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
<select id="selectByStoreId" resultType="com.imyeyu.api.modules.gao.entity.GaoProductCategory">
|
||||
SELECT * FROM `gao_product_category`
|
||||
WHERE `store_id` = #{storeId} AND `deleted_at` IS NULL
|
||||
ORDER BY `sort`, `name`, `created_at`
|
||||
</select>
|
||||
<select id="selectByStoreIdAndName" resultType="com.imyeyu.api.modules.gao.entity.GaoProductCategory">
|
||||
SELECT * FROM `gao_product_category`
|
||||
WHERE `store_id` = #{storeId} AND `name` = #{name} AND `deleted_at` IS NULL
|
||||
<if test="excludeId != null">AND `id` != #{excludeId}</if>
|
||||
LIMIT 1
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?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.GaoProductMapper">
|
||||
<select id="countByQuery" resultType="long">
|
||||
SELECT COUNT(1) FROM `gao_product`
|
||||
WHERE `deleted_at` IS NULL
|
||||
<if test="storeId != null and storeId != ''">AND `store_id` = #{storeId}</if>
|
||||
<choose>
|
||||
<when test="categoryIdList != null and categoryIdList.size() > 0">
|
||||
AND `category_id` IN <foreach collection="categoryIdList" item="categoryIdItem" separator="," open="(" close=")">#{categoryIdItem}</foreach>
|
||||
</when>
|
||||
<when test="categoryId != null and categoryId != ''">AND `category_id` = #{categoryId}</when>
|
||||
</choose>
|
||||
<if test="status != null">AND `status` = #{status}</if>
|
||||
<if test="productType != null">AND `product_type` = #{productType}</if>
|
||||
<if test="keyword != null and keyword.trim() != ''">AND (`code` LIKE CONCAT('%', #{keyword}, '%') OR `name` LIKE CONCAT('%', #{keyword}, '%'))</if>
|
||||
</select>
|
||||
<select id="selectByQuery" resultType="com.imyeyu.api.modules.gao.entity.GaoProduct">
|
||||
SELECT * FROM `gao_product`
|
||||
WHERE `deleted_at` IS NULL
|
||||
<if test="storeId != null and storeId != ''">AND `store_id` = #{storeId}</if>
|
||||
<choose>
|
||||
<when test="categoryIdList != null and categoryIdList.size() > 0">
|
||||
AND `category_id` IN <foreach collection="categoryIdList" item="categoryIdItem" separator="," open="(" close=")">#{categoryIdItem}</foreach>
|
||||
</when>
|
||||
<when test="categoryId != null and categoryId != ''">AND `category_id` = #{categoryId}</when>
|
||||
</choose>
|
||||
<if test="status != null">AND `status` = #{status}</if>
|
||||
<if test="productType != null">AND `product_type` = #{productType}</if>
|
||||
<if test="keyword != null and keyword.trim() != ''">AND (`code` LIKE CONCAT('%', #{keyword}, '%') OR `name` LIKE CONCAT('%', #{keyword}, '%'))</if>
|
||||
ORDER BY `sort`, `name`, `code`, `created_at` DESC
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
<select id="selectByStoreIdAndCode" resultType="com.imyeyu.api.modules.gao.entity.GaoProduct">
|
||||
SELECT * FROM `gao_product`
|
||||
WHERE `store_id` = #{storeId} AND `code` = #{code} AND `deleted_at` IS NULL
|
||||
<if test="excludeId != null">AND `id` != #{excludeId}</if>
|
||||
LIMIT 1
|
||||
</select>
|
||||
<select id="selectForUpdate" resultType="com.imyeyu.api.modules.gao.entity.GaoProduct">
|
||||
SELECT * FROM `gao_product`
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL
|
||||
FOR UPDATE
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,60 @@
|
||||
<?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.GaoProductStockMapper">
|
||||
<select id="selectForUpdate" resultType="com.imyeyu.api.modules.gao.entity.GaoProductStock">
|
||||
SELECT * FROM `gao_product_stock`
|
||||
WHERE `store_id` = #{storeId} AND `product_id` = #{productId}
|
||||
FOR UPDATE
|
||||
</select>
|
||||
<select id="selectByStoreIdAndProductId" resultType="com.imyeyu.api.modules.gao.entity.GaoProductStock">
|
||||
SELECT * FROM `gao_product_stock`
|
||||
WHERE `store_id` = #{storeId} AND `product_id` = #{productId}
|
||||
</select>
|
||||
<select id="countByQuery" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM `gao_product_stock` s
|
||||
INNER JOIN `gao_product` p ON p.`id` = s.`product_id` AND p.`deleted_at` IS NULL
|
||||
WHERE 1 = 1
|
||||
<if test="storeId != null and storeId != ''">AND s.`store_id` = #{storeId}</if>
|
||||
<if test="productId != null and productId != ''">AND s.`product_id` = #{productId}</if>
|
||||
<if test="keyword != null and keyword.trim() != ''">AND (p.`code` LIKE CONCAT('%', #{keyword}, '%') OR p.`name` LIKE CONCAT('%', #{keyword}, '%'))</if>
|
||||
</select>
|
||||
<select id="selectByQuery" resultType="com.imyeyu.api.modules.gao.entity.GaoProductStock">
|
||||
SELECT s.*
|
||||
FROM `gao_product_stock` s
|
||||
INNER JOIN `gao_product` p ON p.`id` = s.`product_id` AND p.`deleted_at` IS NULL
|
||||
WHERE 1 = 1
|
||||
<if test="storeId != null and storeId != ''">AND s.`store_id` = #{storeId}</if>
|
||||
<if test="productId != null and productId != ''">AND s.`product_id` = #{productId}</if>
|
||||
<if test="keyword != null and keyword.trim() != ''">AND (p.`code` LIKE CONCAT('%', #{keyword}, '%') OR p.`name` LIKE CONCAT('%', #{keyword}, '%'))</if>
|
||||
ORDER BY p.`sort`, p.`name`, p.`code`
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
<insert id="insertIgnore">
|
||||
INSERT IGNORE INTO `gao_product_stock`
|
||||
(`id`, `store_id`, `product_id`, `on_hand_quantity`, `reserved_quantity`, `updated_by`, `created_at`)
|
||||
VALUES
|
||||
(#{id}, #{storeId}, #{productId}, #{onHandQuantity}, #{reservedQuantity}, #{updatedBy}, #{createdAt})
|
||||
</insert>
|
||||
<update id="updateQuantity">
|
||||
UPDATE `gao_product_stock`
|
||||
SET `on_hand_quantity` = `on_hand_quantity` + #{onHandDelta},
|
||||
`reserved_quantity` = `reserved_quantity` + #{reservedDelta},
|
||||
`updated_by` = #{updatedBy},
|
||||
`updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id}
|
||||
AND `on_hand_quantity` + #{onHandDelta} >= 0
|
||||
AND `reserved_quantity` + #{reservedDelta} >= 0
|
||||
AND `reserved_quantity` + #{reservedDelta} <= `on_hand_quantity` + #{onHandDelta}
|
||||
</update>
|
||||
<update id="reserve">
|
||||
UPDATE `gao_product_stock`
|
||||
SET `reserved_quantity` = `reserved_quantity` + #{quantity}, `updated_by` = #{updatedBy}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id} AND `reserved_quantity` + #{quantity} <= `on_hand_quantity`
|
||||
</update>
|
||||
<update id="release">
|
||||
UPDATE `gao_product_stock`
|
||||
SET `reserved_quantity` = `reserved_quantity` - #{quantity}, `updated_by` = #{updatedBy}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id} AND `reserved_quantity` >= #{quantity}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?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.GaoProductUnitMapper">
|
||||
<resultMap id="unitResultMap" type="com.imyeyu.api.modules.gao.entity.GaoProductUnit">
|
||||
<id column="id" property="id"/>
|
||||
<result column="product_id" property="productId"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="conversion_to_base" property="conversionToBase"/>
|
||||
<result column="is_base" property="isBase"/>
|
||||
<result column="allow_purchase" property="allowPurchase"/>
|
||||
<result column="allow_sale" property="allowSale"/>
|
||||
<result column="sort" property="sort"/>
|
||||
<result column="created_at" property="createdAt"/>
|
||||
<result column="updated_at" property="updatedAt"/>
|
||||
<result column="deleted_at" property="deletedAt"/>
|
||||
</resultMap>
|
||||
<select id="selectByProductId" resultMap="unitResultMap">
|
||||
SELECT * FROM `gao_product_unit`
|
||||
WHERE `product_id` = #{productId} AND `deleted_at` IS NULL
|
||||
ORDER BY `sort`, `created_at`
|
||||
</select>
|
||||
<select id="selectByProductIdList" resultMap="unitResultMap">
|
||||
SELECT * FROM `gao_product_unit`
|
||||
WHERE `deleted_at` IS NULL
|
||||
<choose>
|
||||
<when test="productIdList != null and !productIdList.isEmpty()">
|
||||
AND `product_id` IN <foreach collection="productIdList" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</when>
|
||||
<otherwise>AND FALSE</otherwise>
|
||||
</choose>
|
||||
ORDER BY `product_id`, `sort`, `created_at`
|
||||
</select>
|
||||
<select id="selectForUpdate" resultMap="unitResultMap">
|
||||
SELECT * FROM `gao_product_unit`
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL
|
||||
FOR UPDATE
|
||||
</select>
|
||||
<update id="updateUnit">
|
||||
UPDATE `gao_product_unit`
|
||||
SET `name` = #{name}, `conversion_to_base` = #{conversionToBase}, `is_base` = #{isBase},
|
||||
`allow_purchase` = #{allowPurchase}, `allow_sale` = #{allowSale}, `sort` = #{sort},
|
||||
`updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id} AND `product_id` = #{productId} AND `deleted_at` IS NULL
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?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.GaoSalesOrderItemMapper">
|
||||
<select id="selectBySalesOrderId" resultType="com.imyeyu.api.modules.gao.entity.GaoSalesOrderItem">
|
||||
SELECT * FROM `gao_sales_order_item`
|
||||
WHERE `sales_order_id` = #{salesOrderId} AND `deleted_at` IS NULL
|
||||
ORDER BY `sort`, `created_at`
|
||||
</select>
|
||||
<select id="selectForUpdate" resultType="com.imyeyu.api.modules.gao.entity.GaoSalesOrderItem">
|
||||
SELECT * FROM `gao_sales_order_item`
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL
|
||||
FOR UPDATE
|
||||
</select>
|
||||
<update id="updateReservedQuantity">
|
||||
UPDATE `gao_sales_order_item`
|
||||
SET `reserved_quantity` = `reserved_quantity` + #{delta}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id} AND `reserved_quantity` + #{delta} >= 0
|
||||
AND `fulfilled_quantity` + `reserved_quantity` + #{delta} <= `quantity`
|
||||
</update>
|
||||
<update id="updateFulfilledQuantity">
|
||||
UPDATE `gao_sales_order_item`
|
||||
SET `fulfilled_quantity` = `fulfilled_quantity` + #{delta}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id} AND `fulfilled_quantity` + #{delta} >= 0
|
||||
AND `fulfilled_quantity` + #{delta} <= `quantity`
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,56 @@
|
||||
<?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.GaoSalesOrderMapper">
|
||||
<select id="selectByRequestNo" resultType="com.imyeyu.api.modules.gao.entity.GaoSalesOrder">
|
||||
SELECT * FROM `gao_sales_order`
|
||||
WHERE `store_id` = #{storeId} AND `request_no` = #{requestNo} AND `deleted_at` IS NULL
|
||||
LIMIT 1
|
||||
</select>
|
||||
<select id="selectForUpdate" resultType="com.imyeyu.api.modules.gao.entity.GaoSalesOrder">
|
||||
SELECT * FROM `gao_sales_order`
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL
|
||||
FOR UPDATE
|
||||
</select>
|
||||
<sql id="queryWhere">
|
||||
o.`deleted_at` IS NULL
|
||||
<if test="storeId != null and storeId != ''">AND o.`store_id` = #{storeId}</if>
|
||||
<if test="customerId != null and customerId != ''">AND o.`customer_id` = #{customerId}</if>
|
||||
<if test="orderType != null">AND o.`order_type` = #{orderType}</if>
|
||||
<if test="status != null">AND o.`status` = #{status}</if>
|
||||
<if test="paymentStatus != null">AND o.`payment_status` = #{paymentStatus}</if>
|
||||
<if test="fulfilledButUnpaid != null and fulfilledButUnpaid">AND o.`status` = 'FULFILLED' AND o.`paid_amount` < o.`sale_amount`</if>
|
||||
<if test="keyword != null and keyword.trim() != ''">AND (o.`order_no` LIKE CONCAT('%', #{keyword}, '%') OR c.`name` LIKE CONCAT('%', #{keyword}, '%') OR c.`code` LIKE CONCAT('%', #{keyword}, '%'))</if>
|
||||
<if test="beginAt != null">AND o.`purchased_at` >= #{beginAt}</if>
|
||||
<if test="endAt != null">AND o.`purchased_at` <= #{endAt}</if>
|
||||
</sql>
|
||||
<select id="countByQuery" resultType="long">
|
||||
SELECT COUNT(1) FROM `gao_sales_order` o LEFT JOIN `gao_customer` c ON c.`id` = o.`customer_id` WHERE <include refid="queryWhere"/>
|
||||
</select>
|
||||
<select id="selectByQuery" resultType="com.imyeyu.api.modules.gao.entity.GaoSalesOrder">
|
||||
SELECT o.* FROM `gao_sales_order` o LEFT JOIN `gao_customer` c ON c.`id` = o.`customer_id` WHERE <include refid="queryWhere"/>
|
||||
ORDER BY o.`purchased_at` DESC, o.`created_at` DESC
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
<update id="updatePayment">
|
||||
UPDATE `gao_sales_order`
|
||||
SET `pending_paid_amount` = #{pendingPaidAmount}, `paid_amount` = #{paidAmount}, `refunded_amount` = #{refundedAmount},
|
||||
`payment_status` = #{paymentStatus}, `refund_status` = #{refundStatus}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL
|
||||
</update>
|
||||
<update id="cancelIf">
|
||||
UPDATE `gao_sales_order`
|
||||
SET `status` = #{toStatus}, `cancelled_at` = #{cancelledAt}, `cancel_operator_user_id` = #{cancelOperatorUserId},
|
||||
`cancel_reason` = #{cancelReason}, `refund_status` = #{refundStatus}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id} AND `status` = #{fromStatus} AND `deleted_at` IS NULL
|
||||
</update>
|
||||
<update id="updateSourceEventRecordId">
|
||||
UPDATE `gao_sales_order`
|
||||
SET `source_event_record_id` = #{sourceEventRecordId}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id} AND `source_event_record_id` IS NULL AND `deleted_at` IS NULL
|
||||
</update>
|
||||
<update id="updateStatus">
|
||||
UPDATE `gao_sales_order`
|
||||
SET `status` = #{status}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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.GaoStockRecordMapper">
|
||||
<select id="selectByRequestNo" resultType="com.imyeyu.api.modules.gao.entity.GaoStockRecord">
|
||||
SELECT * FROM `gao_stock_record`
|
||||
WHERE `store_id` = #{storeId} AND `request_no` = #{requestNo}
|
||||
ORDER BY `product_id`, `id`
|
||||
</select>
|
||||
<select id="selectByBiz" resultType="com.imyeyu.api.modules.gao.entity.GaoStockRecord">
|
||||
SELECT * FROM `gao_stock_record`
|
||||
WHERE `biz_type` = #{bizType} AND `biz_id` = #{bizId}
|
||||
ORDER BY `occurred_at`, `id`
|
||||
</select>
|
||||
<select id="selectByBizProduct" resultType="com.imyeyu.api.modules.gao.entity.GaoStockRecord">
|
||||
SELECT * FROM `gao_stock_record`
|
||||
WHERE `biz_type` = #{bizType} AND `biz_id` = #{bizId} AND `product_id` = #{productId} AND `operation_type` = #{operationType}
|
||||
ORDER BY `occurred_at`, `id`
|
||||
LIMIT 1
|
||||
</select>
|
||||
<sql id="queryWhere">
|
||||
1 = 1
|
||||
<if test="storeId != null and storeId != ''">AND r.`store_id` = #{storeId}</if>
|
||||
<if test="productId != null and productId != ''">AND r.`product_id` = #{productId}</if>
|
||||
<if test="bizType != null">AND r.`biz_type` = #{bizType}</if>
|
||||
<if test="bizId != null and bizId != ''">AND r.`biz_id` = #{bizId}</if>
|
||||
<if test="operationType != null">AND r.`operation_type` = #{operationType}</if>
|
||||
<if test="beginAt != null">AND r.`occurred_at` >= #{beginAt}</if>
|
||||
<if test="endAt != null">AND r.`occurred_at` <= #{endAt}</if>
|
||||
</sql>
|
||||
<select id="countByQuery" resultType="long">
|
||||
SELECT COUNT(1) FROM `gao_stock_record` r WHERE <include refid="queryWhere"/>
|
||||
</select>
|
||||
<select id="selectByQuery" resultType="com.imyeyu.api.modules.gao.entity.GaoStockRecord">
|
||||
SELECT r.* FROM `gao_stock_record` r WHERE <include refid="queryWhere"/>
|
||||
ORDER BY r.`occurred_at` DESC, r.`id` DESC
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user