| | |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.order.domain.dto.*; |
| | | import com.ruoyi.order.domain.pojo.account.OrderRefund; |
| | | import com.ruoyi.order.domain.pojo.account.PaymentMessage; |
| | | import com.ruoyi.order.domain.pojo.order.ConsumerGoods; |
| | | import com.ruoyi.order.domain.pojo.order.Order; |
| | | import com.ruoyi.order.domain.pojo.order.OrderGoods; |
| | |
| | | import com.ruoyi.order.service.order.OrderGoodsService; |
| | | import com.ruoyi.order.service.order.OrderService; |
| | | import com.ruoyi.order.service.order.UserServiceRecordService; |
| | | import com.ruoyi.order.tools.request.pay.combine.CombineTransactionsJsRequest; |
| | | import com.ruoyi.order.tools.service.ProfitsSharingService; |
| | | import com.ruoyi.system.api.constant.AppErrorConstant; |
| | | import com.ruoyi.system.api.constant.DelayTaskEnum; |
| | | import com.ruoyi.system.api.constant.SecurityConstant; |
| | |
| | | import com.ruoyi.system.api.domain.poji.sys.SysUser; |
| | | import com.ruoyi.system.api.domain.vo.*; |
| | | import com.ruoyi.system.api.service.*; |
| | | import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension; |
| | | import com.wechat.pay.java.service.payments.jsapi.model.*; |
| | | import org.redisson.api.RLock; |
| | | import org.redisson.api.RedissonClient; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.wechat.pay.java.core.Config; |
| | | import com.wechat.pay.java.core.RSAConfig; |
| | | import com.wechat.pay.java.service.payments.jsapi.JsapiService; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Resource |
| | | private RedisService redisService; |
| | | |
| | | @Resource |
| | | private ProfitsSharingService profitsSharingService; |
| | | |
| | | @Autowired |
| | | private RedissonClient redissonClient; |
| | | |
| | | /** 商户号 */ |
| | | public static String merchantId = ""; |
| | | /** 商户API私钥路径 */ |
| | | public static String privateKeyPath = ""; |
| | | /** 商户证书序列号 */ |
| | | public static String merchantSerialNumber = ""; |
| | | /** 微信支付平台证书路径 */ |
| | | public static String wechatPayCertificatePath = ""; |
| | | /** 微信支付 APIv3 密钥 */ |
| | | public static String apiV3Key = ""; |
| | | /** 微信支付APPID */ |
| | | public static String appId=""; |
| | | /** 微信支付商户ID */ |
| | | public static String mchId=""; |
| | | /** 通知地址 */ |
| | | public static String notifyUrl=""; |
| | | |
| | | /** |
| | | * @description: buyGoods |
| | |
| | | appPlaceOrderVo.setOrderId(orderId); |
| | | appPlaceOrderVo.setOrderNo(orderNo); |
| | | // 调用支付 |
| | | /* CombineTransactionsJsRequest request=new CombineTransactionsJsRequest(); |
| | | request.setCombineAppid(); |
| | | request.setCombineMchid(); |
| | | profitsSharingService.combineTransactions(request);*/ |
| | | |
| | | //构建预下单支付对象 |
| | | PrepayRequest request = new PrepayRequest(); |
| | | Amount amount = new Amount(); |
| | | amount.setTotal(Integer.parseInt(order.getPayMoney().multiply(new BigDecimal(100)).toString())); |
| | | request.setAmount(amount); |
| | | request.setAppid(this.appId); |
| | | request.setMchid(this.mchId); |
| | | request.setDescription(order.getGoodsInfo()); |
| | | request.setNotifyUrl(this.notifyUrl); |
| | | request.setOutTradeNo(order.getOrderId()); |
| | | Payer payer = new Payer(); payer.setOpenid("oLTPCuN5a-nBD4rAL_fa********"); |
| | | |
| | | request.setPayer(payer); |
| | | |
| | | |
| | | //返回前端唤醒支付结果信息 |
| | | PrepayWithRequestPaymentResponse res = this.getJsApIResponse(request); |
| | | |
| | | appPlaceOrderVo.setAppId(this.appId); |
| | | appPlaceOrderVo.setTimeStamp(res.getTimeStamp()); |
| | | appPlaceOrderVo.setNonceStr(res.getNonceStr()); |
| | | appPlaceOrderVo.setPackageStr(res.getPackageVal()); |
| | | appPlaceOrderVo.setTradeType(res.getSignType()); |
| | | appPlaceOrderVo.setPaySign(res.getPaySign()); |
| | | |
| | | |
| | | //减去优惠券 |
| | | if(memberCouponSJ!=null){ |
| | | remoteCouponService.useMemberCoupon(memberCouponSJ.toString()); |
| | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * 功能描述: 预下单,返回支付数据prePayId |
| | | * |
| | | * 构建对象参考 |
| | | * PrepayRequest request = new PrepayRequest(); |
| | | * Amount amount = new Amount(); |
| | | * amount.setTotal(100); |
| | | * request.setAmount(amount); |
| | | * request.setAppid("wxa9d9651ae******"); |
| | | * request.setMchid("190000****"); |
| | | * request.setDescription("测试商品标题"); |
| | | * request.setNotifyUrl("https://notify_url"); |
| | | * request.setOutTradeNo("out_trade_no_001"); |
| | | * Payer payer = new Payer(); |
| | | * payer.setOpenid("oLTPCuN5a-nBD4rAL_fa********"); |
| | | * request.setPayer(payer); |
| | | * |
| | | * @auther: linqingsong |
| | | * @date: 2023/7/22 16:13 |
| | | */ |
| | | /*public String getPrePayId(PrepayRequest request) { |
| | | Config config = |
| | | new RSAConfig.Builder() |
| | | .merchantId(merchantId) |
| | | .privateKeyFromPath(privateKeyPath) |
| | | .merchantSerialNumber(merchantSerialNumber) |
| | | .wechatPayCertificatesFromPath(wechatPayCertificatePath) |
| | | .build(); |
| | | JsapiService service = new JsapiService.Builder().config(config).build(); |
| | | PrepayResponse response = service.prepay(request); |
| | | return response.getPrepayId(); |
| | | }*/ |
| | | |
| | | |
| | | /** |
| | | * |
| | | * 功能描述: 预下单,并返回前端需要换起支付的字符串 |
| | | * |
| | | * 构建对象参考 |
| | | * * PrepayRequest request = new PrepayRequest(); |
| | | * * Amount amount = new Amount(); |
| | | * * amount.setTotal(100); |
| | | * * request.setAmount(amount); |
| | | * * request.setAppid("wxa9d9651ae******"); |
| | | * * request.setMchid("190000****"); |
| | | * * request.setDescription("测试商品标题"); |
| | | * * request.setNotifyUrl("https://notify_url"); |
| | | * * request.setOutTradeNo("out_trade_no_001"); |
| | | * * Payer payer = new Payer(); |
| | | * * payer.setOpenid("oLTPCuN5a-nBD4rAL_fa********"); |
| | | * * request.setPayer(payer); |
| | | * |
| | | * |
| | | * @auther: linqingsong |
| | | * @date: 2023/7/22 16:53 |
| | | */ |
| | | public PrepayWithRequestPaymentResponse getJsApIResponse(PrepayRequest request){ |
| | | Config config = |
| | | new RSAConfig.Builder() |
| | | .merchantId(merchantId) |
| | | .privateKeyFromPath(privateKeyPath) |
| | | .merchantSerialNumber(merchantSerialNumber) |
| | | .wechatPayCertificatesFromPath(wechatPayCertificatePath) |
| | | .build(); |
| | | JsapiServiceExtension service = new JsapiServiceExtension.Builder().config(config).build(); |
| | | |
| | | PrepayWithRequestPaymentResponse response = service.prepayWithRequestPayment(request); |
| | | |
| | | return response; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @param appPlaceActivityDto |
| | | * @return AppPlaceOrderVo |
| | | * @description 创建活动订单 |