| @@ -56,6 +56,9 @@ public class WxCUserBasicInfoController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | private WxCUserBasicInfoService wxCUserBasicInfoService; | ||||
| @Autowired | |||||
| private WxCUserBasicChildService wxCUserBasicChildService; | |||||
| @Autowired | @Autowired | ||||
| private WxCUserTagsService wxCUserTagsService; | private WxCUserTagsService wxCUserTagsService; | ||||
| @@ -104,6 +107,14 @@ public class WxCUserBasicInfoController extends BaseController { | |||||
| } | } | ||||
| } | } | ||||
| private void setUserChildren(WxCUserBasicInfo info) { | |||||
| WxCUserBasicChild uChild = new WxCUserBasicChild(); | |||||
| uChild.setTenantId(info.getFinalTenantId()); | |||||
| uChild.setCUserId(info.getId()); | |||||
| info.setChildrenList(wxCUserBasicChildService.findList(uChild)); | |||||
| } | |||||
| private void setUserInfoTag(WxCUserBasicInfo info) { | private void setUserInfoTag(WxCUserBasicInfo info) { | ||||
| if (info.getTagId() != null) { | if (info.getTagId() != null) { | ||||
| @@ -247,6 +258,7 @@ public class WxCUserBasicInfoController extends BaseController { | |||||
| setUserInfoTag(info); | setUserInfoTag(info); | ||||
| setUserInfoLevel(info); | setUserInfoLevel(info); | ||||
| setUserInfoCar(info); | setUserInfoCar(info); | ||||
| setUserChildren(info); | |||||
| return new ResultData(info); | return new ResultData(info); | ||||
| } | } | ||||
| @@ -0,0 +1,8 @@ | |||||
| INSERT INTO `wx_tags_type`(`id`, `name`, `group_id`, `group_name`, `flag`) VALUES (29, '子女', 2, '生活属性', 0); | |||||
| INSERT INTO `wx_tags`(`id`, `name`, `group_id`, `group_name`, `type_id`, `type_name`) VALUES (166, '婴儿', 2, '生活属性', 29, '子女'); | |||||
| INSERT INTO `wx_tags`(`id`, `name`, `group_id`, `group_name`, `type_id`, `type_name`) VALUES (167, '幼儿', 2, '生活属性', 29, '子女'); | |||||
| INSERT INTO `wx_tags`(`id`, `name`, `group_id`, `group_name`, `type_id`, `type_name`) VALUES (168, '学龄前', 2, '生活属性', 29, '子女'); | |||||
| INSERT INTO `wx_tags`(`id`, `name`, `group_id`, `group_name`, `type_id`, `type_name`) VALUES (169, '学龄初', 2, '生活属性', 29, '子女'); | |||||
| INSERT INTO `wx_tags`(`id`, `name`, `group_id`, `group_name`, `type_id`, `type_name`) VALUES (170, '学龄中', 2, '生活属性', 29, '子女'); | |||||
| INSERT INTO `wx_tags`(`id`, `name`, `group_id`, `group_name`, `type_id`, `type_name`) VALUES (171, '学龄晚', 2, '生活属性', 29, '子女'); | |||||
| @@ -28,7 +28,7 @@ public class WxCuserFloatingLayerController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| WxCuserFloatingLayerService wxCuserFloatingLayerService; | WxCuserFloatingLayerService wxCuserFloatingLayerService; | ||||
| @AuthIgnore | |||||
| // @AuthIgnore | |||||
| @ApiOperation("获取浮层") | @ApiOperation("获取浮层") | ||||
| @GetMapping("/getFloatingLayer") | @GetMapping("/getFloatingLayer") | ||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @@ -47,8 +47,7 @@ public class BaseMyBatisConfiguration { | |||||
| wxCouponrSharding.setCount(100); | wxCouponrSharding.setCount(100); | ||||
| wxCouponrSharding.setRule(EnumShardingRule.HASH.getCode()); | wxCouponrSharding.setRule(EnumShardingRule.HASH.getCode()); | ||||
| shardingList.add(wxCouponrSharding); | shardingList.add(wxCouponrSharding); | ||||
| ShardingSphere wxCouponrMerchantSharding = new ShardingSphere(); | ShardingSphere wxCouponrMerchantSharding = new ShardingSphere(); | ||||
| wxCouponrMerchantSharding.setColumn("tenant_id"); | wxCouponrMerchantSharding.setColumn("tenant_id"); | ||||
| wxCouponrMerchantSharding.setTableName("wx_coupon_merchant"); | wxCouponrMerchantSharding.setTableName("wx_coupon_merchant"); | ||||
| @@ -76,6 +75,13 @@ public class BaseMyBatisConfiguration { | |||||
| basicInfoSharding.setCount(100); | basicInfoSharding.setCount(100); | ||||
| basicInfoSharding.setRule(EnumShardingRule.HASH.getCode()); | basicInfoSharding.setRule(EnumShardingRule.HASH.getCode()); | ||||
| shardingList.add(basicInfoSharding); | shardingList.add(basicInfoSharding); | ||||
| ShardingSphere wxbasicChildSharding = new ShardingSphere(); | |||||
| wxbasicChildSharding.setColumn("tenant_id"); | |||||
| wxbasicChildSharding.setTableName("wx_c_user_basic_child"); | |||||
| wxbasicChildSharding.setCount(100); | |||||
| wxbasicChildSharding.setRule(EnumShardingRule.HASH.getCode()); | |||||
| shardingList.add(wxbasicChildSharding); | |||||
| ShardingSphere wxOrderSharding = new ShardingSphere(); | ShardingSphere wxOrderSharding = new ShardingSphere(); | ||||
| wxOrderSharding.setColumn("tenant_id"); | wxOrderSharding.setColumn("tenant_id"); | ||||
| @@ -127,6 +127,9 @@ public class WxCUserBasicInfo extends TenantEntityWithoutFinalTenantId { | |||||
| private String tagNames; | private String tagNames; | ||||
| @TableField(exist = false) | |||||
| private List<WxCUserBasicChild> childrenList; | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private String tagIds; | private String tagIds; | ||||
| @@ -204,6 +204,13 @@ public enum EnumTag { | |||||
| ID_164(164L, EnumTagType.ID_28, "鞋尺码"), | ID_164(164L, EnumTagType.ID_28, "鞋尺码"), | ||||
| ID_165(165L, EnumTagType.ID_28, "鞋尺码"), | ID_165(165L, EnumTagType.ID_28, "鞋尺码"), | ||||
| ID_166(166L, EnumTagType.ID_29, "婴儿"), | |||||
| ID_167(167L, EnumTagType.ID_29, "幼儿"), | |||||
| ID_168(168L, EnumTagType.ID_29, "学龄前"), | |||||
| ID_169(169L, EnumTagType.ID_29, "学龄初"), | |||||
| ID_170(170L, EnumTagType.ID_29, "学龄中"), | |||||
| ID_171(171L, EnumTagType.ID_29, "学龄晚"), | |||||
| ID_1000(1000L, EnumTagType.ID_50,"一天以内"), | ID_1000(1000L, EnumTagType.ID_50,"一天以内"), | ||||
| ID_1001(1001L, EnumTagType.ID_50,"一周以内"), | ID_1001(1001L, EnumTagType.ID_50,"一周以内"), | ||||
| ID_1002(1002L, EnumTagType.ID_50,"一月以内"), | ID_1002(1002L, EnumTagType.ID_50,"一月以内"), | ||||
| @@ -35,6 +35,8 @@ public enum EnumTagType { | |||||
| ID_27(27L, EnumTagTypeFlag.FLAG_SINGLE, EnumTagGroup.ID_1, "服饰尺码"), | ID_27(27L, EnumTagTypeFlag.FLAG_SINGLE, EnumTagGroup.ID_1, "服饰尺码"), | ||||
| ID_28(28L, EnumTagTypeFlag.FLAG_SINGLE, EnumTagGroup.ID_1, "鞋尺码"), | ID_28(28L, EnumTagTypeFlag.FLAG_SINGLE, EnumTagGroup.ID_1, "鞋尺码"), | ||||
| ID_29(29L, EnumTagTypeFlag.FLAG_NORMAL, EnumTagGroup.ID_2, "子女"), | |||||
| ID_0(0L, EnumTagTypeFlag.FLAG_SINGLE, EnumTagGroup.ID_10, "会员手机"), | ID_0(0L, EnumTagTypeFlag.FLAG_SINGLE, EnumTagGroup.ID_10, "会员手机"), | ||||
| ID_50(50L, EnumTagTypeFlag.FLAG_SINGLE, EnumTagGroup.ID_10, "会员会龄"), | ID_50(50L, EnumTagTypeFlag.FLAG_SINGLE, EnumTagGroup.ID_10, "会员会龄"), | ||||
| ID_51(51L, EnumTagTypeFlag.FLAG_SINGLE, EnumTagGroup.ID_10, "会员等级"), | ID_51(51L, EnumTagTypeFlag.FLAG_SINGLE, EnumTagGroup.ID_10, "会员等级"), | ||||
| @@ -8,7 +8,7 @@ import java.util.List; | |||||
| public interface WxCUserBasicChildMapper extends CommonMapper<WxCUserBasicChild, Long>{ | public interface WxCUserBasicChildMapper extends CommonMapper<WxCUserBasicChild, Long>{ | ||||
| List<WxCreditHistory> findList(WxCUserBasicChild record); | |||||
| List<WxCUserBasicChild> findList(WxCUserBasicChild record); | |||||
| int updDelById(WxCUserBasicChild record); | int updDelById(WxCUserBasicChild record); | ||||
| @@ -8,7 +8,7 @@ public interface WxCUserBasicChildService { | |||||
| PageInfo<WxCUserBasicChild> listAsPage(WxCUserBasicChild record, Integer pageIndex, Integer pageSize); | PageInfo<WxCUserBasicChild> listAsPage(WxCUserBasicChild record, Integer pageIndex, Integer pageSize); | ||||
| List<WxCreditHistory> findList(WxCUserBasicChild record); | |||||
| List<WxCUserBasicChild> findList(WxCUserBasicChild record); | |||||
| WxCUserBasicChild saveOrUpdate(WxCUserBasicChild record); | WxCUserBasicChild saveOrUpdate(WxCUserBasicChild record); | ||||
| @@ -28,7 +28,7 @@ public class WxCUserBasicChildServiceImpl implements WxCUserBasicChildService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public List<WxCreditHistory> findList(WxCUserBasicChild record) { | |||||
| public List<WxCUserBasicChild> findList(WxCUserBasicChild record) { | |||||
| return wxCUserBasicChildMapper.findList(record); | return wxCUserBasicChildMapper.findList(record); | ||||
| } | } | ||||
| @@ -13,6 +13,7 @@ import com.iformall.enums.*; | |||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.service.WxCUserTagsService; | import com.iformall.service.WxCUserTagsService; | ||||
| import com.iformall.service.WxTagsService; | import com.iformall.service.WxTagsService; | ||||
| import com.iformall.utils.DateUtils; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| @@ -32,6 +33,9 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||||
| @Autowired | @Autowired | ||||
| WxCUserBasicInfoMapper wxCUserBasicInfoMapper; | WxCUserBasicInfoMapper wxCUserBasicInfoMapper; | ||||
| @Autowired | |||||
| WxCUserBasicChildMapper wxCUserBasicChildMapper; | |||||
| @Autowired | @Autowired | ||||
| WxCouponOrderMapper wxCouponOrderMapper; | WxCouponOrderMapper wxCouponOrderMapper; | ||||
| @@ -161,6 +165,50 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||||
| return wxTagsMapper.findList(wxTags); | return wxTagsMapper.findList(wxTags); | ||||
| } | } | ||||
| //按type 替换 | |||||
| private List<WxTags> assign(WxCUserBasicInfo user, List<EnumTag> enumTags, EnumTagType type){ | |||||
| if(user == null){ | |||||
| return null; | |||||
| } | |||||
| WxCUserTags record = new WxCUserTags(); | |||||
| record.setUserId(user.getId()); | |||||
| record.setTenantId(user.getFinalTenantId()); | |||||
| List<WxCUserTags> cUserTagsList = wxCUserTagsMapper.findList(record); | |||||
| List<Long> tagIdList; | |||||
| if(cUserTagsList != null && cUserTagsList.size() > 0){ | |||||
| record.setId(cUserTagsList.get(0).getId()); | |||||
| record.setTags(cUserTagsList.get(0).getTags()); | |||||
| } | |||||
| String tags = record.getTags(); | |||||
| if (tags == null){ | |||||
| tagIdList = new ArrayList<Long>(); | |||||
| }else{ | |||||
| tagIdList = JSON.parseArray(tags, Long.class); | |||||
| } | |||||
| Iterator<Long> it = tagIdList.iterator(); | |||||
| while(it.hasNext()){ | |||||
| Long id = it.next(); | |||||
| if(null != id && null != EnumTag.getEnum(id) && EnumTag.getEnum(id).getCode() == type.getCode()){ | |||||
| it.remove(); | |||||
| } | |||||
| } | |||||
| if(enumTags != null && enumTags.size() > 0){ | |||||
| for (EnumTag enumTag:enumTags) { | |||||
| tagIdList.add(enumTag.getCode()); | |||||
| } | |||||
| } | |||||
| record.setTags(JSON.toJSONString(tagIdList)); | |||||
| saveOrUpdate(record); | |||||
| if (user.getTagId() == null || !user.getTagId().equals(record.getId())) { | |||||
| user.setTagId(record.getId()); | |||||
| wxCUserBasicInfoMapper.updateById(user); | |||||
| } | |||||
| WxTags wxTags = new WxTags(); | |||||
| wxTags.setIds(tagIdList); | |||||
| return wxTagsMapper.findList(wxTags); | |||||
| } | |||||
| //去标 | //去标 | ||||
| private List<WxTags> resign(WxCUserBasicInfo user, EnumTag tag){ | private List<WxTags> resign(WxCUserBasicInfo user, EnumTag tag){ | ||||
| if (tag == null || user == null) | if (tag == null || user == null) | ||||
| @@ -593,6 +641,54 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||||
| return resList; | return resList; | ||||
| } | } | ||||
| private List<WxTags> assignTypeId29(WxCUserBasicInfo user) { | |||||
| List<WxTags> resList = null; | |||||
| WxCUserBasicChild uChild = new WxCUserBasicChild(); | |||||
| uChild.setTenantId(user.getFinalTenantId()); | |||||
| uChild.setCUserId(user.getId()); | |||||
| List<WxCUserBasicChild> list = wxCUserBasicChildMapper.findList(uChild); | |||||
| if(list != null && list.size() > 0){ | |||||
| List<EnumTag> tags = new ArrayList<>(); | |||||
| for (WxCUserBasicChild child:list) { | |||||
| if(child.getBirthdate() != null){ | |||||
| Calendar cal = Calendar.getInstance(); | |||||
| if (cal.after(child.getBirthdate())) { | |||||
| int age = DateUtils.getAge(child.getBirthdate()); | |||||
| if(age < 1){ | |||||
| if(!tags.contains(EnumTag.ID_166)){ | |||||
| tags.add(EnumTag.ID_166); | |||||
| } | |||||
| }else if(age >= 1 && age < 3){ | |||||
| if(!tags.contains(EnumTag.ID_167)){ | |||||
| tags.add(EnumTag.ID_167); | |||||
| } | |||||
| }else if(age >= 3 && age < 6){ | |||||
| if(!tags.contains(EnumTag.ID_168)){ | |||||
| tags.add(EnumTag.ID_168); | |||||
| } | |||||
| }else if(age >= 6 && age < 12){ | |||||
| if(!tags.contains(EnumTag.ID_169)){ | |||||
| tags.add(EnumTag.ID_169); | |||||
| } | |||||
| }else if(age >= 12 && age < 15){ | |||||
| if(!tags.contains(EnumTag.ID_170)){ | |||||
| tags.add(EnumTag.ID_170); | |||||
| } | |||||
| }else if(age >= 15 && age < 18){ | |||||
| if(!tags.contains(EnumTag.ID_171)){ | |||||
| tags.add(EnumTag.ID_171); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| resList = assign(user,tags,EnumTagType.ID_29); | |||||
| }else{ | |||||
| resList = assign(user,null,EnumTagType.ID_29); | |||||
| } | |||||
| return resList; | |||||
| } | |||||
| //打标接口 | //打标接口 | ||||
| @Override | @Override | ||||
| public List<WxTags> assignTags(List<Long> tagIdList, WxCUserBasicInfo user) { | public List<WxTags> assignTags(List<Long> tagIdList, WxCUserBasicInfo user) { | ||||
| @@ -638,6 +734,7 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||||
| //学历 | //学历 | ||||
| resList = assignTypeId6(user, param.getEducation()); | resList = assignTypeId6(user, param.getEducation()); | ||||
| } | } | ||||
| resList = assignTypeId29(user); | |||||
| } | } | ||||
| } | } | ||||
| break; | break; | ||||
| @@ -730,6 +827,8 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||||
| //学历 | //学历 | ||||
| resList = assignTypeId6(user, user.getEducation()); | resList = assignTypeId6(user, user.getEducation()); | ||||
| } | } | ||||
| resList = assignTypeId29(user); | |||||
| //消费类别 | //消费类别 | ||||
| resList = assignTypeId14(user,tenantEntity); | resList = assignTypeId14(user,tenantEntity); | ||||
| @@ -1258,4 +1258,34 @@ public class DateUtils { | |||||
| System.out.println(next); | System.out.println(next); | ||||
| } | } | ||||
| */ | */ | ||||
| /** | |||||
| * 获取多少岁 | |||||
| * @param birthDay | |||||
| * @return | |||||
| * @throws Exception | |||||
| */ | |||||
| public static int getAge(Date birthDay){ | |||||
| Calendar cal = Calendar.getInstance(); | |||||
| if (cal.before(birthDay)) { //出生日期晚于当前时间,无法计算 | |||||
| throw new IllegalArgumentException( | |||||
| "The birthDay is before Now.It's unbelievable!"); | |||||
| } | |||||
| int yearNow = cal.get(Calendar.YEAR); //当前年份 | |||||
| int monthNow = cal.get(Calendar.MONTH); //当前月份 | |||||
| int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH); //当前日期 | |||||
| cal.setTime(birthDay); | |||||
| int yearBirth = cal.get(Calendar.YEAR); | |||||
| int monthBirth = cal.get(Calendar.MONTH); | |||||
| int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH); | |||||
| int age = yearNow - yearBirth; //计算整岁数 | |||||
| if (monthNow <= monthBirth) { | |||||
| if (monthNow == monthBirth) { | |||||
| if (dayOfMonthNow < dayOfMonthBirth) age--;//当前日期在生日之前,年龄减一 | |||||
| }else{ | |||||
| age--;//当前月份在生日之前,年龄减一 | |||||
| } | |||||
| } return age; | |||||
| } | |||||
| } | } | ||||