| @@ -0,0 +1,4 @@ | |||
| ALTER TABLE `mallink`.`wx_activity` ADD COLUMN `is_gain_credit` Integer(1) NOT NULL DEFAULT 0 COMMENT '是否获得积分'; | |||
| ALTER TABLE `mallink`.`wx_activity` ADD COLUMN `gain_credit` Integer(11) NOT NULL DEFAULT 0 COMMENT '获得的积分'; | |||
| ALTER TABLE `mallink`.`wx_activity` ADD COLUMN `is_score` Integer(1) NOT NULL DEFAULT 0 COMMENT '是否获得成长值'; | |||
| ALTER TABLE `mallink`.`wx_activity` ADD COLUMN `score` Integer(11) NOT NULL DEFAULT 0 COMMENT '获得的成长值'; | |||
| @@ -1,3 +1,4 @@ | |||
| ###自己后台要加上该配置#### | |||
| CREATE TABLE `wx_mall_version` ( | |||
| `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID', | |||
| `tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户ID', | |||
| @@ -8,6 +9,8 @@ CREATE TABLE `wx_mall_version` ( | |||
| ###现有的抖音版本都要设置该表 | |||
| ###自己后台要加上该配置#### | |||
| create table tt_goods_category_new like tt_goods_category; | |||
| ###自己后台要加上该配置#### | |||
| ALTER TABLE `mallink`.`wx_appinfo` ADD COLUMN `laike_id` varchar(30) COMMENT '来客ID'; | |||
| @@ -125,6 +125,18 @@ public class WxActivity extends TenantEntity { | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value = "报名状态", name = "joinStatus") | |||
| private Integer joinStatus; | |||
| @io.swagger.annotations.ApiModelProperty(value = "是否获得积分EnumYesOrNo", name = "isGainCredit") | |||
| private Integer isGainCredit; | |||
| @io.swagger.annotations.ApiModelProperty(value = "获得的积分", name = "gainCredit") | |||
| private Integer gainCredit; | |||
| @io.swagger.annotations.ApiModelProperty(value = "是否获得成长值EnumYesOrNo", name = "isScore") | |||
| private Integer isScore; | |||
| @io.swagger.annotations.ApiModelProperty(value = "获得的成长值", name = "score") | |||
| private Integer score; | |||
| } | |||
| @@ -18,6 +18,7 @@ public enum EnumScoreType { | |||
| CHANGE_CREDIT(11, "积分兑换"), | |||
| REDUCE_CREDIT(12, "消费积分"), | |||
| ACTIVITY_JOIN(13, "活动报名"), | |||
| ACTIVITY_JOIN_ADD(27,"活动报名增加积分"), | |||
| CLEAN_CREDIT(14, "积分清零计划"), | |||
| GAME_LES_CREDIT(15, "游戏消耗积分"), | |||
| GAME_ADD_CREDIT(16, "游戏奖励积分"), | |||
| @@ -18,6 +18,8 @@ import com.iformall.mq.MqBaseProducer; | |||
| import com.iformall.service.ExcelService; | |||
| import com.iformall.service.WxActivityJoinService; | |||
| import com.iformall.service.WxCreditHistoryService; | |||
| import com.iformall.service.WxScoreHistoryService; | |||
| import com.iformall.service.WxScoreRulesService; | |||
| import com.iformall.utils.DateUtils; | |||
| import com.iformall.utils.RedisLock; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| @@ -69,6 +71,9 @@ public class WxActivityJoinServiceImpl implements WxActivityJoinService { | |||
| @Autowired | |||
| WxCreditHistoryService wxCreditHistoryService; | |||
| @Autowired | |||
| WxScoreRulesService wxScoreRulesService; | |||
| @Override | |||
| @@ -223,9 +228,14 @@ public class WxActivityJoinServiceImpl implements WxActivityJoinService { | |||
| throw new MallinkException(ErrorCode.ACTIVITY_PERSON_LIMITED.getCode(),"活动报名人数已满!"); | |||
| } | |||
| } | |||
| setCreditAndScore(wxActivity, wxActivityJoin,user); | |||
| return new ResultData(); | |||
| } | |||
| @Transactional(propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | |||
| public void setCreditAndScore(WxActivity wxActivity,WxActivityJoin wxActivityJoin,WxCUserBasicInfo user) { | |||
| //查询是否消耗积分 | |||
| if (wxActivity.getUseCredit().equals(EnumActivityUseCreditStatus.YES.getCode())) { | |||
| if (wxActivity.getUseCredit().equals(EnumActivityUseCreditStatus.YES.getCode()) && null != wxActivity.getCredit() && wxActivity.getCredit() > 0) { | |||
| Integer credit = wxActivity.getCredit(); | |||
| //积分历史 | |||
| WxCreditHistory wxCreditHistory = new WxCreditHistory(); | |||
| @@ -240,8 +250,29 @@ public class WxActivityJoinServiceImpl implements WxActivityJoinService { | |||
| wxCreditHistory.setOperatorId(wxActivityJoin.getUserId()); | |||
| wxCreditHistoryService.saveOrUpdate(wxCreditHistory,wxActivity); | |||
| } | |||
| return new ResultData(); | |||
| //查询是否获得积分 | |||
| if (wxActivity.getIsGainCredit().equals(EnumYesOrNo.YES.getCode()) && null != wxActivity.getGainCredit() && wxActivity.getGainCredit() > 0 ) { | |||
| Integer gainCredit = wxActivity.getGainCredit(); | |||
| //积分历史 | |||
| WxCreditHistory wxCreditHistory = new WxCreditHistory(); | |||
| // wxCreditHistory.updateTenantInfo(wxActivity); | |||
| wxCreditHistory.setTenantId(wxActivity.getFinalTenantId()); | |||
| wxCreditHistory.setFinalTenantId(wxActivity.getFinalTenantId()); | |||
| wxCreditHistory.setCUserId(wxActivityJoin.getUserId()); | |||
| wxCreditHistory.setCreditNum(gainCredit); | |||
| wxCreditHistory.setCreditType(EnumScoreType.ACTIVITY_JOIN_ADD.getCode()); | |||
| wxCreditHistory.setChangePurpose(EnumScoreType.ACTIVITY_JOIN_ADD.getMessage()+"["+wxActivity.getTitle()+"]"); | |||
| wxCreditHistory.setOperatorType(EnumUserType.CUSERBASIC.getCode()); | |||
| wxCreditHistory.setOperatorId(wxActivityJoin.getUserId()); | |||
| wxCreditHistoryService.saveOrUpdate(wxCreditHistory,wxActivity); | |||
| } | |||
| //查询是否获得成长值 | |||
| if (wxActivity.getIsScore().equals(EnumYesOrNo.YES.getCode()) && null != wxActivity.getScore() && wxActivity.getScore() > 0 ) { | |||
| Integer score = wxActivity.getScore(); | |||
| wxScoreRulesService.addScore2(wxActivity, EnumScoreType.ACTIVITY_JOIN_ADD, user, score); | |||
| } | |||
| } | |||
| @Override | |||
| @@ -865,6 +865,10 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||
| if (record.getCreditType() == EnumScoreType.ACTIVITY_JOIN.getCode()) { | |||
| return reduceCredit(record,tenantEntity); | |||
| } | |||
| if (record.getCreditType() == EnumScoreType.ACTIVITY_JOIN_ADD.getCode()) { | |||
| record.setRulesTenantId(tenantEntity.getTenantId()); | |||
| return record.getCreditNum(); | |||
| } | |||
| if (record.getCreditType() == EnumScoreType.GAME_LES_CREDIT.getCode()) { | |||
| return reduceCredit(record,tenantEntity); | |||
| } | |||
| @@ -400,6 +400,15 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||
| return addScoreNumber; | |||
| } | |||
| private int simpleAddScore(TenantEntity tenantEntity,Long userId, Integer score) { | |||
| // 5. 增长的成长值 | |||
| updateScore(userId,tenantEntity, score); | |||
| // 6. 记录历史 | |||
| recordSimpleAddScoreHistory(tenantEntity,EnumScoreType.ACTIVITY_JOIN_ADD,userId,score); | |||
| return score; | |||
| } | |||
| private int bindCarAddScore(TenantEntity tenantEntity,WxCUserBasicInfo user) { | |||
| @@ -559,6 +568,19 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||
| history.setScoreAmount(addScoreNumber); | |||
| wxScoreHistoryMapper.insert(history); | |||
| } | |||
| private void recordSimpleAddScoreHistory(TenantEntity tenantEntity,EnumScoreType scoreType,Long userId,int addScoreNumber) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| WxScoreHistory history = new WxScoreHistory(); | |||
| history.setId(idWorker.nextId()); | |||
| history.setTenantId(tenantEntity.getFinalTenantId()); | |||
| history.setRulesTenantId(tenantEntity.getTenantId()); | |||
| history.setCUserId(userId); | |||
| history.setCreateDate(new Date()); | |||
| history.setScoreType(scoreType.getCode()); | |||
| history.setScoreAmount(addScoreNumber); | |||
| wxScoreHistoryMapper.insert(history); | |||
| } | |||
| private void recordReduceScoreHistory(TenantEntity tenantEntity,int reduceScore, String reason, Long id, EnumScoreType wechatPhone) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| @@ -651,6 +673,10 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||
| boolean bHaveCUser = (boolean)(param2); | |||
| return memResetScore(tenantEntity,user, bHaveCUser); | |||
| } | |||
| case ACTIVITY_JOIN_ADD: { | |||
| Integer score = (Integer)(param2); | |||
| return simpleAddScore(tenantEntity,user.getId(), score); | |||
| } | |||
| default: | |||
| break; | |||
| } | |||
| @@ -29,13 +29,17 @@ | |||
| <result column="img_detail" jdbcType="VARCHAR" property="imgDetail"/> | |||
| <result column="send_msg" jdbcType="INTEGER" property="sendMsg"/> | |||
| <result column="selectques" jdbcType="VARCHAR" property="selectques"/> | |||
| <result column="is_gain_credit" jdbcType="INTEGER" property="isGainCredit"/> | |||
| <result column="gain_credit" jdbcType="INTEGER" property="gainCredit"/> | |||
| <result column="is_score" jdbcType="INTEGER" property="isScore"/> | |||
| <result column="score" jdbcType="INTEGER" property="score"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`,`cover_img`,`title`,`sub_title`,`detail`,`html`,`activity_type`,`signup_examine`,`person_limit`,`activity_start_time`,`activity_end_time`, | |||
| `use_credit`,`credit`,`type`,`status`,`start_time`,`end_time`,`question`,`is_expired`,`create_time`,`update_time`,`use_img`, | |||
| `img_detail`,`send_msg`,`selectques` | |||
| `img_detail`,`send_msg`,`selectques`,`is_gain_credit`,`gain_credit`,`is_score`,`score` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||