Просмотр исходного кода

[标签][修改]:业态消费标签,餐饮子业态消费标签

release_toaliyun_real
hupeng 7 лет назад
Родитель
Сommit
e4571b7e36
6 измененных файлов: 295 добавлений и 69 удалений
  1. +7
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxCardSpend.java
  2. +23
    -1
      mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrder.java
  3. +57
    -0
      mallinkService/src/main/java/com/iformall/enums/EnumSubBusiness.java
  4. +116
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxCUserTagsServiceImpl.java
  5. +46
    -30
      mallinkService/src/main/resources/mapper/WxCardSpendMapper.xml
  6. +46
    -38
      mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml

+ 7
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxCardSpend.java Просмотреть файл

@@ -1,6 +1,7 @@
package com.iformall.domain.po;

import cn.afterturn.easypoi.excel.annotation.Excel;
import io.swagger.models.auth.In;
import lombok.Data;
import javax.persistence.*;
import java.math.BigDecimal;
@@ -106,6 +107,12 @@ public class WxCardSpend implements Serializable {
@io.swagger.annotations.ApiModelProperty(value="时段(0,工作日白天,1,工作日晚上,2周末白天,3周末晚上)",name="timeSlot")
private Integer timeSlot;

@Transient
private Integer businessId;

@Transient
private Integer subBusinessId;

public String getDeductionAmountStr() {
if(getDeductionAmount()!=null) {
deductionAmountStr = new BigDecimal(getDeductionAmount()).divide(new BigDecimal(100)).toString();


+ 23
- 1
mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrder.java Просмотреть файл

@@ -102,7 +102,13 @@ public class WxCouponOrder extends BaseEntity{
@Transient
@io.swagger.annotations.ApiModelProperty(value="时段(0,工作日白天,1,工作日晚上,2周末白天,3周末晚上)",name="timeSlot")
private Integer timeSlot;

@Transient
private Integer businessId;

@Transient
private Integer subBusinessId;

public String getCouponPriceStr() {
if(couponPrice!=null) {
DecimalFormat df=new DecimalFormat("0.00");
@@ -271,6 +277,22 @@ public class WxCouponOrder extends BaseEntity{
this.timeSlot = timeSlot;
}

public Integer getBusinessId() {
return businessId;
}

public void setBusinessId(Integer businessId) {
this.businessId = businessId;
}

public Integer getSubBusinessId() {
return subBusinessId;
}

public void setSubBusinessId(Integer subBusinessId) {
this.subBusinessId = subBusinessId;
}

public static enum Field {
Id_ASC("`id` ASC"), Id_DESC("`id` DESC"),
TenantId_ASC("`tenant_id` ASC"), TenantId_DESC("`tenant_id` DESC"),


+ 57
- 0
mallinkService/src/main/java/com/iformall/enums/EnumSubBusiness.java Просмотреть файл

@@ -0,0 +1,57 @@
package com.iformall.enums;

/**
* Created by Stormeye on 2018/08/09.
*/
public enum EnumSubBusiness {

SUB_BUSINESS_NULL(0,"无" ),
SUB_BUSINESS_ID1 (1,"西餐"),
SUB_BUSINESS_ID2 (2,"日本料理"),
SUB_BUSINESS_ID3 (3,"韩国料理"),
SUB_BUSINESS_ID4 (4,"东南亚菜"),
SUB_BUSINESS_ID5 (5,"自助餐"),
SUB_BUSINESS_ID6 (6,"火锅"),
SUB_BUSINESS_ID7 (7,"特色菜"),
SUB_BUSINESS_ID8 (8,"私房菜"),
SUB_BUSINESS_ID9 (9,"素食"),
SUB_BUSINESS_ID10(10,"烧烤"),
SUB_BUSINESS_ID11(11,"小吃快餐"),
SUB_BUSINESS_ID12(12,"川菜"),
SUB_BUSINESS_ID13(13,"湘菜"),
SUB_BUSINESS_ID14(14,"鲁菜"),
SUB_BUSINESS_ID15(15,"粤菜"),
SUB_BUSINESS_ID16(16,"湖北菜"),
SUB_BUSINESS_ID17(17,"云贵菜"),
SUB_BUSINESS_ID18(18,"东北菜"),
SUB_BUSINESS_ID19(19,"面包店"),
SUB_BUSINESS_ID20(20,"咖啡厅"),
SUB_BUSINESS_ID21(21,"饮品店")
;


public static EnumSubBusiness getEnum(Integer code) {
for (EnumSubBusiness value : values()) {
if (value.getCode().equals(code)) {
return value;
}
}
return null;
}

private Integer code;
private String message;

EnumSubBusiness(Integer code, String message) {
this.code = code;
this.message = message;
}

public Integer getCode() {
return code;
}

public String getMessage() {
return message;
}
}

+ 116
- 0
mallinkService/src/main/java/com/iformall/service/impl/WxCUserTagsServiceImpl.java Просмотреть файл

@@ -44,6 +44,12 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService {
@Autowired
WxCUserCarMapper wxCUserCarMapper;

@Autowired
WxSubBusinessMapper wxSubBusinessMapper;

@Autowired
WxBusinessMapper wxBusinessMapper;

@Autowired
WxTagsService wxTagsService;

@@ -339,6 +345,106 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService {
return assign(user, EnumTag.ID_58);
}


private List<WxTags> assignTypeId14(WxCUserBasicInfo user, WxCUser param)
{
List<WxTags> resList = null;
Calendar endC = Calendar.getInstance();
Calendar startC = Calendar.getInstance();
endC.setTime(new Date());
startC.setTime(new Date());
startC.add(Calendar.DAY_OF_YEAR, -30);
WxCouponOrder wxCouponOrder = new WxCouponOrder();
wxCouponOrder.setcUserId(param.getId());
wxCouponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode());
wxCouponOrder.setStartTime(startC.getTime());
wxCouponOrder.setEndTime(endC.getTime());

WxCardSpend wxCardSpend = new WxCardSpend();
wxCardSpend.setOwnerId(param.getId());
wxCardSpend.setStartdate(startC.getTime());
wxCardSpend.setEnddate(endC.getTime());

WxBusiness business = new WxBusiness();
List<WxBusiness> list = wxBusinessMapper.findList(business);

list.stream().forEach(b->{
wxCardSpend.setBusinessId(b.getId());
wxCouponOrder.setBusinessId(b.getId());
int count = wxCardSpendMapper.findCount(wxCardSpend);
count += wxCouponOrderMapper.findCount(wxCouponOrder);
if (count > 0) {
EnumTag tag = null;
if (b.getId().intValue() >= EnumBusiness.BUSINESS_ID1.getCode() &&
b.getId().intValue() <= EnumBusiness.BUSINESS_ID5.getCode()){
tag = EnumTag.getEnum(EnumTag.ID_68.getCode()
+ (b.getId().intValue() - EnumBusiness.BUSINESS_ID1.getCode()));
}

if (b.getId().intValue() >= EnumBusiness.BUSINESS_ID7.getCode() &&
b.getId().intValue() <= EnumBusiness.BUSINESS_ID10.getCode()){
tag = EnumTag.getEnum(EnumTag.ID_73.getCode()
+ (b.getId().intValue() - EnumBusiness.BUSINESS_ID7.getCode()));
}
resList.clear();
resList.addAll(assign(user, tag));
}
});

return resList;
}

private List<WxTags> assignTypeId17(WxCUserBasicInfo user, WxCUser param)
{
List<WxTags> resList = null;
Calendar endC = Calendar.getInstance();
Calendar startC = Calendar.getInstance();
endC.setTime(new Date());
startC.setTime(new Date());
startC.add(Calendar.DAY_OF_YEAR, -30);
WxCouponOrder wxCouponOrder = new WxCouponOrder();
wxCouponOrder.setcUserId(param.getId());
wxCouponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode());
wxCouponOrder.setStartTime(startC.getTime());
wxCouponOrder.setEndTime(endC.getTime());
wxCouponOrder.setBusinessId(EnumBusiness.BUSINESS_ID1.getCode());

WxCardSpend wxCardSpend = new WxCardSpend();
wxCardSpend.setOwnerId(param.getId());
wxCardSpend.setStartdate(startC.getTime());
wxCardSpend.setEnddate(endC.getTime());
wxCardSpend.setBusinessId(EnumBusiness.BUSINESS_ID1.getCode());

WxSubBusiness subBusiness = new WxSubBusiness();
subBusiness.setBusinessId(EnumBusiness.BUSINESS_ID1.getCode());
List<WxSubBusiness> list = wxSubBusinessMapper.findList(subBusiness);

list.stream().forEach(sb->{
wxCardSpend.setSubBusinessId(sb.getId());
wxCouponOrder.setSubBusinessId(sb.getId());
int count = wxCardSpendMapper.findCount(wxCardSpend);
count += wxCouponOrderMapper.findCount(wxCouponOrder);
if (count > 0) {
EnumTag tag = null;
if (sb.getId().intValue() >= EnumSubBusiness.SUB_BUSINESS_ID1.getCode() &&
sb.getId().intValue() <= EnumSubBusiness.SUB_BUSINESS_ID5.getCode()){
tag = EnumTag.getEnum(EnumTag.ID_92.getCode()
+ (sb.getId().intValue() - EnumSubBusiness.SUB_BUSINESS_ID1.getCode()));
}

if (sb.getId().intValue() >= EnumSubBusiness.SUB_BUSINESS_ID6.getCode() &&
sb.getId().intValue() <= EnumSubBusiness.SUB_BUSINESS_ID21.getCode()){
tag = EnumTag.getEnum(EnumTag.ID_129.getCode()
+ (sb.getId().intValue() - EnumSubBusiness.SUB_BUSINESS_ID6.getCode()));
}
resList.clear();
resList.addAll(assign(user, tag));
}
});

return resList;
}

private List<WxTags> assignTypeId18(WxCUserBasicInfo user, WxCUser param) {
List<WxTags> resList = null;

@@ -520,6 +626,10 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService {
WxCUser param = (WxCUser) obj;
WxCUserBasicInfo user = wxCUserBasicInfoMapper.selectByPrimaryKey(param.getId());
if (user != null) {
//消费类别
resList = assignTypeId14(user, param);
//饮食偏好
resList = assignTypeId17(user, param);
//消费时段
resList = assignTypeId18(user, param);
//消费频度
@@ -557,6 +667,7 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService {
WxCUserBasicInfo user = (WxCUserBasicInfo) obj;
WxCUser param = wxCUserMapper.selectByPrimaryKey(user.getId());
if (user != null && param != null) {

if (user.getSex() != null) {
//性别
resList = assignTypeId1(user, user.getSex());
@@ -578,6 +689,11 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService {
resList = assignTypeId6(user, user.getEducation());
}

//消费类别
resList = assignTypeId14(user, param);
//饮食偏好
resList = assignTypeId17(user, param);

//消费时段
resList = assignTypeId18(user, param);
//消费频度


+ 46
- 30
mallinkService/src/main/resources/mapper/WxCardSpendMapper.xml Просмотреть файл

@@ -80,34 +80,6 @@
and `create_date` between #{startdate} and #{enddate}
</if>

<if test=" 0 == timeSlot">
and date_format(create_date,'%H:%m') &gt;= '06:00'
and date_format(create_date,'%H:%m') &lt; '18:00'
and date_format(create_date,'%w') in (1,2,3,4,5)
</if>

<if test=" 1 == timeSlot">
and ((date_format(create_date,'%H:%m') &gt;= '18:00'
and date_format(create_date,'%w') in (1,2,3,4))
or
((date_format(create_date,'%H:%m') &lt; '06:00')
and date_format(create_date,'%w') in (1,2,3,4,5)))
</if>

<if test=" 2 == timeSlot">
and date_format(create_date,'%H:%m') &gt;= '06:00'
and date_format(create_date,'%H:%m') &lt; '18:00'
and date_format(create_date,'%w') in (0,6)
</if>

<if test=" 3 == timeSlot">
and ((date_format(create_date,'%H:%m') &gt;= '18:00'
and date_format(create_date,'%w') in (5,6,0))
or
((date_format(create_date,'%H:%m') &lt; '06:00')
and date_format(create_date,'%w') in (6,0)))
</if>

<if test=" null != ids ">
and id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
@@ -145,8 +117,52 @@

<select id="findCount" parameterType="com.iformall.domain.po.WxCardSpend" resultType="Integer">
select count(*)
from wx_card_spend
<include refid="dynamicWhereConditions"/>
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 test=" null != subBusinessId ">
and m.sub_business_id = #{subBusinessId}
</if>
</if>
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') &gt;= '06:00'
and date_format(cs.create_date,'%H:%m') &lt; '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') &gt;= '18:00'
and date_format(cs.create_date,'%w') in (1,2,3,4))
or
((date_format(cs.create_date,'%H:%m') &lt; '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') &gt;= '06:00'
and date_format(cs.create_date,'%H:%m') &lt; '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') &gt;= '18:00'
and date_format(cs.create_date,'%w') in (5,6,0))
or
((date_format(cs.create_date,'%H:%m') &lt; '06:00')
and date_format(cs.create_date,'%w') in (6,0)))
</if>
</select>




+ 46
- 38
mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml Просмотреть файл

@@ -228,87 +228,95 @@
</select>

<select id="findCount" parameterType="com.iformall.domain.po.WxCouponOrder" resultType="java.lang.Integer">
select COUNT(*) FROM wx_coupon_order
select 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 test=" null != subBusinessId ">
and c.sub_business = #{subBusinessId}
</if>
</if>
where 1=1
<if test=" null != tenantId">
and tenant_id = #{tenantId}
and co.tenant_id = #{tenantId}
</if>
<if test=" null != couponOrderStatus">
and coupon_order_status = #{couponOrderStatus}
and co.coupon_order_status = #{couponOrderStatus}
</if>
<if test=" null != cUserId">
and c_user_id = #{cUserId}
and co.c_user_id = #{cUserId}
</if>
<if test=" null != couponId ">
and coupon_id = #{couponId}
and co.coupon_id = #{couponId}
</if>
<if test=" null != couponType ">
and coupon_type = #{couponType}
and co.coupon_type = #{couponType}
</if>

<if test=" 1 == couponOrderStatus">
<if test=" null != startTime">
and update_date &gt;= #{startTime}
and co.update_date &gt;= #{startTime}
</if>
<if test=" null != endTime">
and update_date &lt;= #{endTime}
and co.update_date &lt;= #{endTime}
</if>
<if test=" 0 == timeSlot">
and date_format(update_date,'%H:%m') &gt;= '06:00'
and date_format(update_date,'%H:%m') &lt; '18:00'
and date_format(update_date,'%w') in (1,2,3,4,5)
and date_format(co.update_date,'%H:%m') &gt;= '06:00'
and date_format(co.update_date,'%H:%m') &lt; '18:00'
and date_format(co.update_date,'%w') in (1,2,3,4,5)
</if>
<if test=" 1 == timeSlot">
and ((date_format(update_date,'%H:%m') &gt;= '18:00'
and date_format(update_date,'%w') in (1,2,3,4))
and ((date_format(co.update_date,'%H:%m') &gt;= '18:00'
and date_format(co.update_date,'%w') in (1,2,3,4))
or
((date_format(update_date,'%H:%m') &lt; '06:00')
and date_format(update_date,'%w') in (1,2,3,4,5)))
((date_format(co.update_date,'%H:%m') &lt; '06:00')
and date_format(co.update_date,'%w') in (1,2,3,4,5)))
</if>
<if test=" 2 == timeSlot">
and date_format(update_date,'%H:%m') &gt;= '06:00'
and date_format(update_date,'%H:%m') &lt; '18:00'
and date_format(update_date,'%w') in (0,6)
and date_format(co.update_date,'%H:%m') &gt;= '06:00'
and date_format(co.update_date,'%H:%m') &lt; '18:00'
and date_format(co.update_date,'%w') in (0,6)
</if>
<if test=" 3 == timeSlot">
and ((date_format(update_date,'%H:%m') &gt;= '18:00'
and date_format(update_date,'%w') in (5,6,0))
and ((date_format(co.update_date,'%H:%m') &gt;= '18:00'
and date_format(co.update_date,'%w') in (5,6,0))
or
((date_format(update_date,'%H:%m') &lt; '06:00')
and date_format(update_date,'%w') in (6,0)))
((date_format(co.update_date,'%H:%m') &lt; '06:00')
and date_format(co.update_date,'%w') in (6,0)))
</if>
</if>

<if test=" 1 != couponOrderStatus">
<if test=" null != startTime">
and create_date &gt;= #{startTime}
and co.create_date &gt;= #{startTime}
</if>
<if test=" null != endTime">
and create_date &lt;= #{endTime}
and co.create_date &lt;= #{endTime}
</if>
<if test=" 0 == timeSlot">
and date_format(create_date,'%H:%m') &gt;= '06:00'
and date_format(create_date,'%H:%m') &lt; '18:00'
and date_format(create_date,'%w') in (1,2,3,4,5)
and date_format(co.create_date,'%H:%m') &gt;= '06:00'
and date_format(co.create_date,'%H:%m') &lt; '18:00'
and date_format(co.create_date,'%w') in (1,2,3,4,5)
</if>
<if test=" 1 == timeSlot">
and ((date_format(create_date,'%H:%m') &gt;= '18:00'
and date_format(create_date,'%w') in (1,2,3,4))
and ((date_format(co.create_date,'%H:%m') &gt;= '18:00'
and date_format(co.create_date,'%w') in (1,2,3,4))
or
((date_format(create_date,'%H:%m') &lt; '06:00')
and date_format(create_date,'%w') in (1,2,3,4,5)))
((date_format(co.create_date,'%H:%m') &lt; '06:00')
and date_format(co.create_date,'%w') in (1,2,3,4,5)))
</if>
<if test=" 2 == timeSlot">
and date_format(create_date,'%H:%m') &gt;= '06:00'
and date_format(create_date,'%H:%m') &lt; '18:00'
and date_format(create_date,'%w') in (0,6)
and date_format(co.create_date,'%H:%m') &gt;= '06:00'
and date_format(co.create_date,'%H:%m') &lt; '18:00'
and date_format(co.create_date,'%w') in (0,6)
</if>
<if test=" 3 == timeSlot">
and ((date_format(create_date,'%H:%m') &gt;= '18:00'
and date_format(create_date,'%w') in (5,6,0))
and ((date_format(co.create_date,'%H:%m') &gt;= '18:00'
and date_format(co.create_date,'%w') in (5,6,0))
or
((date_format(create_date,'%H:%m') &lt; '06:00')
and date_format(create_date,'%w') in (6,0)))
((date_format(co.create_date,'%H:%m') &lt; '06:00')
and date_format(co.create_date,'%w') in (6,0)))
</if>
</if>
</select>


Загрузка…
Отмена
Сохранить