| @@ -60,6 +60,7 @@ public class WxCampaignController extends BaseController | |||||
| String[] arys = wxCampaign.getCouponIds().split(","); | String[] arys = wxCampaign.getCouponIds().split(","); | ||||
| wxCampaign.setCouponIds(JSON.toJSONString(arys)); | wxCampaign.setCouponIds(JSON.toJSONString(arys)); | ||||
| } | } | ||||
| wxCampaign.setStatus(0); | |||||
| wxCampaign.setTenantId(getTenantId()); | wxCampaign.setTenantId(getTenantId()); | ||||
| // wxCampaign.setSortNum(sortNum+1); | // wxCampaign.setSortNum(sortNum+1); | ||||
| wxCampaignService.saveOrUpdate(wxCampaign); | wxCampaignService.saveOrUpdate(wxCampaign); | ||||
| @@ -14,6 +14,8 @@ public interface WxCUserBasicInfoMapper extends CommonMapper<WxCUserBasicInfo, S | |||||
| List<WxCUserBasicInfo> list(WxCuerBasicInfoDto record); | List<WxCUserBasicInfo> list(WxCuerBasicInfoDto record); | ||||
| void updateScore(WxCUserBasicInfo record); | |||||
| } | } | ||||
| @@ -11,6 +11,8 @@ public interface WxLevelConfigMapper extends CommonMapper<WxLevelConfig, Long> { | |||||
| void deleteAll(); | void deleteAll(); | ||||
| String getLevel(@Param("tenantId")String tenantId,@Param("poins")Integer poins); | |||||
| @@ -41,6 +41,16 @@ public interface WxCUserBasicInfoService { | |||||
| PageInfo<WxCUserBasicInfo> list(WxCuerBasicInfoDto record, Integer pageIndex, Integer pageSize); | PageInfo<WxCUserBasicInfo> list(WxCuerBasicInfoDto record, Integer pageIndex, Integer pageSize); | ||||
| /** | |||||
| * 修改会员积分 | |||||
| * @param record | |||||
| */ | |||||
| void updateScore(WxCUserBasicInfo record); | |||||
| @@ -39,6 +39,13 @@ public interface WxLevelConfigService { | |||||
| void deleteAll(); | void deleteAll(); | ||||
| /** | |||||
| * 根据积分获取会员等级 | |||||
| * @param tenantId | |||||
| * @param score | |||||
| * @return | |||||
| */ | |||||
| String getLevel(String tenantId,int score); | |||||
| @@ -37,6 +37,15 @@ public interface WxScoreRulesService { | |||||
| * @param id | * @param id | ||||
| */ | */ | ||||
| void deleteById(Long id); | void deleteById(Long id); | ||||
| /** | |||||
| * 登录或消费 调用增长积分 | |||||
| * @param tenantId | |||||
| * @param type 1:登录 2:消费 | |||||
| * @param cUserId | |||||
| * @return 新增的积分值 | |||||
| */ | |||||
| int addScoreByType(String tenantId,int type,Long cUserId); | |||||
| @@ -30,9 +30,14 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserBasicInfoMapper.list(record)); | return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserBasicInfoMapper.list(record)); | ||||
| } | } | ||||
| @Override | |||||
| public void updateScore(WxCUserBasicInfo record) { | |||||
| wxCUserBasicInfoMapper.updateScore(record); | |||||
| } | |||||
| @Override | |||||
| @Override | |||||
| public WxCUserBasicInfo getById(Long id) { | public WxCUserBasicInfo getById(Long id) { | ||||
| return wxCUserBasicInfoMapper.selectByPrimaryKey(id); | return wxCUserBasicInfoMapper.selectByPrimaryKey(id); | ||||
| } | } | ||||
| @@ -49,12 +49,11 @@ public class WxLevelConfigServiceImpl implements WxLevelConfigService { | |||||
| wxLevelConfigMapper.deleteAll(); | wxLevelConfigMapper.deleteAll(); | ||||
| } | } | ||||
| @Override | |||||
| public String getLevel(String tenantId, int score) { | |||||
| return wxLevelConfigMapper.getLevel(tenantId,score); | |||||
| } | |||||
| } | } | ||||
| @@ -3,8 +3,12 @@ package com.simple.service.impl; | |||||
| import java.util.*; | import java.util.*; | ||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.domain.po.WxCUser; | |||||
| import com.simple.domain.po.WxCUserBasicInfo; | |||||
| import com.simple.domain.po.WxScoreRules; | import com.simple.domain.po.WxScoreRules; | ||||
| import com.simple.mapper.WxScoreRulesMapper; | import com.simple.mapper.WxScoreRulesMapper; | ||||
| import com.simple.service.WxCUserBasicInfoService; | |||||
| import com.simple.service.WxCUserService; | |||||
| import com.simple.service.WxScoreRulesService; | import com.simple.service.WxScoreRulesService; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| @@ -15,6 +19,10 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||||
| @Autowired | @Autowired | ||||
| WxScoreRulesMapper wxScoreRulesMapper; | WxScoreRulesMapper wxScoreRulesMapper; | ||||
| @Autowired | |||||
| WxCUserService wxCUserService; | |||||
| @Autowired | |||||
| WxCUserBasicInfoService wxCUserBasicInfoService; | |||||
| @Override | @Override | ||||
| @@ -43,12 +51,43 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||||
| public void deleteById(Long id) { | public void deleteById(Long id) { | ||||
| wxScoreRulesMapper.deleteByPrimaryKey(id); | wxScoreRulesMapper.deleteByPrimaryKey(id); | ||||
| } | } | ||||
| @Override | |||||
| public int addScoreByType(String tenantId, int type, Long cUserId) { | |||||
| int addScoreNumber=0; | |||||
| WxScoreRules scoreRules = new WxScoreRules(); | |||||
| scoreRules.setTenantId(tenantId); | |||||
| List<WxScoreRules> list = wxScoreRulesMapper.findList(scoreRules); | |||||
| if(list.isEmpty()){ | |||||
| return addScoreNumber; | |||||
| } | |||||
| scoreRules = list.get(0); | |||||
| if(type==1){ | |||||
| //login处理 | |||||
| addScoreNumber = scoreRules.getLoginScoreNumber(); | |||||
| } | |||||
| if(type==2){ | |||||
| //消费 | |||||
| addScoreNumber = scoreRules.getConsumptionScoreNumber(); | |||||
| } | |||||
| WxCUser wxCUser = wxCUserService.getById(cUserId); | |||||
| wxCUser.setScore(wxCUser.getScore()+addScoreNumber); | |||||
| wxCUserService.saveOrUpdate(wxCUser); | |||||
| //修改basic表积分 | |||||
| if(wxCUser.getPhone()!=null){ | |||||
| //修改basic表积分 | |||||
| WxCUserBasicInfo wxCUserBasicInfo = new WxCUserBasicInfo(); | |||||
| wxCUserBasicInfo.setTenantId(tenantId); | |||||
| wxCUserBasicInfo.setPhone(wxCUser.getPhone()); | |||||
| wxCUserBasicInfo.setPoins(wxCUser.getScore()); | |||||
| wxCUserBasicInfo.setCUserId(wxCUser.getId()); | |||||
| wxCUserBasicInfoService.updateScore(wxCUserBasicInfo); | |||||
| } | |||||
| return addScoreNumber; | |||||
| } | |||||
| } | } | ||||
| @@ -132,6 +132,12 @@ | |||||
| </if> | </if> | ||||
| </select> | </select> | ||||
| <update id="updateScore" parameterType="com.simple.domain.po.WxCUserBasicInfo"> | |||||
| update wx_c_user_basic_info set poins=#{poins} where phone=#{phone} and tenant_id=#{tenantId} | |||||
| and c_user_id=#{cUserId} | |||||
| </update> | |||||
| @@ -63,7 +63,10 @@ | |||||
| <delete id="deleteAll"> | <delete id="deleteAll"> | ||||
| delete from wx_level_config; | delete from wx_level_config; | ||||
| </delete> | </delete> | ||||
| <select id="getLevel" parameterType="com.simple.domain.po.WxLevelConfig" resultType="String"> | |||||
| SELECT `level` FROM `wx_level_config` where tenant_id=#{tenantId} and points <= #{points} ORDER BY points desc LIMIT 1 | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||