|
|
|
@@ -102,6 +102,190 @@ |
|
|
|
</where> |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="findCountByDateLimit" resultType="java.lang.Integer"> |
|
|
|
select COUNT(*) FROM wx_coupon_order |
|
|
|
where tenant_id = #{tenantId} |
|
|
|
and create_date >= #{startTime} |
|
|
|
and create_date <= #{endTime} |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="couponDataMap" resultType="com.iformall.domain.vo.MarkingCouponDataReportVo" parameterType="hashmap"> |
|
|
|
SELECT DATE_FORMAT(create_date,'%m/%d') as createTime, |
|
|
|
COUNT(DISTINCT c_user_id) as couponUserCount, |
|
|
|
count(*) as couponCount, |
|
|
|
(select Count(*) |
|
|
|
from wx_coupon_order c |
|
|
|
where coupon_order_status=1 |
|
|
|
AND DATE_FORMAT(create_date,'%m/%d')=createTime |
|
|
|
AND tenant_id=#{tenantId} |
|
|
|
AND c.update_date >= #{startTime} |
|
|
|
AND c.update_date <= #{endTime}) as verifyCount, |
|
|
|
(select Count(DISTINCT c_user_id) |
|
|
|
from wx_coupon_order d |
|
|
|
where coupon_order_status=1 |
|
|
|
AND DATE_FORMAT(create_date,'%m/%d')=createTime |
|
|
|
AND tenant_id=#{tenantId} |
|
|
|
AND d.update_date >= #{startTime} |
|
|
|
AND d.update_date <= #{endTime}) as verifyUserCount |
|
|
|
from wx_coupon_order |
|
|
|
where tenant_id=#{tenantId} |
|
|
|
AND create_date >= #{startTime} |
|
|
|
AND create_date <= #{endTime} |
|
|
|
GROUP BY createTime |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="couponDataList" resultType="com.iformall.domain.vo.MarkingCouponDataReportVo" parameterType="hashmap"> |
|
|
|
SELECT DATE_FORMAT(wx_coupon_order.create_date,'%Y-%m-%d') as createTime,wx_coupon_order.coupon_id as couponId |
|
|
|
,COUNT(DISTINCT c_user_id) as couponUserCount,count(*) as couponCount |
|
|
|
,(select Count(coupon_id) from wx_coupon_order c |
|
|
|
where coupon_order_status=1 |
|
|
|
and DATE_FORMAT(create_date,'%Y-%m-%d')=createTime |
|
|
|
and tenant_id=#{tenantId} |
|
|
|
and c.coupon_id=couponId |
|
|
|
<if test="startTime != null"> |
|
|
|
and c.update_date >= #{startTime} |
|
|
|
</if> |
|
|
|
<if test="endTime != null"> |
|
|
|
and c.update_date <= #{endTime} |
|
|
|
</if> |
|
|
|
) as verifyCount |
|
|
|
,(select Count(DISTINCT c_user_id) from wx_coupon_order d |
|
|
|
where coupon_order_status=1 |
|
|
|
and d.coupon_id=couponId |
|
|
|
and DATE_FORMAT(create_date,'%Y-%m-%d')=createTime |
|
|
|
and tenant_id=#{tenantId} |
|
|
|
and d.coupon_id=couponId |
|
|
|
<if test="startTime != null"> |
|
|
|
and d.update_date >= #{startTime} |
|
|
|
</if> |
|
|
|
<if test="endTime != null"> |
|
|
|
and d.update_date <= #{endTime} |
|
|
|
</if> |
|
|
|
) as verifyUserCount |
|
|
|
from wx_coupon_order |
|
|
|
join wx_coupon on wx_coupon_order.coupon_id=wx_coupon.id |
|
|
|
where wx_coupon_order.tenant_id=#{tenantId} |
|
|
|
<if test="startTime != null"> |
|
|
|
and wx_coupon_order.create_date >= #{startTime} |
|
|
|
</if> |
|
|
|
<if test="endTime != null"> |
|
|
|
and wx_coupon_order.create_date <= #{endTime} |
|
|
|
</if> |
|
|
|
<if test="couponType != null"> |
|
|
|
and wx_coupon.type = #{couponType} |
|
|
|
</if> |
|
|
|
<if test="couponTitle != null"> |
|
|
|
and wx_coupon.title like concat('%', #{couponTitle},'%') |
|
|
|
</if> |
|
|
|
GROUP BY createTime,couponId |
|
|
|
order by createTime desc |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="touchUsersReportList" resultType="com.iformall.domain.vo.TouchUsersReportVo" parameterType="hashmap"> |
|
|
|
SELECT DATE_FORMAT(create_date,'%Y-%m-%d') as xTime |
|
|
|
,COUNT(DISTINCT c_user_id) as userCount,count(*) as couponCount |
|
|
|
,(select Count(*) from wx_coupon_order c |
|
|
|
where coupon_order_status=1 |
|
|
|
and DATE_FORMAT(create_date,'%Y-%m-%d')=xTime |
|
|
|
and tenant_id=#{tenantId} |
|
|
|
<if test="startTime != null"> |
|
|
|
and c.update_date >= #{startTime} |
|
|
|
</if> |
|
|
|
<if test="endTime != null"> |
|
|
|
and c.update_date <= #{endTime} |
|
|
|
</if> |
|
|
|
) |
|
|
|
as verifyCount |
|
|
|
,(select Count(DISTINCT c_user_id) from wx_coupon_order d |
|
|
|
where coupon_order_status=1 |
|
|
|
and DATE_FORMAT(create_date,'%Y-%m-%d')=xTime |
|
|
|
and tenant_id=#{tenantId} |
|
|
|
<if test="startTime != null"> |
|
|
|
and d.update_date >= #{startTime} |
|
|
|
</if> |
|
|
|
<if test="endTime != null"> |
|
|
|
and d.update_date <= #{endTime} |
|
|
|
</if> |
|
|
|
) |
|
|
|
as verifyUserCount |
|
|
|
from wx_coupon_order |
|
|
|
where tenant_id=#{tenantId} |
|
|
|
<if test="startTime != null"> |
|
|
|
AND create_date >= #{startTime} |
|
|
|
</if> |
|
|
|
<if test="endTime != null"> |
|
|
|
and create_date <= #{endTime} |
|
|
|
</if> |
|
|
|
GROUP BY xTime |
|
|
|
order by xTime desc |
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
|
|
<select id="queryForSceneRepotyHistoryVerified" resultType="com.iformall.domain.vo.MarkingSceneDataVo" parameterType="hashmap"> |
|
|
|
select DATE_FORMAT(update_date,'%Y-%m-%d') xTime, count(c.id) triggerCount |
|
|
|
from wx_coupon_order c |
|
|
|
where c.tenant_id = #{tenantId} |
|
|
|
and c.coupon_order_status = 1 |
|
|
|
<if test=" null != startTime and null != endTime"> |
|
|
|
and c.update_date BETWEEN #{startTime} and #{endTime} |
|
|
|
</if> |
|
|
|
group by xTime |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="findVerifiedCountByCUser" resultType="java.lang.Integer"> |
|
|
|
select COUNT(*) FROM wx_coupon_order |
|
|
|
where c_user_id = #{cUserId} |
|
|
|
and update_date >= #{startTime} |
|
|
|
and update_date <= #{endTime} |
|
|
|
and coupon_order_status = 1 |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="findOrderedCountByCUser" resultType="java.lang.Integer"> |
|
|
|
select COUNT(*) FROM wx_coupon_order |
|
|
|
where c_user_id = #{cUserId} |
|
|
|
and create_date >= #{startTime} |
|
|
|
and create_date <= #{endTime} |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="findVerifiedCount" resultType="java.lang.Integer"> |
|
|
|
select COUNT(*) FROM wx_coupon_order |
|
|
|
where tenant_id = #{tenantId} |
|
|
|
and update_date >= #{startTime} |
|
|
|
and update_date <= #{endTime} |
|
|
|
and coupon_order_status = 1 |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="findOrderedCount" resultType="java.lang.Integer"> |
|
|
|
select COUNT(*) FROM wx_coupon_order |
|
|
|
where tenant_id = #{tenantId} |
|
|
|
and create_date >= #{startTime} |
|
|
|
and create_date <= #{endTime} |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="queryPriceTotalGroup" resultType="com.iformall.domain.vo.CUserDateAmountVo" > |
|
|
|
SELECT DATE_FORMAT(create_date,'%Y-%m-%d') as xTime,IFNULL(SUM(coupon_price),0) as price from wx_coupon_order |
|
|
|
where tenant_id=#{tenantId} AND create_date >= #{startTime} and create_date < #{endTime} GROUP BY xTime |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="queryPriceTotal" resultType="java.lang.Integer" > |
|
|
|
SELECT IFNULL(SUM(coupon_price),0) from wx_coupon_order |
|
|
|
where tenant_id=#{tenantId} AND create_date >= #{startTime} and create_date < #{endTime} |
|
|
|
</select> |
|
|
|
|
|
|
|
<update id="offExpiredCouponOrderByValidDate"> |
|
|
|
update wx_coupon_order SET coupon_order_status = 2, update_date = now() |
|
|
|
where expired_time < now() and coupon_price = 0 and coupon_order_status = 0 |
|
|
|
</update> |
|
|
|
|
|
|
|
<select id="findExpiredCouponOrderByValidDate" parameterType="com.iformall.domain.po.WxCouponOrder" resultMap="BaseResultMap"> |
|
|
|
select <include refid="allColumns" /> from wx_coupon_order |
|
|
|
where expired_time < now() and coupon_price > 0 and coupon_order_status = 0 |
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -124,46 +308,32 @@ |
|
|
|
<result column="use_price" jdbcType="INTEGER" property="usePrice" /> |
|
|
|
<result column="price" jdbcType="INTEGER" property="price" /> |
|
|
|
|
|
|
|
<result column="merchant_name" jdbcType="VARCHAR" property="merchantName" /> |
|
|
|
<result column="name" jdbcType="VARCHAR" property="bUserName" /> |
|
|
|
<result column="bphone" jdbcType="VARCHAR" property="bUserPhone" /> |
|
|
|
<result column="phone" jdbcType="VARCHAR" property="cUserPhone" /> |
|
|
|
<result column="merchant_name" jdbcType="VARCHAR" property="merchantName" /> |
|
|
|
|
|
|
|
<collection column="{productId=coupon_id}" property="merchantVoList" |
|
|
|
ofType="com.iformall.domain.vo.WxMerchantVo" |
|
|
|
javaType="java.util.ArrayList" |
|
|
|
select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantNameList" > |
|
|
|
</collection> |
|
|
|
</resultMap> |
|
|
|
|
|
|
|
<sql id="allAdminCouponOrderColumns"> |
|
|
|
co.id,co.tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price, |
|
|
|
c.type,c.title,c.sale_price,c.use_price,c.price,c.unit, |
|
|
|
m.name as merchant_name, bu.name, bu.phone as bphone, cu.phone |
|
|
|
</sql> |
|
|
|
|
|
|
|
<sql id="allBUserVerifiedCouponOrderColumns"> |
|
|
|
co.id,co.tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price, |
|
|
|
c.type,c.title,c.sale_price,c.use_price,c.price,c.unit, |
|
|
|
bu.name,cu.phone |
|
|
|
</sql> |
|
|
|
|
|
|
|
<sql id="allBUserOrderedCouponOrderColumns"> |
|
|
|
co.id,co.tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price, |
|
|
|
c.type,c.title,c.sale_price,c.use_price,c.price,c.unit, |
|
|
|
cu.phone |
|
|
|
</sql> |
|
|
|
|
|
|
|
<sql id="allCouponOrderColumns"> |
|
|
|
co.id,co.tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price |
|
|
|
bu.name, bu.phone as bphone, cu.phone, m.name as merchant_name |
|
|
|
</sql> |
|
|
|
|
|
|
|
<select id="findListOfAdmin" parameterType="com.iformall.domain.vo.WxCouponOrderBVo" resultMap="BVoResultMap"> |
|
|
|
select <include refid="allAdminCouponOrderColumns" /> |
|
|
|
from wx_coupon_order co |
|
|
|
inner JOIN wx_order o on o.id = co.order_id |
|
|
|
inner JOIN wx_coupon c on co.coupon_id = c.id |
|
|
|
inner JOIN wx_coupon c on c.id = co.coupon_id |
|
|
|
inner JOIN wx_c_user cu on cu.id = co.c_user_id |
|
|
|
left JOIN wx_merchant_b_user bu on co.b_user_id = bu.id |
|
|
|
left JOIN wx_merchant m on bu.merchant_id = m.id |
|
|
|
left JOIN wx_merchant_b_user bu on bu.id = co.b_user_id |
|
|
|
left JOIN wx_merchant m on m.id = bu.merchant_id |
|
|
|
where 1 = 1 |
|
|
|
<if test=" null != id "> |
|
|
|
and co.id = #{id} |
|
|
|
</if> |
|
|
|
|
|
|
|
<if test=" null != tenantId "> |
|
|
|
and co.tenant_id = #{tenantId} |
|
|
|
@@ -189,11 +359,34 @@ |
|
|
|
|
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="findListOfOrderedByDateForBUser" parameterType="map" resultMap="BVoResultMap"> |
|
|
|
|
|
|
|
<sql id="allBUserVerifiedCouponOrderColumns"> |
|
|
|
co.id,co.tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price, |
|
|
|
c.type,c.title,c.sale_price,c.use_price,c.price,c.unit, |
|
|
|
bu.name, |
|
|
|
cu.phone |
|
|
|
</sql> |
|
|
|
|
|
|
|
<sql id="allBUserOrderedCouponOrderColumns"> |
|
|
|
co.id,co.tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price, |
|
|
|
c.type,c.title,c.sale_price,c.use_price,c.price,c.unit, |
|
|
|
cu.phone |
|
|
|
</sql> |
|
|
|
|
|
|
|
|
|
|
|
<select id="findListOfOrderedByDateForBUser" parameterType="map" resultMap="BVoResultMap"> |
|
|
|
select <include refid="allBUserOrderedCouponOrderColumns" /> |
|
|
|
from wx_coupon_order co,wx_order o,wx_coupon c,wx_c_user cu |
|
|
|
where o.id = co.order_id |
|
|
|
and o.merchant_id = #{merchantId} |
|
|
|
from wx_coupon_order co,wx_order o,wx_coupon c,wx_c_user cu,wx_coupon_merchant cm |
|
|
|
(select tco.id as tcoid, |
|
|
|
(select count(*) from wx_coupon_merchant tcm |
|
|
|
where tcm.product_id = tco.coupon_id) as mc |
|
|
|
from wx_coupon_order tco) com |
|
|
|
where com.mc = 1 |
|
|
|
and com.tcoid = co.id |
|
|
|
and o.id = co.order_id |
|
|
|
and cm.merchant_id = #{merchantId} |
|
|
|
and cm.product_id = c.id |
|
|
|
and cm.status = 0 |
|
|
|
and co.coupon_id = c.id |
|
|
|
and cu.id = co.c_user_id |
|
|
|
<if test="startDate != null"> |
|
|
|
@@ -210,20 +403,24 @@ |
|
|
|
select <include refid="allBUserVerifiedCouponOrderColumns" /> |
|
|
|
from wx_coupon_order co,wx_order o,wx_coupon c,wx_c_user cu,wx_merchant_b_user bu |
|
|
|
where o.id = co.order_id |
|
|
|
and o.merchant_id = #{merchantId} |
|
|
|
and co.coupon_id = c.id |
|
|
|
and cu.id = co.c_user_id |
|
|
|
and bu.id = co.b_user_id |
|
|
|
and bu.merchant_id = #{merchantId} |
|
|
|
<if test="startDate != null"> |
|
|
|
AND co.update_date > #{startDate,jdbcType=TIMESTAMP} |
|
|
|
</if> |
|
|
|
<if test="endDate != null"> |
|
|
|
AND co.update_date < #{endDate,jdbcType=TIMESTAMP} |
|
|
|
</if> |
|
|
|
AND co.coupon_order_status = '1' |
|
|
|
AND co.coupon_order_status = '1' |
|
|
|
order by co.update_date desc |
|
|
|
</select> |
|
|
|
|
|
|
|
<sql id="allCouponOrderColumns"> |
|
|
|
co.id,co.tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price |
|
|
|
</sql> |
|
|
|
|
|
|
|
<select id="findListOfOrderedByDate" parameterType="map" resultMap="BaseResultMap"> |
|
|
|
select <include refid="allCouponOrderColumns" /> |
|
|
|
from wx_coupon_order co,wx_order o |
|
|
|
@@ -235,7 +432,6 @@ |
|
|
|
<if test="endDate != null"> |
|
|
|
AND co.create_date < #{endDate,jdbcType=TIMESTAMP} |
|
|
|
</if> |
|
|
|
|
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="findListOfVerifiedByDate" parameterType="map" resultMap="BaseResultMap"> |
|
|
|
@@ -255,21 +451,16 @@ |
|
|
|
|
|
|
|
|
|
|
|
<sql id="allCUserCouponOrderListColumns"> |
|
|
|
c.id,c.expired_time,c.coupon_order_status,c.create_date,c.update_date,c.coupon_price, |
|
|
|
co.cover_img,co.title,co.sub_title,co.sale_price,co.use_price,co.price,co.unit, |
|
|
|
m.name |
|
|
|
co.id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price, |
|
|
|
c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit |
|
|
|
</sql> |
|
|
|
|
|
|
|
<sql id="allCUserCouponOrderDetailColumns"> |
|
|
|
c.id,c.tenant_id,c.coupon_id,c.c_user_id,c.b_user_id,c.order_id,c.expired_time,c.coupon_order_status,c.create_date,c.update_date,c.coupon_price, |
|
|
|
co.merchant_id,co.type,co.cover_img,co.title,co.sub_title,co.sale_price,co.use_price,co.price,co.unit,co.detail,co.remark, |
|
|
|
m.img_url,m.name,m.link_phone,m.status, |
|
|
|
s.addr,s.shop_number,s.baidu_poi, |
|
|
|
mb.building_name,mf.floor_name |
|
|
|
co.id,co.tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price, |
|
|
|
c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,c.detail,c.remark |
|
|
|
</sql> |
|
|
|
|
|
|
|
<resultMap id="CVoResultMap" type="com.iformall.domain.vo.WxCouponOrderCVo"> |
|
|
|
|
|
|
|
<id column="id" jdbcType="BIGINT" property="id" /> |
|
|
|
<result column="tenant_id" jdbcType="BIGINT" property="tenantId" /> |
|
|
|
<result column="coupon_id" jdbcType="BIGINT" property="couponId" /> |
|
|
|
@@ -282,8 +473,6 @@ |
|
|
|
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> |
|
|
|
<result column="coupon_price" jdbcType="INTEGER" property="couponPrice" /> |
|
|
|
|
|
|
|
|
|
|
|
<result column="merchant_id" jdbcType="BIGINT" property="merchantId" /> |
|
|
|
<result column="type" jdbcType="INTEGER" property="type" /> |
|
|
|
<result column="cover_img" jdbcType="VARCHAR" property="coverImg" /> |
|
|
|
<result column="title" jdbcType="VARCHAR" property="title" /> |
|
|
|
@@ -295,27 +484,19 @@ |
|
|
|
<result column="unit" jdbcType="INTEGER" property="unit" /> |
|
|
|
<result column="remark" jdbcType="VARCHAR" property="remark" /> |
|
|
|
|
|
|
|
|
|
|
|
<result column="img_url" jdbcType="VARCHAR" property="merchantImgUrl" /> |
|
|
|
<result column="name" jdbcType="VARCHAR" property="merchantName" /> |
|
|
|
<result column="link_phone" jdbcType="VARCHAR" property="merchantLinkPhone" /> |
|
|
|
<result column="status" jdbcType="VARCHAR" property="merchantStatus" /> |
|
|
|
|
|
|
|
|
|
|
|
<result column="addr" jdbcType="VARCHAR" property="addr"/> |
|
|
|
<result column="shop_number" jdbcType="VARCHAR" property="shopNumber"/> |
|
|
|
<result column="building_name" jdbcType="VARCHAR" property="buildingName" /> |
|
|
|
<result column="floor_name" jdbcType="VARCHAR" property="floorName" /> |
|
|
|
<result column="baidu_poi" jdbcType="VARCHAR" property="baiduPoi"/> |
|
|
|
<collection column="{productId=coupon_id}" property="merchantVoList" |
|
|
|
ofType="com.iformall.domain.vo.WxMerchantVo" |
|
|
|
javaType="java.util.ArrayList" |
|
|
|
select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" > |
|
|
|
</collection> |
|
|
|
</resultMap> |
|
|
|
|
|
|
|
|
|
|
|
<select id="findListOfCUser" parameterType="com.iformall.domain.vo.WxCouponOrderCVo" resultMap="CVoResultMap"> |
|
|
|
select <include refid="allCUserCouponOrderListColumns" /> |
|
|
|
from wx_coupon_order c,wx_coupon co,wx_merchant m |
|
|
|
from wx_coupon_order c,wx_coupon co |
|
|
|
where 1=1 |
|
|
|
and c.coupon_id = co.id |
|
|
|
and co.merchant_id = m.id |
|
|
|
<if test="cUserId != null"> |
|
|
|
and c.c_user_id = #{cUserId} |
|
|
|
</if> |
|
|
|
@@ -325,163 +506,27 @@ |
|
|
|
<if test="type != null"> |
|
|
|
and co.type = #{type} |
|
|
|
</if> |
|
|
|
<if test="type == null"> |
|
|
|
and co.type < 5 |
|
|
|
</if> |
|
|
|
<if test="type == null"> |
|
|
|
and co.type < 5 |
|
|
|
</if> |
|
|
|
<if test="couponOrderStatus != null"> |
|
|
|
AND c.coupon_order_status = #{couponOrderStatus} |
|
|
|
</if> |
|
|
|
<if test=" null != sortColumns"> order by ${sortColumns} </if> |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="selectDetailOfUser" parameterType="map" resultMap="CVoResultMap"> |
|
|
|
select <include refid="allCUserCouponOrderDetailColumns" /> |
|
|
|
from wx_coupon_order c,wx_coupon co,wx_merchant m |
|
|
|
left join wx_merchant_shop ms on ms.merchant_id = m.id and ms.is_del = 0 |
|
|
|
left join wx_shop s on ms.shop_id = s.id |
|
|
|
left join wx_mall_building mb on s.building = mb.id |
|
|
|
left join wx_mall_floor mf on s.floor = mf.id |
|
|
|
where c.coupon_id = co.id |
|
|
|
and co.merchant_id = m.id |
|
|
|
<if test="cUserId != null"> |
|
|
|
and c.c_user_id = #{cUserId} |
|
|
|
</if> |
|
|
|
<if test="merchantId != null"> |
|
|
|
and co.merchant_id = #{merchantId} |
|
|
|
</if> |
|
|
|
<if test="tenantId != null"> |
|
|
|
and c.tenant_id = #{tenantId} |
|
|
|
</if> |
|
|
|
<if test="couponOrderId != null"> |
|
|
|
and c.id = #{couponOrderId} |
|
|
|
</if> |
|
|
|
|
|
|
|
</select> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="findCountByDateLimit" resultType="java.lang.Integer"> |
|
|
|
select COUNT(*) FROM wx_coupon_order |
|
|
|
where tenant_id = #{tenantId} |
|
|
|
and create_date >= #{startTime} |
|
|
|
and create_date <= #{endTime} |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="couponDataMap" resultType="com.iformall.domain.vo.MarkingCouponDataReportVo" parameterType="hashmap"> |
|
|
|
SELECT DATE_FORMAT(create_date,'%m/%d') as createTime, |
|
|
|
COUNT(DISTINCT c_user_id) as couponUserCount, |
|
|
|
count(*) as couponCount, |
|
|
|
(select Count(*) |
|
|
|
from wx_coupon_order c |
|
|
|
where coupon_order_status=1 |
|
|
|
AND DATE_FORMAT(create_date,'%m/%d')=createTime |
|
|
|
AND tenant_id=#{tenantId} |
|
|
|
AND c.update_date >= #{startTime} |
|
|
|
AND c.update_date <= #{endTime}) as verifyCount, |
|
|
|
(select Count(DISTINCT c_user_id) |
|
|
|
from wx_coupon_order d |
|
|
|
where coupon_order_status=1 |
|
|
|
AND DATE_FORMAT(create_date,'%m/%d')=createTime |
|
|
|
AND tenant_id=#{tenantId} |
|
|
|
AND d.update_date >= #{startTime} |
|
|
|
AND d.update_date <= #{endTime}) as verifyUserCount |
|
|
|
from wx_coupon_order |
|
|
|
where tenant_id=#{tenantId} |
|
|
|
AND create_date >= #{startTime} |
|
|
|
AND create_date <= #{endTime} |
|
|
|
GROUP BY createTime |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="couponDataList" resultType="com.iformall.domain.vo.MarkingCouponDataReportVo" parameterType="hashmap"> |
|
|
|
SELECT DATE_FORMAT(wx_coupon_order.create_date,'%Y-%m-%d') as createTime,wx_coupon_order.coupon_id as couponId |
|
|
|
,COUNT(DISTINCT c_user_id) as couponUserCount,count(*) as couponCount |
|
|
|
,(select Count(coupon_id) from wx_coupon_order c |
|
|
|
where coupon_order_status=1 |
|
|
|
and DATE_FORMAT(create_date,'%Y-%m-%d')=createTime |
|
|
|
and tenant_id=#{tenantId} |
|
|
|
and c.coupon_id=couponId |
|
|
|
<if test="startTime != null"> |
|
|
|
and c.update_date >= #{startTime} |
|
|
|
</if> |
|
|
|
<if test="endTime != null"> |
|
|
|
and c.update_date <= #{endTime} |
|
|
|
</if> |
|
|
|
) as verifyCount |
|
|
|
,(select Count(DISTINCT c_user_id) from wx_coupon_order d |
|
|
|
where coupon_order_status=1 |
|
|
|
and d.coupon_id=couponId |
|
|
|
and DATE_FORMAT(create_date,'%Y-%m-%d')=createTime |
|
|
|
and tenant_id=#{tenantId} |
|
|
|
and d.coupon_id=couponId |
|
|
|
<if test="startTime != null"> |
|
|
|
and d.update_date >= #{startTime} |
|
|
|
</if> |
|
|
|
<if test="endTime != null"> |
|
|
|
and d.update_date <= #{endTime} |
|
|
|
</if> |
|
|
|
) as verifyUserCount |
|
|
|
from wx_coupon_order |
|
|
|
join wx_coupon on wx_coupon_order.coupon_id=wx_coupon.id |
|
|
|
where wx_coupon_order.tenant_id=#{tenantId} |
|
|
|
<if test="startTime != null"> |
|
|
|
and wx_coupon_order.create_date >= #{startTime} |
|
|
|
</if> |
|
|
|
<if test="endTime != null"> |
|
|
|
and wx_coupon_order.create_date <= #{endTime} |
|
|
|
</if> |
|
|
|
<if test="couponType != null"> |
|
|
|
and wx_coupon.type = #{couponType} |
|
|
|
</if> |
|
|
|
<if test="couponTitle != null"> |
|
|
|
and wx_coupon.title like concat('%', #{couponTitle},'%') |
|
|
|
</if> |
|
|
|
GROUP BY createTime,couponId |
|
|
|
order by createTime desc |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="touchUsersReportList" resultType="com.iformall.domain.vo.TouchUsersReportVo" parameterType="hashmap"> |
|
|
|
SELECT DATE_FORMAT(create_date,'%Y-%m-%d') as xTime |
|
|
|
,COUNT(DISTINCT c_user_id) as userCount,count(*) as couponCount |
|
|
|
,(select Count(*) from wx_coupon_order c |
|
|
|
where coupon_order_status=1 |
|
|
|
and DATE_FORMAT(create_date,'%Y-%m-%d')=xTime |
|
|
|
and tenant_id=#{tenantId} |
|
|
|
<if test="startTime != null"> |
|
|
|
and c.update_date >= #{startTime} |
|
|
|
</if> |
|
|
|
<if test="endTime != null"> |
|
|
|
and c.update_date <= #{endTime} |
|
|
|
</if> |
|
|
|
) |
|
|
|
as verifyCount |
|
|
|
,(select Count(DISTINCT c_user_id) from wx_coupon_order d |
|
|
|
where coupon_order_status=1 |
|
|
|
and DATE_FORMAT(create_date,'%Y-%m-%d')=xTime |
|
|
|
and tenant_id=#{tenantId} |
|
|
|
<if test="startTime != null"> |
|
|
|
and d.update_date >= #{startTime} |
|
|
|
</if> |
|
|
|
<if test="endTime != null"> |
|
|
|
and d.update_date <= #{endTime} |
|
|
|
</if> |
|
|
|
) |
|
|
|
as verifyUserCount |
|
|
|
from wx_coupon_order |
|
|
|
where tenant_id=#{tenantId} |
|
|
|
<if test="startTime != null"> |
|
|
|
AND create_date >= #{startTime} |
|
|
|
</if> |
|
|
|
<if test="endTime != null"> |
|
|
|
and create_date <= #{endTime} |
|
|
|
</if> |
|
|
|
GROUP BY xTime |
|
|
|
order by xTime desc |
|
|
|
<select id="findDetail" parameterType="java.lang.Long" resultMap="CVoResultMap"> |
|
|
|
select <include refid="allCUserCouponOrderDetailColumns" /> |
|
|
|
from wx_coupon_order co,wx_coupon c |
|
|
|
where co.coupon_id = c.id |
|
|
|
and co.id = #{id} |
|
|
|
</select> |
|
|
|
|
|
|
|
<sql id="allCUserCouponOrderCarListColumns"> |
|
|
|
c.id,c.expired_time,c.coupon_order_status,c.create_date,c.update_date,c.coupon_price, |
|
|
|
co.cover_img,co.title,co.sub_title,co.sale_price,co.use_price,co.price,co.unit,m.id as merchant_id, |
|
|
|
m.name,json_extract(car.vendor_params,'$.id') as coupon_free_id |
|
|
|
co.id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price, |
|
|
|
c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit, |
|
|
|
json_extract(car.vendor_params,'$.id') as coupon_free_id |
|
|
|
</sql> |
|
|
|
|
|
|
|
<resultMap id="CCarVoResultMap" type="com.iformall.domain.vo.WxCouponOrderCarCVo"> |
|
|
|
@@ -498,8 +543,6 @@ |
|
|
|
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> |
|
|
|
<result column="coupon_price" jdbcType="INTEGER" property="couponPrice" /> |
|
|
|
|
|
|
|
|
|
|
|
<result column="merchant_id" jdbcType="BIGINT" property="merchantId" /> |
|
|
|
<result column="type" jdbcType="INTEGER" property="type" /> |
|
|
|
<result column="cover_img" jdbcType="VARCHAR" property="coverImg" /> |
|
|
|
<result column="title" jdbcType="VARCHAR" property="title" /> |
|
|
|
@@ -510,105 +553,37 @@ |
|
|
|
<result column="price" jdbcType="INTEGER" property="price" /> |
|
|
|
<result column="remark" jdbcType="VARCHAR" property="remark" /> |
|
|
|
|
|
|
|
<result column="img_url" jdbcType="VARCHAR" property="merchantImgUrl" /> |
|
|
|
<result column="name" jdbcType="VARCHAR" property="merchantName" /> |
|
|
|
<result column="link_phone" jdbcType="VARCHAR" property="merchantLinkPhone" /> |
|
|
|
<result column="status" jdbcType="VARCHAR" property="merchantStatus" /> |
|
|
|
|
|
|
|
|
|
|
|
<result column="addr" jdbcType="VARCHAR" property="addr"/> |
|
|
|
<result column="shop_number" jdbcType="VARCHAR" property="shopNumber"/> |
|
|
|
<result column="building_name" jdbcType="VARCHAR" property="buildingName" /> |
|
|
|
<result column="floor_name" jdbcType="VARCHAR" property="floorName" /> |
|
|
|
<result column="baidu_poi" jdbcType="VARCHAR" property="baiduPoi"/> |
|
|
|
|
|
|
|
<result column="coupon_free_id" jdbcType="INTEGER" property="couponFreeId"/> |
|
|
|
|
|
|
|
<collection column="{productId=coupon_id}" property="merchantVoList" |
|
|
|
ofType="com.iformall.domain.vo.WxMerchantVo" |
|
|
|
javaType="java.util.ArrayList" |
|
|
|
select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" > |
|
|
|
</collection> |
|
|
|
</resultMap> |
|
|
|
|
|
|
|
|
|
|
|
<select id="findCarListOfCUser" parameterType="com.iformall.domain.vo.WxCouponOrderCarCVo" resultMap="CCarVoResultMap"> |
|
|
|
select <include refid="allCUserCouponOrderCarListColumns" /> |
|
|
|
from wx_coupon_order c,wx_coupon co,wx_merchant m, wx_coupon_car car |
|
|
|
where 1=1 |
|
|
|
and c.coupon_id = co.id |
|
|
|
and c.coupon_id = car.id |
|
|
|
and co.merchant_id = m.id |
|
|
|
from wx_coupon_order co,wx_coupon c, wx_coupon_car car |
|
|
|
where co.coupon_id = c.id |
|
|
|
and co.coupon_id = car.id |
|
|
|
<if test="cUserId != null"> |
|
|
|
and c.c_user_id = #{cUserId} |
|
|
|
and co.c_user_id = #{cUserId} |
|
|
|
</if> |
|
|
|
<if test="tenantId != null"> |
|
|
|
and c.tenant_id = #{tenantId} |
|
|
|
and co.tenant_id = #{tenantId} |
|
|
|
</if> |
|
|
|
<if test="id != null"> |
|
|
|
and co.id = #{id} |
|
|
|
</if> |
|
|
|
<if test="type != null"> |
|
|
|
and co.type = #{type} |
|
|
|
</if> |
|
|
|
<if test="id != null"> |
|
|
|
and c.id = #{id} |
|
|
|
and c.type = #{type} |
|
|
|
</if> |
|
|
|
<if test="couponOrderStatus != null"> |
|
|
|
AND c.coupon_order_status = #{couponOrderStatus} |
|
|
|
AND co.coupon_order_status = #{couponOrderStatus} |
|
|
|
</if> |
|
|
|
<if test=" null != sortColumns"> order by ${sortColumns} </if> |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="queryForSceneRepotyHistoryVerified" resultType="com.iformall.domain.vo.MarkingSceneDataVo" parameterType="hashmap"> |
|
|
|
select DATE_FORMAT(update_date,'%Y-%m-%d') xTime, count(c.id) triggerCount |
|
|
|
from wx_coupon_order c |
|
|
|
where c.tenant_id = #{tenantId} |
|
|
|
and c.coupon_order_status = 1 |
|
|
|
<if test=" null != startTime and null != endTime"> |
|
|
|
and c.update_date BETWEEN #{startTime} and #{endTime} |
|
|
|
</if> |
|
|
|
group by xTime |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="findVerifiedCountForCUser" resultType="java.lang.Integer"> |
|
|
|
select COUNT(*) FROM wx_coupon_order |
|
|
|
where c_user_id = #{cUserId} |
|
|
|
and update_date >= #{startTime} |
|
|
|
and update_date <= #{endTime} |
|
|
|
and coupon_order_status = 1 |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="findOrderedCountForCUser" resultType="java.lang.Integer"> |
|
|
|
select COUNT(*) FROM wx_coupon_order |
|
|
|
where c_user_id = #{cUserId} |
|
|
|
and create_date >= #{startTime} |
|
|
|
and create_date <= #{endTime} |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="findVerifiedCount" resultType="java.lang.Integer"> |
|
|
|
select COUNT(*) FROM wx_coupon_order |
|
|
|
where tenant_id = #{tenantId} |
|
|
|
and update_date >= #{startTime} |
|
|
|
and update_date <= #{endTime} |
|
|
|
and coupon_order_status = 1 |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="findOrderedCount" resultType="java.lang.Integer"> |
|
|
|
select COUNT(*) FROM wx_coupon_order |
|
|
|
where tenant_id = #{tenantId} |
|
|
|
and create_date >= #{startTime} |
|
|
|
and create_date <= #{endTime} |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="queryPriceTotalGroup" resultType="com.iformall.domain.vo.CUserDateAmountVo" > |
|
|
|
SELECT DATE_FORMAT(create_date,'%Y-%m-%d') as xTime,IFNULL(SUM(coupon_price),0) as price from wx_coupon_order |
|
|
|
where tenant_id=#{tenantId} AND create_date >= #{startTime} and create_date < #{endTime} GROUP BY xTime |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="queryPriceTotal" resultType="java.lang.Integer" > |
|
|
|
SELECT IFNULL(SUM(coupon_price),0) from wx_coupon_order |
|
|
|
where tenant_id=#{tenantId} AND create_date >= #{startTime} and create_date < #{endTime} |
|
|
|
</select> |
|
|
|
|
|
|
|
<update id="offExpiredCouponOrderByValidDate"> |
|
|
|
update wx_coupon_order SET coupon_order_status = 2, update_date = now() |
|
|
|
where expired_time < now() and coupon_price = 0 and coupon_order_status = 0 |
|
|
|
</update> |
|
|
|
|
|
|
|
<select id="findExpiredCouponOrderByValidDate" parameterType="com.iformall.domain.po.WxCouponOrder" resultMap="BaseResultMap"> |
|
|
|
select <include refid="allColumns" /> from wx_coupon_order |
|
|
|
where expired_time < now() and coupon_price > 0 and coupon_order_status = 0 |
|
|
|
</select> |
|
|
|
|
|
|
|
</mapper> |