| @@ -53,7 +53,7 @@ public class CUserBaseInfoT implements Serializable { | |||||
| @Transient | @Transient | ||||
| @Excel(name="成长值",width = 20,orderNum = "11") | @Excel(name="成长值",width = 20,orderNum = "11") | ||||
| private Integer poins; | |||||
| private String poins; | |||||
| public String getName() { | public String getName() { | ||||
| return name; | return name; | ||||
| @@ -135,11 +135,11 @@ public class CUserBaseInfoT implements Serializable { | |||||
| this.tagNames = tagNames; | this.tagNames = tagNames; | ||||
| } | } | ||||
| public Integer getPoins() { | |||||
| public String getPoins() { | |||||
| return poins; | return poins; | ||||
| } | } | ||||
| public void setPoins(Integer poins) { | |||||
| public void setPoins(String poins) { | |||||
| this.poins = poins; | this.poins = poins; | ||||
| } | } | ||||
| } | } | ||||
| @@ -11,7 +11,8 @@ public enum EnumScoreType { | |||||
| WIFI_CONNECTION(4, "连接WIFI"), | WIFI_CONNECTION(4, "连接WIFI"), | ||||
| WECHAT_PERSION(5, "微信用户昵称授权"), | WECHAT_PERSION(5, "微信用户昵称授权"), | ||||
| WECHAT_PHONE(6, "微信用户手机授权"), | WECHAT_PHONE(6, "微信用户手机授权"), | ||||
| COMPLETE_INFO(7, "完善个人信息"); | |||||
| COMPLETE_INFO(7, "完善个人信息"), | |||||
| MEM_IMPORT(8, "会员导入"); | |||||
| public static EnumScoreType getEnum(Integer code) { | public static EnumScoreType getEnum(Integer code) { | ||||
| for (EnumScoreType value : values()) { | for (EnumScoreType value : values()) { | ||||
| @@ -9,8 +9,8 @@ public interface WxScoreHistoryService { | |||||
| * 根据实体查询分页列表 | * 根据实体查询分页列表 | ||||
| * | * | ||||
| * @param record | * @param record | ||||
| * @param offset | |||||
| * @param limit | |||||
| * @param pageIndex | |||||
| * @param pageSize | |||||
| * @return | * @return | ||||
| */ | */ | ||||
| PageInfo<WxScoreHistory> listAsPage(WxScoreHistory record, Integer pageIndex, Integer pageSize); | PageInfo<WxScoreHistory> listAsPage(WxScoreHistory record, Integer pageIndex, Integer pageSize); | ||||
| @@ -19,12 +19,14 @@ import com.iformall.domain.vo.CUserBaseInfoT; | |||||
| import com.iformall.domain.vo.CUserBaseVo; | import com.iformall.domain.vo.CUserBaseVo; | ||||
| import com.iformall.domain.vo.CUserTagVo; | import com.iformall.domain.vo.CUserTagVo; | ||||
| import com.iformall.enums.EnumAssignTagsTrigger; | import com.iformall.enums.EnumAssignTagsTrigger; | ||||
| import com.iformall.enums.EnumScoreType; | |||||
| import com.iformall.mapper.WxCUserBasicInfoMapper; | import com.iformall.mapper.WxCUserBasicInfoMapper; | ||||
| import com.iformall.mapper.WxCUserMapper; | import com.iformall.mapper.WxCUserMapper; | ||||
| import com.iformall.mapper.WxCUserTagsMapper; | import com.iformall.mapper.WxCUserTagsMapper; | ||||
| import com.iformall.mapper.WxTagsMapper; | import com.iformall.mapper.WxTagsMapper; | ||||
| import com.iformall.service.WxCUserBasicInfoService; | import com.iformall.service.WxCUserBasicInfoService; | ||||
| import com.iformall.service.WxCUserTagsService; | import com.iformall.service.WxCUserTagsService; | ||||
| import com.iformall.service.WxScoreRulesService; | |||||
| import com.iformall.utils.Constant; | import com.iformall.utils.Constant; | ||||
| import org.apache.commons.io.FileUtils; | import org.apache.commons.io.FileUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| @@ -73,6 +75,9 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||||
| @Autowired | @Autowired | ||||
| StringRedisTemplate stringRedisTemplate; | StringRedisTemplate stringRedisTemplate; | ||||
| @Autowired | |||||
| WxScoreRulesService wxScoreRulesService; | |||||
| @Override | @Override | ||||
| public PageInfo<WxCUserBasicInfo> listAsPage(WxCUserBasicInfo record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxCUserBasicInfo> listAsPage(WxCUserBasicInfo record, Integer pageIndex, Integer pageSize) { | ||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserBasicInfoMapper.findList(record)); | return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserBasicInfoMapper.findList(record)); | ||||
| @@ -363,7 +368,7 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||||
| updateDateCellTwo.setCellValue("2018-08-10"); | updateDateCellTwo.setCellValue("2018-08-10"); | ||||
| createDateCellTwo.setCellValue("2018-08-10"); | createDateCellTwo.setCellValue("2018-08-10"); | ||||
| tagCellTwo.setCellValue("附近住户"); | tagCellTwo.setCellValue("附近住户"); | ||||
| scoreCellTwo.setCellValue(100); | |||||
| scoreCellTwo.setCellValue("100"); | |||||
| } | } | ||||
| { | { | ||||
| rowtwo = sheetTwo.createRow(2); | rowtwo = sheetTwo.createRow(2); | ||||
| @@ -387,7 +392,7 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||||
| updateDateCellTwo.setCellValue("2018-08-10"); | updateDateCellTwo.setCellValue("2018-08-10"); | ||||
| createDateCellTwo.setCellValue("2018-08-10"); | createDateCellTwo.setCellValue("2018-08-10"); | ||||
| tagCellTwo.setCellValue("男/附近住户"); | tagCellTwo.setCellValue("男/附近住户"); | ||||
| scoreCellTwo.setCellValue(200); | |||||
| scoreCellTwo.setCellValue("200"); | |||||
| } | } | ||||
| { | { | ||||
| rowtwo = sheetTwo.createRow(3); | rowtwo = sheetTwo.createRow(3); | ||||
| @@ -411,7 +416,7 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||||
| updateDateCellTwo.setCellValue("2018-08-10"); | updateDateCellTwo.setCellValue("2018-08-10"); | ||||
| createDateCellTwo.setCellValue("2018-08-10"); | createDateCellTwo.setCellValue("2018-08-10"); | ||||
| tagCellTwo.setCellValue("女/附近住户"); | tagCellTwo.setCellValue("女/附近住户"); | ||||
| scoreCellTwo.setCellValue(110); | |||||
| scoreCellTwo.setCellValue("110"); | |||||
| } | } | ||||
| FileOutputStream fileOut = new FileOutputStream(file); | FileOutputStream fileOut = new FileOutputStream(file); | ||||
| @@ -496,8 +501,6 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||||
| userBase.setTagNames(uBase.getTagNames()); | userBase.setTagNames(uBase.getTagNames()); | ||||
| userBase.setPoins(uBase.getPoins()); | |||||
| return userBase; | return userBase; | ||||
| } | } | ||||
| @@ -554,7 +557,6 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||||
| oldUserBase.setBirthdate(userBase.getBirthdate()); | oldUserBase.setBirthdate(userBase.getBirthdate()); | ||||
| oldUserBase.setAddress(userBase.getAddress()); | oldUserBase.setAddress(userBase.getAddress()); | ||||
| oldUserBase.setUpdateDate(new Date()); | oldUserBase.setUpdateDate(new Date()); | ||||
| oldUserBase.setPoins(userBase.getPoins()); | |||||
| oldUserBase.setCreateDate(userBase.getCreateDate()); | oldUserBase.setCreateDate(userBase.getCreateDate()); | ||||
| } else { | } else { | ||||
| // check c_user 是否存在 | // check c_user 是否存在 | ||||
| @@ -623,6 +625,16 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||||
| else{ | else{ | ||||
| wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_IMPORT,userBase); | wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_IMPORT,userBase); | ||||
| } | } | ||||
| // 成长值 | |||||
| if (StringUtils.isNotBlank(uBase.getPoins())) { | |||||
| if (oldUserBase != null) { | |||||
| wxScoreRulesService.addScore2(EnumScoreType.MEM_IMPORT, oldUserBase, uBase.getPoins()); | |||||
| } else { | |||||
| wxScoreRulesService.addScore2(EnumScoreType.MEM_IMPORT, userBase, uBase.getPoins()); | |||||
| } | |||||
| } | |||||
| //记数 | //记数 | ||||
| stringRedisTemplate.opsForHash().increment(userId,"successCount",1); | stringRedisTemplate.opsForHash().increment(userId,"successCount",1); | ||||
| }); | }); | ||||
| @@ -122,6 +122,27 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||||
| } | } | ||||
| } | } | ||||
| private void resetBasicUserScore(Long userId, int scoreNumber) { | |||||
| // 1. basicUser | |||||
| WxCUserBasicInfo user = wxCUserBasicInfoService.getById(userId); | |||||
| if(user == null) { | |||||
| return; | |||||
| } | |||||
| // 2. update score/ 修改basic表积分 | |||||
| user.setPoins(scoreNumber); | |||||
| wxCUserBasicInfoService.updateScore(user); | |||||
| // 3. 修改 c_user表积分 score | |||||
| if (user.getPhone() != null) { | |||||
| WxCUser wxCUser = new WxCUser(); | |||||
| wxCUser.setTenantId(user.getTenantId()); | |||||
| wxCUser.setPhone(user.getPhone()); | |||||
| wxCUser.setScore(scoreNumber); | |||||
| wxCUserService.saveOrUpdate(wxCUser); | |||||
| } | |||||
| } | |||||
| private int checkTodayLoginScoreCount(WxCUser cUser) { | private int checkTodayLoginScoreCount(WxCUser cUser) { | ||||
| WxScoreHistory scoreHistory = new WxScoreHistory(); | WxScoreHistory scoreHistory = new WxScoreHistory(); | ||||
| scoreHistory.setTenantId(cUser.getTenantId()); | scoreHistory.setTenantId(cUser.getTenantId()); | ||||
| @@ -193,7 +214,7 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||||
| updateScore(order.getCUserId(), addScoreNumber); | updateScore(order.getCUserId(), addScoreNumber); | ||||
| // 6. 记录历史 | // 6. 记录历史 | ||||
| recordScoreHistory(addScoreNumber, order.getTenantId(), order.getCUserId(), EnumScoreType.CONSUMPTION); | |||||
| recordPayScoreHistory(addScoreNumber, order, EnumScoreType.CONSUMPTION); | |||||
| return addScoreNumber; | return addScoreNumber; | ||||
| } | } | ||||
| @@ -281,6 +302,16 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||||
| return addScoreNumber; | return addScoreNumber; | ||||
| } | } | ||||
| private int infoResetScore(WxCUserBasicInfo userInfo, Integer score) { | |||||
| // 1. 导入成长值 | |||||
| resetBasicUserScore(userInfo.getId(), score); | |||||
| // 2. 记录历史 | |||||
| recordScoreHistory(score, userInfo.getTenantId(), userInfo.getId(), EnumScoreType.MEM_IMPORT); | |||||
| return score; | |||||
| } | |||||
| private void recordScoreHistory(int addScoreNumber, String tenantId, Long id, EnumScoreType wechatPhone) { | private void recordScoreHistory(int addScoreNumber, String tenantId, Long id, EnumScoreType wechatPhone) { | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| WxScoreHistory history = new WxScoreHistory(); | WxScoreHistory history = new WxScoreHistory(); | ||||
| @@ -293,6 +324,23 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||||
| wxScoreHistoryMapper.insert(history); | wxScoreHistoryMapper.insert(history); | ||||
| } | } | ||||
| private void recordPayScoreHistory(int addScoreNumber, WxOrder order, EnumScoreType wechatPhone) { | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| WxScoreHistory history = new WxScoreHistory(); | |||||
| history.setId(idWorker.nextId()); | |||||
| history.setTenantId(order.getTenantId()); | |||||
| history.setCUserId(order.getCUserId()); | |||||
| history.setCreateDate(new Date()); | |||||
| history.setScoreType(EnumScoreType.CONSUMPTION.getCode()); | |||||
| history.setOrderId(order.getId()); | |||||
| history.setPayType(order.getPaymentType()); | |||||
| history.setPayAmount(order.getPayment()); | |||||
| history.setScoreAmount(addScoreNumber); | |||||
| history.setScoreType(wechatPhone.getCode()); | |||||
| history.setScoreAmount(addScoreNumber); | |||||
| wxScoreHistoryMapper.insert(history); | |||||
| } | |||||
| @Override | @Override | ||||
| public int addScore(EnumScoreType scoreType, Object param) { | public int addScore(EnumScoreType scoreType, Object param) { | ||||
| @@ -321,6 +369,7 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||||
| WxCUserBasicInfo user = (WxCUserBasicInfo) param; | WxCUserBasicInfo user = (WxCUserBasicInfo) param; | ||||
| return infoAddScore(user); | return infoAddScore(user); | ||||
| } | } | ||||
| default: { | default: { | ||||
| } | } | ||||
| } | } | ||||
| @@ -336,8 +385,13 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||||
| Integer bussinessId = (Integer) param2; | Integer bussinessId = (Integer) param2; | ||||
| return payAddScore(order, bussinessId); | return payAddScore(order, bussinessId); | ||||
| } | } | ||||
| default: { | |||||
| case MEM_IMPORT: { | |||||
| WxCUserBasicInfo user = (WxCUserBasicInfo) param1; | |||||
| Integer score = Integer.valueOf((String)param2); | |||||
| return infoResetScore(user, score); | |||||
| } | } | ||||
| default: | |||||
| break; | |||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||