Compare commits
2 Commits
d23cb8b71b
...
64b1841782
| Author | SHA1 | Date |
|---|---|---|
|
|
64b1841782 | |
|
|
d9b314df18 |
|
|
@ -41,7 +41,7 @@ public class UShopConsumeDiscountController {
|
||||||
*/
|
*/
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public CzgResult<MkShopConsumeDiscountRecord> get(@RequestParam Long shopId, @RequestParam Long orderId) {
|
public CzgResult<MkShopConsumeDiscountRecord> get(@RequestParam Long shopId, @RequestParam Long orderId) {
|
||||||
return CzgResult.success(shopConsumeDiscountRecordService.get(shopId, StpKit.USER.getLoginIdAsLong(), orderId));
|
return CzgResult.success(shopConsumeDiscountRecordService.getDiscount(shopId, StpKit.USER.getLoginIdAsLong(), orderId));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,5 +61,6 @@ public class MkShopConsumeDiscountRecord implements Serializable {
|
||||||
* 门店id
|
* 门店id
|
||||||
*/
|
*/
|
||||||
private Long shopId;
|
private Long shopId;
|
||||||
|
private Integer isUse;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,5 +10,19 @@ import com.czg.market.entity.MkShopConsumeDiscountRecord;
|
||||||
* @since 2025-09-17
|
* @since 2025-09-17
|
||||||
*/
|
*/
|
||||||
public interface MkShopConsumeDiscountRecordService extends IService<MkShopConsumeDiscountRecord> {
|
public interface MkShopConsumeDiscountRecordService extends IService<MkShopConsumeDiscountRecord> {
|
||||||
MkShopConsumeDiscountRecord get(Long shopId, Long userId, Long orderId);
|
/**
|
||||||
|
* 获取减免金额
|
||||||
|
* @param shopId 门店id
|
||||||
|
* @param userId 用户id
|
||||||
|
* @param orderId 订单id
|
||||||
|
* @return 减免信息
|
||||||
|
*/
|
||||||
|
MkShopConsumeDiscountRecord getDiscount(Long shopId, Long userId, Long orderId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改记录状态
|
||||||
|
* @param recordId MkShopConsumeDiscountRecord 主键
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
boolean useDiscount(Long recordId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
package com.czg.service.market.service.impl;
|
package com.czg.service.market.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
|
import cn.hutool.core.date.DateUnit;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.czg.account.entity.ShopUser;
|
import com.czg.account.entity.ShopUser;
|
||||||
import com.czg.account.service.ShopUserService;
|
import com.czg.account.service.ShopUserService;
|
||||||
import com.czg.constant.TableValueConstant;
|
import com.czg.constant.TableValueConstant;
|
||||||
|
|
@ -32,8 +35,16 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopCo
|
||||||
private MkConsumeDiscountService consumeDiscountService;
|
private MkConsumeDiscountService consumeDiscountService;
|
||||||
@DubboReference
|
@DubboReference
|
||||||
private ShopUserService shopUserService;
|
private ShopUserService shopUserService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MkShopConsumeDiscountRecord get(Long shopId, Long userId, Long orderId) {
|
public boolean useDiscount(Long recordId) {
|
||||||
|
return updateChain().eq(MkShopConsumeDiscountRecord::getId, recordId)
|
||||||
|
.eq(MkShopConsumeDiscountRecord::getIsUse, 0)
|
||||||
|
.set(MkShopConsumeDiscountRecord::getIsUse, 1).update();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MkShopConsumeDiscountRecord getDiscount(Long shopId, Long userId, Long orderId) {
|
||||||
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getUserId, userId).eq(ShopUser::getShopId, shopId));
|
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getUserId, userId).eq(ShopUser::getShopId, shopId));
|
||||||
MkShopConsumeDiscountRecord discountRecord = getOne(new QueryWrapper().eq(MkShopConsumeDiscountRecord::getShopId, shopId)
|
MkShopConsumeDiscountRecord discountRecord = getOne(new QueryWrapper().eq(MkShopConsumeDiscountRecord::getShopId, shopId)
|
||||||
.eq(MkShopConsumeDiscountRecord::getOrderId, orderId)
|
.eq(MkShopConsumeDiscountRecord::getOrderId, orderId)
|
||||||
|
|
@ -47,6 +58,11 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopCo
|
||||||
throw new ApiNotPrintException("新客立减未开启");
|
throw new ApiNotPrintException("新客立减未开启");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DateTime now = DateUtil.date();
|
||||||
|
|
||||||
|
if (!now.isAfterOrEquals(DateUtil.date(consumeDiscountVO.getStartTime())) || !now.isBeforeOrEquals(DateUtil.date(consumeDiscountVO.getEndTime()))) {
|
||||||
|
throw new ApiNotPrintException("此时间段未开启新客立减");
|
||||||
|
}
|
||||||
MkShopConsumeDiscountRecord shopConsumeDiscountRecord = new MkShopConsumeDiscountRecord();
|
MkShopConsumeDiscountRecord shopConsumeDiscountRecord = new MkShopConsumeDiscountRecord();
|
||||||
shopConsumeDiscountRecord.setShopId(shopId);
|
shopConsumeDiscountRecord.setShopId(shopId);
|
||||||
shopConsumeDiscountRecord.setShopUserId(shopUser.getId());
|
shopConsumeDiscountRecord.setShopUserId(shopUser.getId());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue