From 138e3641fbe49a114a399323aa145774f310627e Mon Sep 17 00:00:00 2001 From: xin <1099200748@qq.com> Date: Fri, 11 Jul 2025 18:06:31 +0800 Subject: [PATCH] 订单信息优化 --- oying-system/src/main/resources/mapper/sh/OrderMapper.xml | 141 +++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 123 insertions(+), 18 deletions(-) diff --git a/oying-system/src/main/resources/mapper/sh/OrderMapper.xml b/oying-system/src/main/resources/mapper/sh/OrderMapper.xml index 7162d03..bd2fb2c 100644 --- a/oying-system/src/main/resources/mapper/sh/OrderMapper.xml +++ b/oying-system/src/main/resources/mapper/sh/OrderMapper.xml @@ -6,6 +6,8 @@ <result column="order_num" property="orderNum"/> <result column="order_status" property="orderStatus"/> <result column="order_status_describe" property="orderStatusDescribe"/> + <result column="order_remark" property="orderRemark"/> + <result column="order_time" property="orderTime"/> <result column="user_id" property="userId"/> <result column="username" property="username"/> <result column="store_id" property="storeId"/> @@ -31,63 +33,166 @@ <result column="create_time" property="createTime"/> <result column="update_by" property="updateBy"/> <result column="update_time" property="updateTime"/> + <collection property="productSnapshots" ofType="com.oying.modules.sh.domain.OrderProductSnapshot"> + <id column="snapshot_id" property="snapshotId"/> + <result column="product_id" property="productId"/> + <result column="product_code" property="productCode"/> + <result column="product_barcode" property="productBarcode"/> + <result column="product_name" property="productName"/> + <result column="product_title" property="productTitle"/> + <result column="product_main_image" property="productMainImage"/> + <result column="product_description" property="productDescription"/> + <result column="param_data" property="paramData"/> + <result column="unit_price" property="unitPrice"/> + <result column="detail_count" property="detailCount"/> + <result column="original_price" property="originalPrice"/> + <result column="paid_price" property="paidPrice"/> + <result column="actually_pay_price" property="actuallyPayPrice"/> + <result column="pay_state" property="payState"/> + </collection> </resultMap> <sql id="Base_Column_List"> - order_id, order_num, order_status, order_status_describe, user_id, username, store_id, store_name, store_logo, order_describe, original_price, paid_price, actually_pay_price, pay_state, pay_message, pay_type, pay_time, expire_time, openid, app_id, timestamp, nonce_str, package_val, sign_type, pay_sign, create_by, create_time, update_by, update_time + o.order_id, o.order_num, o.order_status, o.order_status_describe, o.order_remark, o.order_time, o.user_id, o.username, o.store_id, + o.store_name, o.store_logo, o.order_describe, o.original_price, o.paid_price, o.actually_pay_price, o.pay_state, o.pay_message, + o.pay_type, o.pay_time, o.expire_time, o.openid, o.app_id, o.timestamp, o.nonce_str, o.package_val, o.sign_type, o.pay_sign, + o.create_by, o.create_time, o.update_by, o.update_time + </sql> + + <sql id="product_Column_List"> + p.snapshot_id, p.product_id, p.product_code, p.product_barcode, p.product_name, p.product_title, + p.product_main_image, p.product_description, p.param_data, p.unit_price, p.detail_count, p.original_price, p.paid_price, + p.actually_pay_price, p.pay_state </sql> <update id="updatePayStatus"> - update sh_order set pay_state = #{payState}, pay_message = #{payMessage}, - pay_time = #{payTime} where order_num = #{orderNum} + update sh_order + set pay_state = #{payState}, + pay_message = #{payMessage}, + pay_time = #{payTime} + where order_num = #{orderNum} </update> <update id="updateCloseStatus"> - update sh_order set pay_state = #{payState} where order_num = #{orderNum} + update sh_order + set pay_state = #{payState} + where order_num = #{orderNum} </update> <select id="findAll" resultMap="BaseResultMap"> + select o.*, + <include refid="product_Column_List"/> + from ( select <include refid="Base_Column_List"/> - from sh_order + from sh_order as o <where> <if test="criteria.orderNum != null and criteria.orderNum != ''"> - and order_num like concat('%',#{criteria.orderNum},'%') + and o.order_num like concat('%',#{criteria.orderNum},'%') </if> <if test="criteria.orderStatus != null and criteria.orderStatus != ''"> - and order_status = #{criteria.orderStatus} + and o.order_status = #{criteria.orderStatus} </if> <if test="criteria.userId != null and criteria.userId != ''"> - and user_id = #{criteria.userId} + and o.user_id = #{criteria.userId} </if> <if test="criteria.username != null and criteria.username != ''"> - and username like concat('%',#{criteria.username},'%') + and o.username like concat('%',#{criteria.username},'%') </if> <if test="criteria.storeId != null and criteria.storeId != ''"> - and store_id = #{criteria.storeId} + and o.store_id = #{criteria.storeId} </if> <if test="criteria.orderDescribe != null and criteria.orderDescribe != ''"> - and order_describe like concat('%',#{criteria.orderDescribe},'%') + and o.order_describe like concat('%',#{criteria.orderDescribe},'%') </if> <if test="criteria.payState != null and criteria.payState != ''"> - and pay_state = #{criteria.payState} + and o.pay_state = #{criteria.payState} </if> <if test="criteria.payType != null and criteria.payType != ''"> - and pay_type = #{criteria.payType} + and o.pay_type = #{criteria.payType} </if> <if test="criteria.payTime != null and criteria.payTime.size() > 0"> - AND pay_time BETWEEN #{criteria.payTime[0]} AND #{criteria.payTime[1]} + AND o.pay_time BETWEEN #{criteria.payTime[0]} AND #{criteria.payTime[1]} </if> <if test="criteria.createTime != null and criteria.createTime.size() > 0"> - AND create_time BETWEEN #{criteria.createTime[0]} AND #{criteria.createTime[1]} + AND o.create_time BETWEEN #{criteria.createTime[0]} AND #{criteria.createTime[1]} </if> </where> - order by order_id desc + order by o.order_id desc + <if test="criteria.offset != null"> + limit #{criteria.offset}, #{criteria.size} + </if> + ) o + left join sh_order_product_snapshot as p on p.order_num = o.order_num + where 1=1 + <if test="criteria.blurry != null and criteria.blurry != ''"> + and (o.product_code like concat('%',#{criteria.blurry},'%') + or o.product_barcode like concat('%',#{criteria.blurry},'%') + or o.product_name like concat('%',#{criteria.blurry},'%') + or o.product_title like concat('%',#{criteria.blurry},'%') + or o.product_description like concat('%',#{criteria.blurry},'%')) + </if> + order by o.order_id desc </select> <select id="getByOrderNum" resultMap="BaseResultMap"> select <include refid="Base_Column_List"/> - from sh_order - where order_num = #{orderNum} + from sh_order as o + where o.order_num = #{orderNum} + </select> + <select id="countAll" resultType="java.lang.Long"> + select count(1) + from ( select distinct o.*, + p.product_code, + p.product_barcode, + p.product_name, + p.product_title, + p.product_description + from ( + select + <include refid="Base_Column_List"/> + from sh_order as o + <where> + <if test="criteria.orderNum != null and criteria.orderNum != ''"> + and o.order_num like concat('%',#{criteria.orderNum},'%') + </if> + <if test="criteria.orderStatus != null and criteria.orderStatus != ''"> + and o.order_status = #{criteria.orderStatus} + </if> + <if test="criteria.userId != null and criteria.userId != ''"> + and o.user_id = #{criteria.userId} + </if> + <if test="criteria.username != null and criteria.username != ''"> + and o.username like concat('%',#{criteria.username},'%') + </if> + <if test="criteria.storeId != null and criteria.storeId != ''"> + and o.store_id = #{criteria.storeId} + </if> + <if test="criteria.orderDescribe != null and criteria.orderDescribe != ''"> + and o.order_describe like concat('%',#{criteria.orderDescribe},'%') + </if> + <if test="criteria.payState != null and criteria.payState != ''"> + and o.pay_state = #{criteria.payState} + </if> + <if test="criteria.payType != null and criteria.payType != ''"> + and o.pay_type = #{criteria.payType} + </if> + <if test="criteria.payTime != null and criteria.payTime.size() > 0"> + AND o.pay_time BETWEEN #{criteria.payTime[0]} AND #{criteria.payTime[1]} + </if> + <if test="criteria.createTime != null and criteria.createTime.size() > 0"> + AND o.create_time BETWEEN #{criteria.createTime[0]} AND #{criteria.createTime[1]} + </if> + </where> + ) o + left join sh_order_product_snapshot as p on p.order_num = o.order_num + where 1=1 + <if test="criteria.blurry != null and criteria.blurry != ''"> + and (p.product_code like concat('%',#{criteria.blurry},'%') + or p.product_barcode like concat('%',#{criteria.blurry},'%') + or p.product_name like concat('%',#{criteria.blurry},'%') + or p.product_title like concat('%',#{criteria.blurry},'%') + or p.product_description like concat('%',#{criteria.blurry},'%')) + </if>) t </select> </mapper> -- Gitblit v1.9.3