Merge remote-tracking branch 'origin/master'

This commit is contained in:
Tankaikai
2025-02-28 17:37:35 +08:00
8 changed files with 64 additions and 16 deletions

View File

@@ -13,6 +13,7 @@ import java.util.List;
/** /**
* 店铺充值活动管理 * 店铺充值活动管理
*
* @author ww * @author ww
* @description * @description
*/ */
@@ -29,8 +30,8 @@ public class ShopActivateController {
*/ */
@SaAdminCheckPermission("activate:list") @SaAdminCheckPermission("activate:list")
@GetMapping @GetMapping
public CzgResult<List<ShopActivateDTO>> detail() { public CzgResult<List<ShopActivateDTO>> detail(@RequestParam(required = false) Long shopId) {
return CzgResult.success(shopActivateService.getList()); return CzgResult.success(shopActivateService.getList(shopId));
} }
/** /**

View File

@@ -6,6 +6,7 @@ import com.czg.resp.CzgResult;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
@@ -25,8 +26,8 @@ public class UserShopActivateController {
* 店铺充值活动列表 * 店铺充值活动列表
*/ */
@GetMapping @GetMapping
public CzgResult<List<ShopActivateDTO>> detail() { public CzgResult<List<ShopActivateDTO>> detail(@RequestParam(required = false) Long shopId) {
return CzgResult.success(shopActivateService.getList()); return CzgResult.success(shopActivateService.getList(shopId));
} }
} }

View File

@@ -121,7 +121,7 @@ public class OrderPayController {
* 获取店铺订单支付URL * 获取店铺订单支付URL
*/ */
@PostMapping("/shopPayApi/orderPayUrl") @PostMapping("/shopPayApi/orderPayUrl")
public CzgResult<String> getOrderPayUrl(Long shopId, Long orderId, @RequestParam(required = false) String extend, public CzgResult<String> getOrderPayUrl(@RequestHeader Long shopId, Long orderId, @RequestParam(required = false) String extend,
@RequestParam(required = false) CheckOrderPay checkOrderPay) { @RequestParam(required = false) CheckOrderPay checkOrderPay) {
AssertUtil.isNull(shopId, "店铺id不能为空"); AssertUtil.isNull(shopId, "店铺id不能为空");
AssertUtil.isNull(orderId, "订单Id不能为空"); AssertUtil.isNull(orderId, "订单Id不能为空");

View File

@@ -64,12 +64,14 @@ public class SaTokenConfigure implements WebMvcConfigurer {
ApplicationInfo.routePrefix = ""; ApplicationInfo.routePrefix = "";
SaRouter.match("/user/**").notMatch("/user/login", "/user/test", "/user/geo/**", "/user/home/**") SaRouter.match("/user/**").notMatch("/user/login", "/user/test", "/user/geo/**", "/user/home/**")
.notMatch("/pay/**")
.notMatch("/notify/**")
.check(r -> MyStpLogic.CLIENT_LOGIC.checkLogin()) .check(r -> MyStpLogic.CLIENT_LOGIC.checkLogin())
.setHit(true) .setHit(true)
// .match("/**") // .match("/**")
.notMatch("/user/**") .notMatch("/user/**")
.notMatch("/pay/**")
.notMatch("/admin/auth/**") .notMatch("/admin/auth/**")
.notMatch("/notify/**")
.check(r -> MyStpLogic.ADMIN_LOGIC.checkLogin()); .check(r -> MyStpLogic.ADMIN_LOGIC.checkLogin());
})).addPathPatterns("/**"); })).addPathPatterns("/**");

View File

@@ -2,6 +2,7 @@ package com.czg.sa;
import cn.dev33.satoken.config.SaTokenConfig; import cn.dev33.satoken.config.SaTokenConfig;
import cn.dev33.satoken.context.SaHolder; import cn.dev33.satoken.context.SaHolder;
import cn.dev33.satoken.context.model.SaRequest;
import cn.dev33.satoken.dao.SaTokenDao; import cn.dev33.satoken.dao.SaTokenDao;
import cn.dev33.satoken.exception.NotPermissionException; import cn.dev33.satoken.exception.NotPermissionException;
import cn.dev33.satoken.fun.SaFunction; import cn.dev33.satoken.fun.SaFunction;
@@ -84,8 +85,14 @@ public class MyStpLogic {
shopId = info instanceof Long l ? l : null; shopId = info instanceof Long l ? l : null;
errType = 0; errType = 0;
} else { } else {
String header = SaHolder.getRequest().getHeader("shopId"); SaRequest request = SaHolder.getRequest();
shopId = StrUtil.isBlank(header) ? null : Long.parseLong(header); String requestParam = request.getParam("shopId");
if (StrUtil.isBlank(requestParam)) {
String header = request.getHeader("shopId");
shopId = StrUtil.isBlank(header) ? null : Long.parseLong(header);
}else {
shopId = Long.parseLong(requestParam);
}
errType = 1; errType = 1;
} }

View File

@@ -16,7 +16,7 @@ import java.util.List;
*/ */
public interface ShopActivateService extends IService<ShopActivate> { public interface ShopActivateService extends IService<ShopActivate> {
List<ShopActivateDTO> getList(); List<ShopActivateDTO> getList(Long shopId);
Boolean add(ShopActivateDTO activateDTO); Boolean add(ShopActivateDTO activateDTO);

View File

@@ -49,9 +49,9 @@ public class ShopActivateServiceImpl extends ServiceImpl<ShopActivateMapper, Sho
private ShopUserService shopUserService; private ShopUserService shopUserService;
@Override @Override
public List<ShopActivateDTO> getList() { public List<ShopActivateDTO> getList(Long shopId) {
List<ShopActivateDTO> activateDtoS = queryChain().select() List<ShopActivateDTO> activateDtoS = queryChain().select()
.eq(ShopActivate::getShopId, StpKit.USER.getShopId()) .eq(ShopActivate::getShopId, shopId == null ? StpKit.USER.getShopId() : shopId)
.orderBy(ShopActivate::getAmount, true) .orderBy(ShopActivate::getAmount, true)
.listAs(ShopActivateDTO.class); .listAs(ShopActivateDTO.class);
for (ShopActivateDTO activateDTO : activateDtoS) { for (ShopActivateDTO activateDTO : activateDtoS) {

View File

@@ -194,7 +194,7 @@ public class PayServiceImpl implements PayService {
if (payParam.getCheckOrderPay().getOrderId() == null) { if (payParam.getCheckOrderPay().getOrderId() == null) {
orderInfo = orderInfoService.createPayOrder(payParam.getShopId(), payParam.getCheckOrderPay().getOrderAmount(), orderInfo = orderInfoService.createPayOrder(payParam.getShopId(), payParam.getCheckOrderPay().getOrderAmount(),
payParam.getCheckOrderPay().getRemark()); payParam.getCheckOrderPay().getRemark());
}else { } else {
orderInfo = orderInfoService.getById(payParam.getCheckOrderPay().getOrderId()); orderInfo = orderInfoService.getById(payParam.getCheckOrderPay().getOrderId());
} }
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId(); String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
@@ -432,6 +432,7 @@ public class PayServiceImpl implements PayService {
isPay = false; isPay = false;
refPayOrderNo = ""; refPayOrderNo = "";
} }
orderInfo.setStatus(OrderStatusEnums.PART_REFUND.getCode());
if (CollUtil.isNotEmpty(param.getRefundDetails())) { if (CollUtil.isNotEmpty(param.getRefundDetails())) {
for (OrderDetail refundDetail : param.getRefundDetails()) { for (OrderDetail refundDetail : param.getRefundDetails()) {
AssertUtil.isNull(refundDetail.getNum(), "退单数量不能为空"); AssertUtil.isNull(refundDetail.getNum(), "退单数量不能为空");
@@ -475,10 +476,30 @@ public class PayServiceImpl implements PayService {
} }
orderDetail.setRefundNo(refPayOrderNo); orderDetail.setRefundNo(refPayOrderNo);
orderDetail.setRefundRemark(orderDetail.getRefundRemark() + param.getRefundReason()); orderDetail.setRefundRemark(orderDetail.getRefundRemark() + param.getRefundReason());
if (orderDetail.getNum().compareTo(orderDetail.getRefundNum().add(orderDetail.getReturnNum())) == 0) {
orderDetail.setStatus(OrderStatusEnums.REFUND.getCode());
} else {
orderDetail.setStatus(OrderStatusEnums.PART_REFUND.getCode());
}
orderDetailService.updateById(orderDetail); orderDetailService.updateById(orderDetail);
} }
} else { } else {
refundAmountTotal = param.getRefundAmount(); refundAmountTotal = param.getRefundAmount();
if (isPay) {
orderDetailService.updateChain()
.eq(OrderDetail::getOrderId, param.getOrderId())
.setRaw(OrderDetail::getRefundNum, "num-refund_num")
.setRaw(OrderDetail::getReturnAmount, "pay_amount")
.set(OrderDetail::getStatus, OrderStatusEnums.REFUND.getCode())
.update();
} else {
orderDetailService.updateChain()
.eq(OrderDetail::getOrderId, param.getOrderId())
.setRaw(OrderDetail::getReturnNum, "num")
.set(OrderDetail::getStatus, OrderStatusEnums.REFUND.getCode())
.update();
}
} }
//总退款金额 //总退款金额
//TODO 退款 券 未处理 //TODO 退款 券 未处理
@@ -501,7 +522,7 @@ public class PayServiceImpl implements PayService {
.bizEnum(ShopUserFlowBizEnum.ORDER_REFUND) .bizEnum(ShopUserFlowBizEnum.ORDER_REFUND)
.build(); .build();
shopUserService.updateMoney(orderInfo.getShopId(), shopUserMoneyEditDTO); shopUserService.updateMoney(orderInfo.getShopId(), shopUserMoneyEditDTO);
} else { } else if (!orderInfo.getPayType().equals(PayEnums.CASH_PAY.getValue())) {
//退款 param.getRefundAmount() //退款 param.getRefundAmount()
refundOrder(orderInfo.getShopId(), orderInfo.getId(), orderInfo.getPayOrderId(), refundOrder(orderInfo.getShopId(), orderInfo.getId(), orderInfo.getPayOrderId(),
refPayOrderNo, param.getRefundReason(), param.getRefundAmount()); refPayOrderNo, param.getRefundReason(), param.getRefundAmount());
@@ -515,9 +536,25 @@ public class PayServiceImpl implements PayService {
if (orderInfo.getRefundAmount().compareTo(orderInfo.getPayAmount()) < 0) { if (orderInfo.getRefundAmount().compareTo(orderInfo.getPayAmount()) < 0) {
throw new ValidateException("退单失败,可退金额不足"); throw new ValidateException("退单失败,可退金额不足");
} }
//退款 refundAmountTotal //非现金退款
refundOrder(orderInfo.getShopId(), orderInfo.getId(), orderInfo.getPayOrderId(), if (!param.isCash()) {
refPayOrderNo, param.getRefundReason(), refundAmountTotal); if (orderInfo.getPayType().equals(PayEnums.VIP_PAY.getValue())) {
ShopUser shopUser = shopUserService.getShopUserInfo(orderInfo.getShopId(), orderInfo.getUserId());
//会员支付 退钱
ShopUserMoneyEditDTO shopUserMoneyEditDTO = ShopUserMoneyEditDTO.builder()
.id(shopUser.getId())
.money(param.getRefundAmount())
.type(1)
.relationId(orderInfo.getId())
.bizEnum(ShopUserFlowBizEnum.ORDER_REFUND)
.build();
shopUserService.updateMoney(orderInfo.getShopId(), shopUserMoneyEditDTO);
} else if (!orderInfo.getPayType().equals(PayEnums.CASH_PAY.getValue())) {
//退款 param.getRefundAmount()
refundOrder(orderInfo.getShopId(), orderInfo.getId(), orderInfo.getPayOrderId(),
refPayOrderNo, param.getRefundReason(), param.getRefundAmount());
}
}
} }
} else { } else {
orderInfo.setOrderAmount(orderInfo.getOrderAmount().subtract(refundAmountTotal)); orderInfo.setOrderAmount(orderInfo.getOrderAmount().subtract(refundAmountTotal));