Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -7,6 +7,7 @@ import com.czg.resp.CzgResult;
|
||||
import com.czg.service.order.dto.OrderPayParamDTO;
|
||||
import com.czg.service.order.dto.VipPayParamDTO;
|
||||
import com.czg.service.order.dto.VipRefundDTO;
|
||||
import lombok.NonNull;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
@@ -43,6 +44,8 @@ public interface PayService {
|
||||
*/
|
||||
CzgResult<Map<String, Object>> jsPayOrder(String clintIp, OrderPayParamDTO payParam);
|
||||
|
||||
CzgResult<Map<String, Object>> js2PayOrder(@NonNull String clintIp, OrderPayParamDTO payParam);
|
||||
|
||||
/**
|
||||
* 小程序支付
|
||||
*/
|
||||
@@ -102,6 +105,8 @@ public interface PayService {
|
||||
CzgResult<Object> refundOrder(Long shopId, Long orderId, Long payOrderId, String refPayOrderNo, String refundReason, BigDecimal refundAmount);
|
||||
|
||||
|
||||
CzgResult<Map<String, Object>> queryPayOrder(@NonNull Long orderId);
|
||||
|
||||
/**
|
||||
* 支付查询
|
||||
*
|
||||
|
||||
@@ -71,6 +71,10 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
private OrderPaymentService paymentService;
|
||||
@Resource
|
||||
private CashierCartService cartService;
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
@Resource
|
||||
private RabbitPublisher rabbitPublisher;
|
||||
@DubboReference
|
||||
private ShopInfoService shopInfoService;
|
||||
@DubboReference
|
||||
@@ -89,10 +93,6 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
private ShopCouponService couponService;
|
||||
@DubboReference
|
||||
private ShopActivateCouponRecordService couponRecordService;
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
@Resource
|
||||
private RabbitPublisher rabbitPublisher;
|
||||
|
||||
@Override
|
||||
public Page<OrderInfoVo> getOrderByPage(OrderInfoQueryDTO param) {
|
||||
@@ -115,7 +115,8 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
.eq(OrderInfo::getOrderNo, CzgStrUtils.getStrOrNull(param.getOrderNo()))
|
||||
.gt(OrderInfo::getCreateTime, CzgStrUtils.getStrOrNull(param.getStartTime()))
|
||||
.le(OrderInfo::getCreateTime, CzgStrUtils.getStrOrNull(param.getEndTime()))
|
||||
.in(OrderInfo::getId, like);
|
||||
.in(OrderInfo::getId, like)
|
||||
.orderBy(OrderInfo::getId).desc();
|
||||
Page<OrderInfoVo> orderInfoVoPage = pageAs(PageUtil.buildPage(), queryWrapper, OrderInfoVo.class);
|
||||
orderInfoVoPage.getRecords().parallelStream().forEach(s -> {
|
||||
List<OrderDetailSmallVO> orderDetails = orderDetailService.queryChain().select()
|
||||
@@ -132,8 +133,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
if (orderId == null && StrUtil.isBlank(tableCode)) {
|
||||
throw new ValidateException("订单id或台桌码不可为空");
|
||||
}
|
||||
HistoryOrderVo historyOrderVo = new HistoryOrderVo();
|
||||
// OrderInfo orderInfo;
|
||||
HistoryOrderVo historyOrderVo;
|
||||
if (orderId == null) {
|
||||
historyOrderVo = queryChain()
|
||||
.select()
|
||||
@@ -197,11 +197,11 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
List<OrderDetail> orderDetails = cartService.getCartByTableCode(param.getTableCode(), param.isVipPrice() ? 1 : 0, param.getPlaceNum());
|
||||
log.info("下单1 {}", JSONObject.toJSONString(orderDetails));
|
||||
//总打包费
|
||||
BigDecimal packAmount = BigDecimal.ZERO;
|
||||
BigDecimalDTO packAmount = new BigDecimalDTO(BigDecimal.ZERO);
|
||||
//总商品支付金额 不包含打包费 用来计算后续
|
||||
BigDecimal totalAmount = processOrderDetails(orderDetails, packAmount);
|
||||
log.info("下单2 总金额{} {}", totalAmount, JSONObject.toJSONString(orderDetails));
|
||||
if (packAmount.compareTo(param.getPackFee()) != 0) {
|
||||
if (packAmount.getPrice().compareTo(param.getPackFee()) != 0) {
|
||||
throw new ValidateException("生成订单失败,打包费不正确");
|
||||
}
|
||||
log.info("下单3 打包费{} 金额{}", param.getPackFee(), param.getOriginAmount());
|
||||
@@ -337,11 +337,11 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
* @param orderDetails 订单详情 需要回填
|
||||
* @param packAmount 打包费
|
||||
*/
|
||||
private BigDecimal processOrderDetails(List<OrderDetail> orderDetails, BigDecimal packAmount) {
|
||||
private BigDecimal processOrderDetails(List<OrderDetail> orderDetails, BigDecimalDTO packAmount) {
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
for (OrderDetail detail : orderDetails) {
|
||||
if (detail.getPackNumber().compareTo(BigDecimal.ZERO) > 0 && detail.getPackAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||
packAmount = packAmount.add(detail.getPackAmount().multiply(detail.getPackNumber()));
|
||||
packAmount.setPrice(packAmount.getPrice().add(detail.getPackAmount().multiply(detail.getPackNumber())));
|
||||
}
|
||||
detail.setPayAmount(detail.getNum().multiply(detail.getPrice()));
|
||||
totalAmount = totalAmount.add(detail.getPayAmount());
|
||||
@@ -564,6 +564,32 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付使用的空订单
|
||||
*/
|
||||
@Override
|
||||
public OrderInfo createPayOrder(Long shopId, BigDecimal amount, String remark) {
|
||||
ShopInfo shopInfo = shopInfoService.getById(shopId);
|
||||
OrderInfoAddDTO param = new OrderInfoAddDTO();
|
||||
param.setShopId(shopInfo.getId());
|
||||
param.setUserId(0L);
|
||||
param.setStaffId(0L);
|
||||
param.setSeatNum(0);
|
||||
param.setOriginAmount(amount);
|
||||
param.setTableCode("");
|
||||
param.setOrderType("cash");
|
||||
param.setPlatformType("H5");
|
||||
param.setPayMode("no-table");
|
||||
param.setDineMode("dine-in");
|
||||
param.setRemark(remark);
|
||||
param.setPlaceNum(1);
|
||||
param.setCreditBuyerId(null);
|
||||
param.setWaitCall(false);
|
||||
param.setVipPrice(false);
|
||||
param.setPackFee(BigDecimal.ZERO);
|
||||
return initOrderInfo(param, shopInfo, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化订单信息
|
||||
*/
|
||||
@@ -627,7 +653,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
orderInfo.setFullCouponDiscountAmount(param.getFullCouponDiscountAmount());
|
||||
orderInfo.setDiscountAmount(param.getDiscountAmount());
|
||||
//优惠券
|
||||
orderInfo.setCouponInfoList(JSONObject.toJSONString(param.getCouponList()));
|
||||
orderInfo.setCouponInfoList(CollUtil.isEmpty(param.getCouponList()) ? "" : JSONObject.toJSONString(param.getCouponList()));
|
||||
//折扣信息
|
||||
orderInfo.setDiscountInfo(buildDiscountInfo(orderInfo));
|
||||
//最终折扣
|
||||
|
||||
@@ -185,6 +185,26 @@ public class PayServiceImpl implements PayService {
|
||||
"点餐支付", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CzgResult<Map<String, Object>> js2PayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
||||
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
||||
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
|
||||
OrderInfo orderInfo;
|
||||
if (payParam.getCheckOrderPay().getOrderId() == null) {
|
||||
orderInfo = orderInfoService.createPayOrder(payParam.getShopId(), payParam.getCheckOrderPay().getOrderAmount(),
|
||||
payParam.getCheckOrderPay().getRemark());
|
||||
}else {
|
||||
orderInfo = orderInfoService.getById(payParam.getCheckOrderPay().getOrderId());
|
||||
}
|
||||
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
|
||||
Long paymentId = initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
|
||||
"order", payOrderNo, "", orderInfo.getOrderAmount()));
|
||||
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId);
|
||||
return jsPay(payParam.getShopId(), payParam.getPayType(), new CzgJsPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(MONEY_RATE).longValue(),
|
||||
"点餐支付", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CzgResult<Map<String, Object>> ltPayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
||||
@@ -469,8 +489,8 @@ public class PayServiceImpl implements PayService {
|
||||
throw new ValidateException("退单失败,可退金额不足");
|
||||
}
|
||||
//非现金退款
|
||||
if(!param.isCash()){
|
||||
if(orderInfo.getPayType().equals(PayEnums.VIP_PAY.getValue())){
|
||||
if (!param.isCash()) {
|
||||
if (orderInfo.getPayType().equals(PayEnums.VIP_PAY.getValue())) {
|
||||
ShopUser shopUser = shopUserService.getShopUserInfo(orderInfo.getShopId(), orderInfo.getUserId());
|
||||
//会员支付 退钱
|
||||
ShopUserMoneyEditDTO shopUserMoneyEditDTO = ShopUserMoneyEditDTO.builder()
|
||||
@@ -480,8 +500,8 @@ public class PayServiceImpl implements PayService {
|
||||
.relationId(orderInfo.getId())
|
||||
.bizEnum(ShopUserFlowBizEnum.ORDER_REFUND)
|
||||
.build();
|
||||
shopUserService.updateMoney(orderInfo.getShopId(),shopUserMoneyEditDTO);
|
||||
}else {
|
||||
shopUserService.updateMoney(orderInfo.getShopId(), shopUserMoneyEditDTO);
|
||||
} else {
|
||||
//退款 param.getRefundAmount()
|
||||
refundOrder(orderInfo.getShopId(), orderInfo.getId(), orderInfo.getPayOrderId(),
|
||||
refPayOrderNo, param.getRefundReason(), param.getRefundAmount());
|
||||
@@ -522,6 +542,26 @@ public class PayServiceImpl implements PayService {
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CzgResult<Map<String, Object>> queryPayOrder(@NonNull Long orderId) {
|
||||
OrderInfo orderInfo = orderInfoService.getById(orderId);
|
||||
AssertUtil.isNull(orderInfo, "订单不存在");
|
||||
OrderPayment payment = paymentService.getById(orderInfo.getPayOrderId());
|
||||
AssertUtil.isNull(payment, "订单不存在");
|
||||
CzgResult<CzgBaseResp> res = queryPayOrder(orderInfo.getShopId(), payment.getOrderNo(), null);
|
||||
CzgResult<Map<String, Object>> result = CzgResult.success();
|
||||
if (res.getCode() != 200 || res.getData() == null) {
|
||||
result.setCode(500);
|
||||
result.setMsg(res.getMsg());
|
||||
return result;
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("payOrderId", payment.getOrderNo());
|
||||
result.setData(map);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CzgResult<CzgBaseResp> queryPayOrder(@NonNull Long shopId, String payOrderId, String mchOrderNo) {
|
||||
|
||||
Reference in New Issue
Block a user