Commit c5c7ee3a by ping.wu

现金支付扣减积分优化

parent 5d6b1acd
...@@ -66,6 +66,7 @@ import org.springframework.stereotype.Component; ...@@ -66,6 +66,7 @@ import org.springframework.stereotype.Component;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
@Component @Component
public class PointsMallOrderServiceImpl implements PointsMallOrderService { public class PointsMallOrderServiceImpl implements PointsMallOrderService {
...@@ -198,7 +199,7 @@ public class PointsMallOrderServiceImpl implements PointsMallOrderService { ...@@ -198,7 +199,7 @@ public class PointsMallOrderServiceImpl implements PointsMallOrderService {
return ResponseUtil.error(createOrderResponseDto.getCode(), "支付异常," + response.getData().getResultMsg()); return ResponseUtil.error(createOrderResponseDto.getCode(), "支付异常," + response.getData().getResultMsg());
} }
//唤起支付返回参数 //唤起支付返回参数
pointsMallOrderAdapter.convent2CreateOrderResponseVo(createOrderResponseVo,appId,response.getData()); pointsMallOrderAdapter.convent2CreateOrderResponseVo(createOrderResponseVo, appId, response.getData());
} }
//保存支付信息 //保存支付信息
BaseResponse baseResponse1 = updateOrder(orderCode, points, cashPrice, partnerId, storeId, createOrderResponseVo.getFmId(), channel); BaseResponse baseResponse1 = updateOrder(orderCode, points, cashPrice, partnerId, storeId, createOrderResponseVo.getFmId(), channel);
...@@ -213,7 +214,7 @@ public class PointsMallOrderServiceImpl implements PointsMallOrderService { ...@@ -213,7 +214,7 @@ public class PointsMallOrderServiceImpl implements PointsMallOrderService {
} }
//全积分支付商品,订单完成 //全积分支付商品,订单完成
if (ExchangeTypeEnum.TYPE_1.getCode().equals(exchangeType)) { if (ExchangeTypeEnum.TYPE_1.getCode().equals(exchangeType)) {
BaseResponse response1 = orderPaySuccess(createOrderResponseDto.getResult(), points,false); BaseResponse response1 = orderPaySuccess(createOrderResponseDto.getResult(), points, false);
if (!Objects.equals(ResponseCodeConstant.RESPONSE_SUCCESS_STR, response1.getCode())) { if (!Objects.equals(ResponseCodeConstant.RESPONSE_SUCCESS_STR, response1.getCode())) {
return response1; return response1;
} }
...@@ -287,7 +288,7 @@ public class PointsMallOrderServiceImpl implements PointsMallOrderService { ...@@ -287,7 +288,7 @@ public class PointsMallOrderServiceImpl implements PointsMallOrderService {
orderItemList.add(orderItemResp); orderItemList.add(orderItemResp);
} }
orderInfo.setOrderItemList(orderItemList); orderInfo.setOrderItemList(orderItemList);
BaseResponse baseResponse = orderPaySuccess(orderInfo, 0,true); BaseResponse baseResponse = orderPaySuccess(orderInfo, 0, true);
if (!Objects.equals(ResponseCodeConstant.RESPONSE_SUCCESS_STR, baseResponse.getCode())) { if (!Objects.equals(ResponseCodeConstant.RESPONSE_SUCCESS_STR, baseResponse.getCode())) {
return refundFaileMessage(baseResponse.getMessage()); return refundFaileMessage(baseResponse.getMessage());
} }
...@@ -515,7 +516,7 @@ public class PointsMallOrderServiceImpl implements PointsMallOrderService { ...@@ -515,7 +516,7 @@ public class PointsMallOrderServiceImpl implements PointsMallOrderService {
//共用支付成功方法 //共用支付成功方法
private BaseResponse orderPaySuccess(OrderInfoReqs orderInfo, Integer points,Boolean isCash) { private BaseResponse orderPaySuccess(OrderInfoReqs orderInfo, Integer points, Boolean isCash) {
String nickName = orderInfo.getUserName(); String nickName = orderInfo.getUserName();
String orderCode = orderInfo.getOrderCode(); String orderCode = orderInfo.getOrderCode();
String partnerId = orderInfo.getPartnerId(); String partnerId = orderInfo.getPartnerId();
...@@ -557,12 +558,16 @@ public class PointsMallOrderServiceImpl implements PointsMallOrderService { ...@@ -557,12 +558,16 @@ public class PointsMallOrderServiceImpl implements PointsMallOrderService {
return ResponseUtil.error(updateOrderStateResp.getCode(), "更新订单异常"); return ResponseUtil.error(updateOrderStateResp.getCode(), "更新订单异常");
} }
//有现金支付,扣减积分 //有现金支付,扣减积分
if (isCash) { if (isCash && CollectionUtils.isNotEmpty(orderInfo.getOrderPayItemCreateReqList())) {
points = orderInfo.getOrderPayItemCreateReqList().get(0).getPayAmount().intValue(); List<OrderPayItemResp> collect = orderInfo.getOrderPayItemCreateReqList().stream().filter(orderPayItemResp ->
UseScoreRequest userScoreRequest = pointsMallOrderAdapter.convent2UseScoreRequest(partnerId, memberId, appId, orderCode, points); orderPayItemResp.getPayChannelType().equals(PayChannelType.POINTS.getIndex().intValue())).collect(Collectors.toList());
CustomerPropertyBaseResponse baseResponse = customerPropertyClient.useScore(userScoreRequest); if (CollectionUtils.isNotEmpty(collect)) {
if (!Objects.equals(ResponseCodeConstant.RESPONSE_SUCCESS_STR, baseResponse.getCode())) { points = collect.get(0).getPayAmount().intValue();
return ResponseUtil.error(baseResponse.getCode(), "扣减积分失败"); UseScoreRequest userScoreRequest = pointsMallOrderAdapter.convent2UseScoreRequest(partnerId, memberId, appId, orderCode, points);
CustomerPropertyBaseResponse baseResponse = customerPropertyClient.useScore(userScoreRequest);
if (!Objects.equals(ResponseCodeConstant.RESPONSE_SUCCESS_STR, baseResponse.getCode())) {
return ResponseUtil.error(baseResponse.getCode(), "扣减积分失败");
}
} }
} }
return ResponseUtil.success(); return ResponseUtil.success();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment