拼团 订单

This commit is contained in:
2025-12-16 18:06:04 +08:00
parent 48f368c1b1
commit 01ca38079b
38 changed files with 1485 additions and 116 deletions

View File

@@ -0,0 +1,14 @@
package com.czg.service.order.mapper;
import com.mybatisflex.core.BaseMapper;
import com.czg.order.entity.GbOrderDetail;
/**
* 拼团订单详情表 映射层。
*
* @author ww
* @since 2025-12-16
*/
public interface GbOrderDetailMapper extends BaseMapper<GbOrderDetail> {
}

View File

@@ -0,0 +1,25 @@
package com.czg.service.order.mapper;
import com.czg.order.dto.GbOrderQueryParam;
import com.czg.order.vo.GbOrderDetailVO;
import com.czg.order.vo.GbOrderUserVO;
import com.mybatisflex.core.BaseMapper;
import com.czg.order.entity.GbOrder;
import java.util.List;
/**
* 拼团订单表 映射层。
*
* @author ww
* @since 2025-12-16
*/
public interface GbOrderMapper extends BaseMapper<GbOrder> {
List<GbOrderDetailVO> getGbOrderPage(GbOrderQueryParam param, Long shopId, Long mainShopId);
GbOrderDetailVO getGbOrderDetail(Long shopId, Long detailId);
List<GbOrderUserVO> getGbOrderDetailUsers(Long mainShopId, Long shopId, String groupOrderNo);
}

View File

