| | |
| | | import cc.mrbird.febs.common.enumerates.FlowTypeEnum; |
| | | import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum; |
| | | import cc.mrbird.febs.common.properties.XcxProperties; |
| | | import cc.mrbird.febs.common.utils.MallUtils; |
| | | import cc.mrbird.febs.common.utils.OssUtils; |
| | | import cc.mrbird.febs.common.utils.RedisUtils; |
| | | import cc.mrbird.febs.common.utils.SpringContextHolder; |
| | | import cc.mrbird.febs.common.utils.*; |
| | | import cc.mrbird.febs.mall.dto.ApiRechargeWalletDto; |
| | | import cc.mrbird.febs.mall.dto.RechargeWalletMessageSendDto; |
| | | import cc.mrbird.febs.mall.entity.DataDictionaryCustom; |
| | | import cc.mrbird.febs.mall.entity.MallMember; |
| | | import cc.mrbird.febs.mall.entity.MallOrderInfo; |
| | | import cc.mrbird.febs.mall.entity.MallOrderItem; |
| | | import cc.mrbird.febs.mall.mapper.DataDictionaryCustomMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallMemberMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallOrderInfoMapper; |
| | | import cc.mrbird.febs.mall.entity.*; |
| | | import cc.mrbird.febs.mall.mapper.*; |
| | | import cc.mrbird.febs.mall.service.IMallMoneyFlowService; |
| | | import cc.mrbird.febs.mall.vo.RechargeWalletMessageSendVo; |
| | | import cc.mrbird.febs.pay.model.*; |
| | |
| | | import cc.mrbird.febs.pay.util.WeixinServiceUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.IdUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | |
| | | WeixinServiceUtil weixinServiceUtil; |
| | | @Autowired |
| | | private DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | @Autowired |
| | | private MallMoneyFlowMapper mallMoneyFlowMapper; |
| | | @Autowired |
| | | private MallMemberWithdrawMapper mallMemberWithdrawMapper; |
| | | private final IMallMoneyFlowService mallMoneyFlowService; |
| | | @Autowired |
| | | RedisUtils redisUtils; |
| | |
| | | ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, orderStateMsgVo, String.class); |
| | | log.info(responseEntity.getBody()); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public Boolean memberWithdrawal(MemberWithdrawalDto info) { |
| | | log.info("后台同意提现申请..."+JSONUtil.toJsonStr(info)); |
| | | boolean flag=false; |
| | | BigDecimal unit = new BigDecimal("100"); |
| | | BigDecimal money = new BigDecimal(info.getTotalFee().toString()); |
| | | String outTradeNo = info.getOutTradeNo(); |
| | | String openid = info.getOpenid(); |
| | | String desc = info.getDesc(); |
| | | |
| | | MallMember mallMember = mallMemberMapper.selectMemberByOpenId(openid); |
| | | if(ObjectUtil.isEmpty(mallMember)){ |
| | | return flag; |
| | | } |
| | | MallMemberWithdraw mallMemberWithdraw = mallMemberWithdrawMapper.selectByWithDrawNoAndMemberIdAndState(outTradeNo,mallMember.getId(),1); |
| | | if(ObjectUtil.isEmpty(mallMemberWithdraw)){ |
| | | return flag; |
| | | } |
| | | Boolean debug = xcxProperties.getDebug(); |
| | | if (debug) { |
| | | flag = weixinServiceUtil.comPay("[测试]" + desc, outTradeNo, |
| | | 1, openid); |
| | | } else { |
| | | flag = weixinServiceUtil.comPay(desc, outTradeNo, |
| | | unit.multiply(money).intValue(),openid); |
| | | } |
| | | return flag; |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | public FebsResponse generateQrCode(WxGenerateQrCodeDto wxGenerateQrCodeDto) { |
| | | String base64 = null; |
| | | try { |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + redisUtils.get(WechatConfigure.WX_ACCESS_TOKEN_REDIS_KEY); |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("scene", wxGenerateQrCodeDto.getScene()); |
| | | params.put("page", wxGenerateQrCodeDto.getPage()); |
| | | params.put("width", 430); |
| | | ResponseEntity<byte[]> responseEntity = restTemplate.postForEntity(url, params, byte[].class); |
| | | if (responseEntity.getStatusCode() == HttpStatus.OK) { |
| | | byte[] body = responseEntity.getBody(); |
| | | InputStream inputStream = new ByteArrayInputStream(body); |
| | | // 将获取流转为base64格式 |
| | | byte[] data = null; |
| | | ByteArrayOutputStream swapStream = new ByteArrayOutputStream(); |
| | | byte[] buff = new byte[100]; |
| | | int rc = 0; |
| | | while ((rc = inputStream.read(buff, 0, 100)) > 0) { |
| | | swapStream.write(buff, 0, rc); |
| | | } |
| | | data = swapStream.toByteArray(); |
| | | base64 = Base64.byteArrayToBase64(data); |
| | | inputStream.close(); |
| | | swapStream.close(); |
| | | } |
| | | } catch (IOException e) { |
| | | throw new ApiException("生成二维码失败"); |
| | | } |
| | | return new FebsResponse().success().data(base64); |
| | | // try { |
| | | // RestTemplate restTemplate = new RestTemplate(); |
| | | // String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + redisUtils.get(WechatConfigure.WX_ACCESS_TOKEN_REDIS_KEY); |
| | | // Map<String, Object> params = new HashMap<>(); |
| | | // params.put("scene", wxGenerateQrCodeDto.getScene()); |
| | | // params.put("page", wxGenerateQrCodeDto.getPage()); |
| | | // params.put("width", 430); |
| | | // ResponseEntity<byte[]> responseEntity = restTemplate.postForEntity(url, params, byte[].class); |
| | | // log.info(String.valueOf(JSONUtil.parse(responseEntity))); |
| | | // if (responseEntity.getStatusCode() == HttpStatus.OK) { |
| | | // byte[] body = responseEntity.getBody(); |
| | | // InputStream inputStream = new ByteArrayInputStream(body); |
| | | // // 将获取流转为base64格式 |
| | | // byte[] data = null; |
| | | // ByteArrayOutputStream swapStream = new ByteArrayOutputStream(); |
| | | // byte[] buff = new byte[100]; |
| | | // int rc = 0; |
| | | // while ((rc = inputStream.read(buff, 0, 100)) > 0) { |
| | | // swapStream.write(buff, 0, rc); |
| | | // } |
| | | // data = swapStream.toByteArray(); |
| | | // base64 = Base64.byteArrayToBase64(data); |
| | | // inputStream.close(); |
| | | // swapStream.close(); |
| | | // |
| | | // return new FebsResponse().success().data(body); |
| | | // } |
| | | // } catch (IOException e) { |
| | | // throw new ApiException("生成二维码失败"); |
| | | // } |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | /** |