935090232@qq.com
2021-10-06 e7eea688585603c5a8f134d92762e8431d885d36
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxUserAction.java
@@ -4,24 +4,29 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.matrix.component.redis.RedisUserLoginUtils;
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;
import com.matrix.system.hive.dao.SysVipInfoDao;
import com.matrix.system.hive.service.SysVipInfoService;
import com.matrix.system.score.dao.ScoreVipDetailDao;
import com.matrix.system.shopXcx.api.WeChatApiTools;
import com.matrix.system.shopXcx.api.dto.XcxUserSaveUserInfoDto;
import com.matrix.system.shopXcx.dao.ShopCouponRecordDao;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -58,10 +63,17 @@
    @Autowired
    WeChatApiTools weChatApiTools;
    @Autowired
    private ScoreVipDetailDao scoreVipDetailDao;
    @Autowired
    private WeixinServiceUtil weixinServiceUtil;
    private MoneyCardUseDao moneyCardUseDao;
    @Autowired
    ShopCouponRecordDao shopCouponRecordDao;
    @Autowired
    ActivitySignReceiveRecordDao activitySignReceiveRecordDao;
    @Value("${debug}")
    private String isDebug;
@@ -108,14 +120,14 @@
                    sysVipInfo.setSessionKey(sessionKey);
                    sysVipInfo.setCompanyId(HostInterceptor.getCompanyId());
                    sysVipInfo.setArrivalWay("微商城");
                    sysVipInfo.setVipName("微信用户");
                    sysVipInfo.setVipState(Dictionary.VIP_STATE_HY);
                    sysVipInfo.setVipType(Dictionary.VIP_TYPE_NOCARD);
                    sysVipInfo.setIsDeal(SysVipInfo.UNDEAL_VIP);
                    sysVipInfo.setVipNo(openId);
                    sysVipInfoService.add(sysVipInfo);
                }else{
                } else {
                    sysVipInfo.setSessionKey(sessionKey);
                    sysVipInfoDao.update(sysVipInfo);
                }
@@ -134,6 +146,10 @@
        return res;
    }
    @Autowired
    ShopSalesmanGradeDao shopSalesmanGradeDao;
    /**
     * 查询用户信息
     */
@@ -141,10 +157,22 @@
    public @ResponseBody
    AjaxResult findUserInfo() {
        SysVipInfo loginUser = redisUserLoginUtils.getLoginUser(SysVipInfo.class);
        String openId = loginUser.getOpenId();
        SysVipInfo sysVipInfo = sysVipInfoService.findByOpenId(openId);
        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", 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;
    }
@@ -156,7 +184,7 @@
    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);
@@ -172,10 +200,17 @@
    AjaxResult saveUserInfo(@RequestBody XcxUserSaveUserInfoDto xcxUserSaveUserInfoDto) {
        SysVipInfo loginUser = redisUserLoginUtils.getLoginUser(SysVipInfo.class);
        SysVipInfo sysVipInfo=new SysVipInfo();
        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("微信用户")) {
            sysVipInfo.setVipName(xcxUserSaveUserInfoDto.getNickName());
        }
        if (StringUtils.isBlank(loginUser.getSex())) {
            sysVipInfo.setSex(xcxUserSaveUserInfoDto.getGender() == 1 ? "男" : "女");
        }
        int i = sysVipInfoDao.update(sysVipInfo);
@@ -185,7 +220,6 @@
        }
        return new AjaxResult(AjaxResult.STATUS_SUCCESS, Collections.singletonList(sysVipInfo));
    }
    void checkNeedToBeSalesman(SysVipInfo sysVipInfo, SysVipInfo loginUser) {
@@ -201,12 +235,7 @@
                    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);
                    }
                }
            }