| | |
| | | package com.matrix.system.shopXcx.api.action; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.matrix.component.redis.RedisUserLoginUtils; |
| | | import com.matrix.system.common.constance.AppConstance; |
| | | import com.matrix.system.common.init.UserCacheManager; |
| | | import com.matrix.component.tools.HttpCurlUtil; |
| | | import com.matrix.component.wechat.externalInterface.weixinUtil.WeixinServiceUtil; |
| | | import com.matrix.core.pojo.AjaxResult; |
| | | import com.matrix.core.tools.LogUtil; |
| | | import com.matrix.core.tools.StringUtils; |
| | | import com.matrix.core.web.BaseAction; |
| | | import com.matrix.system.activity.dao.ActivitySignReceiveRecordDao; |
| | | import com.matrix.system.common.bean.BusParameterSettings; |
| | | import com.matrix.system.common.dao.BusParameterSettingsDao; |
| | | import com.matrix.system.common.interceptor.HostInterceptor; |
| | | import com.matrix.system.constance.Dictionary; |
| | | import com.matrix.system.fenxiao.constant.FenxiaoSettingConstant; |
| | | import com.matrix.system.fenxiao.dao.ShopSalesmanApplyDao; |
| | | import com.matrix.system.fenxiao.dao.ShopSalesmanGradeDao; |
| | | import com.matrix.system.fenxiao.entity.ShopSalesmanApply; |
| | | import com.matrix.system.fenxiao.entity.ShopSalesmanGrade; |
| | | import com.matrix.system.fenxiao.service.ShopSalesmanApplyService; |
| | | import com.matrix.system.hive.bean.SysVipInfo; |
| | | import com.matrix.system.hive.dao.MoneyCardUseDao; |
| | |
| | | @Autowired |
| | | BusParameterSettingsDao busParameterSettingsDao; |
| | | @Autowired |
| | | private RedisUserLoginUtils redisUserLoginUtils; |
| | | private UserCacheManager userCacheManager; |
| | | @Autowired |
| | | ShopSalesmanApplyDao salesmanApplyDao; |
| | | |
| | |
| | | private MoneyCardUseDao moneyCardUseDao; |
| | | |
| | | @Autowired |
| | | private WeixinServiceUtil weixinServiceUtil; |
| | | ShopCouponRecordDao shopCouponRecordDao; |
| | | |
| | | @Autowired |
| | | ActivitySignReceiveRecordDao activitySignReceiveRecordDao; |
| | | @Value("${debug}") |
| | | private String isDebug; |
| | | |
| | |
| | | sysVipInfo.setVipNo(openId); |
| | | sysVipInfoService.add(sysVipInfo); |
| | | |
| | | }else{ |
| | | } else { |
| | | sysVipInfo.setSessionKey(sessionKey); |
| | | sysVipInfoDao.update(sysVipInfo); |
| | | } |
| | | } |
| | | // 存放redis |
| | | sysVipInfo.setLevelCard(null); |
| | | String token = redisUserLoginUtils.saveUserInfo(sysVipInfo); |
| | | String token = userCacheManager.saveUserInfo(sysVipInfo); |
| | | LogUtil.info("用户token={}", token); |
| | | res.putInMap("token", token); |
| | | res.putInMap("userInfo", sysVipInfo); |
| | |
| | | return res; |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | ShopCouponRecordDao shopCouponRecordDao; |
| | | ShopSalesmanGradeDao shopSalesmanGradeDao; |
| | | |
| | | /** |
| | | * 查询用户信息 |
| | |
| | | @RequestMapping(value = "/findUserInfo") |
| | | public @ResponseBody |
| | | AjaxResult findUserInfo() { |
| | | SysVipInfo loginUser = redisUserLoginUtils.getLoginUser(SysVipInfo.class); |
| | | SysVipInfo sysVipInfo = sysVipInfoService.findById(loginUser.getId()); |
| | | sysVipInfo.setPointAll(scoreVipDetailDao.selectUserTotalScore(loginUser.getId())); |
| | | sysVipInfo.setBalance(moneyCardUseDao.selectVipCardTotalMoney(loginUser.getId())); |
| | | AjaxResult res = new AjaxResult(); |
| | | res.putInMap("couponCount", shopCouponRecordDao.countUnuseCouponRecord(loginUser.getId())); |
| | | res.putInMap("prizeCount",0); |
| | | res.putInMap("userInfo", sysVipInfo); |
| | | SysVipInfo loginUser = userCacheManager.getLoginUser(); |
| | | SysVipInfo sysVipInfo = sysVipInfoService.findById(loginUser.getId()); |
| | | |
| | | if (sysVipInfo != null) { |
| | | if (SysVipInfo.VALID_FLAG_Y == sysVipInfo.getValidFlag()) { |
| | | sysVipInfo.setBalance(moneyCardUseDao.selectVipCardTotalMoney(loginUser.getId())); |
| | | sysVipInfo.setPointAll(scoreVipDetailDao.selectUserTotalScore(loginUser.getId())); |
| | | } else { |
| | | sysVipInfo.setBalance(0D); |
| | | sysVipInfo.setPointAll(0); |
| | | } |
| | | |
| | | res.putInMap("couponCount", shopCouponRecordDao.countUnuseCouponRecord(loginUser.getId())); |
| | | res.putInMap("prizeCount", activitySignReceiveRecordDao.getSignAwardReceiveCount(loginUser.getId(), loginUser.getCompanyId())); |
| | | res.putInMap("userInfo", sysVipInfo); |
| | | //查询会员等级 |
| | | if (sysVipInfo.getSalesmanGrade() != null) { |
| | | ShopSalesmanGrade shopSalesmanGrade = shopSalesmanGradeDao.selectById(sysVipInfo.getSalesmanGrade()); |
| | | res.putInMap("vipLevel", shopSalesmanGrade.getName()); |
| | | } else if (sysVipInfo.getVipLevel() != null) { |
| | | res.putInMap("vipLevel", sysVipInfo.getVipLevel().getLevelName()); |
| | | } else { |
| | | res.putInMap("vipLevel", "初级会员"); |
| | | } |
| | | } |
| | | res.setStatus(AjaxResult.STATUS_SUCCESS); |
| | | return res; |
| | | } |
| | |
| | | public @ResponseBody |
| | | AjaxResult findUserInfo(@PathVariable String openId) { |
| | | SysVipInfo sysVipInfo = sysVipInfoService.findByOpenId(openId); |
| | | SysVipInfo bizUserQuery=new SysVipInfo(); |
| | | SysVipInfo bizUserQuery = new SysVipInfo(); |
| | | bizUserQuery.setNickName(sysVipInfo.getNickName()); |
| | | bizUserQuery.setAvatarUrl(sysVipInfo.getAvatarUrl()); |
| | | bizUserQuery.setOpenId(openId); |
| | |
| | | public @ResponseBody |
| | | AjaxResult saveUserInfo(@RequestBody XcxUserSaveUserInfoDto xcxUserSaveUserInfoDto) { |
| | | |
| | | SysVipInfo loginUser = redisUserLoginUtils.getLoginUser(SysVipInfo.class); |
| | | SysVipInfo sysVipInfo=new SysVipInfo(); |
| | | SysVipInfo loginUser = userCacheManager.getLoginUser(); |
| | | SysVipInfo sysVipInfo = new SysVipInfo(); |
| | | sysVipInfo.setId(loginUser.getId()); |
| | | |
| | | BeanUtil.copyProperties(xcxUserSaveUserInfoDto,sysVipInfo); |
| | | BeanUtil.copyProperties(xcxUserSaveUserInfoDto, sysVipInfo); |
| | | sysVipInfo.setPhone(xcxUserSaveUserInfoDto.getPhoneNumber()); |
| | | if(StringUtils.isBlank(loginUser.getVipName())||loginUser.getVipName().equals("微信用户")){ |
| | | if (StringUtils.isBlank(loginUser.getVipName()) || loginUser.getVipName().equals("微信用户")) { |
| | | sysVipInfo.setVipName(xcxUserSaveUserInfoDto.getNickName()); |
| | | } |
| | | if(StringUtils.isBlank(loginUser.getSex())){ |
| | | sysVipInfo.setSex(xcxUserSaveUserInfoDto.getGender()==1?"男":"女"); |
| | | if (StringUtils.isBlank(loginUser.getSex())) { |
| | | sysVipInfo.setSex(xcxUserSaveUserInfoDto.getGender() == 1 ? "男" : "女"); |
| | | } |
| | | |
| | | int i = sysVipInfoDao.update(sysVipInfo); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | void checkNeedToBeSalesman(SysVipInfo sysVipInfo, SysVipInfo loginUser) { |
| | | //查询是否需要自动成为分销员 |
| | | if ((loginUser.getIsSales() == null || loginUser.getIsSales() == 2) |
| | | && StringUtils.isNotBlank(sysVipInfo.getNickName())) {//目前还不是分销员 |
| | | BusParameterSettings fxSwith = busParameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_SWITCH, HostInterceptor.getCompanyId()); |
| | | if (fxSwith.getParamValue().equals("1")) {//开启分销 |
| | | if (fxSwith!=null && "1".equals(fxSwith.getParamValue())) {//开启分销 |
| | | BusParameterSettings applyWay = busParameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_APPLY_WAY, loginUser.getCompanyId()); |
| | | if (applyWay.getParamValue().equals(FenxiaoSettingConstant.FX_APPLY_WAY_AUTO)) {//自动成为分销员 |
| | | QueryWrapper<ShopSalesmanApply> queryWrapper = new QueryWrapper<>(); |
| | |
| | | queryWrapper.eq("apply_status", ShopSalesmanApply.APPLY_STATUS_DSH); |
| | | ShopSalesmanApply shopSalesmanApply = salesmanApplyDao.selectOne(queryWrapper); |
| | | if (shopSalesmanApply == null) {//没有待审核记录 |
| | | try { |
| | | shopSalesmanApplyService.applyToBeAnSalesman(loginUser.getId(), null, null, 2); |
| | | }catch (Exception e){ |
| | | LogUtil.debug(e.getMessage()); |
| | | } |
| | | |
| | | shopSalesmanApplyService.applyToBeAnSalesman(loginUser.getId(), null, null, 2); |
| | | } |
| | | } |
| | | } |