@@ -2,9 +2,11 @@ package com.czg.service.order.service;
import com.czg.entity.resp.CzgBaseResp;
import com.czg.entity.resp.CzgRefundResp;
import com.czg.order.dto.LtPayOtherDTO;
import com.czg.order.dto.OrderInfoRefundDTO;
import com.czg.order.dto.PointGoodsExchangeDTO;
import com.czg.order.entity.OrderPayment;
import com.czg.order.enums.PaymentPayTypeEnum;
import com.czg.resp.CzgResult;
import com.czg.service.order.dto.*;
import lombok.NonNull;
@@ -104,9 +106,15 @@ public interface PayService {
CzgResult<Map<String, Object>> recharge(String clientIP, VipPayParamDTO rechargeDTO, Long userId);
//-----------------------------------------------------------------积分商品 付款 ----------------------------------------------------------
//-----------------------------------------------------------------积分商品/拼团 付款 ----------------------------------------------------------
CzgResult<Map<String, Object>> ltPayPointsGoods(String ip, PointGoodsExchangeDTO param, Long recordId);
/**
*
* @param param 支付参数
* @param payType 暂时只有 POINT 积分 和 WARE 拼团商品
* @param detail 操作描述 如 积分商品购买 / 拼团商品购买
*/
CzgResult<Map<String, Object>> ltPayOther(LtPayOtherDTO param, PaymentPayTypeEnum payType, String detail);
//-----------------------------------------------------------------退款-----------------------------------------------------------------
@@ -130,7 +138,7 @@ public interface PayService {
/**
* 统一退款接口
*
* @param refPayOrderNo 自定义退单号
* @param refPayOrderNo 自定义退单号 {@link com.czg.enums.OrderNoPrefixEnum} + 雪花Id
*/
void unifyRefund(Long shopId, Long sourceId, Long payOrderId, String refPayOrderNo, String refundReason, BigDecimal refundAmount);

View File

@@ -70,7 +70,9 @@ public class DistributionPayServiceImpl implements DistributionPayService {
ShopUser shopUserInfo = shopUserService.getShopUserInfo(payParam.getShopId(), userId);
OrderPayment orderPayment = new OrderPayment().setShopId(payParam.getShopId()).setSourceId(isRecharge ? payParam.getShopId() : shopUserInfo.getId())
.setPayType(isRecharge ? "distributionRecharge" : "distribution").setOrderNo(payParam.getPlatformType() + IdUtil.getSnowflakeNextId()).setAmount(isRecharge ? payParam.getAmount() : detail.getPayAmount());
.setPayType(isRecharge ? "distributionRecharge" : "distribution")
.setOrderNo(payParam.getPlatformType() + IdUtil.getSnowflakeNextId())
.setAmount(isRecharge ? payParam.getAmount() : detail.getPayAmount());
orderPaymentService.save(orderPayment);
InitInfo initInfo = new InitInfo().setConfig(detail);

View File

@@ -0,0 +1,18 @@
package com.czg.service.order.service.impl;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.czg.order.entity.GbOrderDetail;
import com.czg.order.service.GbOrderDetailService;
import com.czg.service.order.mapper.GbOrderDetailMapper;
import org.springframework.stereotype.Service;
/**
* 拼团订单详情表 服务层实现。
*
* @author ww
* @since 2025-12-16
*/
@Service
public class GbOrderDetailServiceImpl extends ServiceImpl<GbOrderDetailMapper, GbOrderDetail> implements GbOrderDetailService{
}

View File

@@ -0,0 +1,362 @@
package com.czg.service.order.service.impl;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import com.czg.account.entity.ShopInfo;
import com.czg.account.entity.ShopUser;
import com.czg.account.service.ShopInfoService;
import com.czg.account.service.ShopUserService;
import com.czg.enums.OrderNoPrefixEnum;
import com.czg.enums.YesNoEnum;
import com.czg.exception.CzgException;
import com.czg.market.entity.GbWare;
import com.czg.market.entity.MkPointsGoodsRecord;
import com.czg.market.service.GbWareService;
import com.czg.order.dto.CommonRefundDTO;
import com.czg.order.dto.GbOrderQueryParam;
import com.czg.order.dto.GroupJoinDTO;
import com.czg.order.entity.GbOrder;
import com.czg.order.entity.GbOrderDetail;
import com.czg.order.enums.PaymentPayTypeEnum;
import com.czg.order.service.GbOrderDetailService;
import com.czg.order.service.GbOrderService;
import com.czg.order.vo.GbOrderDetailVO;
import com.czg.order.vo.GbOrderUserVO;
import com.czg.order.vo.GbWareOrderVO;
import com.czg.order.vo.GbWareVO;
import com.czg.resp.CzgResult;
import com.czg.service.order.mapper.GbOrderMapper;
import com.czg.service.order.service.PayService;
import com.czg.utils.AssertUtil;
import com.czg.utils.CzgRandomUtils;
import com.czg.utils.PageUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 拼团订单表 服务层实现。
*
* @author ww
* @since 2025-12-16
*/
@Slf4j
@Service
public class GbOrderServiceImpl extends ServiceImpl<GbOrderMapper, GbOrder> implements GbOrderService {
@Resource
private GbWareService wareService;
@Resource
private GbOrderDetailService detailService;
@DubboReference
private ShopInfoService shopInfoService;
@DubboReference
private ShopUserService shopUserService;
@Resource
@Lazy
private PayService payService;
@Override
public Page<GbOrderDetailVO> getGbOrderPage(GbOrderQueryParam param) {
Long mainIdByShopId = shopInfoService.getMainIdByShopId(param.getShopId());
PageHelper.startPage(param.getPage(), param.getSize());
List<GbOrderDetailVO> result = mapper.getGbOrderPage(param, param.getShopId(), mainIdByShopId);
return PageUtil.convert(new PageInfo<>(result));
}
@Override
public GbOrderDetailVO getGoodsRecordDetail(Long shopId, Long detailId) {
Long mainIdByShopId = shopInfoService.getMainIdByShopId(shopId);
GbOrderDetailVO gbOrderDetail = mapper.getGbOrderDetail(shopId, detailId);
AssertUtil.isNull(gbOrderDetail, "记录不存在");
List<GbOrderUserVO> users = mapper.getGbOrderDetailUsers(mainIdByShopId, shopId, gbOrderDetail.getGroupOrderNo());
gbOrderDetail.setUsers(users);
return gbOrderDetail;
}
@Override
public GbWareVO getWareDetail(Long shopId, Long wareId) {
GbWareVO ware = wareService.getOneAs(query().eq(GbWare::getId, wareId), GbWareVO.class);
AssertUtil.isNull(ware, "商品不存在");
if (ware.getIsDel() || ware.getOnlineStatus() == 0) {
throw new CzgException("商品已下架");
}
ShopInfo shopInfo = shopInfoService.getById(shopId);
if (shopInfo != null) {
ware.setShopName(shopInfo.getShopName());
ware.setShopAddress(shopInfo.getAddress());
}
List<GbWareOrderVO> orderIng = listAs(query().eq(GbOrder::getId, wareId)
.eq(GbOrder::getShopId, shopId)
.eq(GbOrder::getStatus, "ing")
, GbWareOrderVO.class);
orderIng.forEach(ing -> {
QueryWrapper queryWrapper = QueryWrapper.create();
queryWrapper.eq(GbOrderDetail::getIsDel, 0)
.and(q -> {
q.eq(GbOrderDetail::getStatus, "待成团").or(GbOrderDetail::getStatus).eq("退款中");
})
.orderBy(GbOrderDetail::getPayTime);
queryWrapper.eq(GbOrderDetail::getGroupOrderNo, ing.getGroupOrderNo());
GbOrderDetail detail = detailService.getOne(queryWrapper);
if (detail != null) {
ShopUser userInfo = shopUserService.getUserInfo(detail.getShopId(), detail.getUserId());
if (userInfo != null) {
ing.setAvatar(userInfo.getHeadImg());
ing.setNickName(userInfo.getNickName());
}
}
});
ware.setGbOrderList(orderIng);
return ware;
}
@Override
public CzgResult<Map<String, Object>> groupJoin(GroupJoinDTO param) {
GbWare ware = wareService.getById(param.getParamId());
if (ware == null) {
throw new CzgException("拼团失败,商品不存在");
}
if (ware.getOnlineStatus() == 0) {
throw new CzgException("拼团失败,商品已下架");
}
if (ware.getLimitBuyNum() > param.getNumber()) {
throw new CzgException("拼团失败,该商品每人限购" + ware.getLimitBuyNum() + "");
}
if (StrUtil.isNotBlank(param.getGroupOrderNo())) {
GbOrder order = getOne(query().eq(GbOrder::getGroupOrderNo, param.getGroupOrderNo())
.eq(GbOrder::getShopId, param.getShopId()));
if (order == null || !"ing".equals(order.getStatus())) {
throw new CzgException("拼团失败,该拼团单不存在或已结束");
}
}
param.setPrice(ware.getGroupPrice().multiply(BigDecimal.valueOf(param.getNumber())));
GbOrderDetail record = new GbOrderDetail();
record.setShopId(param.getShopId());
record.setUserId(param.getUserId());
record.setWareId(param.getParamId());
record.setCreateTime(LocalDateTime.now());
record.setPayAmount(param.getPrice());
record.setStatus("待支付");
record.setOrderNo(CzgRandomUtils.randomNumber(OrderNoPrefixEnum.GBO, 12, false));
record.setIsDel(YesNoEnum.YES.value());
detailService.save(record);
CzgResult<Map<String, Object>> result = CzgResult.success();
CzgResult<Map<String, Object>> mapCzgResult = payService.ltPayOther(param, PaymentPayTypeEnum.WARE, "拼团商品购买");
if (200 != mapCzgResult.getCode()) {
return mapCzgResult;
}
Map<String, Object> resultMap = new HashMap<>(2);
resultMap.put("payInfo", mapCzgResult.getData());
resultMap.put("record", record);
result.setData(resultMap);
return result;
}
@Override
public boolean checkout(String verifyCode, Long shopId) {
GbOrderDetail record = detailService.getOne(query()
.eq(GbOrderDetail::getIsDel, YesNoEnum.NO.value())
.eq(GbOrderDetail::getVerifyCode, verifyCode)
.eq(GbOrderDetail::getShopId, shopId));
if (record == null) {
throw new CzgException("核销失败,核销码不存在");
}
if (!"待核销".equals(record.getStatus()) && !"退款中".equals(record.getStatus())) {
throw new CzgException("核销失败,该商品不可核销");
}
boolean success = exists(query().eq(GbOrder::getGroupOrderNo, record.getGroupOrderNo())
.eq(GbOrder::getShopId, shopId)
.eq(GbOrder::getStatus, "success"));
if (!success) {
throw new CzgException("核销失败,请拼团成功后核销");
}
GbOrderDetail upRecord = new GbOrderDetail();
upRecord.setVerifyTime(LocalDateTime.now());
upRecord.setStatus("已完成");
return detailService.update(upRecord, query().eq(GbOrderDetail::getId, record.getId()));
}
@Transactional
@Override
public void payCallBack(Long recordId, Long payOrderId) {
GbOrderDetail record = detailService.getById(recordId);
if (record == null) {
log.error("积分兑换商品发放失败,记录不存在");
return;
}
record.setIsDel(YesNoEnum.NO.value());
record.setPayOrderId(payOrderId);
record.setPayTime(LocalDateTime.now());
record.setVerifyCode(CzgRandomUtils.randomNumber(12, true));
if (StrUtil.isBlank(record.getGroupOrderNo())) {
GbWare ware = wareService.getById(record.getWareId());
if (ware == null || ware.getOnlineStatus() == 0 || ware.getIsDel()) {
CommonRefundDTO refundDTO = new CommonRefundDTO();
refundDTO.setRecordId(recordId);
refundDTO.setOrderNo(record.getOrderNo());
refundDTO.setReason("商品已下架 自动退款。");
agreeRefund(refundDTO, record.getShopId());
return;
}
GbOrder order = new GbOrder();
order.setShopId(record.getShopId());
String groupOrderNo = CzgRandomUtils.randomNumber(OrderNoPrefixEnum.GBO, 12, false);
order.setGroupOrderNo(groupOrderNo);
order.setWareId(record.getWareId());
//(商品名称,商品描述,商品图片,商品详情图片)
JSONObject wareJson = new JSONObject();
wareJson.put("wareName", ware.getWareName());
wareJson.put("wareImgs", ware.getWareImgs());
wareJson.put("wareDetail", ware.getWareDetail());
wareJson.put("wareCommentImgs", ware.getWareCommentImgs());
order.setWareJson(wareJson.toJSONString());
order.setWareGroupPrice(ware.getGroupPrice());
order.setWareOriginalPrice(ware.getOriginalPrice());
order.setGroupPeopleNum(ware.getGroupPeopleNum());
order.setCurrentPeopleNum(1);
order.setGroupEndTime(LocalDateTime.now().plusHours(ware.getGroupTimeoutHour()));
order.setCreateTime(LocalDateTime.now());
order.setStatus("ing");
if (ware.getGroupPeopleNum() == 1) {
order.setStatus("success");
}
save(order);
record.setGroupOrderNo(order.getGroupOrderNo());
if ("success".equals(order.getStatus())) {
record.setStatus("待核销");
}
} else {
GbOrder order = getOne(query().eq(GbOrder::getGroupOrderNo, record.getGroupOrderNo())
.eq(GbOrder::getShopId, record.getShopId()));
order.setCurrentPeopleNum(order.getCurrentPeopleNum() + 1);
if (order.getCurrentPeopleNum().equals(order.getGroupPeopleNum())) {
record.setStatus("待核销");
order.setStatus("success");
order.setGroupEndTime(LocalDateTime.now());
GbOrderDetail upRecord = new GbOrderDetail();
upRecord.setStatus("待核销");
detailService.update(upRecord, query()
.eq(GbOrderDetail::getGroupOrderNo, order.getGroupOrderNo())
.eq(GbOrderDetail::getShopId, order.getShopId())
.eq(GbOrderDetail::getIsDel, YesNoEnum.NO.value())
.eq(GbOrderDetail::getStatus, "待成团")
);
}
updateById(order);
}
detailService.updateById(record);
}
@Override
public boolean applyRefund(CommonRefundDTO param, Long userId) {
GbOrderDetail record = detailService.getOne(query()
.eq(GbOrderDetail::getIsDel, YesNoEnum.NO.value())
.eq(GbOrderDetail::getId, param.getRecordId())
.eq(GbOrderDetail::getUserId, userId));
AssertUtil.isNull(record, "记录不存在");
if (!"待成团".equals(record.getStatus()) && !"待核销".equals(record.getStatus())) {
throw new CzgException("申请失败,该商品不可申请退款");
}
if ("待成团".equals(record.getStatus())) {
return refundAmount(record, "");
}
GbOrderDetail upRecord = new GbOrderDetail();
record.setStatus("退款中");
record.setCancelReason(param.getReason());
record.setCancelTime(LocalDateTime.now());
return detailService.update(upRecord, QueryWrapper.create()
.eq(GbOrderDetail::getId, param.getRecordId())
.eq(GbOrderDetail::getOrderNo, param.getOrderNo())
.eq(GbOrderDetail::getUserId, userId)
.eq(GbOrderDetail::getShopId, record.getShopId())
);
}
@Override
public boolean cancelRefund(CommonRefundDTO param, Long userId, Long shopId) {
GbOrderDetail record = detailService.getOne(query()
.eq(GbOrderDetail::getId, param.getRecordId())
.eq(GbOrderDetail::getIsDel, YesNoEnum.NO.value())
.eq(GbOrderDetail::getUserId, userId));
AssertUtil.isNull(record, "取消失败,订单不存在");
if (!"待退款".equals(record.getStatus())) {
throw new CzgException("取消失败,订单不处于退款中");
}
boolean success = exists(query().eq(GbOrder::getGroupOrderNo, record.getGroupOrderNo())
.eq(GbOrder::getShopId, shopId)
.eq(GbOrder::getStatus, "success"));
GbOrderDetail upRecord = new GbOrderDetail();
if (success) {
upRecord.setStatus("待核销");
} else {
upRecord.setStatus("待成团");
}
if (record.getVerifyTime() != null) {
upRecord.setStatus("已核销");
}
upRecord.setCancelReason(param.getReason());
upRecord.setCancelTime(LocalDateTime.now());
return detailService.update(upRecord, QueryWrapper.create()
.eq(GbOrderDetail::getId, param.getRecordId())
.eq(GbOrderDetail::getOrderNo, param.getOrderNo())
.eq(GbOrderDetail::getUserId, userId)
.eq(GbOrderDetail::getShopId, shopId)
);
}
@Transactional
@Override
public boolean agreeRefund(CommonRefundDTO param, Long shopId) {
GbOrderDetail record = detailService.getOne(QueryWrapper.create()
.eq(GbOrderDetail::getIsDel, YesNoEnum.NO.value())
.eq(GbOrderDetail::getId, param.getRecordId())
.eq(GbOrderDetail::getShopId, shopId));
AssertUtil.isNull(record, "退款失败,订单不存在");
//待支付/待核销/待成团/已核销/退款中/已退款
if (!"待核销".equals(record.getStatus()) && !"待成团".equals(record.getStatus()) && !"退款中".equals(record.getStatus())) {
throw new CzgException("退款失败,订单不处于待退款");
}
return refundAmount(record, param.getReason());
}
private boolean refundAmount(GbOrderDetail record, String reason) {
//退钱
String refPayOrderNo = CzgRandomUtils.snowflake(OrderNoPrefixEnum.REP);
payService.unifyRefund(record.getShopId(), record.getId(), record.getPayOrderId(), refPayOrderNo,
StrUtil.isBlankIfStr(reason) ? "拼团退款" : reason, record.getPayAmount());
//回退 人数
GbOrder gbOrder = getOne(query().eq(GbOrder::getGroupOrderNo, record.getGroupOrderNo()).eq(GbOrder::getShopId, record.getShopId()));
if (gbOrder != null) {
GbOrder upOrder = new GbOrder();
upOrder.setCurrentPeopleNum(gbOrder.getCurrentPeopleNum() - 1);
if (upOrder.getCurrentPeopleNum() == 0) {
upOrder.setStatus("fail");
upOrder.setGroupEndTime(LocalDateTime.now());
}
updateById(upOrder);
}
GbOrderDetail upRecord = new GbOrderDetail();
upRecord.setStatus("已退款");
return detailService.update(upRecord, query().eq(GbOrderDetail::getId, record.getId()));
}
}

View File

@@ -19,6 +19,7 @@ import com.czg.constant.MarketConstants;
import com.czg.constant.TableValueConstant;
import com.czg.entity.notify.CzgPayNotifyDTO;
import com.czg.entity.notify.CzgRefundNotifyDTO;
import com.czg.order.enums.PaymentPayTypeEnum;
import com.czg.enums.ShopTableStatusEnum;
import com.czg.enums.ShopUserFlowBizEnum;
import com.czg.exception.CzgException;
@@ -48,9 +49,7 @@ import com.czg.service.RedisService;
import com.czg.service.order.enums.OrderStatusEnums;
import com.czg.service.order.mapper.OrderInfoCustomMapper;
import com.czg.service.order.print.PrinterHandler;
import com.czg.utils.AssertUtil;
import com.czg.utils.CzgStrUtils;
import com.czg.utils.FunUtils;
import com.czg.utils.*;
import com.czg.utils.PageUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
@@ -60,7 +59,6 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.jetbrains.annotations.NotNull;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization;
@@ -128,6 +126,8 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
@Resource
private PointsGoodPayService goodPayService;
@Resource
private GbOrderService gbOrderService;
@Resource
private ShopCouponService couponService;
@Resource
private MkShopCouponRecordService couponRecordService;
@@ -1046,7 +1046,7 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
payment.setPayStatus("fail");
if ("TRADE_SUCCESS".equals(czgCallBackDto.getState())) {
payment.setPayStatus("success");
if ("order".equals(payment.getPayType())) {
if (PaymentPayTypeEnum.ORDER.getValue().equals(payment.getPayType())) {
OrderInfo orderInfo = orderInfoService.getById(payment.getSourceId());
if (orderInfo == null) {
log.error("订单支付回调失败,订单不存在,支付记录Id,{}", payment.getId());
@@ -1058,8 +1058,8 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
distributionUserService.costUpgradeLevelBefore(orderInfo.getUserId(), orderInfo.getShopId());
// 分销奖励
distributionUserService.distribute(orderInfo.getId(), orderInfo.getOrderNo(), payment.getAmount(), orderInfo.getUserId(), orderInfo.getShopId(), "order");
} else if ("memberIn".equals(payment.getPayType()) || "free".equals(payment.getPayType())) {
boolean isFree = "free".equals(payment.getPayType());
} else if (PaymentPayTypeEnum.MEMBER_IN.getValue().equals(payment.getPayType()) || PaymentPayTypeEnum.FREE.getValue().equals(payment.getPayType())) {
boolean isFree = PaymentPayTypeEnum.FREE.getValue().equals(payment.getPayType());
ShopUser shopUser = shopUserService.getById(payment.getSourceId());
OrderInfo orderInfo = null;
if (shopUser == null) {
@@ -1159,7 +1159,7 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
// if (orderInfo != null) {
// distributionUserService.distribute(payment.getId(), payment.getOrderNo(), payment.getAmount(), orderInfo.getUserId(), payment.getShopId(), "recharge");
// }
} else if ("memberPay".equals(payment.getPayType())) {
} else if (PaymentPayTypeEnum.MEMBER_PAY.getValue().equals(payment.getPayType())) {
//购买会员
ShopUser shopUser = shopUserService.getById(payment.getSourceId());
memberConfigService.joinMember(payment.getShopId(), shopUser.getUserId(), payment.getRelatedId());
@@ -1167,10 +1167,12 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
// memberConfigService.deliver(shopUser.getMainShopId(), shopUser.getUserId(), TableValueConstant.MemberExpFlow.Type.COST, payment.getAmount(), null, payment.getId());
// 分销员开通
} else if ("distribution".equals(payment.getPayType())) {
} else if (PaymentPayTypeEnum.DISTRIBUTION.getValue().equals(payment.getPayType())) {
distributionUserService.open(payment.getSourceId(), payment.getAmount(), payment.getShopId(), payment.getId());
} else if ("point".equals(payment.getPayType())) {
} else if (PaymentPayTypeEnum.POINT.getValue().equals(payment.getPayType())) {
goodPayService.payCallBack(payment.getSourceId(), payment.getId());
} else if (PaymentPayTypeEnum.WARE.getValue().equals(payment.getPayType())) {
gbOrderService.payCallBack(payment.getSourceId(), payment.getId());
}
}
paymentService.updateById(payment);
@@ -1409,7 +1411,7 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
throw new CzgException("生成订单失败,订单已结束,请重新下单");
}
} else {
orderInfo.setOrderNo(param.getPlatformType() + IdUtil.getSnowflakeNextId());
orderInfo.setOrderNo(param.getPlatformType() + CzgRandomUtils.snowflake());
orderInfo.setShopId(param.getShopId());
if (table != null) {
orderInfo.setTableCode(table.getTableCode());

View File

@@ -26,12 +26,14 @@ import com.czg.market.entity.MkShopRechargeDetail;
import com.czg.market.service.*;
import com.czg.market.vo.MkShopRechargeVO;
import com.czg.order.dto.CheckOrderPay;
import com.czg.order.dto.LtPayOtherDTO;
import com.czg.order.dto.OrderInfoRefundDTO;
import com.czg.order.dto.PointGoodsExchangeDTO;
import com.czg.order.entity.OrderDetail;
import com.czg.order.entity.OrderInfo;
import com.czg.order.entity.OrderPayment;
import com.czg.order.enums.PayEnums;
import com.czg.order.enums.PaymentPayTypeEnum;
import com.czg.order.service.CreditBuyerOrderService;
import com.czg.order.service.OrderDetailService;
import com.czg.order.service.OrderInfoCustomService;
@@ -50,6 +52,7 @@ import com.czg.service.order.service.PayService;
import com.czg.system.enums.SysParamCodeEnum;
import com.czg.system.service.SysParamsService;
import com.czg.utils.AssertUtil;
import com.czg.utils.CzgRandomUtils;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotBlank;
@@ -279,7 +282,7 @@ public class PayServiceImpl implements PayService {
log.info("充值金额小于订单金额,充值金额:{} 订单金额:{}", rechargeDetail.getAmount(), orderInfo.getOrderAmount());
return CzgResult.failure("支付失败 充值金额必须大雨订单金额");
}
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
Long paymentId = initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), "memberIn", payOrderNo,
"", rechargeDetail.getAmount(), rechargeDetail.getId()));
upOrderPayInfo(orderInfo.getId(), PayEnums.VIP_PAY, paymentId,
@@ -292,7 +295,7 @@ public class PayServiceImpl implements PayService {
@Transactional(noRollbackFor = PaySuccessException.class)
public CzgResult<Map<String, Object>> h5PayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
Long paymentId = initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
"order", payOrderNo, "", orderInfo.getOrderAmount()));
upOrderPayInfo(orderInfo.getId(), PayEnums.H5_PAY, paymentId,
@@ -308,7 +311,7 @@ public class PayServiceImpl implements PayService {
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
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,
@@ -332,7 +335,7 @@ public class PayServiceImpl implements PayService {
} else {
orderInfo = orderInfoService.getById(payParam.getCheckOrderPay().getOrderId());
}
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
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,
@@ -347,7 +350,7 @@ public class PayServiceImpl implements PayService {
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
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,
@@ -370,7 +373,7 @@ public class PayServiceImpl implements PayService {
Long mainShopId = shopInfoService.getMainIdByShopId(payParam.getShopId());
BigDecimal amount = shopRechargeService.checkRecharge(mainShopId, payParam.getShopId(), shopUser.getUserId(), payParam.getRechargeDetailId(), payParam.getAmount());
payParam.setAmount(amount);
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
Long paymentId = initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
"order", payOrderNo, "", orderInfo.getOrderAmount()));
upOrderPayInfo(orderInfo.getId(), PayEnums.MAIN_SCAN, paymentId,
@@ -397,7 +400,7 @@ public class PayServiceImpl implements PayService {
payParam.setAmount(amount);
}
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
Long paymentId = initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
"order", payOrderNo, payParam.getAuthCode(), orderInfo.getOrderAmount()));
CzgResult<Map<String, Object>> mapCzgResult = microPay(payParam.getShopId(), new CzgMicroPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(MONEY_RATE).longValue(),
@@ -446,7 +449,7 @@ public class PayServiceImpl implements PayService {
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
String payOrderNo = payParam.getPlatformType() + IdUtil.getSnowflakeNextId();
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), isFree ? "free" : "memberIn", payOrderNo,
"", payParam.getAmount(), isFree ? payParam.getOrderId() : payParam.getActivateId()));
return jsPay(payParam.getShopId(), payParam.getPayType(), new CzgJsPayReq(payOrderNo, payParam.getAmount().multiply(MONEY_RATE).longValue(),
@@ -466,7 +469,7 @@ public class PayServiceImpl implements PayService {
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
String payOrderNo = payParam.getPlatformType() + IdUtil.getSnowflakeNextId();
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), "memberPay", payOrderNo,
"", memberOrder.getAmount(), memberOrder.getId()));
return ltPay(payParam.getShopId(), payParam.getPayType(), new CzgLtPayReq(payOrderNo, memberOrder.getAmount().multiply(MONEY_RATE).longValue(),
@@ -493,7 +496,7 @@ public class PayServiceImpl implements PayService {
payParam.setAmount(amount);
}
String payOrderNo = payParam.getPlatformType() + IdUtil.getSnowflakeNextId();
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), isFree ? "free" : "memberIn", payOrderNo,
"", payParam.getAmount(), isFree ? payParam.getOrderId() : payParam.getActivateId()));
return ltPay(payParam.getShopId(), payParam.getPayType(), new CzgLtPayReq(payOrderNo, payParam.getAmount().multiply(MONEY_RATE).longValue(),
@@ -515,7 +518,7 @@ public class PayServiceImpl implements PayService {
UserInfo userInfo = userInfoService.getById(shopUser.getUserId());
BigDecimal amount = shopRechargeService.checkRecharge(mainShopId, rechargeDTO.getShopId(), shopUser.getUserId(), rechargeDTO.getRechargeDetailId(), rechargeDTO.getAmount());
String payOrderNo = rechargeDTO.getPlatformType() + IdUtil.getSnowflakeNextId();
String payOrderNo = rechargeDTO.getPlatformType() + CzgRandomUtils.snowflake();
initOrderPayment(new OrderPayment(rechargeDTO.getShopId(), shopUser.getId(), isFree ? "free" : "memberIn", payOrderNo,
"", amount, isFree ? rechargeDTO.getOrderId() : rechargeDTO.getRechargeDetailId()));
return ltPay(rechargeDTO.getShopId(), rechargeDTO.getPayType(), new CzgLtPayReq(payOrderNo, amount.multiply(MONEY_RATE).longValue(),
@@ -529,7 +532,7 @@ public class PayServiceImpl implements PayService {
boolean isFree = checkPayVip(payParam);
ShopUser shopUser = shopUserService.getById(payParam.getShopUserId());
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
String payOrderNo = payParam.getPlatformType() + IdUtil.getSnowflakeNextId();
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), isFree ? "free" : "memberIn", payOrderNo,
"", payParam.getAmount(), isFree ? payParam.getOrderId() : payParam.getActivateId()));
return scanPay(payParam.getShopId(), new CzgScanPayReq(payOrderNo, payParam.getAmount().multiply(MONEY_RATE).longValue(),
@@ -543,7 +546,7 @@ public class PayServiceImpl implements PayService {
AssertUtil.isBlank(payParam.getAuthCode(), "扫描码不能为空");
ShopUser shopUser = shopUserService.getById(payParam.getShopUserId());
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
String payOrderNo = payParam.getPlatformType() + IdUtil.getSnowflakeNextId();
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), isFree ? "free" : "memberIn", payOrderNo,
payParam.getAuthCode(), payParam.getAmount(), isFree ? payParam.getOrderId() : payParam.getActivateId()));
CzgResult<Map<String, Object>> mapCzgResult = microPay(payParam.getShopId(), new CzgMicroPayReq(payOrderNo, payParam.getAmount().multiply(MONEY_RATE).longValue(),
@@ -555,14 +558,14 @@ public class PayServiceImpl implements PayService {
@Override
@Transactional
public CzgResult<Map<String, Object>> ltPayPointsGoods(String ip, PointGoodsExchangeDTO param, Long mkPointsGoodsRecordId) {
public CzgResult<Map<String, Object>> ltPayOther(LtPayOtherDTO param, PaymentPayTypeEnum payType, String detail) {
AssertUtil.isBlank(param.getOpenId(), "用户小程序ID不能为空");
AssertUtil.isBlank(param.getPayType(), "支付方式不能为空");
String payOrderNo = "DH" + IdUtil.getSnowflakeNextId();
initOrderPayment(new OrderPayment(param.getShopId(), mkPointsGoodsRecordId, "point", payOrderNo,
initOrderPayment(new OrderPayment(param.getShopId(), param.getRecordId(), payType.getValue(), payOrderNo,
"", param.getPrice(), null));
return ltPay(param.getShopId(), param.getPayType(), new CzgLtPayReq(payOrderNo, param.getPrice().multiply(MONEY_RATE).longValue(),
param.getPayType(), "积分商品购买", param.getOpenId(), ip, "", "", ""));
param.getPayType(), detail, param.getOpenId(), param.getIp(), "", "", ""));
}
@Override

View File

@@ -1,11 +1,11 @@
package com.czg.service.order.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import com.czg.account.entity.ShopUser;
import com.czg.account.service.ShopUserService;
import com.czg.enums.OrderNoPrefixEnum;
import com.czg.exception.CzgException;
import com.czg.market.dto.MkShopCouponGiftDTO;
import com.czg.market.entity.MkPointsGoods;
@@ -14,8 +14,9 @@ import com.czg.market.entity.MkPointsUser;
import com.czg.market.entity.ShopCoupon;
import com.czg.market.enums.PointsConstant;
import com.czg.market.service.*;
import com.czg.order.dto.PointGoodsExchangeDTO;
import com.czg.order.dto.PointGoodsRefundDTO;
import com.czg.order.dto.CommonRefundDTO;
import com.czg.order.dto.LtPayOtherDTO;
import com.czg.order.enums.PaymentPayTypeEnum;
import com.czg.order.service.PointsGoodPayService;
import com.czg.resp.CzgResult;
import com.czg.service.order.service.PayService;
@@ -56,8 +57,8 @@ public class PointsGoodPayServiceImpl implements PointsGoodPayService {
@Override
@Transactional
public CzgResult<Map<String, Object>> exchange(String ip, PointGoodsExchangeDTO param) {
MkPointsGoods goods = goodsService.getById(param.getPointsGoodsId());
public CzgResult<Map<String, Object>> exchange(LtPayOtherDTO param) {
MkPointsGoods goods = goodsService.getById(param.getParamId());
if (goods == null) {
throw new CzgException("兑换失败,商品不存在");
}
@@ -68,7 +69,7 @@ public class PointsGoodPayServiceImpl implements PointsGoodPayService {
throw new CzgException("兑换失败,商品库存不足");
}
Integer boughtCount = goodsRecordService.getOneAs(QueryWrapper.create().select("sum(number)")
.eq(MkPointsGoodsRecord::getPointsGoodsId, param.getPointsGoodsId())
.eq(MkPointsGoodsRecord::getPointsGoodsId, param.getParamId())
.ne(MkPointsGoodsRecord::getStatus, "已退款")
.eq(MkPointsGoodsRecord::getUserId, param.getUserId()), Integer.class);
if (goods.getLimitQuota() != null && goods.getLimitQuota() > 0 && boughtCount != null && boughtCount >= goods.getLimitQuota()) {
@@ -87,9 +88,9 @@ public class PointsGoodPayServiceImpl implements PointsGoodPayService {
}
MkPointsGoodsRecord record = new MkPointsGoodsRecord();
record.setOrderNo("DH" + CzgRandomUtils.randomNumFirstNoZero(20));
record.setOrderNo(CzgRandomUtils.randomNumber(OrderNoPrefixEnum.DH, 20, true));
record.setShopId(param.getShopId());
record.setPointsGoodsId(param.getPointsGoodsId());
record.setPointsGoodsId(param.getParamId());
record.setPointsGoodsName(goods.getGoodsName());
record.setGoodsImageUrl(goods.getGoodsImageUrl());
record.setGoodsCategory(goods.getGoodsCategory());
@@ -101,12 +102,14 @@ public class PointsGoodPayServiceImpl implements PointsGoodPayService {
record.setExtraPaymentAmount(goods.getExtraPrice() != null ? goods.getExtraPrice().multiply(new BigDecimal(param.getNumber())) : BigDecimal.ZERO);
record.setCreateTime(LocalDateTime.now());
if (goods.getExtraPrice() != null && goods.getExtraPrice().compareTo(BigDecimal.ZERO) > 0) {
param.checkPayInfo();
param.setPrice(record.getExtraPaymentAmount());
record.setStatus("待支付");
record.setIsDel(1);
goodsRecordService.save(record);
param.setRecordId(record.getId());
CzgResult<Map<String, Object>> result = CzgResult.success();
CzgResult<Map<String, Object>> mapCzgResult = payService.ltPayPointsGoods(ip, param, record.getId());
CzgResult<Map<String, Object>> mapCzgResult = payService.ltPayOther(param, PaymentPayTypeEnum.POINT, "积分商品购买");
if (200 != mapCzgResult.getCode()) {
return mapCzgResult;
}
@@ -123,7 +126,7 @@ public class PointsGoodPayServiceImpl implements PointsGoodPayService {
}
@Override
public boolean applyRefund(PointGoodsRefundDTO param, Long userId) {
public boolean applyRefund(CommonRefundDTO param, Long userId) {
MkPointsGoodsRecord record = new MkPointsGoodsRecord();
record.setStatus("退款中");
record.setCancelOrRefundReason(param.getReason());
@@ -137,7 +140,7 @@ public class PointsGoodPayServiceImpl implements PointsGoodPayService {
}
@Override
public boolean cancelRefund(PointGoodsRefundDTO param, Long userId, Long shopId) {
public boolean cancelRefund(CommonRefundDTO param, Long userId, Long shopId) {
MkPointsGoodsRecord record1 = goodsRecordService.getById(param.getRecordId());
if (record1 == null) {
throw new CzgException("取消失败,订单不存在");
@@ -164,13 +167,17 @@ public class PointsGoodPayServiceImpl implements PointsGoodPayService {
@Override
@Transactional
public boolean agreeRefund(PointGoodsRefundDTO param, Long shopId) {
public boolean agreeRefund(CommonRefundDTO param, Long shopId) {
MkPointsGoodsRecord record = goodsRecordService.getOne(QueryWrapper.create()
.eq(MkPointsGoodsRecord::getId, param.getRecordId())
.eq(MkPointsGoodsRecord::getShopId, shopId));
.eq(MkPointsGoodsRecord::getShopId, shopId)
.eq(MkPointsGoodsRecord::getIsDel, 0));
if (record == null) {
throw new CzgException("操作失败,记录不存在");
}
if (!"待核销".equals(record.getStatus()) && !"退款中".equals(record.getStatus())) {
throw new CzgException("退款失败,订单不处于待退款");
}
//退积分
if (record.getSpendPoints() != null && record.getSpendPoints() > 0) {
//回增积分
@@ -179,7 +186,7 @@ public class PointsGoodPayServiceImpl implements PointsGoodPayService {
}
//退钱
if (record.getExtraPaymentAmount() != null && record.getExtraPaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
String refPayOrderNo = "REP" + IdUtil.getSnowflakeNextId();
String refPayOrderNo = CzgRandomUtils.snowflake(OrderNoPrefixEnum.REP);
payService.unifyRefund(shopId, record.getId(), record.getPayOrderId(), refPayOrderNo,
StrUtil.isBlankIfStr(param.getReason()) ? "积分商品退款" : param.getReason(), record.getExtraPaymentAmount());
}
@@ -238,7 +245,7 @@ public class PointsGoodPayServiceImpl implements PointsGoodPayService {
return record;
} else {
record.setStatus("待核销");
record.setCouponCode(CzgRandomUtils.randomNumFirstNoZero(12));
record.setCouponCode(CzgRandomUtils.randomNumber(12, true));
goodsRecordService.saveOrUpdate(record);
goodsService.upNumberById(goods.getId(), goods.getQuantity() - record.getNumber(), goods.getTotalExchangeCount() + record.getNumber());
//扣除积分

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.czg.service.order.mapper.GbOrderDetailMapper">
</mapper>

View File

@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.czg.service.order.mapper.GbOrderMapper">
<select id="getGbOrderPage" resultType="com.czg.order.vo.GbOrderDetailVO">
SELECT
detail.* ,`order`.ware_json as wareJson,`user`.nick_name as userName,
`user`.phone as userPhone,shop.shop_name as shopName,shop.address as shopAddress
FROM
`gb_order_detail` detail
LEFT JOIN gb_order `order` on detail.group_order_no = `order`.group_order_no and `order`.shop_id = #{shopId}
left join tb_shop_user `user` on `user`.main_shop_id = #{mainShopId} and `user`.user_id = detail.user_id
LEFT JOIN tb_shop_info shop on detail.shop_id = shop.id
WHERE
detail.shop_id = #{shopId}
and detail.is_del = 0
<if test="param.orderNo != null">
and detail.order_no = #{param.orderNo}
</if>
<if test="param.groupOrderNo != null">
AND detail.group_order_no = #{param.groupOrderNo}
</if>
<if test="param.status != null">
<if test="param.status == '退款'">
AND (detail.STATUS = '退款中' or detail.STATUS = '已退款')
</if>
<if test="param.status != '退款'">
AND detail.STATUS = #{param.status}
</if>
</if>
<if test="param.userId != null">
AND detail.user_id = #{param.userId}
</if>
<if test="param.orderStartTime != null and param.orderEndTime != null ">
and detail.pay_time BETWEEN #{param.orderStartTime} and #{param.orderEndTime}
</if>
<if test="param.verifyStartTime != null and param.verifyEndTime != null ">
and detail.verify_time BETWEEN #{param.verifyStartTime} and #{param.verifyEndTime}
</if>
order by detail.create_time desc
</select>
<select id="getGbOrderDetail" resultType="com.czg.order.vo.GbOrderDetailVO">
SELECT
detail.* ,`order`.ware_json as wareJson,`user`.nick_name as userName,
`user`.phone as userPhone,shop.shop_name as shopName,shop.address as shopAddress
FROM
`gb_order_detail` detail
LEFT JOIN gb_order `order` on detail.group_order_no = `order`.group_order_no and `order`.shop_id = #{shopId}
left join tb_shop_user `user` on `user`.main_shop_id = #{mainShopId} and `user`.user_id = detail.user_id
LEFT JOIN tb_shop_info shop on detail.shop_id = shop.id
WHERE
detail.shop_id = #{shopId} and detail.id=#{id}
order by detail.create_time desc
</select>
<select id="getGbOrderDetailUsers" resultType="com.czg.order.vo.GbOrderUserVO">
select `user`.nick_name as userName, `user`.phone as userPhone, `user`.head_img as userAvatar
from gb_order_detail detail
left join tb_shop_user `user`
on `user`.main_shop_id = #{mainShopId} and `user`.user_id = detail.user_id
where detail.shop_id = #{shopId}
and detail.group_order_no = #{groupOrderNo}
and (detail.status = '待成团' or detail.status = '待核销' or detail.status = '退款中')
order by detail.pay_time
limit 10
</select>
</mapper>