Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -13,6 +13,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* 店铺充值活动管理
|
||||
*
|
||||
* @author ww
|
||||
* @description
|
||||
*/
|
||||
@@ -29,8 +30,8 @@ public class ShopActivateController {
|
||||
*/
|
||||
@SaAdminCheckPermission("activate:list")
|
||||
@GetMapping
|
||||
public CzgResult<List<ShopActivateDTO>> detail() {
|
||||
return CzgResult.success(shopActivateService.getList());
|
||||
public CzgResult<List<ShopActivateDTO>> detail(@RequestParam(required = false) Long shopId) {
|
||||
return CzgResult.success(shopActivateService.getList(shopId));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.czg.resp.CzgResult;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
@@ -25,8 +26,8 @@ public class UserShopActivateController {
|
||||
* 店铺充值活动列表
|
||||
*/
|
||||
@GetMapping
|
||||
public CzgResult<List<ShopActivateDTO>> detail() {
|
||||
return CzgResult.success(shopActivateService.getList());
|
||||
public CzgResult<List<ShopActivateDTO>> detail(@RequestParam(required = false) Long shopId) {
|
||||
return CzgResult.success(shopActivateService.getList(shopId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ public class OrderPayController {
|
||||
* 获取店铺订单支付URL
|
||||
*/
|
||||
@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) {
|
||||
AssertUtil.isNull(shopId, "店铺id不能为空");
|
||||
AssertUtil.isNull(orderId, "订单Id不能为空");
|
||||
|
||||
@@ -64,12 +64,14 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
ApplicationInfo.routePrefix = "";
|
||||
|
||||
SaRouter.match("/user/**").notMatch("/user/login", "/user/test", "/user/geo/**", "/user/home/**")
|
||||
.notMatch("/pay/**")
|
||||
.notMatch("/notify/**")
|
||||
.check(r -> MyStpLogic.CLIENT_LOGIC.checkLogin())
|
||||
.setHit(true)
|
||||
// .match("/**")
|
||||
.notMatch("/user/**")
|
||||
.notMatch("/pay/**")
|
||||
.notMatch("/admin/auth/**")
|
||||
.notMatch("/notify/**")
|
||||
.check(r -> MyStpLogic.ADMIN_LOGIC.checkLogin());
|
||||
|
||||
})).addPathPatterns("/**");
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.czg.sa;
|
||||
|
||||
import cn.dev33.satoken.config.SaTokenConfig;
|
||||
import cn.dev33.satoken.context.SaHolder;
|
||||
import cn.dev33.satoken.context.model.SaRequest;
|
||||
import cn.dev33.satoken.dao.SaTokenDao;
|
||||
import cn.dev33.satoken.exception.NotPermissionException;
|
||||
import cn.dev33.satoken.fun.SaFunction;
|
||||
@@ -84,8 +85,14 @@ public class MyStpLogic {
|
||||
shopId = info instanceof Long l ? l : null;
|
||||
errType = 0;
|
||||
} else {
|
||||
String header = SaHolder.getRequest().getHeader("shopId");
|
||||
shopId = StrUtil.isBlank(header) ? null : Long.parseLong(header);
|
||||
SaRequest request = SaHolder.getRequest();
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.util.List;
|
||||
*/
|
||||
public interface ShopActivateService extends IService<ShopActivate> {
|
||||
|
||||
List<ShopActivateDTO> getList();
|
||||
List<ShopActivateDTO> getList(Long shopId);
|
||||
|
||||
Boolean add(ShopActivateDTO activateDTO);
|
||||
|
||||
|
||||
@@ -49,9 +49,9 @@ public class ShopActivateServiceImpl extends ServiceImpl<ShopActivateMapper, Sho
|
||||
private ShopUserService shopUserService;
|
||||
|
||||
@Override
|
||||
public List<ShopActivateDTO> getList() {
|
||||
public List<ShopActivateDTO> getList(Long shopId) {
|
||||
List<ShopActivateDTO> activateDtoS = queryChain().select()
|
||||
.eq(ShopActivate::getShopId, StpKit.USER.getShopId())
|
||||
.eq(ShopActivate::getShopId, shopId == null ? StpKit.USER.getShopId() : shopId)
|
||||
.orderBy(ShopActivate::getAmount, true)
|
||||
.listAs(ShopActivateDTO.class);
|
||||
for (ShopActivateDTO activateDTO : activateDtoS) {
|
||||
|
||||
@@ -194,7 +194,7 @@ public class PayServiceImpl implements PayService {
|
||||
if (payParam.getCheckOrderPay().getOrderId() == null) {
|
||||
orderInfo = orderInfoService.createPayOrder(payParam.getShopId(), payParam.getCheckOrderPay().getOrderAmount(),
|
||||
payParam.getCheckOrderPay().getRemark());
|
||||
}else {
|
||||
} else {
|
||||
orderInfo = orderInfoService.getById(payParam.getCheckOrderPay().getOrderId());
|
||||
}
|
||||
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
|
||||
@@ -432,6 +432,7 @@ public class PayServiceImpl implements PayService {
|
||||
isPay = false;
|
||||
refPayOrderNo = "";
|
||||
}
|
||||
orderInfo.setStatus(OrderStatusEnums.PART_REFUND.getCode());
|
||||
if (CollUtil.isNotEmpty(param.getRefundDetails())) {
|
||||
for (OrderDetail refundDetail : param.getRefundDetails()) {
|
||||
AssertUtil.isNull(refundDetail.getNum(), "退单数量不能为空");
|
||||
@@ -475,10 +476,30 @@ public class PayServiceImpl implements PayService {
|
||||
}
|
||||
orderDetail.setRefundNo(refPayOrderNo);
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
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 退款 券 未处理
|
||||
@@ -501,7 +522,7 @@ public class PayServiceImpl implements PayService {
|
||||
.bizEnum(ShopUserFlowBizEnum.ORDER_REFUND)
|
||||
.build();
|
||||
shopUserService.updateMoney(orderInfo.getShopId(), shopUserMoneyEditDTO);
|
||||
} else {
|
||||
} else if (!orderInfo.getPayType().equals(PayEnums.CASH_PAY.getValue())) {
|
||||
//退款 param.getRefundAmount()
|
||||
refundOrder(orderInfo.getShopId(), orderInfo.getId(), orderInfo.getPayOrderId(),
|
||||
refPayOrderNo, param.getRefundReason(), param.getRefundAmount());
|
||||
@@ -515,9 +536,25 @@ public class PayServiceImpl implements PayService {
|
||||
if (orderInfo.getRefundAmount().compareTo(orderInfo.getPayAmount()) < 0) {
|
||||
throw new ValidateException("退单失败,可退金额不足");
|
||||
}
|
||||
//退款 refundAmountTotal
|
||||
refundOrder(orderInfo.getShopId(), orderInfo.getId(), orderInfo.getPayOrderId(),
|
||||
refPayOrderNo, param.getRefundReason(), refundAmountTotal);
|
||||
//非现金退款
|
||||
if (!param.isCash()) {
|
||||
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 {
|
||||
orderInfo.setOrderAmount(orderInfo.getOrderAmount().subtract(refundAmountTotal));
|
||||
|
||||
Reference in New Issue
Block a user