|  |  |  | 
|---|
|  |  |  | import cc.mrbird.febs.mall.vo.*; | 
|---|
|  |  |  | import cc.mrbird.febs.pay.model.AgreementPayDto; | 
|---|
|  |  |  | import cc.mrbird.febs.pay.model.AgreementSignDto; | 
|---|
|  |  |  | import cc.mrbird.febs.pay.model.LaKaLaCreateOrderReqDate; | 
|---|
|  |  |  | import cc.mrbird.febs.pay.model.UnipayDto; | 
|---|
|  |  |  | import cc.mrbird.febs.pay.service.IAliPayService; | 
|---|
|  |  |  | import cc.mrbird.febs.pay.service.IPayService; | 
|---|
|  |  |  | import cc.mrbird.febs.pay.service.LaKaLaService; | 
|---|
|  |  |  | import cc.mrbird.febs.pay.service.UnipayService; | 
|---|
|  |  |  | import cc.mrbird.febs.rabbit.producter.AgentProducer; | 
|---|
|  |  |  | import cn.hutool.core.collection.CollUtil; | 
|---|
|  |  |  | 
|---|
|  |  |  | private final IMallAchieveService mallAchieveService; | 
|---|
|  |  |  | private final UnipayService unipayService; | 
|---|
|  |  |  | private final IPayService wechatPayService; | 
|---|
|  |  |  | private final LaKaLaService laKaLaService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private final MallMemberBankSignMapper mallMemberBankSignMapper; | 
|---|
|  |  |  | private final MallMemberBankMapper mallMemberBankMapper; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | this.baseMapper.updateById(orderInfo); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | agentProducer.sendOrderCancelDelayMsg(orderInfo.getId(), 15 * 60 * 1000L); | 
|---|
|  |  |  | return orderInfo.getId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | orderInfo.setPayResult("2"); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case "2": | 
|---|
|  |  |  | //                if (StrUtil.isNotBlank(orderInfo.getPayOrderNo())) { | 
|---|
|  |  |  | //                    payResultStr = orderInfo.getPayOrderNo(); | 
|---|
|  |  |  | //                } else { | 
|---|
|  |  |  | //                    payResultStr = payService.aliPay(orderInfo); | 
|---|
|  |  |  | LaKaLaCreateOrderReqDate laKaLaCreateOrderReqDate = new LaKaLaCreateOrderReqDate(); | 
|---|
|  |  |  | //订单编号 | 
|---|
|  |  |  | laKaLaCreateOrderReqDate.setOut_order_no(orderInfo.getOrderNo()); | 
|---|
|  |  |  | //订单金额,分计 | 
|---|
|  |  |  | laKaLaCreateOrderReqDate.setTotal_amount(orderInfo.getAmount().multiply(new BigDecimal(100)).longValue()); | 
|---|
|  |  |  | List<MallOrderItem> itemsLKL = orderInfo.getItems(); | 
|---|
|  |  |  | //商品名称 | 
|---|
|  |  |  | if(CollUtil.isEmpty(itemsLKL)){ | 
|---|
|  |  |  | laKaLaCreateOrderReqDate.setOrder_info("商品"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | laKaLaCreateOrderReqDate.setOrder_info(itemsLKL.get(0).getGoodsName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | payResultStr = laKaLaService.verifyCreateOrder(laKaLaCreateOrderReqDate); | 
|---|
|  |  |  | JSONObject parseObj = JSONUtil.parseObj(payResultStr); | 
|---|
|  |  |  | String code = parseObj.get("code").toString(); | 
|---|
|  |  |  | if (!"true".equals(code)) { | 
|---|
|  |  |  | throw new FebsException("跳转收银台失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | orderInfo.setPayOrderNo(parseObj.get("payOrderNo").toString()); | 
|---|
|  |  |  | orderInfo.setPayMethod("拉卡拉支付"); | 
|---|
|  |  |  | orderInfo.setPayResult("2"); | 
|---|
|  |  |  | //                UnipayDto unipayDto = new UnipayDto(); | 
|---|
|  |  |  | //                unipayDto.setAmount(orderInfo.getAmount()); | 
|---|
|  |  |  | //                unipayDto.setFrpCode("ALIPAY_H5"); | 
|---|
|  |  |  | //                unipayDto.setTradeMerchantNo("777184100385821"); | 
|---|
|  |  |  | //                unipayDto.setOrderNo(orderInfo.getOrderNo()); | 
|---|
|  |  |  | //                List<MallOrderItem> items = orderInfo.getItems(); | 
|---|
|  |  |  | //                if(CollUtil.isEmpty(items)){ | 
|---|
|  |  |  | //                    unipayDto.setProductName("商品"); | 
|---|
|  |  |  | //                }else{ | 
|---|
|  |  |  | //                    unipayDto.setProductName(items.get(0).getGoodsName()); | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | UnipayDto unipayDto = new UnipayDto(); | 
|---|
|  |  |  | //                unipayDto.setAmount(new BigDecimal("0.01")); | 
|---|
|  |  |  | unipayDto.setAmount(orderInfo.getAmount()); | 
|---|
|  |  |  | unipayDto.setFrpCode("ALIPAY_H5"); | 
|---|
|  |  |  | unipayDto.setTradeMerchantNo("777184100385821"); | 
|---|
|  |  |  | unipayDto.setOrderNo(orderInfo.getOrderNo()); | 
|---|
|  |  |  | List<MallOrderItem> items = orderInfo.getItems(); | 
|---|
|  |  |  | if(CollUtil.isEmpty(items)){ | 
|---|
|  |  |  | unipayDto.setProductName("商品"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | unipayDto.setProductName(items.get(0).getGoodsName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String unipayStr = unipayService.unipay(unipayDto); | 
|---|
|  |  |  | if("fail" == unipayStr){ | 
|---|
|  |  |  | throw new FebsException("支付失败"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //                    JSONUtil.parseObj(unipayStr); | 
|---|
|  |  |  | JSONObject jsonObject = JSONUtil.parseObj(unipayStr); | 
|---|
|  |  |  | payResultStr = (String) jsonObject.get("r7_TrxNo"); | 
|---|
|  |  |  | rcResult = (String) jsonObject.get("rc_Result"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orderInfo.setPayOrderNo(payResultStr); | 
|---|
|  |  |  | orderInfo.setPayMethod("支付宝支付"); | 
|---|
|  |  |  | //                agentProducer.sendOrderReturn(orderInfo.getId()); | 
|---|
|  |  |  | //                String unipayStr = unipayService.unipay(unipayDto); | 
|---|
|  |  |  | //                if("fail" == unipayStr){ | 
|---|
|  |  |  | //                    throw new FebsException("支付失败"); | 
|---|
|  |  |  | //                }else{ | 
|---|
|  |  |  | //                    JSONObject jsonObject = JSONUtil.parseObj(unipayStr); | 
|---|
|  |  |  | //                    payResultStr = (String) jsonObject.get("r7_TrxNo"); | 
|---|
|  |  |  | //                    rcResult = (String) jsonObject.get("rc_Result"); | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //                orderInfo.setPayOrderNo(payResultStr); | 
|---|
|  |  |  | //                orderInfo.setPayMethod("支付宝支付"); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case "3": | 
|---|
|  |  |  | payResultStr = balancePay(orderInfo, payOrderDto.getTradePwd(), "balance"); | 
|---|
|  |  |  | 
|---|
|  |  |  | mallMqRecord.setRetryTimes(2); | 
|---|
|  |  |  | mallMqRecord.setCreateTime(orderInfo.getPayTime()); | 
|---|
|  |  |  | mallMqRecordMapper.insert(mallMqRecord); | 
|---|
|  |  |  | //发送补贴消息 | 
|---|
|  |  |  | agentProducer.sendPerkMoneyMsg(orderInfo.getId()); | 
|---|
|  |  |  | //发送代理自动升级消息 | 
|---|
|  |  |  | agentProducer.sendAutoLevelUpMsg(member.getId()); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case "4": | 
|---|
|  |  |  | if (orderInfo.getOrderType() != 2) { | 
|---|
|  |  |  | 
|---|
|  |  |  | if(prizeScore.compareTo(score) < 0){ | 
|---|
|  |  |  | throw new FebsException("积分不足"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(hasTc){ | 
|---|
|  |  |  | //系统设置的个人贡献点最大值 | 
|---|
|  |  |  | DataDictionaryCustom starGetDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( | 
|---|
|  |  |  | DataDictionaryEnum.STAR_GET.getType(), | 
|---|
|  |  |  | DataDictionaryEnum.STAR_GET.getCode()); | 
|---|
|  |  |  | if(ObjectUtil.isNotEmpty(starGetDic)){ | 
|---|
|  |  |  | String starGetStr = StrUtil.isEmpty(starGetDic.getValue()) ? "0" : starGetDic.getValue(); | 
|---|
|  |  |  | BigDecimal starGet = new BigDecimal(starGetStr); | 
|---|
|  |  |  | BigDecimal star = new BigDecimal(mallMemberWallet.getStar()); | 
|---|
|  |  |  | if(starGet.compareTo(BigDecimal.ZERO) != 0 && starGet.compareTo(star) <= 0){ | 
|---|
|  |  |  | throw new FebsException("无法购买套餐"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 使用积分折扣现金 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | 
|---|
|  |  |  | if(scorePercentMaxAmount.compareTo(score) < 0){ | 
|---|
|  |  |  | throw new FebsException("最多可使用"+scorePercentMaxAmount+"积分"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(hasTc){ | 
|---|
|  |  |  | //系统设置的个人贡献点最大值 | 
|---|
|  |  |  | DataDictionaryCustom starGetDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( | 
|---|
|  |  |  | DataDictionaryEnum.STAR_GET.getType(), | 
|---|
|  |  |  | DataDictionaryEnum.STAR_GET.getCode()); | 
|---|
|  |  |  | if(ObjectUtil.isNotEmpty(starGetDic)){ | 
|---|
|  |  |  | String starGetStr = StrUtil.isEmpty(starGetDic.getValue()) ? "0" : starGetDic.getValue(); | 
|---|
|  |  |  | BigDecimal starGet = new BigDecimal(starGetStr); | 
|---|
|  |  |  | BigDecimal star = new BigDecimal(mallMemberWallet.getStar()); | 
|---|
|  |  |  | if(starGet.compareTo(BigDecimal.ZERO) != 0 && starGet.compareTo(star) <= 0){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new FebsResponse().success().message("购买套餐不会获得贡献点"); | 
|---|
|  |  |  | //                    throw new FebsException("无法购买套餐"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return new FebsResponse().success(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|