| @@ -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'; | |||
| @@ -5,20 +5,26 @@ import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||
| import com.iformall.enums.EnumAppPlat; | |||
| import com.iformall.enums.EnumPayVersion; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.service.CUserTokenService; | |||
| import com.iformall.service.SysConfigService; | |||
| import com.iformall.utils.RedisCacheUtils; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.SysConfigConstant; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxAppinfoService; | |||
| import com.iformall.service.WxMerchantBUserService; | |||
| import com.iformall.service.WxPayAccountService; | |||
| import com.iformall.service.cuser.CUserServiceFactory; | |||
| import com.iformall.service.wechat.FmOpenService; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.IPUtil; | |||
| import com.iformall.utils.MaUtil; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.WebDataBinder; | |||
| import org.springframework.web.bind.annotation.InitBinder; | |||
| @@ -45,6 +51,12 @@ public class BaseController { | |||
| @Autowired | |||
| private WxPayAccountService wxPayAccountService; | |||
| @Autowired | |||
| private SysConfigService sysConfigService; | |||
| @Autowired | |||
| private CUserServiceFactory cuserFactory; | |||
| @Autowired | |||
| MaUtil maUtil; | |||
| @@ -172,4 +184,30 @@ public class BaseController { | |||
| String ipaddress = IPUtil.getIpAddr(request); | |||
| return ipaddress; | |||
| } | |||
| public void checkLoginUserPhone(WxMerchantBUser orgUser,Long bUserId,EnumAppPlat appPlat) throws Exception { | |||
| if (null == bUserId) { | |||
| return; | |||
| } | |||
| CUser user = cuserFactory.getBUserService(appPlat).getById(bUserId, orgUser.getTenantId()); | |||
| if (null == user) { | |||
| return; | |||
| } | |||
| if (StringUtils.isBlank(user.getPhone())) { | |||
| return; | |||
| } | |||
| SysConfig config = sysConfigService.getByKey(SysConfigConstant.merchant_Login_CheckPhone, orgUser); | |||
| if (null != config ) { | |||
| String v = config.getConfigItemValue(); | |||
| if (!StringUtils.isBlank(v)) { | |||
| Integer iv = Integer.parseInt(v); | |||
| if (iv.intValue() == EnumYesOrNo.YES.getCode().intValue()) { | |||
| //校验当前登陆人的授权手机号和账号手机号是否一致 | |||
| if (!user.getPhone().equals(orgUser.getPhone())) { | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"当前用户授权手机号非登录账号,不允许登录"); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -162,6 +162,11 @@ public class WxInfoController extends BaseController { | |||
| // if (StringUtils.isNotBlank(buUser.getParentTenantId())) { | |||
| // request.setAttribute(Constant.PARENT_TENANT_ID, buUser.getParentTenantId()); | |||
| // } | |||
| try { | |||
| checkLoginUserPhone(buUser, buUser.getId(),appPlat); | |||
| }catch(Exception e) { | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); | |||
| } | |||
| return new ResultData(resultMap); | |||
| } | |||
| @@ -7,13 +7,18 @@ import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.common.SysConfigConstant; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.vo.WxMerchantBuInfoVo; | |||
| import com.iformall.enums.EnumAppPlat; | |||
| import com.iformall.enums.EnumCreditLockedStatus; | |||
| import com.iformall.enums.EnumEnableType; | |||
| import com.iformall.enums.EnumMerchantBUserStatus; | |||
| import com.iformall.enums.EnumMerchantStatus; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.*; | |||
| import com.iformall.service.cuser.CUserServiceFactory; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.HashUtil; | |||
| import com.iformall.utils.IPUtil; | |||
| @@ -158,6 +163,11 @@ public class WxMerchantBUserController extends BaseController { | |||
| if(!wxAppinfo.getEnable().equals(EnumEnableType.Enable.getCode())){ | |||
| return new ResultData(ErrorCode.APP_ID_NOT_ENABLE); | |||
| } | |||
| EnumAppPlat appPlat = EnumAppPlat.getByCode(wxAppinfo.getPlat()); | |||
| if(appPlat == null){ | |||
| return new ResultData(ErrorCode.APP_PLAT_ERROR); | |||
| } | |||
| WxMerchantBUser userQ = new WxMerchantBUser(); | |||
| userQ.updateTenantInfo(wxAppinfo); | |||
| @@ -175,13 +185,6 @@ public class WxMerchantBUserController extends BaseController { | |||
| // check merchant 状态 | |||
| ResultData merchantStatus = checkMerchantStatus(orgUser); | |||
| if (merchantStatus != null) return merchantStatus; | |||
| // try { | |||
| // wxMerchantBUserService.saveOrUpdate(orgUser); | |||
| // } catch (Exception e) { | |||
| // logger.error("B端用户更新用户信息失败, e:" + e.getMessage()); | |||
| // return new ResultData(ErrorCode.DB_FAIL.getCode(), "数据库保存失败,e:" + e.getMessage()); | |||
| // } | |||
| Map<String, Object> resultMap = new HashMap<>(); | |||
| resultMap.put("bUserId", orgUser.getId()); | |||
| resultMap.put("logined", true); | |||
| @@ -221,24 +224,28 @@ public class WxMerchantBUserController extends BaseController { | |||
| return new ResultData(ErrorCode.USER_IS_EMPTY); | |||
| } | |||
| } | |||
| @TenantIgnore | |||
| @AuthIgnore | |||
| @PostMapping("/selectMerchant") | |||
| @ApiOperation(value = "选择商户", notes = "{" + | |||
| "\"appId\":\"string\"," + | |||
| "\"buUserId\":\"string\"," + | |||
| "\"merchantId\":\"string\"}") | |||
| public ResultData selectMerchant(@RequestBody Map<String, String> map) { | |||
| String buUserIdStr = map.get("buUserId"); | |||
| String merchantIdStr = map.get("merchantId"); | |||
| String appId = map.get("appId"); | |||
| if (StringUtils.isBlank(buUserIdStr)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "buUserId不能为空"); | |||
| } | |||
| if (StringUtils.isBlank(merchantIdStr)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "merchantId不能为空"); | |||
| } | |||
| if (StringUtils.isBlank(appId)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "appId不能为空"); | |||
| } | |||
| WxMerchantBUser userQ = new WxMerchantBUser(); | |||
| userQ.setId(Long.valueOf(buUserIdStr)); | |||
| userQ.setMerchantId(Long.valueOf(merchantIdStr)); | |||
| @@ -248,15 +255,26 @@ public class WxMerchantBUserController extends BaseController { | |||
| if (orgUser != null) { | |||
| ResultData merchantStatus = checkMerchantStatus(orgUser); | |||
| if (merchantStatus != null) return merchantStatus; | |||
| // try { | |||
| // wxMerchantBUserService.saveOrUpdate(orgUser); | |||
| // } catch (Exception e) { | |||
| // logger.error("B端用户更新用户信息失败, e:" + e.getMessage()); | |||
| // return new ResultData(ErrorCode.DB_FAIL.getCode(), "数据库保存失败,e:" + e.getMessage()); | |||
| // } | |||
| Map<String, Object> resultMap = new HashMap<>(); | |||
| resultMap.put("bUserId", orgUser.getId()); | |||
| resultMap.put("logined", true); | |||
| try { | |||
| WxAppinfo wxAppinfo = getAppInfo(appId); | |||
| if(wxAppinfo == null){ | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||
| } | |||
| if(!wxAppinfo.getEnable().equals(EnumEnableType.Enable.getCode())){ | |||
| return new ResultData(ErrorCode.APP_ID_NOT_ENABLE); | |||
| } | |||
| EnumAppPlat appPlat = EnumAppPlat.getByCode(wxAppinfo.getPlat()); | |||
| if(appPlat == null){ | |||
| return new ResultData(ErrorCode.APP_PLAT_ERROR); | |||
| } | |||
| checkLoginUserPhone(orgUser, orgUser.getId(),appPlat); | |||
| }catch(Exception e) { | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); | |||
| } | |||
| return new ResultData(resultMap); | |||
| } else { | |||
| logger.error("B端用户不存在"); | |||
| @@ -9,5 +9,6 @@ public class SysConfigConstant { | |||
| public static final String coupon_list_show_selled = "couponListShowSelled"; | |||
| public static final String member_seconds_key="memberSeconds"; | |||
| public static final String merchant_credit_locked="merchantCreditLocked"; | |||
| public static final String merchant_Login_CheckPhone = "merchantLoginCheckPhone"; | |||
| } | |||
| @@ -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"> | |||