| | |
| | | package cc.mrbird.febs.mall.service.impl; |
| | | |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.enumerates.AgentLevelEnum; |
| | | import cc.mrbird.febs.common.enumerates.DataDictionaryEnum; |
| | | import cc.mrbird.febs.common.enumerates.FlowTypeEnum; |
| | | import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum; |
| | | import cc.mrbird.febs.common.enumerates.ScoreFlowTypeEnum; |
| | | import cc.mrbird.febs.common.exception.FebsException; |
| | | import cc.mrbird.febs.common.properties.XcxProperties; |
| | | import cc.mrbird.febs.common.utils.*; |
| | | import cc.mrbird.febs.mall.controller.dependentStation.enums.SalesServiceEnums; |
| | | import cc.mrbird.febs.mall.conversion.MallMemberConversion; |
| | | import cc.mrbird.febs.mall.conversion.MallShopApplyConversion; |
| | | import cc.mrbird.febs.mall.conversion.MallStoreConversion; |
| | | import cc.mrbird.febs.mall.dto.*; |
| | | import cc.mrbird.febs.mall.entity.*; |
| | | import cc.mrbird.febs.mall.mapper.*; |
| | | import cc.mrbird.febs.mall.service.IApiMallMemberService; |
| | | import cc.mrbird.febs.mall.service.IApiMallMemberWalletService; |
| | | import cc.mrbird.febs.mall.service.ICommonService; |
| | | import cc.mrbird.febs.mall.service.*; |
| | | import cc.mrbird.febs.mall.vo.*; |
| | | import cc.mrbird.febs.pay.model.BrandWCPayRequestData; |
| | | import cc.mrbird.febs.pay.service.IXcxPayService; |
| | | import cc.mrbird.febs.pay.util.MD5; |
| | | import cc.mrbird.febs.vip.VipSettingUnAliveSettingBo; |
| | | import cc.mrbird.febs.vip.entity.MallVipConfig; |
| | | import cc.mrbird.febs.vip.mapper.MallVipConfigMapper; |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateUnit; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.IdUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.crypto.SecureUtil; |
| | | import cn.hutool.crypto.asymmetric.KeyType; |
| | | import cn.hutool.crypto.asymmetric.RSA; |
| | | import cn.hutool.json.JSONArray; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author wzy |
| | |
| | | private final MallMemberWalletMapper mallMemberWalletMapper; |
| | | private final ICommonService commonService; |
| | | private final RedisUtils redisUtils; |
| | | private final MallOrderInfoMapper mallOrderInfoMapper; |
| | | private final MallShoppingCartMapper mallShoppingCartMapper; |
| | | private final MallMoneyFlowMapper mallMoneyFlowMapper; |
| | | private final IApiMallMemberWalletService walletService; |
| | | private final MallMemberPaymentMapper mallMemberPaymentMapper; |
| | | private final DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | private final MallShopApplyMapper mallShopApplyMapper; |
| | | private final MallRegisterAppealMapper mallRegisterAppealMapper; |
| | | private final MallAgentRecordMapper mallAgentRecordMapper; |
| | | private final CouponGoodsMapper couponGoodsMapper; |
| | | private final MallMemberCouponMapper mallMemberCouponMapper; |
| | | private final MallAddressInfoMapper mallAddressInfoMapper; |
| | | |
| | | |
| | | @Value("${spring.profiles.active}") |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public FebsResponse register(RegisterDto registerDto) { |
| | | MallMember mallMember = this.baseMapper.selectInfoByAccount(registerDto.getAccount()); |
| | | if (mallMember != null) { |
| | | throw new FebsException("该账号已被占用"); |
| | | } |
| | | |
| | | List<MallMember> mallMembers = this.baseMapper.selectMemberByName(registerDto.getName()); |
| | | if (CollUtil.isNotEmpty(mallMembers)) { |
| | | MallRegisterAppeal registerAppeal = mallRegisterAppealMapper.selectByPhoneAndName(registerDto.getName(), registerDto.getAccount()); |
| | | if (registerAppeal == null || registerAppeal.getStatus() != 1) { |
| | | return new FebsResponse().code(HttpStatus.ACCEPTED).message("用户名已存在"); |
| | | } |
| | | } |
| | | |
| | | String account = registerDto.getAccount(); |
| | | if (!"admin".equals(registerDto.getRegistType())) { |
| | | String code = registerDto.getCode(); |
| | | boolean flags = commonService.verifyCode(account, code); |
| | | if (!flags) { |
| | | throw new FebsException("验证码错误"); |
| | | } |
| | | MallMember mallMember = this.baseMapper.selectInfoByAccount(account); |
| | | if (mallMember != null) { |
| | | throw new FebsException("Registered"); |
| | | } |
| | | |
| | | /** |
| | | * 验证两次密码是否一致 |
| | | */ |
| | | String password = registerDto.getPassword(); |
| | | String confirmPassword = registerDto.getConfirmPassword(); |
| | | if (!password.equals(confirmPassword)) { |
| | | throw new FebsException("The two passwords are inconsistent"); |
| | | } |
| | | mallMember = new MallMember(); |
| | | mallMember.setPassword(SecureUtil.md5(registerDto.getPassword())); |
| | | |
| | | // 判断账号类型 |
| | | if (AppContants.ACCOUNT_TYPE_MOBILE.equals(registerDto.getType())) { |
| | | mallMember.setPhone(registerDto.getAccount()); |
| | | } else { |
| | | mallMember.setEmail(registerDto.getAccount()); |
| | | } |
| | | |
| | | Integer count = this.baseMapper.selectCount(null); |
| | | if (count != null && count != 0) { |
| | | MallMember inviteMember = this.baseMapper.selectInfoByInviteId(registerDto.getInviteId()); |
| | | if (inviteMember == null) { |
| | | throw new FebsException("邀请码不存在"); |
| | | } |
| | | |
| | | mallMember.setReferrerId(registerDto.getInviteId()); |
| | | |
| | | } |
| | | mallMember.setName(registerDto.getName()); |
| | | mallMember.setName(registerDto.getLastName() + registerDto.getFirstName()); |
| | | mallMember.setPhone(registerDto.getPhoneNumber()); |
| | | mallMember.setEmail(registerDto.getAccount()); |
| | | mallMember.setPassword(SecureUtil.md5(password)); |
| | | mallMember.setAccountStatus(MallMember.ACCOUNT_STATUS_ENABLE); |
| | | mallMember.setAccountType(MallMember.ACCOUNT_TYPE_NORMAL); |
| | | mallMember.setLevel(AgentLevelEnum.ZERO_LEVEL.name()); |
| | | mallMember.setSex("男"); |
| | | mallMember.setBindPhone(registerDto.getAccount()); |
| | | |
| | | this.baseMapper.insert(mallMember); |
| | | |
| | | String inviteId = ShareCodeUtil.toSerialCode(mallMember.getId()); |
| | | mallMember.setInviteId(inviteId); |
| | | MallAddressInfo mallAddressInfo = new MallAddressInfo(); |
| | | mallAddressInfo.setMemberId(mallMember.getId()); |
| | | mallAddressInfo.setName(registerDto.getLastName()); |
| | | mallAddressInfo.setFristName(registerDto.getFirstName()); |
| | | mallAddressInfo.setPhone(registerDto.getPhoneNumber()); |
| | | mallAddressInfoMapper.insert(mallAddressInfo); |
| | | |
| | | //推荐人和推荐人链 |
| | | boolean flag = false; |
| | | String parentId = mallMember.getReferrerId(); |
| | | if (StrUtil.isBlank(parentId)) { |
| | | flag = true; |
| | | } |
| | | String ids = ""; |
| | | while (!flag) { |
| | | if (StrUtil.isBlank(ids)) { |
| | | ids += parentId; |
| | | } else { |
| | | ids += ("," + parentId); |
| | | } |
| | | MallMember parentMember = this.baseMapper.selectInfoByInviteId(parentId); |
| | | if (parentMember == null) { |
| | | break; |
| | | } |
| | | parentId = parentMember.getReferrerId(); |
| | | if (StrUtil.isBlank(parentMember.getReferrerId())) { |
| | | flag = true; |
| | | } |
| | | } |
| | | |
| | | if (StrUtil.isNotBlank(ids)) { |
| | | mallMember.setReferrerIds(ids); |
| | | } |
| | | this.baseMapper.updateById(mallMember); |
| | | |
| | | MallMemberWallet wallet = new MallMemberWallet(); |
| | | wallet.setBalance(BigDecimal.ZERO); |
| | | wallet.setMemberId(mallMember.getId()); |
| | | mallMemberWalletMapper.insert(wallet); |
| | | return new FebsResponse().success().message("注册成功"); |
| | | return new FebsResponse().success().message("registered successfully"); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | MallMember mallMember = this.baseMapper.selectInfoByAccountAndPwd(loginDto.getAccount(), md5Pwd); |
| | | if (mallMember == null) { |
| | | throw new FebsException("用户不存在或账号密码错误"); |
| | | throw new FebsException("The user does not exist or the account password is incorrect"); |
| | | } |
| | | |
| | | if (MallMember.ACCOUNT_STATUS_DISABLED.equals(mallMember.getAccountStatus())) { |
| | | throw new FebsException("该账号存在异常, 暂限制登录"); |
| | | throw new FebsException("The account is abnormal and is temporarily restricted from logging in"); |
| | | } |
| | | |
| | | String redisKey = AppContants.APP_LOGIN_PREFIX + mallMember.getId(); |
| | |
| | | |
| | | public String generateAsaToken(String token) { |
| | | RSA rsa = new RSA(null, AppContants.PUBLIC_KEY); |
| | | return rsa.encryptBase64(token + "_" + System.currentTimeMillis(), KeyType.PublicKey); |
| | | // return rsa.encryptBase64(token + "_" + System.currentTimeMillis(), KeyType.PublicKey); |
| | | //去掉时间戳 |
| | | return rsa.encryptBase64(token, KeyType.PublicKey); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse forgetPwd(ForgetPwdDto forgetPwdDto) { |
| | | MallMember mallMember = this.baseMapper.selectInfoByAccount(forgetPwdDto.getAccount()); |
| | | |
| | | Long id = LoginUserUtil.getLoginUser().getId(); |
| | | MallMember mallMember = this.baseMapper.selectById(id); |
| | | if (mallMember == null) { |
| | | throw new FebsException("账号不存在"); |
| | | throw new FebsException("Setup failed"); |
| | | } |
| | | |
| | | boolean b = commonService.verifyCode(forgetPwdDto.getAccount(), forgetPwdDto.getCode()); |
| | | if (!b) { |
| | | throw new FebsException("验证码错误"); |
| | | if (!forgetPwdDto.getNewPassword().equals(forgetPwdDto.getNewPasswordAgain())){ |
| | | throw new FebsException("Setup failed"); |
| | | } |
| | | |
| | | String pwd = SecureUtil.md5(forgetPwdDto.getPassword()); |
| | | String pwd = SecureUtil.md5(forgetPwdDto.getNewPassword()); |
| | | mallMember.setPassword(pwd); |
| | | |
| | | this.baseMapper.updateById(mallMember); |
| | | return new FebsResponse().success().message("重置成功"); |
| | | this.baseMapper.update( |
| | | null, |
| | | Wrappers.lambdaUpdate(MallMember.class) |
| | | .set(MallMember::getPassword, pwd) |
| | | .eq(MallMember::getId, id) |
| | | ); |
| | | return new FebsResponse().success().message("Setup successful"); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse logout() { |
| | | Long id = LoginUserUtil.getLoginUser().getId(); |
| | | |
| | | String redisKey = AppContants.APP_LOGIN_PREFIX + id; |
| | | String existToken = redisUtils.getString(redisKey); |
| | | if (StrUtil.isNotBlank(existToken)) { |
| | | Object o = redisUtils.get(existToken); |
| | | if (ObjectUtil.isNotEmpty(o)) { |
| | | redisUtils.del(existToken); |
| | | } |
| | | } |
| | | redisUtils.del(AppContants.APP_LOGIN_PREFIX + id); |
| | | return new FebsResponse().success().message("退出登录"); |
| | | redisUtils.del(AppContants.XCX_LOGIN_PHONE_PREFIX + id); |
| | | return new FebsResponse().success().message("Log out"); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse findMemberInfo() { |
| | | Long id = LoginUserUtil.getLoginUser().getId(); |
| | | MallMember mallMember = this.baseMapper.selectById(id); |
| | | |
| | | MallMemberVo mallMemberVo = MallMemberConversion.INSTANCE.entityToVo(mallMember); |
| | | |
| | | MallMember referMember = this.baseMapper.selectInfoByInviteId(mallMember.getReferrerId()); |
| | | if (referMember != null) { |
| | | mallMemberVo.setReferrerName(referMember.getName()); |
| | | } |
| | | |
| | | if (StrUtil.isNotBlank(mallMember.getTradePassword())) { |
| | | mallMemberVo.setHasTradePwd(1); |
| | | } |
| | | |
| | | MallMemberPayment payment = mallMemberPaymentMapper.selectByMemberId(id); |
| | | if (payment != null) { |
| | | mallMemberVo.setHasPayment(1); |
| | | } |
| | | |
| | | DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(AppContants.AGENT_LEVEL, mallMember.getLevel()); |
| | | if (dic != null) { |
| | | mallMemberVo.setLevelName(dic.getDescription()); |
| | | } |
| | | MallMemberWallet wallet = mallMemberWalletMapper.selectWalletByMemberId(mallMemberVo.getId()); |
| | | mallMemberVo.setBalance(wallet.getBalance()); |
| | | mallMemberVo.setScore(wallet.getScore()); |
| | | mallMemberVo.setPrizeScore(wallet.getPrizeScore()); |
| | | mallMemberVo.setTotalCost(mallOrderInfoMapper.selectTotalAmount(id)); |
| | | MallMemberVo mallMemberVo = new MallMemberVo(); |
| | | mallMemberVo.setName(mallMember.getName()); |
| | | mallMemberVo.setEmail(mallMember.getEmail()); |
| | | mallMemberVo.setPhoneNumber(mallMember.getPhone()); |
| | | mallMemberVo.setAvatar(mallMember.getAvatar()); |
| | | return new FebsResponse().success().data(mallMemberVo); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse findMemberMarkCnt() { |
| | | Long id = LoginUserUtil.getLoginUser().getId(); |
| | | |
| | | List<Map<String, Integer>> maps = mallOrderInfoMapper.selectMemberOrderStatusCnt(id); |
| | | Map<Integer, Integer> orderCnt = new HashMap<>(); |
| | | if (CollUtil.isNotEmpty(maps)) { |
| | | for (Map<String, Integer> map : maps) { |
| | | orderCnt.put(map.get("status"), map.get("cnt")); |
| | | } |
| | | } |
| | | |
| | | List<MallShoppingCart> carts = mallShoppingCartMapper.selectCartGoodsList(id); |
| | | Map<String, Object> result = new HashMap<>(); |
| | | result.put("order", orderCnt); |
| | | result.put("carts", carts.size()); |
| | | return new FebsResponse().success().data(result); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse setTradePwd(ForgetPwdDto forgetPwdDto) { |
| | | MallMember memberId = LoginUserUtil.getLoginUser(); |
| | | MallMember mallMember = this.baseMapper.selectById(memberId); |
| | | if (mallMember == null) { |
| | | throw new FebsException("账号不存在"); |
| | | } |
| | | |
| | | boolean b = commonService.verifyCode(forgetPwdDto.getAccount(), forgetPwdDto.getCode()); |
| | | if (!b) { |
| | | throw new FebsException("验证码错误"); |
| | | } |
| | | |
| | | mallMember.setTradePassword(SecureUtil.md5(forgetPwdDto.getPassword())); |
| | | this.baseMapper.updateById(mallMember); |
| | | return new FebsResponse().success().message("设置成功"); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse modifyMemberInfo(ModifyMemberInfoDto modifyMemberInfoDto) { |
| | | MallMember member = LoginUserUtil.getLoginUser(); |
| | | MallMember mallMember = this.baseMapper.selectById(member.getId()); |
| | | Long memberId = LoginUserUtil.getLoginUser().getId(); |
| | | MallMember mallMember = this.baseMapper.selectById(memberId); |
| | | if (StrUtil.isNotBlank(modifyMemberInfoDto.getName())) { |
| | | mallMember.setName(modifyMemberInfoDto.getName()); |
| | | } |
| | | |
| | | if (StrUtil.isNotBlank(modifyMemberInfoDto.getPhoto())) { |
| | | mallMember.setAvatar(modifyMemberInfoDto.getPhoto()); |
| | | } |
| | | |
| | | this.baseMapper.updateById(mallMember); |
| | | return new FebsResponse().success().message("修改成功"); |
| | | return new FebsResponse().success().message("success"); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse teamList(TeamListDto teamListDto) { |
| | | Long memberId = null; |
| | | if (teamListDto.getId() == null) { |
| | | memberId = LoginUserUtil.getLoginUser().getId(); |
| | | } else { |
| | | memberId = teamListDto.getId(); |
| | | } |
| | | |
| | | MallMember mallMember = this.baseMapper.selectById(memberId); |
| | | |
| | | List<TeamListVo> list = this.baseMapper.selectTeamListByInviteId(mallMember.getInviteId()); |
| | | // BigDecimal ownAmount = this.baseMapper.selectOwnOrderAmountByInviteId(mallMember.getInviteId()); |
| | | // TeamListVo own = new TeamListVo(); |
| | | // own.setCreatedTime(mallMember.getCreatedTime()); |
| | | // own.setAmount(ownAmount); |
| | | // own.setName(mallMember.getName()); |
| | | // own.setPhone(mallMember.getPhone()); |
| | | // own.setInviteId(mallMember.getInviteId()); |
| | | // own.setIsCurrent(1); |
| | | // own.setCnt(this.baseMapper.selectOwnCntByInviteId(mallMember.getInviteId())); |
| | | // own.setOrderCnt(this.baseMapper.selectOwnOrderCntByInviteId(mallMember.getInviteId())); |
| | | // own.setId(mallMember.getId()); |
| | | |
| | | MyTeamVo myTeamVo = new MyTeamVo(); |
| | | myTeamVo.setTeam(list); |
| | | myTeamVo.setMyAchieve(this.baseMapper.selectAchieveByMemberId(mallMember.getInviteId(), 1)); |
| | | myTeamVo.setMyTeamAchieve(this.baseMapper.selectAchieveByMemberId(mallMember.getInviteId(), 2)); |
| | | myTeamVo.setMyTeamCnt(list.size()); |
| | | return new FebsResponse().success().data(myTeamVo); |
| | | } |
| | | |
| | | @Override |
| | | public MyTeamVo teamListForMine(TeamListDto teamListDto) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse moneyFlows(MoneyFlowDto moneyFlowDto) { |
| | | IPage<MoneyFlowVo> page = new Page<>(moneyFlowDto.getPageNum(), moneyFlowDto.getPageSize()); |
| | | Long id = LoginUserUtil.getLoginUser().getId(); |
| | | moneyFlowDto.setMemberId(id); |
| | | IPage<MoneyFlowVo> pages = mallMoneyFlowMapper.selectApiMoneyFlowInPage(page, moneyFlowDto); |
| | | return new FebsResponse().success().data(pages); |
| | | } |
| | | |
| | | @Override |
| | | public void addMoneyFlow(Long memberId, BigDecimal amount, Integer type, String orderNo, String description, String remark, Long rtMemberId, Integer status, Integer flowType) { |
| | |
| | | mallMoneyFlowMapper.insert(flow); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void transfer(TransferDto transferDto) { |
| | | MallMember mallMember = this.baseMapper.selectInfoByAccount(transferDto.getAccount()); |
| | | if (mallMember == null) { |
| | | throw new FebsException("用户不存在"); |
| | | } |
| | | |
| | | Long memberId = LoginUserUtil.getLoginUser().getId(); |
| | | MallMember loginMember = this.baseMapper.selectById(memberId); |
| | | |
| | | if (loginMember.getPhone().equals(transferDto.getAccount()) || loginMember.getInviteId().equals(transferDto.getAccount())) { |
| | | throw new FebsException("不能给自己转账"); |
| | | } |
| | | |
| | | if (StrUtil.isBlank(loginMember.getTradePassword())) { |
| | | throw new FebsException("未设置支付密码"); |
| | | } |
| | | |
| | | if (!loginMember.getTradePassword().equals(SecureUtil.md5(transferDto.getTradePwd()))) { |
| | | throw new FebsException("支付密码错误"); |
| | | } |
| | | |
| | | walletService.reduceBalance(transferDto.getAmount(), memberId); |
| | | String orderNo = MallUtils.getOrderNum("T"); |
| | | this.addMoneyFlow(memberId, transferDto.getAmount().negate(), MoneyFlowTypeEnum.TRANSFER.getValue(), orderNo, null, null, mallMember.getId(), null, FlowTypeEnum.BALANCE.getValue()); |
| | | |
| | | walletService.addBalance(transferDto.getAmount(), mallMember.getId()); |
| | | this.addMoneyFlow(mallMember.getId(), transferDto.getAmount(), MoneyFlowTypeEnum.TRANSFER.getValue(), orderNo, null, null, memberId, null, FlowTypeEnum.BALANCE.getValue()); |
| | | } |
| | | |
| | | @Override |
| | | public void setPayment(MallMemberPayment mallMemberPayment) { |
| | | MallMember member = LoginUserUtil.getLoginUser(); |
| | | |
| | | MallMemberPayment exist = mallMemberPaymentMapper.selectByMemberId(member.getId()); |
| | | if (exist == null) { |
| | | mallMemberPayment.setMemberId(member.getId()); |
| | | mallMemberPaymentMapper.insert(mallMemberPayment); |
| | | } else { |
| | | mallMemberPayment.setId(exist.getId()); |
| | | mallMemberPaymentMapper.updateById(mallMemberPayment); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public MallMemberPayment findMemberPayment() { |
| | | MallMember member = LoginUserUtil.getLoginUser(); |
| | | return mallMemberPaymentMapper.selectByMemberId(member.getId()); |
| | | } |
| | | |
| | | @Override |
| | | public void bindPhone(AccountAndCodeDto accountAndCodeDto) { |
| | |
| | | Long id = LoginUserUtil.getLoginUser().getId(); |
| | | MallMember member = this.baseMapper.selectById(id); |
| | | |
| | | member.setBindPhone(accountAndCodeDto.getAccount()); |
| | | member.setPhone(accountAndCodeDto.getAccount()); |
| | | this.baseMapper.updateById(member); |
| | | } |
| | | |
| | | @Override |
| | | public BigDecimal canMoney() { |
| | | Long memberId = LoginUserUtil.getLoginUser().getId(); |
| | | MallMemberWallet wallet = mallMemberWalletMapper.selectWalletByMemberId(memberId); |
| | | BigDecimal profit = mallMoneyFlowMapper.selectProfitByDateAndMemberId(memberId); |
| | | |
| | | BigDecimal canMoney = wallet.getBalance(); |
| | | if (profit != null) { |
| | | if(canMoney.compareTo(BigDecimal.ZERO) > 0) { |
| | | canMoney = canMoney.subtract(profit); |
| | | } |
| | | } |
| | | return canMoney; |
| | | } |
| | | |
| | | @Override |
| | | public List<MallMember> findRankList(RankListDto rankListDto) { |
| | | IPage<MallMember> page = new Page<>(rankListDto.getPageNum(), rankListDto.getPageSize()); |
| | | |
| | | MallMember member = new MallMember(); |
| | | member.setQuery("2"); |
| | | member.setCreatedTime(new Date()); |
| | | IPage<MallMember> list = this.baseMapper.selectRankListInPage(page, member); |
| | | |
| | | return list.getRecords(); |
| | | } |
| | | |
| | | @Override |
| | | public MallMember findMemberInfoByAccount(String phone) { |
| | | return this.baseMapper.selectInfoByAccount(phone); |
| | | } |
| | | |
| | | @Override |
| | | public MyCommissionVo myCommission() { |
| | | Long id = LoginUserUtil.getLoginUser().getId(); |
| | | MallMember mallMember = this.baseMapper.selectById(id); |
| | | |
| | | MyCommissionVo commissionVo = MallMemberConversion.INSTANCE.entityToCommissionVo(mallMember); |
| | | |
| | | MallMember referMember = this.baseMapper.selectInfoByInviteId(mallMember.getReferrerId()); |
| | | if (referMember != null) { |
| | | commissionVo.setReferrerName(referMember.getName()); |
| | | commissionVo.setAvatar(referMember.getAvatar()); |
| | | } |
| | | |
| | | DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(AppContants.AGENT_LEVEL, mallMember.getLevel()); |
| | | if (dic != null) { |
| | | commissionVo.setLevelName(dic.getDescription()); |
| | | } |
| | | |
| | | MallMemberWallet wallet = mallMemberWalletMapper.selectWalletByMemberId(id); |
| | | commissionVo.setCommission(wallet.getCommission()); |
| | | commissionVo.setToday(mallMoneyFlowMapper.selectCommissionIncome(1, new Date(), id)); |
| | | commissionVo.setMonth(mallMoneyFlowMapper.selectCommissionIncome(2, new Date(), id)); |
| | | commissionVo.setTotal(mallMoneyFlowMapper.selectCommissionIncome(null, null, id)); |
| | | commissionVo.setWaitCommission(BigDecimal.ZERO); |
| | | return commissionVo; |
| | | } |
| | | |
| | | @Override |
| | | public void shopApply(ShopApplyDto shopApplyDto) { |
| | |
| | | return mallShopApplyMapper.selectNewestApplyByMemberId(member.getId()); |
| | | } |
| | | |
| | | @Override |
| | | public void addRegisterAppeal(RegisterAppealDto registerAppeal) { |
| | | MallRegisterAppeal isExist = mallRegisterAppealMapper.selectByPhoneAndName(registerAppeal.getName(), registerAppeal.getPhone()); |
| | | if (isExist != null) { |
| | | throw new FebsException("申诉已存在"); |
| | | } |
| | | |
| | | isExist = new MallRegisterAppeal(); |
| | | isExist.setName(registerAppeal.getName()); |
| | | isExist.setPhone(registerAppeal.getPhone()); |
| | | isExist.setStatus(2); |
| | | |
| | | mallRegisterAppealMapper.insert(isExist); |
| | | } |
| | | |
| | | @Override |
| | | public CashOutSettingVo cashOutSetting() { |
| | | CashOutSettingVo cashOutSettingVo = new CashOutSettingVo(); |
| | | DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.CASHOUT_SETTING.getType(), DataDictionaryEnum.CASHOUT_SETTING.getCode()); |
| | | if (dic != null) { |
| | | cashOutSettingVo = JSONObject.parseObject(dic.getValue(), CashOutSettingVo.class); |
| | | } |
| | | return cashOutSettingVo; |
| | | } |
| | | |
| | | @Override |
| | | public List<ShopListVo> findShopListVo(ShopListDto shopListDto) { |
| | |
| | | } |
| | | return MallShopApplyConversion.INSTANCE.entitiesToVOs(list); |
| | | } |
| | | |
| | | |
| | | private final XcxProperties xcxProperties = SpringContextHolder.getBean(XcxProperties.class); |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void updateMemberAgent(Long memberId,String levelCode) { |
| | | mallAgentRecordMapper.updateStateByMemberId(memberId); |
| | | MallAgentRecord mallAgentRecord = mallAgentRecordMapper.selectById(memberId); |
| | | //更新用户表中的LEVEL |
| | | MallMember mallMember = this.baseMapper.selectById(mallAgentRecord.getMemberId()); |
| | | mallMember.setLevel(levelCode); |
| | | this.baseMapper.updateById(mallMember); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public FebsResponse memberPayCoupon(MallMemberCouponDto mallMemberCouponDto) { |
| | | Long memberId = LoginUserUtil.getLoginUser().getId(); |
| | | mallMemberCouponDto.setMemberId(memberId); |
| | | mallMemberCouponDto.setExpireTime(DateUtil.date()); |
| | | // List<Long> couponIds = couponGoodsMapper.selectByGoodId(mallMemberCouponDto.getGoodsId()); |
| | | List<Long> goodsIdList = mallMemberCouponDto.getGoodsIdList(); |
| | | List<Long> couponIds = couponGoodsMapper.selectByGoodIdList(goodsIdList); |
| | | |
| | | List<MallMemberCouponVo> mallMemberCouponVos = new ArrayList<>(); |
| | | if(CollUtil.isNotEmpty(couponIds)){ |
| | | mallMemberCouponVos = mallMemberCouponMapper.selectListCreateInPage(mallMemberCouponDto,couponIds); |
| | | } |
| | | return new FebsResponse().success().data(mallMemberCouponVos); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public FebsResponse setInvite(ApiSetInviteDto apiSetInviteDto) { |
| | | Long memberId = LoginUserUtil.getLoginUser().getId(); |
| | | MallMember mallMember = this.baseMapper.selectById(memberId); |
| | | if(ObjectUtil.isNotEmpty(mallMember.getReferrerId())){ |
| | | throw new FebsException("已绑定"); |
| | | } |
| | | String inviteId = apiSetInviteDto.getInviteId(); |
| | | if(inviteId.equals(mallMember.getInviteId())){ |
| | | return new FebsResponse().success(); |
| | | } |
| | | MallMember member = this.baseMapper.selectInfoByInviteId(inviteId); |
| | | if (member != null) { |
| | | if (StrUtil.isNotBlank(member.getReferrerIds()) && member.getReferrerIds().contains(mallMember.getInviteId())) { |
| | | log.info("下级不能邀请上级"); |
| | | return new FebsResponse().success(); |
| | | } |
| | | mallMember.setReferrerId(member.getInviteId()); |
| | | |
| | | //推荐人和推荐人链 |
| | | boolean flag = false; |
| | | String parentId = mallMember.getReferrerId(); |
| | | if (StrUtil.isBlank(parentId)) { |
| | | flag = true; |
| | | } |
| | | String ids = ""; |
| | | while (!flag) { |
| | | if (StrUtil.isBlank(ids)) { |
| | | ids += parentId; |
| | | } else { |
| | | ids += ("," + parentId); |
| | | } |
| | | MallMember parentMember = this.baseMapper.selectInfoByInviteId(parentId); |
| | | if (parentMember == null) { |
| | | break; |
| | | } |
| | | parentId = parentMember.getReferrerId(); |
| | | if (StrUtil.isBlank(parentMember.getReferrerId())) { |
| | | flag = true; |
| | | } |
| | | } |
| | | if (StrUtil.isNotBlank(ids)) { |
| | | mallMember.setReferrerIds(ids); |
| | | } |
| | | this.baseMapper.updateById(mallMember); |
| | | } |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | private String getXcxLoginUrl(String code) { |
| | | String wechatLoginUrl =xcxProperties.getWecharLoginUrl(); |
| | | return String.format(wechatLoginUrl, xcxProperties.getXcxAppid(), xcxProperties.getXcxSecret(), code); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public FebsResponse salesService() { |
| | | MallSalesServiceVo mallSalesServiceVo = new MallSalesServiceVo(); |
| | | |
| | | List<DataDictionaryCustom> dataDictionaryCustoms = dataDictionaryCustomMapper.selectDicByType( |
| | | SalesServiceEnums.WHATSAPP.getType() |
| | | ); |
| | | if (dataDictionaryCustoms.size() > 0){ |
| | | |
| | | for (DataDictionaryCustom dataDictionaryCustom : dataDictionaryCustoms){ |
| | | if (SalesServiceEnums.WHATSAPP.getCode().equals(dataDictionaryCustom.getCode())){ |
| | | mallSalesServiceVo.setWhatsApp(dataDictionaryCustom.getValue()); |
| | | } |
| | | if (SalesServiceEnums.PHONE.getCode().equals(dataDictionaryCustom.getCode())){ |
| | | mallSalesServiceVo.setPhone(dataDictionaryCustom.getValue()); |
| | | } |
| | | if (SalesServiceEnums.EMAIL.getCode().equals(dataDictionaryCustom.getCode())){ |
| | | mallSalesServiceVo.setEmail(dataDictionaryCustom.getValue()); |
| | | } |
| | | if (SalesServiceEnums.WORKINGHOURS.getCode().equals(dataDictionaryCustom.getCode())){ |
| | | mallSalesServiceVo.setWorkingHours(dataDictionaryCustom.getValue()); |
| | | } |
| | | if (SalesServiceEnums.ADDRESS.getCode().equals(dataDictionaryCustom.getCode())){ |
| | | mallSalesServiceVo.setAddress(dataDictionaryCustom.getValue()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | return new FebsResponse().success().data(mallSalesServiceVo); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | Long userld = 173L; |
| | | String shopAccount = "luohu"; |
| | | String shopPwd = "123456"; |
| | | |
| | | HashMap<String, String> objectObjectHashMap = new HashMap<>(); |
| | | |
| | | objectObjectHashMap.put("shopAccount",shopAccount); |
| | | objectObjectHashMap.put("shopPwd",shopPwd); |
| | | objectObjectHashMap.put("userId",userld.toString()); |
| | | |
| | | //sign= MD5(shopAccount+shopPwd+userId) |
| | | StringBuffer stringBuffer = new StringBuffer(); |
| | | stringBuffer.append(shopAccount); |
| | | stringBuffer.append(shopPwd); |
| | | stringBuffer.append(userld); |
| | | String sign = MD5.MD5Encode(stringBuffer.toString()); |
| | | objectObjectHashMap.put("sign",sign); |
| | | |
| | | System.out.println(sign); |
| | | |
| | | System.out.println(objectObjectHashMap); |
| | | String url = "https://data.muchun.co/api/getCustomerCheckRecords"; |
| | | String result = HttpCurlUtil.sendPost(url, objectObjectHashMap); |
| | | Integer retCode = JSONUtil.parseObj(result).getInt("retCode"); |
| | | String message = JSONUtil.parseObj(result).getStr("message"); |
| | | if(0 != retCode){ |
| | | System.out.println(message); |
| | | } |
| | | |
| | | JSONArray data = JSONUtil.parseObj(result).getJSONArray("data"); |
| | | System.out.println(data); |
| | | } |
| | | |
| | | |
| | | } |