add sales order
This commit is contained in:
@@ -26,8 +26,9 @@
|
||||
<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
|
||||
WHERE <include refid="queryWhere"/>
|
||||
ORDER BY p.`purchased_at` DESC, p.`created_at` DESC
|
||||
ORDER BY o.`purchased_at` DESC, p.`created_at` DESC
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -11,6 +11,13 @@
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL
|
||||
FOR UPDATE
|
||||
</select>
|
||||
<select id="selectWithSalesOrderSummary" resultType="com.imyeyu.api.modules.gao.entity.GaoFundRecord">
|
||||
SELECT f.*, o.`sale_amount` AS `sales_order_amount`
|
||||
FROM `gao_fund_record` f
|
||||
LEFT JOIN `gao_sales_order` o ON o.`id` = f.`biz_id` AND o.`store_id` = f.`store_id` AND o.`deleted_at` IS NULL
|
||||
WHERE f.`id` = #{id} AND f.`deleted_at` IS NULL
|
||||
LIMIT 1
|
||||
</select>
|
||||
<select id="selectRevokeBySourceRecordId" resultType="com.imyeyu.api.modules.gao.entity.GaoFundRecord">
|
||||
SELECT * FROM `gao_fund_record`
|
||||
WHERE `source_record_id` = #{sourceRecordId} AND `deleted_at` IS NULL
|
||||
@@ -21,9 +28,18 @@
|
||||
WHERE `biz_id` = #{bizId} AND `operation_type` = 'RECEIVE' AND `status` = 'PENDING' AND `deleted_at` IS NULL
|
||||
</select>
|
||||
<select id="selectByBizId" resultType="com.imyeyu.api.modules.gao.entity.GaoFundRecord">
|
||||
SELECT * FROM `gao_fund_record`
|
||||
WHERE `biz_id` = #{bizId} AND `deleted_at` IS NULL
|
||||
ORDER BY `occurred_at` DESC, `created_at` DESC
|
||||
SELECT f.*,
|
||||
o.`sale_amount` AS `sales_order_amount`,
|
||||
(
|
||||
SELECT r.`id`
|
||||
FROM `gao_fund_record` r
|
||||
WHERE r.`source_record_id` = f.`id` AND r.`deleted_at` IS NULL
|
||||
LIMIT 1
|
||||
) AS `revoke_record_id`
|
||||
FROM `gao_fund_record` f
|
||||
LEFT JOIN `gao_sales_order` o ON o.`id` = f.`biz_id` AND o.`store_id` = f.`store_id` AND o.`deleted_at` IS NULL
|
||||
WHERE f.`biz_id` = #{bizId} AND f.`deleted_at` IS NULL
|
||||
ORDER BY f.`occurred_at` DESC, f.`created_at` DESC
|
||||
</select>
|
||||
<sql id="queryWhere">
|
||||
f.`deleted_at` IS NULL
|
||||
@@ -41,7 +57,16 @@
|
||||
SELECT COUNT(1) FROM `gao_fund_record` f WHERE <include refid="queryWhere"/>
|
||||
</select>
|
||||
<select id="selectByQuery" resultType="com.imyeyu.api.modules.gao.entity.GaoFundRecord">
|
||||
SELECT f.* FROM `gao_fund_record` f WHERE <include refid="queryWhere"/>
|
||||
SELECT f.*, o.`sale_amount` AS `sales_order_amount`,
|
||||
(
|
||||
SELECT r.`id`
|
||||
FROM `gao_fund_record` r
|
||||
WHERE r.`source_record_id` = f.`id` AND r.`deleted_at` IS NULL
|
||||
LIMIT 1
|
||||
) AS `revoke_record_id`
|
||||
FROM `gao_fund_record` f
|
||||
LEFT JOIN `gao_sales_order` o ON o.`id` = f.`biz_id` AND o.`store_id` = f.`store_id` AND o.`deleted_at` IS NULL
|
||||
WHERE <include refid="queryWhere"/>
|
||||
ORDER BY f.`occurred_at` DESC, f.`created_at` DESC
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
|
||||
@@ -6,6 +6,14 @@
|
||||
WHERE `fulfillment_id` = #{fulfillmentId}
|
||||
ORDER BY `created_at`
|
||||
</select>
|
||||
<select id="selectByFulfillmentIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoOrderFulfillmentItem">
|
||||
SELECT * FROM `gao_order_fulfillment_item`
|
||||
WHERE `fulfillment_id` IN
|
||||
<foreach collection="fulfillmentIdList" item="fulfillmentId" separator="," open="(" close=")">
|
||||
#{fulfillmentId}
|
||||
</foreach>
|
||||
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}
|
||||
|
||||
@@ -31,6 +31,16 @@
|
||||
ORDER BY `sort`, `name`, `code`, `created_at` DESC
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
<select id="selectByIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoProduct">
|
||||
SELECT * FROM `gao_product`
|
||||
WHERE `deleted_at` IS NULL
|
||||
<choose>
|
||||
<when test="idList != null and !idList.isEmpty()">
|
||||
AND `id` IN <foreach collection="idList" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</when>
|
||||
<otherwise>AND FALSE</otherwise>
|
||||
</choose>
|
||||
</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
|
||||
|
||||
@@ -12,20 +12,37 @@
|
||||
</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>
|
||||
FROM `gao_product` p
|
||||
LEFT JOIN `gao_product_stock` s ON s.`product_id` = p.`id`
|
||||
<choose>
|
||||
<when test="storeId != null and storeId != ''">AND s.`store_id` = #{storeId}</when>
|
||||
<otherwise>AND s.`store_id` = p.`store_id`</otherwise>
|
||||
</choose>
|
||||
WHERE p.`deleted_at` IS NULL
|
||||
AND p.`stock_enabled` = 1
|
||||
<if test="storeId != null and storeId != ''">AND p.`store_id` = #{storeId}</if>
|
||||
<if test="productId != null and productId != ''">AND p.`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>
|
||||
SELECT s.`id`,
|
||||
p.`store_id`,
|
||||
p.`id` AS `product_id`,
|
||||
COALESCE(s.`on_hand_quantity`, 0) AS `on_hand_quantity`,
|
||||
COALESCE(s.`reserved_quantity`, 0) AS `reserved_quantity`,
|
||||
s.`updated_by`,
|
||||
s.`created_at`,
|
||||
s.`updated_at`
|
||||
FROM `gao_product` p
|
||||
LEFT JOIN `gao_product_stock` s ON s.`product_id` = p.`id`
|
||||
<choose>
|
||||
<when test="storeId != null and storeId != ''">AND s.`store_id` = #{storeId}</when>
|
||||
<otherwise>AND s.`store_id` = p.`store_id`</otherwise>
|
||||
</choose>
|
||||
WHERE p.`deleted_at` IS NULL
|
||||
AND p.`stock_enabled` = 1
|
||||
<if test="storeId != null and storeId != ''">AND p.`store_id` = #{storeId}</if>
|
||||
<if test="productId != null and productId != ''">AND p.`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}
|
||||
|
||||
@@ -35,6 +35,20 @@
|
||||
<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="activeReservationOnly == true">
|
||||
AND r.`operation_type` = 'ORDER_RESERVE'
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM `gao_product_stock_record` c
|
||||
WHERE c.`store_id` = r.`store_id`
|
||||
AND c.`biz_type` = r.`biz_type`
|
||||
AND c.`biz_id` = r.`biz_id`
|
||||
AND c.`product_id` = r.`product_id`
|
||||
AND c.`operation_type` IN ('ORDER_RELEASE', 'ORDER_OUT')
|
||||
)
|
||||
</if>
|
||||
<if test="direction != null and direction.name() == 'IN'">AND 0 < r.`on_hand_delta`</if>
|
||||
<if test="direction != null and direction.name() == 'OUT'">AND r.`on_hand_delta` < 0</if>
|
||||
<if test="beginAt != null">AND r.`occurred_at` >= #{beginAt}</if>
|
||||
<if test="endAt != null">AND r.`occurred_at` <= #{endAt}</if>
|
||||
</sql>
|
||||
|
||||
@@ -6,6 +6,15 @@
|
||||
WHERE `sales_order_id` = #{salesOrderId} AND `deleted_at` IS NULL
|
||||
ORDER BY `sort`, `created_at`
|
||||
</select>
|
||||
<select id="selectBySalesOrderIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoSalesOrderItem">
|
||||
SELECT * FROM `gao_sales_order_item`
|
||||
WHERE `sales_order_id` IN
|
||||
<foreach collection="salesOrderIdList" item="salesOrderId" separator="," open="(" close=")">
|
||||
#{salesOrderId}
|
||||
</foreach>
|
||||
AND `deleted_at` IS NULL
|
||||
ORDER BY `sales_order_id`, `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
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
<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="refundStatus != null">AND o.`refund_status` = #{refundStatus}</if>
|
||||
<if test="pendingReceive != null and pendingReceive">AND o.`status` IN ('ACTIVE', 'FULFILLED') AND o.`payment_status` IN ('UNPAID', 'PARTIALLY_PAID')</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>
|
||||
@@ -48,4 +50,9 @@
|
||||
SET `status` = #{status}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL
|
||||
</update>
|
||||
<update id="updateRemark">
|
||||
UPDATE `gao_sales_order`
|
||||
SET `remark` = #{remark}, `updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
|
||||
WHERE `id` = #{id} AND `deleted_at` IS NULL
|
||||
</update>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user