前端随机立减金额获取
This commit is contained in:
parent
a0c5903aa6
commit
31e11323c6
|
|
@ -32,7 +32,8 @@ public class ShopRechargeController {
|
|||
|
||||
@GetMapping("/test")
|
||||
public CzgResult<MkShopConsumeDiscountRecord> get(@RequestParam Long shopId) {
|
||||
return CzgResult.success(shopConsumeDiscountRecordService.get(shopId));
|
||||
// return CzgResult.success(shopConsumeDiscountRecordService.get(shopId));
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ public class UShopConsumeDiscountController {
|
|||
* @return 金额
|
||||
*/
|
||||
@GetMapping
|
||||
public CzgResult<MkShopConsumeDiscountRecord> get(@RequestParam Long shopId) {
|
||||
return CzgResult.success(shopConsumeDiscountRecordService.get(shopId));
|
||||
public CzgResult<MkShopConsumeDiscountRecord> get(@RequestParam Long shopId, @RequestParam Long orderId) {
|
||||
return CzgResult.success(shopConsumeDiscountRecordService.get(shopId, StpKit.USER.getLoginIdAsLong(), orderId));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ public class MkShopConsumeDiscountRecord implements Serializable {
|
|||
* 消费立减id
|
||||
*/
|
||||
private Long consumeDiscountId;
|
||||
private Long orderId;
|
||||
private Long shopUserId;
|
||||
|
||||
/**
|
||||
* 减免金额
|
||||
|
|
|
|||
|
|
@ -10,5 +10,5 @@ import com.czg.market.entity.MkShopConsumeDiscountRecord;
|
|||
* @since 2025-09-17
|
||||
*/
|
||||
public interface MkShopConsumeDiscountRecordService extends IService<MkShopConsumeDiscountRecord> {
|
||||
MkShopConsumeDiscountRecord get(Long shopId);
|
||||
MkShopConsumeDiscountRecord get(Long shopId, Long userId, Long orderId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,19 @@
|
|||
package com.czg.service.market.service.impl;
|
||||
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.czg.account.service.ShopUserService;
|
||||
import com.czg.constant.TableValueConstant;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.czg.market.entity.MkConsumeDiscountRandom;
|
||||
import com.czg.market.service.MkConsumeDiscountService;
|
||||
import com.czg.market.vo.MkConsumeDiscountVO;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.market.entity.MkShopConsumeDiscountRecord;
|
||||
import com.czg.market.service.MkShopConsumeDiscountRecordService;
|
||||
import com.czg.service.market.mapper.MkShopConsumeDiscountRecordMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
|
@ -26,8 +30,18 @@ import java.util.Random;
|
|||
public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopConsumeDiscountRecordMapper, MkShopConsumeDiscountRecord> implements MkShopConsumeDiscountRecordService{
|
||||
@Resource
|
||||
private MkConsumeDiscountService consumeDiscountService;
|
||||
@DubboReference
|
||||
private ShopUserService shopUserService;
|
||||
@Override
|
||||
public MkShopConsumeDiscountRecord get(Long shopId) {
|
||||
public MkShopConsumeDiscountRecord get(Long shopId, Long userId, Long orderId) {
|
||||
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getUserId, userId).eq(ShopUser::getShopId, shopId));
|
||||
MkShopConsumeDiscountRecord discountRecord = getOne(new QueryWrapper().eq(MkShopConsumeDiscountRecord::getShopId, shopId)
|
||||
.eq(MkShopConsumeDiscountRecord::getOrderId, orderId)
|
||||
.eq(MkShopConsumeDiscountRecord::getShopUserId, shopUser.getId()));
|
||||
if (discountRecord != null) {
|
||||
return discountRecord;
|
||||
}
|
||||
|
||||
MkConsumeDiscountVO consumeDiscountVO = consumeDiscountService.detail(shopId);
|
||||
if (consumeDiscountVO.getIsEnable() != 1) {
|
||||
throw new ApiNotPrintException("新客立减未开启");
|
||||
|
|
@ -35,6 +49,8 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopCo
|
|||
|
||||
MkShopConsumeDiscountRecord shopConsumeDiscountRecord = new MkShopConsumeDiscountRecord();
|
||||
shopConsumeDiscountRecord.setShopId(shopId);
|
||||
shopConsumeDiscountRecord.setShopUserId(shopUser.getId());
|
||||
shopConsumeDiscountRecord.setOrderId(orderId);
|
||||
shopConsumeDiscountRecord.setConsumeDiscountId(consumeDiscountVO.getId());
|
||||
|
||||
// 固定金额
|
||||
|
|
|
|||
Loading…
Reference in New Issue