|
|
@@ -53,6 +53,7 @@ import com.cyksj.mapper.market.task.UserBindDetailMapper;
|
|
|
import com.cyksj.model.dto.*;
|
|
|
import com.cyksj.model.entity.Address;
|
|
|
import com.cyksj.model.entity.*;
|
|
|
+import com.cyksj.model.manage.dto.GiftCardDto;
|
|
|
import com.cyksj.model.manage.views.GroupsRelationView;
|
|
|
import com.cyksj.model.manage.views.OrderDonView;
|
|
|
import com.cyksj.model.request.GiftCardPayReq;
|
|
|
@@ -232,7 +233,11 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
public OrderDon submit(OrderPayRequest payRequest) throws Exception {
|
|
|
GoodsDonSku sku = null;
|
|
|
Long goodsId;
|
|
|
- List<GiftCardPayReq> giftCards = payRequest.getGiftCards();
|
|
|
+ List<GiftCardPayReq> giftCards = null;
|
|
|
+ GiftCardDto gcPayInfo = payRequest.getGcPayInfo();
|
|
|
+ if (gcPayInfo != null && gcPayInfo.getGiftCards() != null) {
|
|
|
+ giftCards = gcPayInfo.getGiftCards();
|
|
|
+ }
|
|
|
AtomicBoolean isGiftCardPay = new AtomicBoolean(false);
|
|
|
if (CollUtil.isNotEmpty(giftCards)) {
|
|
|
goodsId = payRequest.getGoodsId();
|
|
|
@@ -462,8 +467,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
|
orderDon.setSpecialType(goodsDon.getSpecialType());
|
|
|
//礼品卡购买记录
|
|
|
- if (CollUtil.isNotEmpty(payRequest.getGiftCards())) {
|
|
|
- redisService.set(RedisService.key.GIFT_CARD_USER_PAY_SUCCESS_RECORD_KEY.getName() + orderDon.getId(), payRequest.getGiftCards(), RedisService.key.GIFT_CARD_USER_PAY_SUCCESS_RECORD_KEY.getTimeout());
|
|
|
+ if (CollUtil.isNotEmpty(giftCards)) {
|
|
|
+ redisService.set(RedisService.key.GIFT_CARD_USER_PAY_SUCCESS_RECORD_KEY.getName() + orderDon.getId(), gcPayInfo, RedisService.key.GIFT_CARD_USER_PAY_SUCCESS_RECORD_KEY.getTimeout());
|
|
|
}
|
|
|
//礼品卡现金使用记录
|
|
|
if (CollUtil.isNotEmpty(orderDon.getGcUseRecords())) {
|
|
|
@@ -2074,10 +2079,10 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
//礼品卡购买记录
|
|
|
Object giftCardPay = redisService.get(RedisService.key.GIFT_CARD_USER_PAY_SUCCESS_RECORD_KEY.getName() + orderDon.getId());
|
|
|
if (giftCardPay != null) {
|
|
|
- List<GiftCardPayReq> giftCardPayReqs = Jsons.parseList(giftCardPay, GiftCardPayReq.class);
|
|
|
- if (CollUtil.isNotEmpty(giftCardPayReqs)) {
|
|
|
+ GiftCardDto giftCardDto = Jsons.parseObject(giftCardPay.toString(), GiftCardDto.class);
|
|
|
+ if (giftCardDto != null) {
|
|
|
log.info("记录用户userId:{}订单orderId:{}购买成功礼品卡", orderDon.getUserId(), orderDon.getId());
|
|
|
- giftCardUserPayRecord(giftCardPayReqs, orderDon);
|
|
|
+ giftCardUserPayRecord(giftCardDto, orderDon);
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
@@ -2136,17 +2141,20 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
/**
|
|
|
* 用户购买成功礼品卡记录
|
|
|
*/
|
|
|
- private void giftCardUserPayRecord(List<GiftCardPayReq> giftCards, OrderDon orderDon) {
|
|
|
+ private void giftCardUserPayRecord(GiftCardDto giftCardDto, OrderDon orderDon) {
|
|
|
//礼品卡规格
|
|
|
Map<Long, Integer> giftCardPayNumMap = new ConcurrentHashMap<>();
|
|
|
AtomicInteger init_size = new AtomicInteger(0);
|
|
|
+ List<GiftCardPayReq> giftCards = giftCardDto.getGiftCards();
|
|
|
+ String gcImg = giftCardDto.getGcImg();
|
|
|
+ String gcShowType = giftCardDto.getGcShowType();
|
|
|
giftCards.stream().forEach(data -> {
|
|
|
giftCardPayNumMap.putIfAbsent(data.getGcId(), data.getNum());
|
|
|
init_size.addAndGet(data.getNum());
|
|
|
});
|
|
|
List<GiftCardGoodsSkuFrontView> giftCardViews = beanSearcher.searchAll(GiftCardGoodsSkuFrontView.class, MapUtils.builder().field(GiftCardGoodsSkuFrontView::getId, giftCardPayNumMap.keySet()).build());
|
|
|
if (giftCardViews.size() != giftCards.size()) {
|
|
|
- throw BusinessRuntimeException.getInstance("系统异常,请刷新页面重试");
|
|
|
+ log.info("用户userId:{}购买orderId:{}成功后,礼品卡兑换数量错误", orderDon.getUserId(), orderDon.getId());
|
|
|
}
|
|
|
List<GiftCardUserRecord> gcUserPayRecords = new ArrayList<>(init_size.get());
|
|
|
for (GiftCardGoodsSkuFrontView data : giftCardViews) {
|
|
|
@@ -2168,6 +2176,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
giftCardUserRecord.setUserId(orderDon.getUserId());
|
|
|
giftCardUserRecord.setGcType(data.getGcType());
|
|
|
giftCardUserRecord.setGcDetail(gcDetail);
|
|
|
+ giftCardUserRecord.setType(gcShowType);
|
|
|
+ giftCardUserRecord.setImg(gcImg);
|
|
|
gcUserPayRecords.add(giftCardUserRecord);
|
|
|
}
|
|
|
}
|