|
@@ -770,39 +770,6 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
List<AppCoursesPriceRules> priceRulesList = appCoursesPriceRulesMapper.selectList(Wrappers.<AppCoursesPriceRules>lambdaQuery().eq(AppCoursesPriceRules::getCoursesId, appCourse.getId()));
|
|
|
AppSite appSite = appSiteMapper.selectById(appCourse.getAddressSiteId());
|
|
|
|
|
|
- String productId = createOrderForm.getProductIds();
|
|
|
-
|
|
|
- productKey = "ORDER_TYPE_5_PRODUCT_" + productId; // ORDER_TYPE_1_PRODUCT_N001
|
|
|
- stockKey = "ORDER_TYPE_5_PRODUCT_STOCK_" + productId; // ORDER_TYPE_1_PRODUCT_STOCK_N001
|
|
|
-
|
|
|
- // 查询库存
|
|
|
- Integer stock = (Integer) redisTemplate.opsForValue().get(stockKey);
|
|
|
- // 缓存没有商品库存,查询数据库
|
|
|
- if (stock == null) {
|
|
|
- AppSitePriceRules product = appSitePriceRulesMapper.selectById(productId);
|
|
|
- if (Objects.isNull(product)) {
|
|
|
- throw new JeecgBootException("订单提交失败,商品已下架");
|
|
|
- }
|
|
|
- redisTemplate.opsForValue().set(productKey, JSON.toJSONString(product));
|
|
|
- // 数据库的库存信息要根据实际业务来获取,如果商品有规格信息,库存应该根据规格来获取
|
|
|
- stock = product.getTicketNum();
|
|
|
- redisTemplate.opsForValue().set(stockKey, stock);
|
|
|
- }
|
|
|
-
|
|
|
- // 检查库存是否足够
|
|
|
- if (stock < count) {
|
|
|
- throw new JeecgBootException("订单提交失败,库存不足");
|
|
|
- }
|
|
|
-
|
|
|
- // 更新数据库中的库存数据
|
|
|
- int row = appSitePriceRulesMapper.update(null, Wrappers.<AppSitePriceRules>lambdaUpdate()
|
|
|
- .eq(AppSitePriceRules::getId, productId)
|
|
|
- .set(AppSitePriceRules::getTicketNum, stock - count));
|
|
|
- if (row > 0) {
|
|
|
- // 更新Redis中缓存的商品库存数据
|
|
|
- redisTemplate.opsForValue().decrement(stockKey, count);
|
|
|
- }
|
|
|
-
|
|
|
appOrder.setType(CommonConstant.ORDER_TYPE_2);
|
|
|
appOrder.setOrgCode(appCourse.getOrgCode());
|
|
|
appOrder.setTenantId(appCourse.getTenantId());
|
|
@@ -1040,7 +1007,7 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
params.put("attach", appOrder.getOrderCode()); //附加数据 选填
|
|
|
// 在查询API和支付通知中原样返回 可作为自定义参数使用
|
|
|
params.put("notify_url", WechatUrlConstants.PAY_V3_NOTIFY); //支付结果异步通知接口
|
|
|
-
|
|
|
+ params.put("trade_type", WechatConstants.WECHAT_MP_TRADE_TYPE);//JSAPI
|
|
|
//分账必传参数
|
|
|
JSONObject settleInfo = new JSONObject();
|
|
|
settleInfo.put("profit_sharing", Boolean.TRUE);
|
|
@@ -1060,7 +1027,7 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
params.put("payer", payer);
|
|
|
|
|
|
//拉起支付-返回JSAPI参数
|
|
|
-// Map<String, String> result = weChatPayService.wechatPay(params);
|
|
|
+ Map<String, String> result = weChatPayService.wechatPay(params);
|
|
|
// payForm.setParams(result);
|
|
|
|
|
|
//发布任务到redission延迟队列
|