Commit 64ea212c by huiyang.chen

svc卡支付

parent 038fc4f8
...@@ -146,6 +146,24 @@ public class OrderController { ...@@ -146,6 +146,24 @@ public class OrderController {
} }
/** /**
* 围餐-svc卡支付调用接口-预览订单
* @param queryOrderVo
* @return
*/
@ApiAnnotation(logMessage = "previewOrderInfoSvcCheck")
@PostMapping("/previewOrderInfoSvcCheck")
public BaseResponse previewOrderInfoSvcCheck(@Validated @LogParams @RequestBody QueryOrderVo queryOrderVo){
CreateReserveOrderVo createReserveOrderVo = new CreateReserveOrderVo();
createReserveOrderVo.setSessionId(queryOrderVo.getSessionId());
createReserveOrderVo.setActivityCode(queryOrderVo.getActivityCode());
createReserveOrderVo.setCouponCode(queryOrderVo.getCouponCode());
createReserveOrderVo.setUseCustomerScore(queryOrderVo.getUseCustomerScore());
createReserveOrderVo.setCardCode(queryOrderVo.getCardCode());
createReserveOrderVo.setPartnerId(queryOrderVo.getPartnerId());
return encircleOrderService.previewOrderInfoSvcCheck(createReserveOrderVo);
}
/**
* 获取订单详情 * 获取订单详情
*/ */
@ApiAnnotation(logMessage = "queryOrderById") @ApiAnnotation(logMessage = "queryOrderById")
......
...@@ -76,4 +76,9 @@ public class QueryOrderVo { ...@@ -76,4 +76,9 @@ public class QueryOrderVo {
*/ */
private Integer useCustomerScore; private Integer useCustomerScore;
/**
* svc 卡支付使用
*/
private String cardCode;
} }
...@@ -18,6 +18,11 @@ import javax.validation.constraints.NotNull; ...@@ -18,6 +18,11 @@ import javax.validation.constraints.NotNull;
public class CreateReserveOrderVo extends EncircleReserveBaseVo{ public class CreateReserveOrderVo extends EncircleReserveBaseVo{
/**
* 商户ID
*/
private String partnerId;
private Integer repastNumber; private Integer repastNumber;
private Integer carVer; private Integer carVer;
...@@ -42,4 +47,8 @@ public class CreateReserveOrderVo extends EncircleReserveBaseVo{ ...@@ -42,4 +47,8 @@ public class CreateReserveOrderVo extends EncircleReserveBaseVo{
* 3=显示积分且扣减 * 3=显示积分且扣减
*/ */
private Integer useCustomerScore; private Integer useCustomerScore;
/**
* svc 卡支付使用
*/
private String cardCode;
} }
...@@ -116,5 +116,9 @@ public class PreviewOrderInfoVo { ...@@ -116,5 +116,9 @@ public class PreviewOrderInfoVo {
* 用户积分抵扣信息 * 用户积分抵扣信息
*/ */
private ShoppingCartCustomerScoreVo customerScoreVo; private ShoppingCartCustomerScoreVo customerScoreVo;
/**
* svc卡支付描述
*/
private String svcDiscountDesc;
} }
...@@ -31,7 +31,7 @@ public enum ResponseResult { ...@@ -31,7 +31,7 @@ public enum ResponseResult {
USER_ADDRECEIVEADDRESS_ERROR("41010", "新增收货地址异常"), USER_ADDRECEIVEADDRESS_ERROR("41010", "新增收货地址异常"),
USER_DELETERECEIVEADDRESS_ERROR("41011", "删除收货地址异常"), USER_DELETERECEIVEADDRESS_ERROR("41011", "删除收货地址异常"),
USER_SVC_CARD_ERROR("41012", "用户卡号异常"), USER_SVC_CARD_ERROR("41012", "用户卡号异常"),
USER_SVC_CARD_AMOUNT_DEFICIENCY("41013", "储值卡余额不足"),
/** /**
* 验证码 状态码 * 验证码 状态码
......
...@@ -61,4 +61,10 @@ public interface EncircleOrderService { ...@@ -61,4 +61,10 @@ public interface EncircleOrderService {
*/ */
BaseResponse emptyTableNumber(EmptyTableNumberVo emptyTableNumberVo); BaseResponse emptyTableNumber(EmptyTableNumberVo emptyTableNumberVo);
/**
* 围餐--svc卡支付预览订单
* @param createReserveOrderVo
* @return
*/
BaseResponse previewOrderInfoSvcCheck(CreateReserveOrderVo createReserveOrderVo);
} }
...@@ -42,8 +42,10 @@ import com.freemud.application.sdk.api.ordercenter.enums.ProductTypeEnum; ...@@ -42,8 +42,10 @@ import com.freemud.application.sdk.api.ordercenter.enums.ProductTypeEnum;
import com.freemud.application.sdk.api.ordercenter.request.OrderExtInfoDto; import com.freemud.application.sdk.api.ordercenter.request.OrderExtInfoDto;
import com.freemud.application.sdk.api.paymentcenter.client.request.PaymentCloseUnifiedOrderRequest; import com.freemud.application.sdk.api.paymentcenter.client.request.PaymentCloseUnifiedOrderRequest;
import com.freemud.application.sdk.api.paymentcenter.client.request.PaymentQueryRequest; import com.freemud.application.sdk.api.paymentcenter.client.request.PaymentQueryRequest;
import com.freemud.application.sdk.api.paymentcenter.client.request.SVCCardAmountRequest;
import com.freemud.application.sdk.api.paymentcenter.client.response.PaymentCloseUnifiedOrderResponse; import com.freemud.application.sdk.api.paymentcenter.client.response.PaymentCloseUnifiedOrderResponse;
import com.freemud.application.sdk.api.paymentcenter.client.response.PaymentQueryResponse; import com.freemud.application.sdk.api.paymentcenter.client.response.PaymentQueryResponse;
import com.freemud.application.sdk.api.paymentcenter.client.response.SVCCardAmountResponse;
import com.freemud.application.sdk.api.paymentcenter.client.service.PaymentNewService; import com.freemud.application.sdk.api.paymentcenter.client.service.PaymentNewService;
import com.freemud.application.sdk.api.storecenter.request.GetStoreTableRequest; import com.freemud.application.sdk.api.storecenter.request.GetStoreTableRequest;
import com.freemud.application.sdk.api.storecenter.response.GetStoreTableResponse; import com.freemud.application.sdk.api.storecenter.response.GetStoreTableResponse;
...@@ -64,10 +66,8 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -64,10 +66,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.math.BigDecimal;
import java.util.Collections; import java.util.*;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -404,6 +404,56 @@ public class EncircleOrderServiceImpl implements EncircleOrderService { ...@@ -404,6 +404,56 @@ public class EncircleOrderServiceImpl implements EncircleOrderService {
} }
@Override @Override
public BaseResponse previewOrderInfoSvcCheck(CreateReserveOrderVo createReserveOrderVo) {
if (StringUtils.isBlank(createReserveOrderVo.getCardCode())) {
return ResponseUtil.error(ResponseResult.PARAMETER_MISSING);
}
BaseResponse<PreviewOrderInfoVo> baseResponse = queryOrderInfo(createReserveOrderVo);
if (baseResponse == null || !ResponseResult.SUCCESS.getCode().equals(baseResponse.getCode())) {
return baseResponse;
}
PreviewOrderInfoVo shoppingCartGoodsResponseVo = baseResponse.getResult();
String partnerId = createReserveOrderVo.getPartnerId();
//SVC卡支付
SVCCardPay(createReserveOrderVo.getCardCode(), partnerId, shoppingCartGoodsResponseVo);
return ResponseUtil.success();
}
/**
* 储值卡支付余额校验
*/
private void SVCCardPay(String cardCode, String partnerId,
PreviewOrderInfoVo previewOrderInfoVo) {
if (StringUtils.isBlank(cardCode)) {
return;
}
Integer orderAmount = previewOrderInfoVo.getAmount().intValue();
String trackingNo = LogThreadLocal.getTrackingNo();
SVCCardAmountRequest request = new SVCCardAmountRequest();
request.setPartnerId(partnerId);
request.setCardCodes(Arrays.asList(cardCode));
//查询svc卡金额
com.freemud.application.sdk.api.base.BaseResponse<SVCCardAmountResponse> response = paymentNewService.querySVCCardAmount(request, trackingNo);
if (response == null) {
throw new ServiceException(ResponseResult.SYSTEM_BUSINESS_ERROR);
}
if (response.getData() == null || response.getData().getData() == null || response.getData().getData().getCardSimpleInfos().size() > 1) {
throw new ServiceException(ResponseResult.USER_SVC_CARD_ERROR);
}
Integer amount1 = response.getData().getData().getCardSimpleInfos().get(0).getAmount();
Integer vamount = response.getData().getData().getCardSimpleInfos().get(0).getVamount();
if (orderAmount > amount1 + vamount) {
throw new ServiceException(ResponseResult.USER_SVC_CARD_AMOUNT_DEFICIENCY);
}
BigDecimal bigDecimal = new BigDecimal(orderAmount);
String amountStr = bigDecimal.divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP).toString();
previewOrderInfoVo.setAmount(0L);
previewOrderInfoVo.setSvcDiscountDesc("储值卡支付¥" + amountStr);
}
@Override
public BaseResponse createPrepaymentOrder(CreateReserveOrderVo createReserveOrderVo) { public BaseResponse createPrepaymentOrder(CreateReserveOrderVo createReserveOrderVo) {
//获取缓存(用户信息,桌号信息,桌号与订单号信息) //获取缓存(用户信息,桌号信息,桌号与订单号信息)
AssortmentCustomerInfoVo assortmentCustomerInfoVo = assortmentCustomerInfoManager.getCustomerInfoByObject(createReserveOrderVo.getSessionId()); AssortmentCustomerInfoVo assortmentCustomerInfoVo = assortmentCustomerInfoManager.getCustomerInfoByObject(createReserveOrderVo.getSessionId());
...@@ -414,6 +464,8 @@ public class EncircleOrderServiceImpl implements EncircleOrderService { ...@@ -414,6 +464,8 @@ public class EncircleOrderServiceImpl implements EncircleOrderService {
if(StringUtils.isBlank(orderId)){ if(StringUtils.isBlank(orderId)){
return ResponseUtil.error(ResponseResult.ORDER_QUERYORDER_ERROR); return ResponseUtil.error(ResponseResult.ORDER_QUERYORDER_ERROR);
} }
// 校验svc卡
checkOrder.checkCardCode(createReserveOrderVo.getPartnerId(),assortmentCustomerInfoVo.getMemberId(), createReserveOrderVo.getCardCode());
CreateOrderResponseVo orderResponseVo = null; CreateOrderResponseVo orderResponseVo = null;
//拉取订单详细信息 //拉取订单详细信息
BaseQueryOrderRequest baseQueryOrderRequest = new BaseQueryOrderRequest(); BaseQueryOrderRequest baseQueryOrderRequest = new BaseQueryOrderRequest();
...@@ -503,7 +555,7 @@ public class EncircleOrderServiceImpl implements EncircleOrderService { ...@@ -503,7 +555,7 @@ public class EncircleOrderServiceImpl implements EncircleOrderService {
//此处使用订单修改金额后的金额数据显示支付 //此处使用订单修改金额后的金额数据显示支付
queryOrderByIdResponse.getData().setAmount(baseOrderResponse.getData().getAmount()); queryOrderByIdResponse.getData().setAmount(baseOrderResponse.getData().getAmount());
//调用预支付 //调用预支付
orderResponseVo = orderCommonService.createPrePaymentOrder(baseOrderResponse.getData(),assortmentCustomerInfoVo,assortmentCustomerInfoVo.getPartnerId(),0); orderResponseVo = orderCommonService.createPrePaymentOrder(baseOrderResponse.getData(),assortmentCustomerInfoVo,assortmentCustomerInfoVo.getPartnerId(),0,createReserveOrderVo.getCardCode());
if(orderResponseVo != null){ if(orderResponseVo != null){
if(orderResponseVo.getPaySuccess()){ if(orderResponseVo.getPaySuccess()){
//如果是商品券支付0元,调用回调接口 //如果是商品券支付0元,调用回调接口
......
...@@ -86,6 +86,7 @@ public class OrderAdapterServiceImpl implements OrderAdapterService { ...@@ -86,6 +86,7 @@ public class OrderAdapterServiceImpl implements OrderAdapterService {
createReserveOrderVo.setOrderUpdateVer(createOrderVo.getOrderUpdateVer()); createReserveOrderVo.setOrderUpdateVer(createOrderVo.getOrderUpdateVer());
createReserveOrderVo.setCouponCode(createOrderVo.getCouponCode()); createReserveOrderVo.setCouponCode(createOrderVo.getCouponCode());
createReserveOrderVo.setUseCustomerScore(createOrderVo.getUseCustomerScore()); createReserveOrderVo.setUseCustomerScore(createOrderVo.getUseCustomerScore());
createReserveOrderVo.setCardCode(createOrderVo.getCardCode());
if(createOrderVo.getOperation() == null) throw new ServiceException(ResponseResult.ORDER_CREATE_OPERATION_ERROR); if(createOrderVo.getOperation() == null) throw new ServiceException(ResponseResult.ORDER_CREATE_OPERATION_ERROR);
switch (createOrderVo.getOperation()){ switch (createOrderVo.getOperation()){
case 2:// 开台 case 2:// 开台
......
...@@ -53,6 +53,7 @@ import com.freemud.sdk.api.assortment.payment.service.StandardPaymentService; ...@@ -53,6 +53,7 @@ import com.freemud.sdk.api.assortment.payment.service.StandardPaymentService;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -103,12 +104,15 @@ public class OrderCommonService { ...@@ -103,12 +104,15 @@ public class OrderCommonService {
private RedisService redisService; private RedisService redisService;
@Autowired @Autowired
private CouponActivityService couponActivityService; private CouponActivityService couponActivityService;
@Autowired
private OrderServiceImpl orderService;
private final Integer RESPONSE_SUCCESS_CODE = 100; private final Integer RESPONSE_SUCCESS_CODE = 100;
/** /**
* 创建预支付信息 * 创建预支付信息
* cardCode svc卡号
*/ */
public CreateOrderResponseVo createPrePaymentOrder(QueryOrdersResponse.DataBean.OrderBean orderBean,AssortmentCustomerInfoVo assortmentCustomerInfoVo, String partnerId, int cardAmount){ public CreateOrderResponseVo createPrePaymentOrder(QueryOrdersResponse.DataBean.OrderBean orderBean,AssortmentCustomerInfoVo assortmentCustomerInfoVo, String partnerId, int cardAmount, String cardCode){
OrderPayResponse orderPayResponse = null; OrderPayResponse orderPayResponse = null;
String wxAppId = assortmentCustomerInfoVo.getWxAppId(); String wxAppId = assortmentCustomerInfoVo.getWxAppId();
//设置支付信息 //设置支付信息
...@@ -120,17 +124,17 @@ public class OrderCommonService { ...@@ -120,17 +124,17 @@ public class OrderCommonService {
paymentRequest.setReverseNotifyiDcUrl(reverseNotifyiDcUrl); paymentRequest.setReverseNotifyiDcUrl(reverseNotifyiDcUrl);
//修改订单信息 //修改订单信息
OrderExtInfoDto orderExtInfoDto = JSONObject.parseObject(orderBean.getExtInfo(), OrderExtInfoDto.class) == null ? new OrderExtInfoDto() : JSONObject.parseObject(orderBean.getExtInfo(), OrderExtInfoDto.class); OrderExtInfoDto orderExtInfoDto = JSONObject.parseObject(orderBean.getExtInfo(), OrderExtInfoDto.class) == null ? new OrderExtInfoDto() : JSONObject.parseObject(orderBean.getExtInfo(), OrderExtInfoDto.class);
if(orderBean.getAmount() > 0){ if(orderBean.getAmount() > 0 && StringUtils.isEmpty(cardCode)) {
try { try {
String transId = orderBean.getOid() + redisService.increment(RedisUtil.getPaymentTransIdSequenceKey(orderBean.getOid()), 1L, TimeUnit.DAYS); String transId = orderBean.getOid() + redisService.increment(RedisUtil.getPaymentTransIdSequenceKey(orderBean.getOid()), 1L, TimeUnit.DAYS);
UnifiedOrderRequest request = orderAdapter.convent2UnifiedOrderRequest(orderBean, paymentRequest, orderBean.getAmount(), cardAmount, transId); UnifiedOrderRequest request = orderAdapter.convent2UnifiedOrderRequest(orderBean, paymentRequest, orderBean.getAmount(), cardAmount, transId);
if(SDKCommonBaseContextWare.getProfile().equals(SDKCommonBaseContextWare.profiles.DEFAULT.getProfile()) if (SDKCommonBaseContextWare.getProfile().equals(SDKCommonBaseContextWare.profiles.DEFAULT.getProfile())
|| SDKCommonBaseContextWare.getProfile().equals(SDKCommonBaseContextWare.profiles.DEV.getProfile()) || SDKCommonBaseContextWare.getProfile().equals(SDKCommonBaseContextWare.profiles.DEV.getProfile())
|| SDKCommonBaseContextWare.getProfile().equals(SDKCommonBaseContextWare.profiles.TEST.getProfile())){ || SDKCommonBaseContextWare.getProfile().equals(SDKCommonBaseContextWare.profiles.TEST.getProfile())) {
request.setAmount(1L); request.setAmount(1L);
} }
ApiLog.info("支付transId :{},payRequest:{}",request.getTransId(),JSON.toJSONString(request)); ApiLog.info("支付transId :{},payRequest:{}", request.getTransId(), JSON.toJSONString(request));
redisService.savePaymentTransIdOrder(RedisUtil.getPaymentTransIdOrderKey(transId), orderBean.getOid(), 1L, TimeUnit.DAYS); redisService.savePaymentTransIdOrder(RedisUtil.getPaymentTransIdOrderKey(transId), orderBean.getOid(), 1L, TimeUnit.DAYS);
com.freemud.application.sdk.api.base.BaseResponse<UnifiedOrderResponse> responseBase = standardPaymentService.unifiedOrder(request, LogThreadLocal.getTrackingNo()); com.freemud.application.sdk.api.base.BaseResponse<UnifiedOrderResponse> responseBase = standardPaymentService.unifiedOrder(request, LogThreadLocal.getTrackingNo());
if (!ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(responseBase.getCode())) { if (!ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(responseBase.getCode())) {
...@@ -148,6 +152,9 @@ public class OrderCommonService { ...@@ -148,6 +152,9 @@ public class OrderCommonService {
//给出支付失败提示 //给出支付失败提示
return null; return null;
} }
}else if(orderBean.getAmount() > 0 && StringUtils.isNotEmpty(cardCode)){
//svc卡支付
orderPayResponse = orderService.svcPay(cardCode, orderBean, paymentRequest, orderBean.getOid(), LogThreadLocal.getTrackingNo());
}else if(orderBean.getAmount() < 0){ }else if(orderBean.getAmount() < 0){
throw new ServiceException(ResponseResult.PAY_AMOUNT_ERROR); throw new ServiceException(ResponseResult.PAY_AMOUNT_ERROR);
}else{ }else{
......
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