| @@ -154,7 +154,7 @@ public class ShiroConfig { | |||
| filterChainDefinitionMap.put("/logout", "authc"); | |||
| filterChainDefinitionMap.put("/**", "corsFilter,token,authc"); | |||
| filterChainDefinitionMap.put("/**", "anon"); | |||
| // filterChainDefinitionMap.put("/**", "anon"); | |||
| shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap); | |||
| @@ -66,11 +66,9 @@ public class BaseController { | |||
| * @return | |||
| */ | |||
| public TenantEntity getTenantInfo(){ | |||
| // Session session = SecurityUtils.getSubject().getSession(); | |||
| // String tenantId = (String)session.getAttribute(UserSession.tenantId); | |||
| // String parentTenantId = (String)session.getAttribute(UserSession.parentTenantId); | |||
| String tenantId = "789"; | |||
| String parentTenantId = null; | |||
| Session session = SecurityUtils.getSubject().getSession(); | |||
| String tenantId = (String)session.getAttribute(UserSession.tenantId); | |||
| String parentTenantId = (String)session.getAttribute(UserSession.parentTenantId); | |||
| TenantEntity tenantEntity = new TenantEntity(); | |||
| tenantEntity.setTenantId(tenantId); | |||
| tenantEntity.setParentTenantId(parentTenantId); | |||
| @@ -24,6 +24,8 @@ public class WxCouponOrder extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "卡券ID", name = "couponId") | |||
| private Long couponId; | |||
| @TableField(exist = false) | |||
| private List<Long> couponIds; | |||
| @io.swagger.annotations.ApiModelProperty(value = "券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,8.砍价券,9.团购券,10.预购商品,11.可配送商品,12.券礼包,50.积分券,51.积分停车券,100.消费卡)", name = "couponType") | |||
| private Integer couponType; | |||
| @io.swagger.annotations.ApiModelProperty(value = "c端用户id", name = "cUserId") | |||
| @@ -195,11 +195,6 @@ public class WxCouponOrderBVo extends WxCouponOrder { | |||
| @TableField(exist = false) | |||
| private Date verifyEndDate; | |||
| @TableField(exist = false) | |||
| private Long couponId; | |||
| @TableField(exist = false) | |||
| private List<Long> couponIds; | |||
| @Excel(name = "类型", width = 50, orderNum = "16", replace = {"满减券_1", "代金券_2", "团购券_3", "礼品券_4", "停车券_5", "通用券_6", "砍价券_8", "团购券_9", "预购商品_10", "可配送商品_11", "券礼包_12", "积分券_50", "积分停车券_51", "消费卡_100"}) | |||
| @TableField(exist = false) | |||
| private Integer couponType; | |||
| @@ -217,16 +212,6 @@ public class WxCouponOrderBVo extends WxCouponOrder { | |||
| @TableField(exist = false) | |||
| private String buildingStr; | |||
| @Override | |||
| public Long getCouponId() { | |||
| return couponId; | |||
| } | |||
| @Override | |||
| public void setCouponId(Long couponId) { | |||
| this.couponId = couponId; | |||
| } | |||
| @Override | |||
| public Integer getCouponType() { | |||
| return couponType; | |||
| @@ -13,8 +13,7 @@ public interface WxCardSpendMapper extends CommonMapper<WxCardSpend, Long> { | |||
| int findCount(WxCardSpend wxCardSpend); | |||
| List<Map<String,Object>> getCountByBusinessId(WxCardSpend wxCardSpend); | |||
| List<Map<String,Object>> getCountBySubBusinessId(WxCardSpend wxCardSpend); | |||
| List<Map<String,Object>> getMerchantCount(WxCardSpend wxCardSpend); | |||
| List<WxCardSpendVo> findCardSpendVoList(WxCardSpendVo wxCardSpend); | |||
| @@ -37,8 +37,7 @@ public interface WxCouponOrderMapper extends CommonMapper<WxCouponOrder, Long> { | |||
| //统一的计数接口 | |||
| int findCount(WxCouponOrder wxCouponOrder); | |||
| int findProductCount(WxCouponOrder wxCouponOrder); | |||
| List<Map<String, Object>> getCountByBusinessId(WxCouponOrder wxCouponOrder); | |||
| List<Map<String, Object>> getCountBySubBusinessId(WxCouponOrder wxCouponOrder); | |||
| List<Map<String, Object>> getCouponCount(WxCouponOrder wxCouponOrder); | |||
| //统一额度统计接口 | |||
| int queryPriceTotal(WxCouponOrder wxCouponOrder); | |||
| @@ -47,6 +47,10 @@ public class WxCUserTagsServiceHelper{ | |||
| WxSubBusinessMapper wxSubBusinessMapper; | |||
| @Autowired | |||
| WxCUserBasicChildMapper wxCUserBasicChildMapper; | |||
| @Autowired | |||
| WxCouponMapper wxCouponMapper; | |||
| @Autowired | |||
| WxMerchantMapper wxMerchantMapper; | |||
| //打标 | |||
| public List<WxTags> assign(WxCUserBasicInfo user, EnumTag tag, WxCUserTagsService wxCUserTagsService){ | |||
| @@ -361,24 +365,60 @@ public class WxCUserTagsServiceHelper{ | |||
| 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<Map<String, Object>> cardSpendMerchantCountList = wxCardSpendMapper.getMerchantCount(wxCardSpend); | |||
| //查询商户 | |||
| WxMerchant merchantQ = new WxMerchant(); | |||
| merchantQ.updateTenantInfo(tenantEntity); | |||
| List<WxMerchant> merchantList = wxMerchantMapper.findList(merchantQ); | |||
| Map<Long,Integer> merchantBussinessMap = new HashMap<Long,Integer>(); | |||
| if (null != merchantList) { | |||
| for (int i = 0 ; i < merchantList.size() ;i ++) { | |||
| WxMerchant m = merchantList.get(i); | |||
| merchantBussinessMap.put(m.getId(), m.getBusinessId()); | |||
| } | |||
| } | |||
| List<Map<String, Object>> couponCountList = wxCouponOrderMapper.getCouponCount(wxCouponOrder); | |||
| //查询业态 | |||
| WxCoupon couponQ = new WxCoupon(); | |||
| couponQ.updateTenantInfo(tenantEntity); | |||
| Map<Long,Integer> couponBussinessMap = new HashMap<Long,Integer>(); | |||
| List<WxCoupon> couponList = wxCouponMapper.newfindCList(couponQ); | |||
| if (null != couponList) { | |||
| for (int i = 0 ; i < couponList.size() ;i ++) { | |||
| WxCoupon c = couponList.get(i); | |||
| couponBussinessMap.put(c.getId(), c.getBusiness()); | |||
| } | |||
| } | |||
| list.stream().forEach(b->{ | |||
| int count = 0; | |||
| if(cardSpendCountList.size() > 0) { | |||
| for (Map<String, Object> cardSpendCount : cardSpendCountList) { | |||
| if(null != cardSpendMerchantCountList && cardSpendMerchantCountList.size() > 0) { | |||
| for (Map<String, Object> cardSpendCount : cardSpendMerchantCountList) { | |||
| Long merchantId = (Long)cardSpendCount.get("merchantId") ; | |||
| Long merchantCount = (Long)cardSpendCount.get("count"); | |||
| if (null != merchantId && null != merchantCount) { | |||
| Integer bussiness = merchantBussinessMap.get(merchantId); | |||
| if (null != bussiness && bussiness.intValue() == b.getId().intValue()) { | |||
| count += merchantCount.intValue(); | |||
| } | |||
| } | |||
| if (cardSpendCount.get("business_id") != null | |||
| && cardSpendCount.get("business_id").equals(b.getId().toString())) { | |||
| count += (Integer) cardSpendCount.get("bu_count"); | |||
| } | |||
| } | |||
| } | |||
| if(cardOrderCountList.size() > 0) { | |||
| for (Map<String, Object> cardOrderCount : cardOrderCountList) { | |||
| if (cardOrderCount.get("business") != null | |||
| && cardOrderCount.get("business").equals(b.getId().toString())) { | |||
| count += (Integer) cardOrderCount.get("bu_count"); | |||
| if(null!= couponCountList && couponCountList.size() > 0) { | |||
| for (Map<String, Object> cardOrderCount : couponCountList) { | |||
| Long couponId = (Long)cardOrderCount.get("couponId") ; | |||
| Long couponCount = (Long)cardOrderCount.get("count"); | |||
| if (null != couponId && null != couponCount) { | |||
| Integer bussiness = couponBussinessMap.get(couponId); | |||
| if (null != bussiness && bussiness.intValue() == b.getId().intValue()) { | |||
| count += couponCount.intValue(); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -432,24 +472,64 @@ public class WxCUserTagsServiceHelper{ | |||
| subBusiness.setBusinessId(EnumBusiness.BUSINESS_ID1.getCode()); | |||
| List<WxSubBusiness> list = wxSubBusinessMapper.findList(subBusiness); | |||
| List<Map<String, Object>> cardSpendCountList = wxCardSpendMapper.getCountBySubBusinessId(wxCardSpend); | |||
| List<Map<String, Object>> cardOrderCountList = wxCouponOrderMapper.getCountBySubBusinessId(wxCouponOrder); | |||
| List<Map<String, Object>> cardSpendMerchantCountList = wxCardSpendMapper.getMerchantCount(wxCardSpend); | |||
| //查询商户子业态 | |||
| WxMerchant merchantQ = new WxMerchant(); | |||
| merchantQ.updateTenantInfo(tenantEntity); | |||
| merchantQ.setSubBusinessId(wxCouponOrder.getSubBusinessId()); | |||
| List<WxMerchant> merchantList = wxMerchantMapper.findList(merchantQ); | |||
| Map<Long,Integer> merchantBussinessMap = new HashMap<Long,Integer>(); | |||
| if (null != merchantList) { | |||
| for (int i = 0 ; i < merchantList.size() ;i ++) { | |||
| WxMerchant m = merchantList.get(i); | |||
| merchantBussinessMap.put(m.getId(), m.getSubBusinessId()); | |||
| } | |||
| } | |||
| List<Map<String, Object>> couponCountList = wxCouponOrderMapper.getCouponCount(wxCouponOrder); | |||
| //查询券子业态 | |||
| WxCoupon couponQ = new WxCoupon(); | |||
| couponQ.updateTenantInfo(tenantEntity); | |||
| couponQ.setBusiness(wxCouponOrder.getBusinessId()); | |||
| List<WxCoupon> couponList = wxCouponMapper.newfindCList(couponQ); | |||
| Map<Long,Integer> couponBussinessMap = new HashMap<Long,Integer>(); | |||
| if (null != couponList) { | |||
| for (int i = 0 ; i < couponList.size() ;i ++) { | |||
| WxCoupon c = couponList.get(i); | |||
| couponBussinessMap.put(c.getId(), c.getSubBusiness()); | |||
| } | |||
| } | |||
| list.stream().forEach(sb->{ | |||
| int count = 0; | |||
| if(cardSpendCountList.size() > 0) { | |||
| for (Map<String, Object> cardSpendCount : cardSpendCountList) { | |||
| if(null != cardSpendMerchantCountList && cardSpendMerchantCountList.size() > 0) { | |||
| for (Map<String, Object> cardSpendCount : cardSpendMerchantCountList) { | |||
| Long merchantId = (Long)cardSpendCount.get("merchantId") ; | |||
| Long merchantCount = (Long)cardSpendCount.get("count"); | |||
| if (null != merchantId && null != merchantCount) { | |||
| Integer subBussiness = merchantBussinessMap.get(merchantId); | |||
| if (null != subBussiness && subBussiness.intValue() == sb.getId().intValue()) { | |||
| count += merchantCount.intValue(); | |||
| } | |||
| } | |||
| Long subBusinessId = (Long)cardSpendCount.get("subBusinessId"); | |||
| if (subBusinessId != null && subBusinessId.equals(sb.getId())) { | |||
| count += (Integer) cardSpendCount.get("buCount"); | |||
| } | |||
| } | |||
| } | |||
| if(cardOrderCountList.size() > 0) { | |||
| for (Map<String, Object> cardOrderCount : cardOrderCountList) { | |||
| Long subBusinessId = (Long)cardOrderCount.get("subBusiness"); | |||
| if (subBusinessId != null && subBusinessId.equals(sb.getId())) { | |||
| count += (Integer) cardOrderCount.get("buCount"); | |||
| if(null!= couponCountList && couponCountList.size() > 0) { | |||
| for (Map<String, Object> cardOrderCount : couponCountList) { | |||
| Long couponId = (Long)cardOrderCount.get("couponId") ; | |||
| Long couponCount = (Long)cardOrderCount.get("count"); | |||
| if (null != couponId && null != couponCount) { | |||
| Integer subBussiness = couponBussinessMap.get(couponId); | |||
| if (null != subBussiness && subBussiness.intValue() == sb.getId().intValue()) { | |||
| count += couponCount.intValue(); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -189,17 +189,10 @@ | |||
| </if> | |||
| </select> | |||
| <select id="getCountByBusinessId" parameterType="com.iformall.domain.po.WxCardSpend" resultType="hashmap"> | |||
| select m.business_id, count(m.business_id) bu_count | |||
| <select id="getMerchantCount" parameterType="com.iformall.domain.po.WxCardSpend" resultType="hashmap"> | |||
| select cs.merchant_id as merchantId, count(1) as 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 '' != tenantId"> | |||
| and cs.`tenant_id` = #{tenantId} | |||
| </if> | |||
| where cs.`owner_id` = #{ownerId} and cs.`tenant_id` = #{tenantId} | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and cs.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| @@ -233,59 +226,15 @@ | |||
| ((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="getCountBySubBusinessId" parameterType="com.iformall.domain.po.WxCardSpend" resultType="hashmap"> | |||
| select m.sub_business_id, count(m.sub_business_id) bu_count | |||
| from wx_card_spend cs | |||
| <if test=" null != businessId "> | |||
| inner join wx_merchant m on m.id = cs.merchant_id and m.business_id = #{businessId} | |||
| </if> | |||
| where 1 = 1 | |||
| <if test=" null != ownerId "> | |||
| and cs.`owner_id` = #{ownerId} | |||
| </if> | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and cs.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and cs.`parent_tenant_id` = #{parentTenantId} | |||
| </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 test=" null != merchantIds "> | |||
| and cs.merchant_id in | |||
| <foreach collection="merchantIds" index="index" item="merchantIdItem" open="(" separator="," close=")"> | |||
| #{merchantIdItem} | |||
| </foreach> | |||
| </if> | |||
| group by m.sub_business_id | |||
| group by cs.merchant_id | |||
| </select> | |||
| <resultMap id="VoResultMap" type="com.iformall.domain.vo.WxCardSpendVo"> | |||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||
| @@ -1241,6 +1241,12 @@ | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != business "> | |||
| and `business` = #{business} | |||
| </if> | |||
| <if test=" null != subBusiness "> | |||
| and `sub_business` = #{subBusiness} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| @@ -568,14 +568,9 @@ | |||
| </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 '' != tenantId"> | |||
| and co.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <select id="getCouponCount" parameterType="com.iformall.domain.po.WxCouponOrder" resultType="hashmap"> | |||
| select co.coupon_id as couponId, count(1) as count FROM wx_coupon_order co | |||
| where co.`tenant_id` = #{tenantId} | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and co.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| @@ -591,101 +586,12 @@ | |||
| <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="getCountBySubBusinessId" parameterType="com.iformall.domain.po.WxCouponOrder" resultType="hashmap"> | |||
| select c.sub_business, COUNT(c.sub_business) bu_count | |||
| FROM wx_coupon_order co | |||
| <if test=" null != businessId "> | |||
| inner join wx_coupon c on c.id = co.coupon_id and c.business = #{businessId} | |||
| </if> | |||
| where 1=1 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and co.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and co.`parent_tenant_id` = #{parentTenantId} | |||
| </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 test=" null != couponIds"> | |||
| and co.coupon_id in | |||
| <foreach collection="couponIds" index="index" item="couponIdItem" open="(" separator="," close=")"> | |||
| #{couponIdItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" 1 == couponOrderStatus"> | |||
| <if test=" null != startTime"> | |||
| and co.update_date >= #{startTime} | |||
| @@ -751,7 +657,7 @@ | |||
| and date_format(co.create_date,'%w') in (6,0))) | |||
| </if> | |||
| </if> | |||
| group by c.sub_business | |||
| group by co.coupon_id | |||
| </select> | |||
| <select id="queryPriceTotalGroup" resultType="com.iformall.domain.vo.CUserDateAmountVo" > | |||