<?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.panzhihua.service_community.dao.ComShopFlowerOrderDAO">
|
<resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ComShopFlowerOrderDO">
|
<!--@mbg.generated-->
|
<!--@Table com_shop_flower_order-->
|
<id column="id" jdbcType="BIGINT" property="id"/>
|
<result column="store_id" jdbcType="BIGINT" property="storeId"/>
|
<result column="user_id" jdbcType="BIGINT" property="userId"/>
|
<result column="order_no" jdbcType="VARCHAR" property="orderNo"/>
|
<result column="pay_no" jdbcType="VARCHAR" property="payNo"/>
|
<result column="wx_tarde_no" jdbcType="VARCHAR" property="wxTardeNo"/>
|
<result column="status" jdbcType="TINYINT" property="status"/>
|
<result column="pay_status" jdbcType="TINYINT" property="payStatus"/>
|
<result column="receiver_id" jdbcType="BIGINT" property="receiverId"/>
|
<result column="delete_status" jdbcType="TINYINT" property="deleteStatus"/>
|
<result column="total_amount" jdbcType="DECIMAL" property="totalAmount"/>
|
<result column="discount_amount" jdbcType="DECIMAL" property="discountAmount"/>
|
<result column="pay_amount" jdbcType="DECIMAL" property="payAmount"/>
|
<result column="pay_type" jdbcType="TINYINT" property="payType"/>
|
<result column="pay_time" jdbcType="TIMESTAMP" property="payTime"/>
|
<result column="delivery_type" jdbcType="TINYINT" property="deliveryType"/>
|
<result column="delivery_status" jdbcType="TINYINT" property="deliveryStatus"/>
|
<result column="remark" jdbcType="VARCHAR" property="remark"/>
|
<result column="logistics_company" jdbcType="VARCHAR" property="logisticsCompany"/>
|
<result column="logistics_no" jdbcType="VARCHAR" property="logisticsNo"/>
|
<result column="create_at" jdbcType="TIMESTAMP" property="createAt"/>
|
<result column="update_at" jdbcType="TIMESTAMP" property="updateAt"/>
|
<result column="delivery_time" jdbcType="TIMESTAMP" property="deliveryTime"/>
|
<result column="service_time" jdbcType="TIMESTAMP" property="serviceTime"/>
|
<result column="receiving_time" jdbcType="TIMESTAMP" property="receivingTime"/>
|
<result column="refund_time" jdbcType="TIMESTAMP" property="refundTime"/>
|
<result column="delivery_id" jdbcType="TIMESTAMP" property="deliveryId"/>
|
<result column="delivery_no" jdbcType="TIMESTAMP" property="deliveryNo"/>
|
|
</resultMap>
|
<sql id="Base_Column_List">
|
<!--@mbg.generated-->
|
id, store_id, user_id, order_no, pay_no, wx_tarde_no, `status`, pay_status, receiver_id,
|
delete_status, total_amount, discount_amount, pay_amount, pay_type, pay_time, delivery_type,
|
delivery_status, remark, logistics_company, logistics_no, create_at, update_at, delivery_time,
|
service_time, receiving_time, refund_time,point_id,delivery_id,delivery_no
|
</sql>
|
|
<select id="pageOrderList" resultType="com.panzhihua.common.model.vos.shop.ComShopFlowerOrderPageVO">
|
select id as orderId,order_no,store_id,`status`,pay_status,receiver_id,total_amount as
|
orderTotal,pay_amount,delivery_type,remark,create_at, logistics_company, logistics_no,receiving_time from com_shop_flower_order as cso
|
where cso.delete_status = 1 and cso.`status` != 0
|
<if test="comOrderListDTO.userId != null">
|
and cso.user_id = #{comOrderListDTO.userId}
|
</if>
|
<if test='comOrderListDTO.status != null'>
|
AND cso.status = #{comOrderListDTO.status}
|
</if>
|
order by create_at desc
|
</select>
|
|
<select id="pageOrderListNoDelivery" resultType="com.panzhihua.common.model.vos.shop.ComShopFlowerOrderPageVO">
|
select cso.id as orderId,cso.order_no,cso.store_id,cso.`status`,cso.pay_status,cso.receiver_id,cso.total_amount as
|
orderTotal,cso.pay_amount,cso.delivery_type,cso.remark,cso.create_at , g.goods_name,g.goods_attr_name,g.amount,g.goods_attr_price,
|
g.goods_attr_pic
|
from com_shop_flower_order as cso LEFT JOIN com_shop_flower_order_goods g ON cso.id = g.order_id
|
where 1=1 and
|
cso.delete_status = 1 and cso.status = 1 and cso.delivery_type = 1
|
<if test='comOrderListDTO.pointId != null'>
|
AND cso.point_id = #{comOrderListDTO.pointId}
|
</if>
|
order by create_at desc
|
</select>
|
|
<select id="pageOrderBy" resultType="com.panzhihua.common.model.vos.shop.ComShopOrderSearchVO">
|
SELECT sr.id, sr.store_id, sr.user_id, su.phone AS userName , sr.order_no, sr.pay_no,
|
sr.wx_tarde_no, sr.status, sr.pay_status, sr.receiver_id,
|
sr.total_amount, sr.discount_amount, sr.pay_amount, sr.pay_type,
|
sr.pay_time, sr.delivery_type, sr.delivery_status, sr.logistics_company,
|
sr.logistics_no, sr.create_at, uad.name as receiver_name, uad.phone as receiver_phone,
|
group_concat(og.goods_name)
|
as goodsName, ss.name as store_name ,ccep.address,ccep.`name` point_name
|
FROM com_shop_flower_order sr LEFT JOIN com_shop_flower_order_goods og ON sr.id = og.order_id
|
LEFT JOIN com_shop_flower_goods_attr ga ON og.goods_attr_id = ga.id
|
LEFT JOIN sys_user su ON sr.user_id = su.user_id
|
LEFT JOIN com_shop_flower_user_address uad ON sr.receiver_id = uad.id
|
LEFT JOIN com_convenient_merchants ss ON sr.store_id = ss.id
|
LEFT JOIN com_convenient_elevating_point ccep on ccep.id = sr.point_id
|
WHERE sr.delete_status = 1 and sr.`status` != 0
|
<if test='pageComShopOrderSearchDTO.userId != null'>
|
AND sr.user_id = #{pageComShopOrderSearchDTO.userId}
|
</if>
|
<if test='pageComShopOrderSearchDTO.createAtStart != null'>
|
AND #{pageComShopOrderSearchDTO.createAtStart} <![CDATA[<=]]> sr.create_at
|
</if>
|
<if test='pageComShopOrderSearchDTO.createAtEnd != null'>
|
AND sr.create_at <![CDATA[<=]]> #{pageComShopOrderSearchDTO.createAtEnd}
|
</if>
|
<if test='pageComShopOrderSearchDTO.orderNo != null '>
|
AND sr.order_no like concat('%',#{pageComShopOrderSearchDTO.orderNo}, '%')
|
</if>
|
<if test='pageComShopOrderSearchDTO.userAccount != null '>
|
AND su.phone like concat('%',#{pageComShopOrderSearchDTO.userAccount}, '%')
|
</if>
|
<if test='pageComShopOrderSearchDTO.receiverAccount != null '>
|
AND uad.name like concat('%',#{pageComShopOrderSearchDTO.receiverAccount}, '%')
|
</if>
|
<if test='pageComShopOrderSearchDTO.receiverPhone != null '>
|
AND uad.phone like concat('%',#{pageComShopOrderSearchDTO.receiverPhone}, '%')
|
</if>
|
<if test='pageComShopOrderSearchDTO.goodsName != null'>
|
AND og.goods_name like concat('%',#{pageComShopOrderSearchDTO.goodsName}, '%')
|
</if>
|
<if test='pageComShopOrderSearchDTO.status != null '>
|
AND sr.status = #{pageComShopOrderSearchDTO.status}
|
</if>
|
<if test='pageComShopOrderSearchDTO.storeName != null '>
|
AND ss.name like concat('%',#{pageComShopOrderSearchDTO.storeName}, '%')
|
</if>
|
<if test='pageComShopOrderSearchDTO.storeId != null '>
|
AND ss.id = #{pageComShopOrderSearchDTO.storeId}
|
</if>
|
<if test='pageComShopOrderSearchDTO.storeUserId != null '>
|
AND ss.user_id = #{pageComShopOrderSearchDTO.storeUserId}
|
</if>
|
<if test='pageComShopOrderSearchDTO.deliveryType != null '>
|
AND sr.delivery_type = #{pageComShopOrderSearchDTO.deliveryType}
|
</if>
|
<if test="pageComShopOrderSearchDTO.keyWord != null and pageComShopOrderSearchDTO.keyWord != ''">
|
AND (ss.name like concat('%',#{pageComShopOrderSearchDTO.keyWord}, '%')
|
OR sr.order_no like concat('%',#{pageComShopOrderSearchDTO.keyWord}, '%')
|
OR og.goods_name like concat('%',#{pageComShopOrderSearchDTO.keyWord}, '%')
|
)
|
</if>
|
GROUP BY sr.id ORDER BY sr.create_at DESC
|
</select>
|
<update id="updateOrder">
|
update com_shop_flower_order set delivery_time = #{deliveryTime},status = #{status},delivery_id =
|
#{deliveryId},delivery_no = #{deliveryNo}
|
where id in
|
<foreach item='id' index='index' collection='orderIds' open='(' separator=',' close=')'>
|
#{id}
|
</foreach>
|
</update>
|
<update id="updateOrderStatus">
|
update com_shop_flower_order set service_time = #{serviceTime},status = #{status} where delivery_id =#{deliveryId}
|
</update>
|
<select id="pageOrderByStoreId" resultType="com.panzhihua.common.model.vos.shop.ComShopFlowerOrderStoreListVO">
|
SELECT
|
o.id order_id,
|
o.order_no,
|
o.delivery_type,
|
o.`status`,
|
g.goods_name,
|
g.goods_attr_name,
|
g.amount,
|
g.goods_attr_price,
|
g.goods_attr_pic,
|
o.total_amount,
|
a.`name`,
|
a.phone,
|
a.province_name,
|
a.city_name,
|
a.district_name,
|
a.detail_address,
|
o.point_id,
|
o.logistics_company,
|
o.logistics_no
|
FROM
|
com_shop_flower_order o
|
LEFT JOIN com_shop_flower_order_goods g ON o.id = g.order_id
|
LEFT JOIN com_shop_flower_user_address a ON a.id = o.receiver_id
|
WHERE 1=1 and o.`status` != 0
|
<if test="comOrderListDTO.deliveryType != null">
|
and o.delivery_type = #{comOrderListDTO.deliveryType}
|
</if>
|
<if test="comOrderListDTO.storeId != null">
|
and o.store_id = #{comOrderListDTO.storeId}
|
</if>
|
<if test="comOrderListDTO.deliveryId != null">
|
and o.delivery_id = #{comOrderListDTO.deliveryId}
|
</if>
|
<if test="comOrderListDTO.status != null">
|
and o.status = #{comOrderListDTO.status}
|
</if>
|
order by o.create_at desc
|
|
</select>
|
<select id="pageOrderByDeliveryNo" resultType="com.panzhihua.common.model.vos.shop.ComShopFlowerOrderStoreListVO">
|
SELECT
|
o.id order_id,
|
o.order_no,
|
o.delivery_type,
|
o.`status`,
|
g.goods_name,
|
g.goods_attr_name,
|
g.amount,
|
g.goods_attr_price,
|
g.goods_attr_pic,
|
o.total_amount,
|
a.`name`,
|
a.phone,
|
a.province_name,
|
a.city_name,
|
a.district_name,
|
a.detail_address,
|
o.point_id
|
FROM
|
com_shop_flower_order o
|
LEFT JOIN com_shop_flower_order_goods g ON o.id = g.order_id
|
LEFT JOIN com_shop_flower_user_address a ON a.id = o.receiver_id
|
WHERE 1=1 and o.delivery_type = 1 and o.`status` != 0
|
<if test="comOrderListDTO.storeId != null">
|
and o.store_id = #{comOrderListDTO.storeId}
|
</if>
|
<if test="comOrderListDTO.deliveryId != null">
|
and o.delivery_id = #{comOrderListDTO.deliveryId}
|
</if>
|
order by o.create_at desc
|
</select>
|
<select id="selectCountByDeliveryType"
|
resultType="com.panzhihua.common.model.vos.shop.ComShopOrderCountVO">
|
SELECT count(1) amount , `status` FROM com_shop_flower_order WHERE delivery_type = #{deliveryType} and store_id = #{storeId} and `status` != 0 GROUP BY `status`
|
</select>
|
<select id="selectCountByStoreId"
|
resultType="com.panzhihua.common.model.vos.shop.ComShopOrderStoreIdCountVO">
|
|
SELECT count(1) as count_num,'dayCount' as count_name FROM com_shop_flower_order WHERE TO_DAYS(create_at)=TO_DAYS(NOW()) and `status` != 0
|
<if test="storeId != null">
|
and store_id = #{storeId}
|
</if>
|
<if test="deliveryType != null">
|
and delivery_type = #{deliveryType}
|
</if>
|
union all
|
SELECT count(1) as count_num,'monthCount' as count_name FROM com_shop_flower_order WHERE DATE_FORMAT(create_at,'%Y%m')=DATE_FORMAT(CURDATE(),'%Y%m') and `status` != 0
|
<if test="storeId != null">
|
and store_id = #{storeId}
|
</if>
|
<if test="deliveryType != null">
|
and delivery_type = #{deliveryType}
|
</if>
|
union all
|
SELECT count(1) as count_num,'yearCount' as count_name FROM com_shop_flower_order where YEAR(create_at) =YEAR(NOW()) and `status` != 0
|
<if test="storeId != null">
|
and store_id = #{storeId}
|
</if>
|
<if test="deliveryType != null">
|
and delivery_type = #{deliveryType}
|
</if>
|
union all
|
SELECT count(1) as count_num,'allCount' as count_name FROM com_shop_flower_order WHERE `status` != 0
|
<if test="storeId != null">
|
and store_id = #{storeId}
|
</if>
|
<if test="deliveryType != null">
|
and delivery_type = #{deliveryType}
|
</if>
|
</select>
|
<select id="selectSumAmountByStoreId"
|
resultType="com.panzhihua.common.model.vos.shop.ComShopOrderStoreIdNumVO">
|
SELECT IFNULL(sum(pay_amount),0) as count_num,'dayAmount' as count_name FROM com_shop_flower_order WHERE TO_DAYS(create_at)=TO_DAYS(NOW()) and `status` not in (6,7) and `status` != 0
|
<if test="storeId != null">
|
and store_id = #{storeId}
|
</if>
|
union all
|
SELECT IFNULL(sum(pay_amount),0) as count_num,'monthAmount' as count_name FROM com_shop_flower_order WHERE DATE_FORMAT(create_at,'%Y%m')=DATE_FORMAT(CURDATE(),'%Y%m') and `status` not in (6,7) and `status` != 0
|
<if test="storeId != null">
|
and store_id = #{storeId}
|
</if>
|
union all
|
SELECT IFNULL(sum(pay_amount),0) as count_num,'yearAmount' as count_name FROM com_shop_flower_order where YEAR(create_at) =YEAR(NOW()) and `status` not in (6,7) and `status` != 0
|
<if test="storeId != null">
|
and store_id = #{storeId}
|
</if>
|
union all
|
SELECT IFNULL(sum(pay_amount),0) as count_num,'allAmount' as count_name FROM com_shop_flower_order WHERE `status` not in (6,7) and `status` != 0
|
<if test="storeId != null">
|
and store_id = #{storeId}
|
</if>
|
</select>
|
<select id="selectTurnover" resultType="java.math.BigDecimal">
|
SELECT IFNULL(sum(pay_amount),0) as count_num FROM com_shop_flower_order WHERE `status` not in (6,7) and store_id = #{storeId}
|
</select>
|
<select id="selectSettlement" resultType="java.math.BigDecimal">
|
SELECT IFNULL(sum(pay_amount),0) as count_num FROM com_shop_flower_order WHERE `status` in (4,5) and create_at <= date_sub(now(), INTERVAL 15 DAY)
|
</select>
|
<select id="selectSumOrderAndAmountByStoreId"
|
resultType="com.panzhihua.common.model.vos.shop.ComShopOrderStoreIdNumVO">
|
SELECT count(1) count_num ,'pddd' as count_name FROM `com_shop_flower_order` WHERE delivery_type =1 and delete_status = 1 and pay_status = 2 and store_id = #{storeId} and `status` != 0
|
union all
|
SELECT count(1) count_num ,'kddd' as count_name FROM `com_shop_flower_order` WHERE delivery_type =2 and delete_status = 1 and pay_status = 2 and store_id = #{storeId} and `status` != 0
|
union all
|
SELECT count(1) count_num ,'tkdd' as count_name FROM `com_shop_flower_order` WHERE delete_status = 1 and pay_status = 2 and `status` = 7 and store_id = #{storeId} and `status` != 0
|
union all
|
SELECT IFNULL(sum(pay_amount),0) count_num ,'yysr' as count_name FROM `com_shop_flower_order` WHERE `status` not in (6,7) and store_id = #{storeId} and `status` != 0
|
union all
|
SELECT IFNULL(sum(pay_amount),0) count_num ,'tkje' as count_name FROM `com_shop_flower_order` WHERE `status` =7 and store_id = #{storeId} and `status` != 0
|
union all
|
SELECT IFNULL(sum(pay_amount),0) count_num ,'ktxje' as count_name FROM `com_shop_flower_order` WHERE `status` in (4,5) and create_at <= date_sub(now(), INTERVAL 15 DAY) and store_id = #{storeId} and `status` != 0
|
|
|
</select>
|
<select id="selectCountOrderDayByStoreId"
|
resultType="com.panzhihua.common.model.vos.shop.ComShopOrderStoreIdCountVO">
|
SELECT count(1) count_num, date_format(create_at,'%Y-%m-%d') as count_name FROM com_shop_flower_order
|
WHERE date_format(create_at,'%Y-%m-%d') >= date_format(date_sub(now(), INTERVAL #{days} DAY),'%Y-%m-%d')
|
and store_id = #{storeId} and `status` != 0
|
GROUP BY count_name
|
</select>
|
<select id="selectCountOrderMonthByStoreId"
|
resultType="com.panzhihua.common.model.vos.shop.ComShopOrderStoreIdCountVO">
|
SELECT count(1) count_num, date_format(create_at,'%Y-%m') as count_name FROM com_shop_flower_order
|
WHERE date_format(create_at,'%Y-%m') >= date_format(now(),'%Y-01') and store_id = #{storeId} and `status` != 0 GROUP BY count_name
|
</select>
|
<select id="selectOrderSumPayDayByStoreId"
|
resultType="com.panzhihua.common.model.vos.shop.ComShopOrderStoreIdNumVO">
|
SELECT IFNULL(sum(pay_amount),0) count_num, date_format(create_at,'%Y-%m-%d') as count_name FROM com_shop_flower_order
|
WHERE date_format(create_at,'%Y-%m-%d') >= date_format(date_sub(now(), INTERVAL #{days} DAY),'%Y-%m-%d')
|
and store_id = #{storeId} and `status` not in (6,7) and `status` != 0
|
GROUP BY count_name
|
</select>
|
<select id="selectOrderSumMonthByStoreId"
|
resultType="com.panzhihua.common.model.vos.shop.ComShopOrderStoreIdNumVO">
|
SELECT IFNULL(sum(pay_amount),0) count_num, date_format(create_at,'%Y-%m') as count_name FROM com_shop_flower_order
|
WHERE date_format(create_at,'%Y-%m') >= date_format(now(),'%Y-01') and store_id = #{storeId} and `status` not in (6,7) and `status` != 0 GROUP BY count_name
|
</select>
|
|
|
</mapper>
|