| | |
| | | import cc.mrbird.febs.mall.mapper.*; |
| | | import cc.mrbird.febs.mall.service.IApiMallAppService; |
| | | import cc.mrbird.febs.mall.vo.*; |
| | | import cc.mrbird.febs.pay.service.IXcxCodePayService; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.IdUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | |
| | | private final MallOrderInfoMapper mallOrderInfoMapper; |
| | | private final MallOrderItemMapper mallOrderItemMapper; |
| | | private final MallMemberWalletMapper mallMemberWalletMapper; |
| | | private final IXcxCodePayService xcxCodePayService; |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.println(SecureUtil.md5("a123456")); |
| | |
| | | |
| | | @Override |
| | | public FebsResponse appMemberInfo(ApiMallAppMemberInfoDto apiMallAppMemberInfoDto) { |
| | | Long memberId = LoginUserUtil.getLoginUser().getId(); |
| | | // Long memberId = LoginUserUtil.getLoginUser().getId(); |
| | | List<ApiMallAppMemberInfoVo> mallMembers = this.baseMapper.selectMemberInfoLikePhone(apiMallAppMemberInfoDto.getPhone()); |
| | | return new FebsResponse().success().data(mallMembers); |
| | | } |
| | |
| | | orderInfo.setIsApp(AppContants.IS_APP_ORDER); |
| | | orderInfo.setOrderTime(new Date()); |
| | | orderInfo.setMemberId(addOrderDto.getMemberId()); |
| | | orderInfo.setPayResult(2); |
| | | //会员结算 |
| | | orderInfo.setStatus(OrderStatusEnum.WAIT_PAY.getValue()); |
| | | mallOrderInfoMapper.insert(orderInfo); |
| | |
| | | orderInfo.setIsApp(AppContants.IS_APP_ORDER); |
| | | orderInfo.setOrderTime(new Date()); |
| | | orderInfo.setStatus(OrderStatusEnum.WAIT_PAY.getValue()); |
| | | orderInfo.setPayResult(2); |
| | | if (CollUtil.isEmpty(addOrderDto.getItems())) { |
| | | throw new FebsException("商品明细不能为空。"); |
| | | } |
| | |
| | | orderInfo.setIsApp(AppContants.IS_APP_ORDER); |
| | | orderInfo.setOrderTime(new Date()); |
| | | orderInfo.setStatus(OrderStatusEnum.WAIT_PAY.getValue()); |
| | | orderInfo.setPayResult(2); |
| | | if (CollUtil.isEmpty(addOrderDto.getItems())) { |
| | | throw new FebsException("商品明细不能为空。"); |
| | | } |
| | |
| | | return new FebsResponse().success().message("订单已取消"); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse wxCodePay(ApiWxCodePayDto wxCodePayDto) { |
| | | Long orderId = wxCodePayDto.getOrderId(); |
| | | String wxPayCode = wxCodePayDto.getWxPayCode(); |
| | | /** |
| | | * auth_code 扫码支付付款码 微信付款码规则:18位纯数字,前缀以10、11、12、13、14、15开头 |
| | | */ |
| | | String regex = "^(10|11|12|13|14|15)\\d{16}$"; |
| | | boolean flag = wxPayCode.matches(regex); |
| | | if(!flag){ |
| | | throw new FebsException("请打开微信付款码!"); |
| | | } |
| | | MallOrderInfo mallOrderInfo = mallOrderInfoMapper.selectById(orderId); |
| | | if(OrderStatusEnum.FINISH.getValue() == (mallOrderInfo.getStatus())){ |
| | | throw new FebsException("已支付"); |
| | | } |
| | | mallOrderInfo.setTakeCode(wxPayCode); |
| | | List<ApiGetOrderOrderItemVo> appOrderItemByOrderId = mallOrderItemMapper.getAppOrderItemByOrderId(orderId); |
| | | if(CollUtil.isEmpty(appOrderItemByOrderId)){ |
| | | mallOrderInfo.setName("商品"); |
| | | }else{ |
| | | mallOrderInfo.setName(appOrderItemByOrderId.get(0).getGoodsName()); |
| | | } |
| | | // mallOrderInfo.setPayResult(2); |
| | | mallOrderInfoMapper.updateById(mallOrderInfo); |
| | | // 发起付款码支付请求 |
| | | String payResult = xcxCodePayService.pay(mallOrderInfo); |
| | | return new FebsResponse().success().message(payResult); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse cancelOrder(Long id) { |
| | | MallOrderInfo orderInfo = mallOrderInfoMapper.selectById(id); |
| | | if (orderInfo == null || AppContants.DEL_FLAG_Y == orderInfo.getDelFlag()) { |
| | | throw new FebsException("订单不存在"); |
| | | } |
| | | |
| | | if (OrderStatusEnum.WAIT_PAY.getValue() != orderInfo.getStatus()) { |
| | | throw new FebsException("订单不是待付款, 无法取消"); |
| | | } |
| | | |
| | | orderInfo.setStatus(OrderStatusEnum.CANCEL.getValue()); |
| | | orderInfo.setCancelType(MallOrderInfo.CANCEL_BY_SELF); |
| | | mallOrderInfoMapper.updateById(orderInfo); |
| | | return new FebsResponse().success().message("取消成功"); |
| | | } |
| | | |
| | | public String generateAsaToken(String token) { |
| | | RSA rsa = new RSA(null, AppContants.PUBLIC_KEY); |
| | | return rsa.encryptBase64(token + "_" + System.currentTimeMillis(), KeyType.PublicKey); |