You've already forked FrameTour-BE
订单改改改
This commit is contained in:
@@ -6,7 +6,6 @@ import com.aliyuncs.utils.StringUtils;
|
||||
import com.wechat.pay.java.core.Config;
|
||||
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
||||
import com.wechat.pay.java.core.exception.ServiceException;
|
||||
import com.wechat.pay.java.core.http.HttpMethod;
|
||||
import com.wechat.pay.java.core.notification.NotificationConfig;
|
||||
import com.wechat.pay.java.core.notification.NotificationParser;
|
||||
import com.wechat.pay.java.core.notification.RequestParam;
|
||||
@@ -46,7 +45,6 @@ import com.ycwl.basic.service.HttpService;
|
||||
import com.ycwl.basic.service.mobile.WxPayService;
|
||||
import com.ycwl.basic.service.pc.OrderService;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
import com.ycwl.basic.utils.DateUtils;
|
||||
import com.ycwl.basic.utils.SnowFlakeUtil;
|
||||
import com.ycwl.basic.utils.WXPayUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -204,42 +202,7 @@ public class WxPayServiceImpl implements WxPayService {
|
||||
}
|
||||
if (Objects.nonNull(OrderStateEnum)) {
|
||||
long orderId = Long.parseLong(parse.getOutTradeNo());
|
||||
try {
|
||||
orderService.updateOrderState(orderId, OrderStateEnum, null);
|
||||
// 添加统计数据
|
||||
statisticsHandler(orderId);
|
||||
}catch (Exception e) {
|
||||
log.error("[微信支付回调]更新订单状态失败", e);
|
||||
}
|
||||
OrderRespVO byId = orderMapper.getById(orderId);
|
||||
List<OrderItemEntity> orderItemList = orderMapper.listOrderItemByOrderId(orderId);
|
||||
orderItemList.forEach(orderItemVO -> {
|
||||
orderRepository.clearUserBuyItemCache(byId.getMemberId(), orderItemVO.getGoodsType(), orderItemVO.getGoodsId());
|
||||
switch (orderItemVO.getGoodsType()) {
|
||||
case 0: // 成片
|
||||
MemberVideoEntity memberVideoEntity = new MemberVideoEntity();
|
||||
memberVideoEntity.setMemberId(byId.getMemberId());
|
||||
memberVideoEntity.setVideoId(orderItemVO.getGoodsId());
|
||||
memberVideoEntity.setIsBuy(1);
|
||||
memberVideoEntity.setOrderId(orderId);
|
||||
videoMapper.updateRelation(memberVideoEntity);
|
||||
break;
|
||||
case 1: // 源视频
|
||||
case 2: // 源素材
|
||||
MemberSourceEntity memberSourceEntity = new MemberSourceEntity();
|
||||
memberSourceEntity.setMemberId(byId.getMemberId());
|
||||
// 源素材的goodsId是人脸ID
|
||||
memberSourceEntity.setFaceId(orderItemVO.getGoodsId());
|
||||
memberSourceEntity.setType(orderItemVO.getGoodsType());
|
||||
memberSourceEntity.setIsBuy(1);
|
||||
memberSourceEntity.setOrderId(orderId);
|
||||
sourceMapper.updateRelation(memberSourceEntity);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
notifyOrderSuccess(orderId);
|
||||
}
|
||||
}).start();
|
||||
} catch (Exception e) {
|
||||
@@ -247,6 +210,45 @@ public class WxPayServiceImpl implements WxPayService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyOrderSuccess(Long orderId) {
|
||||
try {
|
||||
orderService.updateOrderState(orderId, OrderStateEnum.PAID, null);
|
||||
// 添加统计数据
|
||||
statisticsHandler(orderId);
|
||||
}catch (Exception e) {
|
||||
log.error("[微信支付回调]更新订单状态失败", e);
|
||||
}
|
||||
OrderRespVO byId = orderMapper.getById(orderId);
|
||||
List<OrderItemEntity> orderItemList = orderMapper.listOrderItemByOrderId(orderId);
|
||||
orderItemList.forEach(orderItemVO -> {
|
||||
orderRepository.clearUserBuyItemCache(byId.getMemberId(), orderItemVO.getGoodsType(), orderItemVO.getGoodsId());
|
||||
switch (orderItemVO.getGoodsType()) {
|
||||
case 0: // 成片
|
||||
MemberVideoEntity memberVideoEntity = new MemberVideoEntity();
|
||||
memberVideoEntity.setMemberId(byId.getMemberId());
|
||||
memberVideoEntity.setVideoId(orderItemVO.getGoodsId());
|
||||
memberVideoEntity.setIsBuy(1);
|
||||
memberVideoEntity.setOrderId(orderId);
|
||||
videoMapper.updateRelation(memberVideoEntity);
|
||||
break;
|
||||
case 1: // 源视频
|
||||
case 2: // 源素材
|
||||
MemberSourceEntity memberSourceEntity = new MemberSourceEntity();
|
||||
memberSourceEntity.setMemberId(byId.getMemberId());
|
||||
// 源素材的goodsId是人脸ID
|
||||
memberSourceEntity.setFaceId(orderItemVO.getGoodsId());
|
||||
memberSourceEntity.setType(orderItemVO.getGoodsType());
|
||||
memberSourceEntity.setIsBuy(1);
|
||||
memberSourceEntity.setOrderId(orderId);
|
||||
sourceMapper.updateRelation(memberSourceEntity);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//
|
||||
private void statisticsHandler(Long orderId) {
|
||||
ApiResponse<OrderRespVO> orderDetail = orderService.detail(orderId);
|
||||
|
||||
Reference in New Issue
Block a user