| | |
| | | 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.ecommerce.profitsharing.ProfitSharingApplyRequest; |
| | | 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.core.Config; |
| | | import com.wechat.pay.java.core.RSAConfig; |
| | | import com.wechat.pay.java.service.partnerpayments.jsapi.model.Transaction; |
| | | 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 org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | |
| | | @Resource |
| | | private RedisService redisService; |
| | | |
| | | @Resource |
| | | private ProfitsSharingService profitsSharingService; |
| | | //@Resource |
| | | //@Qualifier("profitsSharingServiceImpl") |
| | | //private ProfitsSharingService profitsSharingService; |
| | | |
| | | @Autowired |
| | | private RedissonClient redissonClient; |
| | |
| | | if(entity.getCouponType()!=1){ |
| | | appGoodsMemberCouponVoList.add(entity); |
| | | }else{ |
| | | if(entity.getMoneyThreshold().compareTo(sureOrderGoodsVo.getGoodsTotalPrice())>0){ |
| | | if(entity.getMoneyThreshold().compareTo(sureOrderGoodsVo.getGoodsTotalPrice())<0){ |
| | | appGoodsMemberCouponVoList.add(entity); |
| | | } |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public AppPlaceOrderVo placeOrder(AppPlaceOrderDto appPlaceOrderDto) { |
| | | // 获取用户ID |
| | | Long userId = appPlaceOrderDto.getUserId(); |
| | |
| | | profitsSharingService.combineTransactions(request);*/ |
| | | |
| | | //构建预下单支付对象 |
| | | PrepayRequest request = new PrepayRequest(); |
| | | /*PrepayRequest request = new PrepayRequest(); |
| | | Amount amount = new Amount(); |
| | | amount.setTotal(Integer.parseInt(order.getPayMoney().multiply(new BigDecimal(100)).toString())); |
| | | request.setAmount(amount); |
| | |
| | | request.setOutTradeNo(order.getOrderId()); |
| | | Payer payer = new Payer(); |
| | | payer.setOpenid("oLTPCuN5a-nBD4rAL_fa********"); |
| | | request.setPayer(payer); |
| | | request.setPayer(payer);*/ |
| | | //返回前端唤醒支付结果信息 |
| | | /*PrepayWithRequestPaymentResponse res = this.getJsApIResponse(request); |
| | | appPlaceOrderVo.setAppId(this.appId); |
| | |
| | | delayTask.setEndTime(DateUtils.addMinutes(new Date(),delayTime)); |
| | | delayTask.setRedisKey(DelayTaskEnum.ORDER_AUTOMATIC_CANCEL.getCode() + "-" + orderId); |
| | | remoteConfigService.addDelayTask(delayTask); |
| | | appPlaceOrderVo.setPayDeadlineTime(DateUtils.addMinutes(order.getCreateTime(),delayTime)); |
| | | appPlaceOrderVo.setEndTime(DateUtils.addMinutes(order.getCreateTime(),delayTime)); |
| | | return appPlaceOrderVo; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * 功能描述: 预下单,返回支付数据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; |
| | | } |
| | | |
| | | |
| | |
| | | * @date 2023/7/6 17:59 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public AppPlaceOrderVo placeActivityOrder(AppPlaceActivityDto appPlaceActivityDto) { |
| | | Long userId = appPlaceActivityDto.getUserId(); |
| | | // 创建订单对象 |
| | |
| | | agStockChangeDto.setUserId(order.getUserId()); |
| | | remoteActivityService.changeActivityStock(agStockChangeDto); |
| | | // 调用支付 |
| | | PrepayRequest request = new PrepayRequest(); |
| | | /*PrepayRequest request = new PrepayRequest(); |
| | | Amount amount = new Amount(); |
| | | amount.setTotal(Integer.parseInt(order.getPayMoney().multiply(new BigDecimal(100)).toString())); |
| | | request.setAmount(amount); |
| | |
| | | // TODO 获取openID |
| | | payer.setOpenid("oLTPCuN5a-nBD4rAL_fa********"); |
| | | |
| | | request.setPayer(payer); |
| | | request.setPayer(payer);*/ |
| | | |
| | | //设置订单允许分账 秒杀活动才允许分账 |
| | | if(order.getOrderFrom()==2){ |
| | | /*if(order.getOrderFrom()==2){ |
| | | SettleInfo settleInfo=new SettleInfo(); |
| | | settleInfo.setProfitSharing(true); |
| | | request.setSettleInfo(settleInfo); |
| | | } |
| | | }*/ |
| | | |
| | | |
| | | //返回前端唤醒支付结果信息 |
| | |
| | | delayTask.setEndTime(DateUtils.addMinutes(new Date(),delayTime)); |
| | | delayTask.setRedisKey(DelayTaskEnum.ORDER_AUTOMATIC_CANCEL.getCode() + "-" + orderId); |
| | | remoteConfigService.addDelayTask(delayTask); |
| | | appPlaceOrderVo.setPayDeadlineTime(DateUtils.addMinutes(order.getCreateTime(),delayTime)); |
| | | appPlaceOrderVo.setEndTime(DateUtils.addMinutes(order.getCreateTime(),delayTime)); |
| | | return appPlaceOrderVo; |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public MerVerifyOrderVo sureVerifyOrder(MerVerifyOrderDto merVerifyOrderDto) { |
| | | String orderId = merVerifyOrderDto.getOrderId(); |
| | | BigDecimal relReceiveMoney = merVerifyOrderDto.getRelReceiveMoney(); |
| | |
| | | * @date 2023/6/28 11:26 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public MerVerifyCouponVo sureVerifyCoupon(MerVerifyCouponDto merVerifyCouponDto) { |
| | | MerVerifyCouponGetVo verifyCouponGetVo = remoteCouponService.getVerifyCoupon(merVerifyCouponDto.getMemberCouponId()).getData(); |
| | | ShopRelUserVo shopRelUserVo = remoteShopService.getShopByUserId(merVerifyCouponDto.getUserId()).getData(); |
| | |
| | | * @return MerVerifyAwardVo |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public MerVerifyAwardVo sureVerifyPrize(MerVerifyPrizeDto merVerifyPrizeDto){ |
| | | MerVerifyAwardVo merVerifyAwardVo = new MerVerifyAwardVo(); |
| | | MemberGiftRecord memberGiftRecord = remoteMemberService.getVerifyPrize(merVerifyPrizeDto.getPrizeId()).getData(); |
| | |
| | | * @return void |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public void autoCancelOrder(String orderId){ |
| | | //更新订单信息 |
| | | Order order = this.getById(orderId); |
| | |
| | | * @description 订单支付回调 |
| | | * @author jqs |
| | | * @date 2023/7/13 17:57 |
| | | * @param Transaction |
| | | * @param transaction |
| | | * @return void |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public void payBack(Transaction transaction) { |
| | | // 更新订单状态 |
| | | String orderId=transaction.getOutTradeNo(); |
| | |
| | | |
| | | |
| | | //活动订单进行分账 |
| | | ProfitSharingApplyRequest request=new ProfitSharingApplyRequest(); |
| | | /*ProfitSharingApplyRequest request=new ProfitSharingApplyRequest(); |
| | | request.setAppid(this.appId); |
| | | request.setSubMchid(""); |
| | | request.setTransactionId(transaction.getTransactionId()); |
| | | profitsSharingService.applyProfitSharing(request); |
| | | profitsSharingService.applyProfitSharing(request);*/ |
| | | } |
| | | //生成支付记录 |
| | | OrderPayment orderPayment = new OrderPayment(); |
| | |
| | | * @return void |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public void refundOrder(String orderId){ |
| | | //更新订单信息 |
| | | Order order = this.getById(orderId); |