Compare commits
2 Commits
bf95ef962f
...
e43f3643f1
| Author | SHA1 | Date |
|---|---|---|
|
|
e43f3643f1 | |
|
|
e17699338b |
|
|
@ -63,6 +63,11 @@ public class HeaderFetchUtil {
|
|||
return NumberUtil.isNumber(value) ? Integer.valueOf(value) : null;
|
||||
}
|
||||
|
||||
public static String getSign(Map<String, String> headers) {
|
||||
String value = getValueFromHeadersIgnoreCase(headers, "sign");
|
||||
return value;
|
||||
}
|
||||
|
||||
public static String getValueFromHeadersIgnoreCase(Map<String, String> headers, String targetKey) {
|
||||
if (CollUtil.isEmpty(headers)) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@ package com.bonus.canteen.core.order.common.business;
|
|||
|
||||
import com.bonus.canteen.core.order.common.constants.OrderRefundBizEnum;
|
||||
import com.bonus.canteen.core.order.common.dto.OrderRefundParam;
|
||||
import com.bonus.canteen.core.order.common.dto.StageRefundParam;
|
||||
import com.bonus.canteen.core.order.common.model.OrderInfo;
|
||||
import com.bonus.canteen.core.order.common.vo.OrderRefundResultVO;
|
||||
import com.bonus.canteen.core.pay.api.vo.UnifyRefundVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -21,4 +23,5 @@ public interface OrderRefundBusiness {
|
|||
// void didEndOrderRefundFlow(Long orderRefundId, boolean isPass, String remark);
|
||||
//
|
||||
// void transferUncheckCorrectAfterOrderCreated(String macOrderId);
|
||||
UnifyRefundVO stageRefund(StageRefundParam stageRefundParam);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ import cn.hutool.core.map.MapUtil;
|
|||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.alibaba.nacos.shaded.com.google.common.collect.Lists;
|
||||
import com.bonus.canteen.core.order.common.dto.StageRefundParam;
|
||||
import com.bonus.canteen.core.pay.common.model.TradeRecord;
|
||||
import com.bonus.canteen.core.pay.common.service.TradeRecordService;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.common.houqin.constant.LeConstants;
|
||||
|
|
@ -133,6 +136,9 @@ public class OrderRefundBusinessImpl implements OrderRefundBusiness {
|
|||
@Autowired
|
||||
@Lazy
|
||||
protected AllocHolidayApi allocHolidayApi;
|
||||
@Lazy
|
||||
@Autowired
|
||||
protected TradeRecordService tradeRecordService;
|
||||
|
||||
public void orderCancel(OrderInfo orderInfo) {
|
||||
if (!this.orderCustomBusiness.refund().willCancelOrder(orderInfo)) {
|
||||
|
|
@ -197,6 +203,21 @@ public class OrderRefundBusinessImpl implements OrderRefundBusiness {
|
|||
return var8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnifyRefundVO stageRefund(StageRefundParam stageRefundParam) {
|
||||
LogUtil.printArgsIn("stagePayRefund", stageRefundParam);
|
||||
TradeRecord tradeRecord = tradeRecordService.getTradeRecordById(stageRefundParam.getTradeId());
|
||||
if (tradeRecord == null) {
|
||||
log.error("[统一支付退款]交易记录不存在");
|
||||
throw new ServiceException("交易记录不存在");
|
||||
}
|
||||
UnifyRefundDTO payRefundDTO = new UnifyRefundDTO();
|
||||
payRefundDTO.setTradeId(stageRefundParam.getTradeId());
|
||||
payRefundDTO.setRefundId(Id.next());
|
||||
payRefundDTO.setRefundAmount(tradeRecord.getAmount());
|
||||
return this.payApi.refund(payRefundDTO);
|
||||
}
|
||||
|
||||
// public void orderCorrect(OrderPartRefundDTO orderPartRefundDTO, OrderRefundBizEnum biz) {
|
||||
// if (CollUtil.isEmpty(orderPartRefundDTO.getDetailRefundList())) {
|
||||
// throw new LeException(I18n.getMessage("order.buffet.correct-lack-detail", new Object[0]));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
package com.bonus.canteen.core.order.common.constants;
|
||||
|
||||
public class StageWhiteList {
|
||||
public static final String STAGE_SIGN_WHITE_LIST = "f678443b-99b4-41ec-8e9a-b7a5c92367f1";
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.bonus.canteen.core.order.common.dto;
|
||||
|
||||
import com.bonus.canteen.core.common.utils.SysUtil;
|
||||
import com.bonus.canteen.core.pay.api.dto.UnifyRefundDTO;
|
||||
import com.bonus.common.houqin.constant.LeConstants;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class StageRefundParam extends OrderRefundParam {
|
||||
private Long tradeId;
|
||||
}
|
||||
|
|
@ -4,7 +4,9 @@ package com.bonus.canteen.core.order.mobile.business;
|
|||
import com.bonus.canteen.core.order.common.dto.RequestHeaderDTO;
|
||||
import com.bonus.canteen.core.order.mobile.dto.OrderPayMobileDTO;
|
||||
import com.bonus.canteen.core.order.mobile.dto.OrderReserveMealTotalDTO;
|
||||
import com.bonus.canteen.core.order.mobile.dto.StagePayMobileDTO;
|
||||
import com.bonus.canteen.core.order.mobile.vo.OrderPayMobileVO;
|
||||
import com.bonus.canteen.core.pay.api.vo.UnifyPayVO;
|
||||
|
||||
public interface OrderPlaceMobileBusiness {
|
||||
// OrderPayMobileVO addCurrentMealOrder(RequestHeaderDTO headerDTO, OrderCurrMealTotalDTO currMealTotalDTO);
|
||||
|
|
@ -22,4 +24,6 @@ public interface OrderPlaceMobileBusiness {
|
|||
// OrderPayMobileVO orderMixPayByTradeId(RequestHeaderDTO headerDTO, OrderMixPayMobileDTO orderMixPayMobileDTO);
|
||||
//
|
||||
// void orderPreBookAdd(RequestHeaderDTO headerDTO, OrderPreBookAddDTO addDTO);
|
||||
|
||||
UnifyPayVO stageOrderPay(RequestHeaderDTO headerDTO, StagePayMobileDTO stagePayDTO);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -332,6 +332,23 @@ public class OrderPlaceMobileBusinessImplV3 implements OrderPlaceMobileBusiness
|
|||
orderSavePO.setAmountChangeList(amountChangeList);
|
||||
return LeConstants.COMMON_YES.equals(orderPayDTO.getIfTrial()) ? this.trialPay(orderSavePO, (OrderDeliveryResultVO)null) : this.saveAndPay(orderSavePO, false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnifyPayVO stageOrderPay(RequestHeaderDTO headerDTO, StagePayMobileDTO stagePayDTO) {
|
||||
CustPayVO custInfo = this.getCustInfo(stagePayDTO.getCustId(), headerDTO.getSourceType());
|
||||
UnifyPayDTO unifyPayDTO = this.createPay(stagePayDTO.getPayType(),
|
||||
stagePayDTO.getCouponId(),
|
||||
headerDTO.getSourceType(),
|
||||
null,
|
||||
null,
|
||||
headerDTO.getOpenid(),
|
||||
custInfo,
|
||||
stagePayDTO);
|
||||
unifyPayDTO.setAmount(stagePayDTO.getAmount());
|
||||
unifyPayDTO.setRemark("驿站支付");
|
||||
return payApi.pay(unifyPayDTO);
|
||||
}
|
||||
|
||||
//
|
||||
// public OrderPayMobileVO orderMixPayByTradeId(RequestHeaderDTO headerDTO, OrderMixPayMobileDTO orderMixPayMobileDTO) {
|
||||
// LogUtil.info("订单混合支付|入参", orderMixPayMobileDTO);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package com.bonus.canteen.core.order.mobile.controller;
|
||||
|
||||
import com.bonus.canteen.core.order.common.constants.StageWhiteList;
|
||||
import com.bonus.canteen.core.order.common.dto.StageRefundParam;
|
||||
import com.bonus.canteen.core.pay.api.vo.UnifyRefundVO;
|
||||
import com.bonus.common.core.domain.R;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
|
|
@ -23,6 +26,7 @@ import com.bonus.canteen.core.pay.api.vo.UnifyPaySelectVO;
|
|||
import com.bonus.common.houqin.utils.LeRequest;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
|
@ -129,6 +133,21 @@ public class OrderInfoMobileController extends BaseController {
|
|||
OrderRefundResultVO resultVO = this.orderRefundBusiness.orderRefund(request.convertToOrderRefundParam(), OrderRefundBizEnum.MOBILE);
|
||||
return resultVO.ifSuccess() ? AjaxResult.success(resultVO) : AjaxResult.error(resultVO.getResultCode(), resultVO.getResultMsg());
|
||||
}
|
||||
|
||||
@PostMapping({"/stage/refund"})
|
||||
@ApiOperation(
|
||||
value = "驿站退款",
|
||||
notes = "驿站退款"
|
||||
)
|
||||
public AjaxResult stageRefundMobile(@RequestHeader Map<String, String> headers,
|
||||
@RequestBody StageRefundParam request) {
|
||||
String sign = HeaderFetchUtil.getSign(headers);
|
||||
if(StringUtils.isBlank(sign) || !sign.equals(StageWhiteList.STAGE_SIGN_WHITE_LIST)) {
|
||||
return AjaxResult.error("签名失败");
|
||||
}
|
||||
UnifyRefundVO resultVO = this.orderRefundBusiness.stageRefund(request);
|
||||
return AjaxResult.success(resultVO);
|
||||
}
|
||||
//
|
||||
// @PostMapping({"/book/stat"})
|
||||
// public LeResponse<OrderBookStatMobileVO> orderBookStat(@RequestHeader Map<String, String> headers, @RequestBody LeRequest<?> request) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
package com.bonus.canteen.core.order.mobile.controller;
|
||||
|
||||
import com.bonus.canteen.core.common.utils.HeaderFetchUtil;
|
||||
import com.bonus.canteen.core.order.common.constants.StageWhiteList;
|
||||
import com.bonus.canteen.core.order.mobile.dto.OrderPayMobileDTO;
|
||||
import com.bonus.canteen.core.order.mobile.dto.StagePayMobileDTO;
|
||||
import com.bonus.canteen.core.pay.api.vo.UnifyPayVO;
|
||||
import com.bonus.canteen.core.pay.common.constants.PayTypeEnum;
|
||||
import com.bonus.common.core.domain.R;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.houqin.constant.RetCodeEnum;
|
||||
|
|
@ -13,6 +18,7 @@ import com.bonus.common.houqin.utils.LeRequest;
|
|||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -127,6 +133,32 @@ public class OrderPlaceMobileController {
|
|||
LogUtil.info("[根据订单id支付]支付耗时", System.currentTimeMillis() - startTime, mobileVO);
|
||||
return !mobileVO.success() ? AjaxResult.error( mobileVO.getMsg(), mobileVO) : AjaxResult.success(mobileVO);
|
||||
}
|
||||
|
||||
@PostMapping({"/stage/pay"})
|
||||
@ApiOperation(
|
||||
value = "驿站付款",
|
||||
notes = "驿站付款"
|
||||
)
|
||||
public AjaxResult stageOrderPay(@RequestHeader Map<String, String> headers,
|
||||
@RequestBody StagePayMobileDTO stagePayDTO) {
|
||||
String sign = HeaderFetchUtil.getSign(headers);
|
||||
if(StringUtils.isBlank(sign) || !sign.equals(StageWhiteList.STAGE_SIGN_WHITE_LIST)) {
|
||||
return AjaxResult.error("签名失败");
|
||||
}
|
||||
UnifyPayVO mobileVO = null;
|
||||
try{
|
||||
long startTime = System.currentTimeMillis();
|
||||
RequestHeaderDTO headerDTO = RequestHeaderDTO.of(headers);
|
||||
stagePayDTO.setCustId(headerDTO.getCustId());
|
||||
stagePayDTO.setPayType(PayTypeEnum.MEAL_CARD.getKey());
|
||||
mobileVO = this.orderPlaceMobileBusiness.stageOrderPay(headerDTO, stagePayDTO);
|
||||
LogUtil.info("[驿站支付]支付耗时", System.currentTimeMillis() - startTime, mobileVO);
|
||||
}catch (Exception ex) {
|
||||
log.error("驿站支付异常", ex);
|
||||
return AjaxResult.error("支付失败", 500);
|
||||
}
|
||||
return AjaxResult.success(mobileVO);
|
||||
}
|
||||
//
|
||||
// @PostMapping({"/mixPay/by/orderId"})
|
||||
// @ApiOperation(
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
package com.bonus.canteen.core.order.mobile.dto;
|
||||
|
||||
import com.bonus.common.houqin.constant.LeConstants;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@ApiModel("移动端根据订单号支付DTO")
|
||||
@Data
|
||||
public class StagePayMobileDTO extends OrderPayMobileDTO{
|
||||
@ApiModelProperty("支付金额")
|
||||
private @NotNull @Min(value = 0L, message = "金额不能小于0") BigDecimal amount;
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue