|  |  |  | 
|---|
|  |  |  | package com.matrix.system.shopXcx.api.action; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.matrix.component.rabbitmq.RabiitMqTemplate; | 
|---|
|  |  |  | import com.matrix.core.constance.MatrixConstance; | 
|---|
|  |  |  | import com.matrix.component.redis.RedisUserLoginUtils; | 
|---|
|  |  |  | import com.matrix.component.tools.AES; | 
|---|
|  |  |  | import com.matrix.core.pojo.AjaxResult; | 
|---|
|  |  |  | import com.matrix.core.tools.LogUtil; | 
|---|
|  |  |  | import com.matrix.core.tools.StringUtils; | 
|---|
|  |  |  | import com.matrix.biz.bean.BizUser; | 
|---|
|  |  |  | import com.matrix.biz.dao.BizUserDao; | 
|---|
|  |  |  | import com.matrix.component.tools.AES; | 
|---|
|  |  |  | import com.matrix.component.redis.RedisUserLoginUtils; | 
|---|
|  |  |  | import com.matrix.system.hive.bean.SysVipInfo; | 
|---|
|  |  |  | import com.matrix.system.hive.dao.SysVipInfoDao; | 
|---|
|  |  |  | import com.matrix.system.shopXcx.api.pojo.BindingPhoneNumberPOJO; | 
|---|
|  |  |  | import com.matrix.system.shopXcx.api.tools.SMSVerifiTools; | 
|---|
|  |  |  | import com.matrix.system.shopXcx.api.vo.DataDecipheringVo; | 
|---|
|  |  |  | import com.matrix.system.shopXcx.mqTask.MQTaskRouting; | 
|---|
|  |  |  | import org.apache.commons.collections.CollectionUtils; | 
|---|
|  |  |  | import org.apache.commons.lang.RandomStringUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.servlet.http.HttpServletRequest; | 
|---|
|  |  |  | import javax.servlet.http.HttpServletResponse; | 
|---|
|  |  |  | import java.util.HashMap; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @author jiangyouyao | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SMSVerifiTools sMSVerifiTools; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private BizUserDao bizUserDao; | 
|---|
|  |  |  | private SysVipInfoDao sysVipInfoDao; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private RedisUserLoginUtils redisUserLoginUtils; | 
|---|
|  |  |  | 
|---|
|  |  |  | if (StringUtils.isBlank(phoneNumber)) { | 
|---|
|  |  |  | return new AjaxResult(AjaxResult.STATUS_FAIL, "手机号码不能为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | BizUser bizUser = new BizUser(); | 
|---|
|  |  |  | bizUser.setPhoneNumber(phoneNumber); | 
|---|
|  |  |  | List<BizUser> bizUsers = bizUserDao.selectByModel(bizUser); | 
|---|
|  |  |  | SysVipInfo sysVipInfo = new SysVipInfo(); | 
|---|
|  |  |  | sysVipInfo.setPhone(phoneNumber); | 
|---|
|  |  |  | List<SysVipInfo> bizUsers = sysVipInfoDao.selectByModel(sysVipInfo); | 
|---|
|  |  |  | if (CollectionUtils.isNotEmpty(bizUsers) && bizUsers.size() > 0) { | 
|---|
|  |  |  | return new AjaxResult(AjaxResult.STATUS_FAIL, "该手机号已被绑定"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | return new AjaxResult(AjaxResult.STATUS_FAIL, "手机号码不能为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //验证通过将手机号加入相应的用户数据中 | 
|---|
|  |  |  | BizUser bizUser = new BizUser(); | 
|---|
|  |  |  | BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class); | 
|---|
|  |  |  | bizUser.setUserId(loginUser.getUserId()); | 
|---|
|  |  |  | bizUser.setPhoneNumber(bindingPhoneNumber.getPhoneNumber()); | 
|---|
|  |  |  | bizUserDao.updateByModel(bizUser); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //绑定号码后同步到erp | 
|---|
|  |  |  | mqTemplate.sendMsg(MQTaskRouting.CREATE_VIP + evn, loginUser.getOpenId()+","+bindingPhoneNumber.getShopId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SysVipInfo sysVipInfo = new SysVipInfo(); | 
|---|
|  |  |  | SysVipInfo loginUser = redisUserLoginUtils.getLoginUser(SysVipInfo.class); | 
|---|
|  |  |  | sysVipInfo.setId(loginUser.getId()); | 
|---|
|  |  |  | if(loginUser.getShopId()==null){ | 
|---|
|  |  |  | sysVipInfo.setShopId(bindingPhoneNumber.getShopId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | sysVipInfo.setPhone(bindingPhoneNumber.getPhoneNumber()); | 
|---|
|  |  |  | sysVipInfoDao.update(sysVipInfo); | 
|---|
|  |  |  | return new AjaxResult(AjaxResult.STATUS_SUCCESS, "绑定成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/deciphering") | 
|---|
|  |  |  | public @ResponseBody | 
|---|
|  |  |  | AjaxResult deciphering(@RequestBody DataDecipheringVo dataDecipheringVo) { | 
|---|
|  |  |  | BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class); | 
|---|
|  |  |  | SysVipInfo loginUser = redisUserLoginUtils.getLoginUser(SysVipInfo.class); | 
|---|
|  |  |  | String session_key = loginUser.getSessionKey(); | 
|---|
|  |  |  | LogUtil.debug(dataDecipheringVo.toString()); | 
|---|
|  |  |  | String jsonResult = AES.wxDecrypt(dataDecipheringVo.getEncryptedData(), session_key, dataDecipheringVo.getIv()); | 
|---|