| | |
| | | import cc.mrbird.febs.mall.service.IApiMallMemberWalletService; |
| | | import cc.mrbird.febs.mall.service.ICommonService; |
| | | import cc.mrbird.febs.mall.vo.*; |
| | | import cc.mrbird.febs.pay.model.BrandWCPayRequestData; |
| | | import cc.mrbird.febs.pay.service.IXcxPayService; |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.IdUtil; |
| | |
| | | import cn.hutool.crypto.SecureUtil; |
| | | import cn.hutool.crypto.asymmetric.KeyType; |
| | | import cn.hutool.crypto.asymmetric.RSA; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | private final MallShopApplyMapper mallShopApplyMapper; |
| | | private final MallRegisterAppealMapper mallRegisterAppealMapper; |
| | | private final MallTeamLeaderMapper mallTeamLeaderMapper; |
| | | private final SpringContextHolder springContextHolder; |
| | | |
| | | |
| | | @Value("${spring.profiles.active}") |
| | |
| | | authInfo.put("token", token); |
| | | authInfo.put("member", mallMember); |
| | | authInfo.put("rasToken", generateAsaToken(token)); |
| | | return new FebsResponse().success().message("登陆成功"); |
| | | return new FebsResponse().success().data(authInfo); |
| | | } |
| | | return new FebsResponse().fail().message("验证码错误"); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse xcxOpen(ApiXcxOpenDto apiXcxOpenDto) { |
| | | DataDictionaryCustom rangeSwitch = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.RANGE_SWITCH.getType(), DataDictionaryEnum.RANGE_SWITCH.getCode()); |
| | | if(StrUtil.isNotBlank(rangeSwitch.getValue()) && "1".equals(rangeSwitch.getValue())){ |
| | | if(ObjectUtil.isNull(apiXcxOpenDto.getLongitude()) || ObjectUtil.isNull(apiXcxOpenDto.getLatitude())){ |
| | | return new FebsResponse().fail().message("请授权位置信息"); |
| | | } |
| | | Double longitude = apiXcxOpenDto.getLongitude(); |
| | | Double latitude = apiXcxOpenDto.getLatitude(); |
| | | |
| | | DataDictionaryCustom rangeSize = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.RANGE_SIZE.getType(), DataDictionaryEnum.RANGE_SIZE.getCode()); |
| | | if(ObjectUtil.isEmpty(rangeSize)){ |
| | | return new FebsResponse().success().data(2); |
| | | } |
| | | if(StrUtil.isBlank(rangeSize.getValue())){ |
| | | return new FebsResponse().success().data(2); |
| | | } |
| | | //方位大小,换成单位:米 |
| | | Integer value = Integer.parseInt(rangeSize.getValue()) * 1000; |
| | | //根据经纬度获取周围团长的距离 |
| | | MallTeamLeader mallTeamLeader = mallTeamLeaderMapper.selectLeaderByLonAndLat(longitude, latitude); |
| | | Double distance = mallTeamLeader.getDistance(); |
| | | if(value <= distance){ |
| | | return new FebsResponse().success().data(2); |
| | | } |
| | | } |
| | | return new FebsResponse().success().data(1); |
| | | } |
| | | |
| | | private final IXcxPayService iXcxPayService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public FebsResponse rechargeWallet(ApiRechargeWalletDto apiRechargeWalletDto) { |
| | | Long memberId = LoginUserUtil.getLoginUser().getId(); |
| | | BigDecimal amount = apiRechargeWalletDto.getAmount(); |
| | | if(BigDecimal.ZERO.compareTo(amount)>0){ |
| | | return new FebsResponse().fail().message("请输入正确的充值金额"); |
| | | } |
| | | apiRechargeWalletDto.setMemberId(memberId); |
| | | BrandWCPayRequestData brandWCPayRequestData = null; |
| | | try { |
| | | brandWCPayRequestData = iXcxPayService.startRechargeWallet(apiRechargeWalletDto); |
| | | } catch (Exception e) { |
| | | throw new FebsException("支付失败"); |
| | | } |
| | | String wxResultStr = JSONUtil.toJsonStr(brandWCPayRequestData); |
| | | String payResultStr = brandWCPayRequestData.getPrepay_id(); |
| | | return new FebsResponse().success().message("充值即将到账"); |
| | | } |
| | | |
| | | private String getXcxLoginUrl(String code) { |
| | | String wechatLoginUrl =xcxProperties.getWecharLoginUrl(); |
| | | return String.format(wechatLoginUrl, xcxProperties.getXcxAppid(), xcxProperties.getXcxSecret(), code); |