| @@ -13,6 +13,9 @@ public interface WxCardSpendMapper extends CommonMapper<WxCardSpend, Long> { | |||
| int findCount(WxCardSpend wxCardSpend); | |||
| List<Map<String,Object>> getCountByBusinessId(WxCardSpend wxCardSpend); | |||
| List<Map<String,Object>> getCountByBusinessIdAndSubId(WxCardSpend wxCardSpend); | |||
| List<WxCardSpendVo> findCardSpendVoList(WxCardSpendVo wxCardSpend); | |||
| List<Map<String,Object>> sumCardSpendVoForMerchant(WxCardSpendVo wxCardSpend); | |||
| @@ -26,6 +26,8 @@ public interface WxCouponOrderMapper extends CommonMapper<WxCouponOrder, Long> { | |||
| //统一的计数接口 | |||
| int findCount(WxCouponOrder wxCouponOrder); | |||
| List<Map<String, Object>> getCountByBusinessId(WxCouponOrder wxCouponOrder); | |||
| List<Map<String, Object>> getCountByBusinessIdAndSubId(WxCouponOrder wxCouponOrder); | |||
| //统一额度统计接口 | |||
| int queryPriceTotal(WxCouponOrder wxCouponOrder); | |||
| @@ -368,11 +368,25 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||
| WxBusiness business = new WxBusiness(); | |||
| List<WxBusiness> list = wxBusinessMapper.findList(business); | |||
| List<Map<String, Object>> cardSpendCountList = wxCardSpendMapper.getCountByBusinessId(wxCardSpend); | |||
| List<Map<String, Object>> cardOrderCountList = wxCouponOrderMapper.getCountByBusinessId(wxCouponOrder); | |||
| list.stream().forEach(b->{ | |||
| wxCardSpend.setBusinessId(b.getId()); | |||
| wxCouponOrder.setBusinessId(b.getId()); | |||
| int count = wxCardSpendMapper.findCount(wxCardSpend); | |||
| count += wxCouponOrderMapper.findCount(wxCouponOrder); | |||
| int count = 0; | |||
| if(cardSpendCountList.size() > 0) { | |||
| for (Map<String, Object> cardSpendCount : cardSpendCountList) { | |||
| if (cardSpendCount.get("businessId").equals(b.getId().toString())) { | |||
| count += (Integer) cardSpendCount.get("buCount"); | |||
| } | |||
| } | |||
| } | |||
| if(cardOrderCountList.size() > 0) { | |||
| for (Map<String, Object> cardOrderCount : cardOrderCountList) { | |||
| if (cardOrderCount.get("business").equals(b.getId().toString())) { | |||
| count += (Integer) cardOrderCount.get("buCount"); | |||
| } | |||
| } | |||
| } | |||
| if (count > 0) { | |||
| EnumTag tag = null; | |||
| if (b.getId().intValue() >= EnumBusiness.BUSINESS_ID1.getCode() && | |||
| @@ -419,11 +433,25 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||
| subBusiness.setBusinessId(EnumBusiness.BUSINESS_ID1.getCode()); | |||
| List<WxSubBusiness> list = wxSubBusinessMapper.findList(subBusiness); | |||
| List<Map<String, Object>> cardSpendCountList = wxCardSpendMapper.getCountByBusinessId(wxCardSpend); | |||
| List<Map<String, Object>> cardOrderCountList = wxCouponOrderMapper.getCountByBusinessId(wxCouponOrder); | |||
| list.stream().forEach(sb->{ | |||
| wxCardSpend.setSubBusinessId(sb.getId()); | |||
| wxCouponOrder.setSubBusinessId(sb.getId()); | |||
| int count = wxCardSpendMapper.findCount(wxCardSpend); | |||
| count += wxCouponOrderMapper.findCount(wxCouponOrder); | |||
| int count = 0; | |||
| if(cardSpendCountList.size() > 0) { | |||
| for (Map<String, Object> cardSpendCount : cardSpendCountList) { | |||
| if (cardSpendCount.get("subBusinessId").equals(sb.getId().toString())) { | |||
| count += (Integer) cardSpendCount.get("buCount"); | |||
| } | |||
| } | |||
| } | |||
| if(cardOrderCountList.size() > 0) { | |||
| for (Map<String, Object> cardOrderCount : cardOrderCountList) { | |||
| if (cardOrderCount.get("subBusiness").equals(sb.getId().toString())) { | |||
| count += (Integer) cardOrderCount.get("buCount"); | |||
| } | |||
| } | |||
| } | |||
| if (count > 0) { | |||
| EnumTag tag = null; | |||
| if (sb.getId().intValue() >= EnumSubBusiness.SUB_BUSINESS_ID1.getCode() && | |||
| @@ -165,6 +165,94 @@ | |||
| </if> | |||
| </select> | |||
| <select id="getCountByBusinessId" parameterType="com.iformall.domain.po.WxCardSpend" resultType="hashmap"> | |||
| select m.business_id, count(m.business_id) bu_count | |||
| from wx_card_spend cs | |||
| inner join wx_merchant m on m.id = cs.merchant_id | |||
| where 1 = 1 | |||
| <if test=" null != ownerId "> | |||
| and cs.`owner_id` = #{ownerId} | |||
| </if> | |||
| <if test=" null != tenantId "> | |||
| and cs.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != startdate and null!=enddate"> | |||
| and cs.`create_date` between #{startdate} and #{enddate} | |||
| </if> | |||
| <if test=" 0 == timeSlot"> | |||
| and date_format(cs.create_date,'%H:%m') >= '06:00' | |||
| and date_format(cs.create_date,'%H:%m') < '18:00' | |||
| and date_format(cs.create_date,'%w') in (1,2,3,4,5) | |||
| </if> | |||
| <if test=" 1 == timeSlot"> | |||
| and ((date_format(cs.create_date,'%H:%m') >= '18:00' | |||
| and date_format(cs.create_date,'%w') in (1,2,3,4)) | |||
| or | |||
| ((date_format(cs.create_date,'%H:%m') < '06:00') | |||
| and date_format(cs.create_date,'%w') in (1,2,3,4,5))) | |||
| </if> | |||
| <if test=" 2 == timeSlot"> | |||
| and date_format(cs.create_date,'%H:%m') >= '06:00' | |||
| and date_format(cs.create_date,'%H:%m') < '18:00' | |||
| and date_format(cs.create_date,'%w') in (0,6) | |||
| </if> | |||
| <if test=" 3 == timeSlot"> | |||
| and ((date_format(cs.create_date,'%H:%m') >= '18:00' | |||
| and date_format(cs.create_date,'%w') in (5,6,0)) | |||
| or | |||
| ((date_format(cs.create_date,'%H:%m') < '06:00') | |||
| and date_format(cs.create_date,'%w') in (6,0))) | |||
| </if> | |||
| group by m.business_id | |||
| </select> | |||
| <select id="getCountByBusinessIdAndSubId" parameterType="com.iformall.domain.po.WxCardSpend" resultType="hashmap"> | |||
| select m.business_id, m.sub_business_id, count(m.business_id + '' + m.sub_business_id) bu_count | |||
| from wx_card_spend cs | |||
| inner join wx_merchant m on m.id = cs.merchant_id | |||
| where 1 = 1 | |||
| <if test=" null != ownerId "> | |||
| and cs.`owner_id` = #{ownerId} | |||
| </if> | |||
| <if test=" null != tenantId "> | |||
| and cs.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != startdate and null!=enddate"> | |||
| and cs.`create_date` between #{startdate} and #{enddate} | |||
| </if> | |||
| <if test=" 0 == timeSlot"> | |||
| and date_format(cs.create_date,'%H:%m') >= '06:00' | |||
| and date_format(cs.create_date,'%H:%m') < '18:00' | |||
| and date_format(cs.create_date,'%w') in (1,2,3,4,5) | |||
| </if> | |||
| <if test=" 1 == timeSlot"> | |||
| and ((date_format(cs.create_date,'%H:%m') >= '18:00' | |||
| and date_format(cs.create_date,'%w') in (1,2,3,4)) | |||
| or | |||
| ((date_format(cs.create_date,'%H:%m') < '06:00') | |||
| and date_format(cs.create_date,'%w') in (1,2,3,4,5))) | |||
| </if> | |||
| <if test=" 2 == timeSlot"> | |||
| and date_format(cs.create_date,'%H:%m') >= '06:00' | |||
| and date_format(cs.create_date,'%H:%m') < '18:00' | |||
| and date_format(cs.create_date,'%w') in (0,6) | |||
| </if> | |||
| <if test=" 3 == timeSlot"> | |||
| and ((date_format(cs.create_date,'%H:%m') >= '18:00' | |||
| and date_format(cs.create_date,'%w') in (5,6,0)) | |||
| or | |||
| ((date_format(cs.create_date,'%H:%m') < '06:00') | |||
| and date_format(cs.create_date,'%w') in (6,0))) | |||
| </if> | |||
| group by m.business_id, m.sub_business_id | |||
| </select> | |||
| <resultMap id="VoResultMap" type="com.iformall.domain.vo.WxCardSpendVo"> | |||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||
| @@ -329,6 +329,184 @@ | |||
| </if> | |||
| </select> | |||
| <select id="getCountByBusinessId" parameterType="com.iformall.domain.po.WxCouponOrder" resultType="hashmap"> | |||
| select c.business, COUNT(c.business) bu_count | |||
| FROM wx_coupon_order co | |||
| inner join wx_coupon c on c.id = co.coupon_id | |||
| where 1=1 | |||
| <if test=" null != tenantId"> | |||
| and co.tenant_id = #{tenantId} | |||
| </if> | |||
| <if test=" null != couponOrderStatus"> | |||
| and co.coupon_order_status = #{couponOrderStatus} | |||
| </if> | |||
| <if test=" null != cUserId"> | |||
| and co.c_user_id = #{cUserId} | |||
| </if> | |||
| <if test=" null != couponId "> | |||
| and co.coupon_id = #{couponId} | |||
| </if> | |||
| <if test=" null != couponType "> | |||
| and co.coupon_type = #{couponType} | |||
| </if> | |||
| <if test=" 1 == couponOrderStatus"> | |||
| <if test=" null != startTime"> | |||
| and co.update_date >= #{startTime} | |||
| </if> | |||
| <if test=" null != endTime"> | |||
| and co.update_date <= #{endTime} | |||
| </if> | |||
| <if test=" 0 == timeSlot"> | |||
| and date_format(co.update_date,'%H:%m') >= '06:00' | |||
| and date_format(co.update_date,'%H:%m') < '18:00' | |||
| and date_format(co.update_date,'%w') in (1,2,3,4,5) | |||
| </if> | |||
| <if test=" 1 == timeSlot"> | |||
| and ((date_format(co.update_date,'%H:%m') >= '18:00' | |||
| and date_format(co.update_date,'%w') in (1,2,3,4)) | |||
| or | |||
| ((date_format(co.update_date,'%H:%m') < '06:00') | |||
| and date_format(co.update_date,'%w') in (1,2,3,4,5))) | |||
| </if> | |||
| <if test=" 2 == timeSlot"> | |||
| and date_format(co.update_date,'%H:%m') >= '06:00' | |||
| and date_format(co.update_date,'%H:%m') < '18:00' | |||
| and date_format(co.update_date,'%w') in (0,6) | |||
| </if> | |||
| <if test=" 3 == timeSlot"> | |||
| and ((date_format(co.update_date,'%H:%m') >= '18:00' | |||
| and date_format(co.update_date,'%w') in (5,6,0)) | |||
| or | |||
| ((date_format(co.update_date,'%H:%m') < '06:00') | |||
| and date_format(co.update_date,'%w') in (6,0))) | |||
| </if> | |||
| </if> | |||
| <if test=" 1 != couponOrderStatus"> | |||
| <if test=" null != startTime"> | |||
| and co.create_date >= #{startTime} | |||
| </if> | |||
| <if test=" null != endTime"> | |||
| and co.create_date <= #{endTime} | |||
| </if> | |||
| <if test=" 0 == timeSlot"> | |||
| and date_format(co.create_date,'%H:%m') >= '06:00' | |||
| and date_format(co.create_date,'%H:%m') < '18:00' | |||
| and date_format(co.create_date,'%w') in (1,2,3,4,5) | |||
| </if> | |||
| <if test=" 1 == timeSlot"> | |||
| and ((date_format(co.create_date,'%H:%m') >= '18:00' | |||
| and date_format(co.create_date,'%w') in (1,2,3,4)) | |||
| or | |||
| ((date_format(co.create_date,'%H:%m') < '06:00') | |||
| and date_format(co.create_date,'%w') in (1,2,3,4,5))) | |||
| </if> | |||
| <if test=" 2 == timeSlot"> | |||
| and date_format(co.create_date,'%H:%m') >= '06:00' | |||
| and date_format(co.create_date,'%H:%m') < '18:00' | |||
| and date_format(co.create_date,'%w') in (0,6) | |||
| </if> | |||
| <if test=" 3 == timeSlot"> | |||
| and ((date_format(co.create_date,'%H:%m') >= '18:00' | |||
| and date_format(co.create_date,'%w') in (5,6,0)) | |||
| or | |||
| ((date_format(co.create_date,'%H:%m') < '06:00') | |||
| and date_format(co.create_date,'%w') in (6,0))) | |||
| </if> | |||
| </if> | |||
| group by c.business | |||
| </select> | |||
| <select id="getCountByBusinessIdAndSubId" parameterType="com.iformall.domain.po.WxCouponOrder" resultType="hashmap"> | |||
| select c.business, c.sub_business, COUNT(c.business+''+c.sub_business) bu_count | |||
| FROM wx_coupon_order co | |||
| inner join wx_coupon c on c.id = co.coupon_id | |||
| where 1=1 | |||
| <if test=" null != tenantId"> | |||
| and co.tenant_id = #{tenantId} | |||
| </if> | |||
| <if test=" null != couponOrderStatus"> | |||
| and co.coupon_order_status = #{couponOrderStatus} | |||
| </if> | |||
| <if test=" null != cUserId"> | |||
| and co.c_user_id = #{cUserId} | |||
| </if> | |||
| <if test=" null != couponId "> | |||
| and co.coupon_id = #{couponId} | |||
| </if> | |||
| <if test=" null != couponType "> | |||
| and co.coupon_type = #{couponType} | |||
| </if> | |||
| <if test=" 1 == couponOrderStatus"> | |||
| <if test=" null != startTime"> | |||
| and co.update_date >= #{startTime} | |||
| </if> | |||
| <if test=" null != endTime"> | |||
| and co.update_date <= #{endTime} | |||
| </if> | |||
| <if test=" 0 == timeSlot"> | |||
| and date_format(co.update_date,'%H:%m') >= '06:00' | |||
| and date_format(co.update_date,'%H:%m') < '18:00' | |||
| and date_format(co.update_date,'%w') in (1,2,3,4,5) | |||
| </if> | |||
| <if test=" 1 == timeSlot"> | |||
| and ((date_format(co.update_date,'%H:%m') >= '18:00' | |||
| and date_format(co.update_date,'%w') in (1,2,3,4)) | |||
| or | |||
| ((date_format(co.update_date,'%H:%m') < '06:00') | |||
| and date_format(co.update_date,'%w') in (1,2,3,4,5))) | |||
| </if> | |||
| <if test=" 2 == timeSlot"> | |||
| and date_format(co.update_date,'%H:%m') >= '06:00' | |||
| and date_format(co.update_date,'%H:%m') < '18:00' | |||
| and date_format(co.update_date,'%w') in (0,6) | |||
| </if> | |||
| <if test=" 3 == timeSlot"> | |||
| and ((date_format(co.update_date,'%H:%m') >= '18:00' | |||
| and date_format(co.update_date,'%w') in (5,6,0)) | |||
| or | |||
| ((date_format(co.update_date,'%H:%m') < '06:00') | |||
| and date_format(co.update_date,'%w') in (6,0))) | |||
| </if> | |||
| </if> | |||
| <if test=" 1 != couponOrderStatus"> | |||
| <if test=" null != startTime"> | |||
| and co.create_date >= #{startTime} | |||
| </if> | |||
| <if test=" null != endTime"> | |||
| and co.create_date <= #{endTime} | |||
| </if> | |||
| <if test=" 0 == timeSlot"> | |||
| and date_format(co.create_date,'%H:%m') >= '06:00' | |||
| and date_format(co.create_date,'%H:%m') < '18:00' | |||
| and date_format(co.create_date,'%w') in (1,2,3,4,5) | |||
| </if> | |||
| <if test=" 1 == timeSlot"> | |||
| and ((date_format(co.create_date,'%H:%m') >= '18:00' | |||
| and date_format(co.create_date,'%w') in (1,2,3,4)) | |||
| or | |||
| ((date_format(co.create_date,'%H:%m') < '06:00') | |||
| and date_format(co.create_date,'%w') in (1,2,3,4,5))) | |||
| </if> | |||
| <if test=" 2 == timeSlot"> | |||
| and date_format(co.create_date,'%H:%m') >= '06:00' | |||
| and date_format(co.create_date,'%H:%m') < '18:00' | |||
| and date_format(co.create_date,'%w') in (0,6) | |||
| </if> | |||
| <if test=" 3 == timeSlot"> | |||
| and ((date_format(co.create_date,'%H:%m') >= '18:00' | |||
| and date_format(co.create_date,'%w') in (5,6,0)) | |||
| or | |||
| ((date_format(co.create_date,'%H:%m') < '06:00') | |||
| and date_format(co.create_date,'%w') in (6,0))) | |||
| </if> | |||
| </if> | |||
| group by c.business, c.sub_business | |||
| </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 | |||