311 lines
14 KiB
XML
311 lines
14 KiB
XML
<?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.wzj.soopin.order.mapper.OrderMapper">
|
|
|
|
<resultMap type="Order" id="OrderResult">
|
|
<result property="id" column="id"/>
|
|
<result property="memberId" column="member_id"/>
|
|
<result property="memberUsername" column="member_username"/>
|
|
<result property="totalAmount" column="total_amount"/>
|
|
<result property="purchasePrice" column="purchase_price"/>
|
|
<result property="payAmount" column="pay_amount"/>
|
|
<result property="freightAmount" column="freight_amount"/>
|
|
<result property="payType" column="pay_type"/>
|
|
<result property="status" column="status"/>
|
|
<result property="aftersaleStatus" column="aftersale_status"/>
|
|
<result property="deliveryCompany" column="delivery_company"/>
|
|
<result property="deliverySn" column="delivery_sn"/>
|
|
<result property="autoConfirmDay" column="auto_confirm_day"/>
|
|
<result property="receiverName" column="receiver_name"/>
|
|
<result property="receiverPhone" column="receiver_phone"/>
|
|
<result property="receiverPostCode" column="receiver_post_code"/>
|
|
<result property="receiverProvince" column="receiver_province"/>
|
|
<result property="receiverCity" column="receiver_city"/>
|
|
<result property="receiverDistrict" column="receiver_district"/>
|
|
<result property="receiverProvinceId" column="receiver_province_id"/>
|
|
<result property="receiverCityId" column="receiver_city_id"/>
|
|
<result property="receiverDistrictId" column="receiver_district_id"/>
|
|
<result property="receiverDetailAddress" column="receiver_detail_address"/>
|
|
<result property="note" column="note"/>
|
|
<result property="confirmStatus" column="confirm_status"/>
|
|
<result property="deleteStatus" column="delete_status"/>
|
|
<result property="paymentTime" column="payment_time"/>
|
|
<result property="deliveryTime" column="delivery_time"/>
|
|
<result property="receiveTime" column="receive_time"/>
|
|
<result property="createBy" column="create_by"/>
|
|
<result property="createTime" column="create_time"/>
|
|
<result property="updateBy" column="update_by"/>
|
|
<result property="updateTime" column="update_time"/>
|
|
<result property="createBy" column="create_by"/>
|
|
<result property="createTime" column="create_time"/>
|
|
<result property="updateBy" column="update_by"/>
|
|
<result property="updateTime" column="update_time" />
|
|
</resultMap>
|
|
|
|
<sql id="selectOrderVo">
|
|
select id, member_id, member_username, total_amount, purchase_price, pay_amount, freight_amount, pay_type, status, aftersale_status, delivery_company, delivery_sn, auto_confirm_day, receiver_name, receiver_phone, receiver_post_code, receiver_province, receiver_city, receiver_district, receiver_province_id, receiver_city_id, receiver_district_id, receiver_detail_address, note, confirm_status, delete_status, payment_time, delivery_time, receive_time, create_by, create_time, update_by, update_time from oms_order
|
|
</sql>
|
|
<update id="cancelBatch">
|
|
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
|
|
update oms_order
|
|
set
|
|
status=#{item.status},
|
|
update_by=#{item.updateBy},
|
|
update_time=#{item.updateTime}
|
|
where id=#{item.id}
|
|
</foreach>
|
|
</update>
|
|
|
|
<select id="selectByEntity" parameterType="Order" resultMap="OrderResult">
|
|
<include refid="selectOrderVo"/>
|
|
<where>
|
|
<if test="memberId != null "> and member_id = #{memberId}</if>
|
|
<if test="memberUsername != null and memberUsername != ''"> and member_username like concat('%', #{memberUsername}, '%')</if>
|
|
<if test="totalAmount != null "> and total_amount = #{totalAmount}</if>
|
|
<if test="purchasePrice != null "> and purchase_price = #{purchasePrice}</if>
|
|
<if test="payAmount != null "> and pay_amount = #{payAmount}</if>
|
|
<if test="freightAmount != null "> and freight_amount = #{freightAmount}</if>
|
|
<if test="payType != null "> and pay_type = #{payType}</if>
|
|
<if test="status != null "> and status = #{status}</if>
|
|
<if test="aftersaleStatus != null "> and aftersale_status = #{aftersaleStatus}</if>
|
|
<if test="deliveryCompany != null and deliveryCompany != ''"> and delivery_company = #{deliveryCompany}</if>
|
|
<if test="deliverySn != null and deliverySn != ''"> and delivery_sn = #{deliverySn}</if>
|
|
<if test="autoConfirmDay != null "> and auto_confirm_day = #{autoConfirmDay}</if>
|
|
<if test="receiverName != null and receiverName != ''"> and receiver_name like concat('%', #{receiverName}, '%')</if>
|
|
<if test="receiverPhone != null and receiverPhone != ''"> and receiver_phone = #{receiverPhone}</if>
|
|
<if test="receiverPostCode != null and receiverPostCode != ''"> and receiver_post_code = #{receiverPostCode}</if>
|
|
<if test="receiverProvince != null and receiverProvince != ''"> and receiver_province = #{receiverProvince}</if>
|
|
<if test="receiverCity != null and receiverCity != ''"> and receiver_city = #{receiverCity}</if>
|
|
<if test="receiverDistrict != null and receiverDistrict != ''"> and receiver_district = #{receiverDistrict}</if>
|
|
<if test="receiverProvinceId != null "> and receiver_province_id = #{receiverProvinceId}</if>
|
|
<if test="receiverCityId != null "> and receiver_city_id = #{receiverCityId}</if>
|
|
<if test="receiverDistrictId != null "> and receiver_district_id = #{receiverDistrictId}</if>
|
|
<if test="receiverDetailAddress != null and receiverDetailAddress != ''"> and receiver_detail_address = #{receiverDetailAddress}</if>
|
|
<if test="note != null and note != ''"> and note = #{note}</if>
|
|
<if test="confirmStatus != null "> and confirm_status = #{confirmStatus}</if>
|
|
<if test="deleteStatus != null "> and delete_status = #{deleteStatus}</if>
|
|
<if test="paymentTime != null "> and payment_time = #{paymentTime}</if>
|
|
<if test="deliveryTime != null "> and delivery_time = #{deliveryTime}</if>
|
|
<if test="receiveTime != null "> and receive_time = #{receiveTime}</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="selectManagerOrderPage" resultType="com.wzj.soopin.order.domain.vo.ManagerOrderVO">
|
|
select
|
|
a.id,
|
|
a.order_sn orderSn,
|
|
a.aftersale_status aftersaleStatus,
|
|
a.status,
|
|
a.member_username userName,
|
|
a.total_amount totalAmount,
|
|
a.pay_amount payAmount,
|
|
a.note,
|
|
a.merchant_note merchantNote,
|
|
a.create_time createTime,
|
|
a.payment_time payTime,
|
|
a.receive_time receiveTime,
|
|
a.pay_type payType,
|
|
a.receiver_name receiverName,
|
|
a.receiver_phone receiverPhone,
|
|
a.receiver_province receiverProvince,
|
|
a.coupon_amount couponAmount,
|
|
a.receiver_city receiverCity,
|
|
a.receiver_district receiverDistrict,
|
|
a.receiver_detail_address receiverDetailAddress,
|
|
a.delivery_time deliveryTime,
|
|
a.delivery_sn deliverySn,
|
|
-- b.quantity buyNum,
|
|
-- b.pic,
|
|
-- b.sp_data spData,
|
|
-- b.product_id productId,
|
|
-- b.product_name productName,
|
|
c.phone_hidden userPhone,
|
|
c.nickname nickName,
|
|
c.mark
|
|
from oms_order a
|
|
-- left join oms_order_item b on a.id = b.order_id
|
|
left join ums_member c on a.member_id = c.id
|
|
where a.aftersale_status = 1
|
|
<if test="orderSn != null and orderSn != ''">
|
|
and a.order_sn = #{orderSn}
|
|
</if>
|
|
<!--<if test="productName != null and productName != ''">-->
|
|
<!--and instr(b.product_name, #{productName}) > 0-->
|
|
<!--</if>-->
|
|
<if test="receiverProvince != null ">
|
|
and a.receiver_province = #{receiverProvince}
|
|
</if>
|
|
<if test="receiverCity != null">
|
|
and a.receiver_city = #{receiverCity}
|
|
</if>
|
|
<if test="receiverDistrict != null">
|
|
and a.receiver_district = #{receiverDistrict}
|
|
</if>
|
|
<if test="userPhone != null and userPhone != ''">
|
|
and c.phone_encrypted=#{userPhone} > 0
|
|
</if>
|
|
<if test="status != null">
|
|
and a.status = #{status}
|
|
</if>
|
|
<if test="payType != null">
|
|
and a.pay_type=#{payType}
|
|
</if>
|
|
<if test="startTime != null and endTime != null">
|
|
and a.create_time between #{startTime} and #{endTime}
|
|
</if>
|
|
order by a.create_time desc
|
|
</select>
|
|
|
|
<select id="orderPage" resultType="com.wzj.soopin.order.domain.vo.H5OrderVO">
|
|
select
|
|
id orderId,
|
|
pay_id,
|
|
order_sn,
|
|
member_id,
|
|
total_amount,
|
|
pay_amount,
|
|
status,
|
|
aftersale_status,
|
|
note,
|
|
delivery_sn,
|
|
coupon_amount,
|
|
create_time,
|
|
payment_time,
|
|
receiver_name,
|
|
receiver_phone,
|
|
receiver_province,
|
|
receiver_city,
|
|
receiver_district,
|
|
receiver_detail_address
|
|
from oms_order
|
|
where
|
|
delete_status=0
|
|
and member_id=#{memberId}
|
|
<if test="status==-1">
|
|
and status in (1,2,3,4)
|
|
</if>
|
|
<if test="status>-1 and status<3">
|
|
and status=#{status}
|
|
and aftersale_status=1
|
|
</if>
|
|
<if test="status==-2">
|
|
and aftersale_status in (2, 3)
|
|
</if>
|
|
order by create_time desc
|
|
</select>
|
|
<select id="selectOrderDetail" resultType="com.wzj.soopin.order.domain.vo.H5OrderVO">
|
|
select
|
|
id orderId,
|
|
pay_id,
|
|
order_sn,
|
|
member_id,
|
|
total_amount,
|
|
pay_amount,
|
|
coupon_amount,
|
|
status,
|
|
aftersale_status,
|
|
note,
|
|
delivery_sn,
|
|
create_time,
|
|
payment_time,
|
|
receiver_name,
|
|
receiver_phone,
|
|
receiver_province,
|
|
receiver_city,
|
|
receiver_district,
|
|
receiver_detail_address
|
|
from oms_order
|
|
where
|
|
delete_status=0
|
|
and id=#{orderId}
|
|
</select>
|
|
<select id="countByStatusAndMemberId" resultType="com.wzj.soopin.order.domain.vo.CountOrderVO">
|
|
select
|
|
IFNULL(sum(case when status=0 and aftersale_status=1 then 1 else 0 end),0) unpaid,
|
|
IFNULL(sum(case when status=1 and aftersale_status=1 then 1 else 0 end),0) nosend,
|
|
IFNULL(sum(case when status=2 and aftersale_status=1 then 1 else 0 end),0) noget,
|
|
IFNULL(sum(case when aftersale_status in (2,3) then 1 else 0 end),0) aftersale
|
|
from oms_order
|
|
where member_id=#{memberId} and delete_status=0
|
|
</select>
|
|
<select id="statOrderCountAndAmount" resultType="com.wzj.soopin.order.domain.vo.MemberDataStatisticsVO">
|
|
select
|
|
IFNULL(count(id), 0) orderCount,
|
|
IFNULL(sum(pay_amount), 0) orderAmount
|
|
from oms_order
|
|
where status in (1,2,3) and aftersale_status=1 and member_id=#{memberId}
|
|
</select>
|
|
<select id="statWaitDelivered" resultType="java.lang.Integer">
|
|
select IFNULL(count(id), 0) from oms_order where status=1 and aftersale_status=1
|
|
</select>
|
|
<select id="statTodayData" resultType="com.wzj.soopin.order.domain.vo.OrderAndAftersaleStatisticsVO">
|
|
select
|
|
IFNULL(sum(case when status in (2,3) then 1 else 0 end), 0) todayHasDeliveredCount,
|
|
IFNULL(count(id), 0) todayOrderCount,
|
|
IFNULL(sum(case when status in (1,2,3) then pay_amount else 0 end), 0) todayTransactionAmount
|
|
from oms_order
|
|
where create_time between #{startTime} and #{endTime}
|
|
</select>
|
|
<select id="statNewAndDeal" resultType="com.wzj.soopin.order.domain.entity.SystemStatistics">
|
|
select
|
|
IFNULL(count(distinct member_id), 0) createOrderMemberCount,
|
|
IFNULL(count(id), 0) orderCount,
|
|
IFNULL(sum(case when status in (1,2,3) then 1 else 0 end), 0) dealCount,
|
|
IFNULL(sum(case when status in (1,2,3) then pay_amount else 0 end), 0) dealAmount
|
|
from oms_order
|
|
where create_time between #{startTime} and #{endTime}
|
|
</select>
|
|
<select id="statDealMember" resultType="java.lang.Integer">
|
|
select
|
|
IFNULL(count(distinct member_id), 0)
|
|
from oms_order
|
|
where status in (1,2,3) and create_time between #{startTime} and #{endTime}
|
|
</select>
|
|
|
|
|
|
<select id="getlist" resultType="com.wzj.soopin.order.domain.vo.OrderVO">
|
|
|
|
SELECT
|
|
o.*,
|
|
um.nickname AS memberNickname,
|
|
um.phone_encrypted AS memberPhoneEncrypted,
|
|
st.contact_user_name AS tenantContactName,
|
|
st.contact_phone AS tenantContactPhone,
|
|
oi.id AS itemId,
|
|
oi.product_id AS productId,
|
|
pp.brand_id AS productBrandId,
|
|
pp.name AS productName,
|
|
pp.price AS productPrice
|
|
FROM
|
|
oms_order o
|
|
LEFT JOIN
|
|
ums_member um ON o.member_id = um.id
|
|
LEFT JOIN
|
|
sys_tenant st ON o.tenant_id = st.tenant_id
|
|
LEFT JOIN
|
|
oms_order_item oi ON o.id = oi.order_id
|
|
LEFT JOIN
|
|
pms_product pp ON oi.product_id = pp.id AND pp.publish_status = 1
|
|
WHERE 1=1
|
|
<if test="query.orderSn != null and query.orderSn != ''">
|
|
AND o.order_sn LIKE CONCAT('%', #{query.orderSn}, '%')
|
|
</if>
|
|
<if test="query.memberId != null and query.memberId != ''">
|
|
AND o.member_id LIKE CONCAT('%', #{query.memberId}, '%')
|
|
</if>
|
|
<if test="query.status != null and query.status != ''">
|
|
AND o.status LIKE CONCAT('%', #{query.status}, '%')
|
|
</if>
|
|
<if test="query.startTime != null">
|
|
AND o.create_time >= #{query.startTime, jdbcType=TIMESTAMP}
|
|
</if>
|
|
<if test="query.endTime != null">
|
|
AND o.create_time <= #{query.endTime, jdbcType=TIMESTAMP}
|
|
</if>
|
|
|
|
</select>
|
|
|
|
</mapper>
|