Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
张松
2025-12-04 09:50:36 +08:00
11 changed files with 27 additions and 21 deletions

View File

@@ -43,11 +43,11 @@ public class AChatCouponController {
*/
@GetMapping("/page")
@SaAdminCheckPermission(value = "chat:coupon:page", name = "群聊优惠券活动-分页查询")
public Page<ChatCouponVO> pageChatCoupon(@RequestParam(required = false, defaultValue = "1") Integer page,
public CzgResult<Page<ChatCouponVO>> pageChatCoupon(@RequestParam(required = false, defaultValue = "1") Integer page,
@RequestParam(required = false, defaultValue = "10") Integer size,
@RequestParam(required = false) Integer status) {
Long shopId = StpKit.USER.getShopId();
return chatCouponService.pageChatCoupon(shopId, page, size, status);
return CzgResult.success(chatCouponService.pageChatCoupon(shopId, page, size, status));
}
/**
@@ -55,10 +55,9 @@ public class AChatCouponController {
*/
@DeleteMapping("/expired/{id}")
@SaAdminCheckPermission(value = "chat:coupon:expired", name = "群聊优惠券活动-失效")
public CzgResult<Void> expiredChatCoupon(@PathVariable Long id) {
public CzgResult<Boolean> expiredChatCoupon(@PathVariable Long id) {
Long shopId = StpKit.USER.getShopId();
chatCouponService.expiredChatCoupon(shopId, id);
return CzgResult.success();
return CzgResult.success(chatCouponService.expiredChatCoupon(shopId, id));
}
/**
@@ -66,11 +65,11 @@ public class AChatCouponController {
*/
@GetMapping("/record")
@SaAdminCheckPermission(value = "chat:coupon:record", name = "群聊优惠券活动-发放记录")
public Page<MkShopCouponRecord> grantChatCouponRecord(@RequestParam Long id,
public CzgResult<Page<MkShopCouponRecord>> grantChatCouponRecord(@RequestParam Long id,
@RequestParam(required = false) Integer status,
@RequestParam(required = false, defaultValue = "1") Integer page,
@RequestParam(required = false, defaultValue = "10") Integer size) {
return chatCouponService.grantChatCouponRecord(id, status, page, size);
return CzgResult.success(chatCouponService.grantChatCouponRecord(id, status, page, size));
}

View File

@@ -23,8 +23,8 @@ public class UChatCouponController {
* 群聊优惠券活动-发放优惠券
*/
@PostMapping("/grant")
public CzgResult<Void> grantChatCoupon(@RequestBody ChatCouponGrantDTO chatCouponGrant) {
public CzgResult<Boolean> grantChatCoupon(@RequestBody ChatCouponGrantDTO chatCouponGrant) {
chatCouponService.grantChatCoupon(chatCouponGrant.getId(), chatCouponGrant.getShopUserId(), chatCouponGrant.getUserId());
return CzgResult.success();
return CzgResult.success(true);
}
}

View File

@@ -122,6 +122,9 @@ public class MkShopCouponRecord implements Serializable {
private LocalDateTime useEndTime;
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime useStartTime;
@Column(ignore = true)
private String couponName;
/**
* 有效期类型fixed固定时间custom自定义时间
*/

View File

@@ -28,7 +28,7 @@ public interface ChatCouponService extends IService<ChatCoupon> {
/**
* 失效
*/
void expiredChatCoupon(Long shopId, Long id);
boolean expiredChatCoupon(Long shopId, Long id);
/**
* 发放优惠券

View File

@@ -44,7 +44,7 @@ public interface ShopCouponService extends IService<ShopCoupon> {
List<UserCouponVo> findCoupon(Long shopId, Long shopUserId, Integer type, Integer isFood);
Boolean use(List<Long> ids, Long shopUserId, Long orderId);
void use(List<Long> ids, Long shopUserId, Long orderId);
Boolean refund(Long orderId, Long shopUserId);

View File

@@ -8,6 +8,7 @@ import lombok.NoArgsConstructor;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* 订单详情 实体类。
@@ -35,6 +36,11 @@ public class OrderDetailSmallVO implements Serializable {
private BigDecimal unitPrice;
private BigDecimal payAmount;
private String remark;
private String subStatus;
private LocalDateTime orderTime;
private LocalDateTime startOrderTime;
private LocalDateTime dishOutTime;
private LocalDateTime foodServeTime;
}

View File

@@ -82,10 +82,10 @@ public class ChatCouponServiceImpl extends ServiceImpl<ChatCouponMapper, ChatCou
* 失效
*/
@Override
public void expiredChatCoupon(Long shopId, Long id) {
public boolean expiredChatCoupon(Long shopId, Long id) {
ChatCoupon coupon = new ChatCoupon();
coupon.setStatus(3);
update(coupon, QueryWrapper.create()
return update(coupon, QueryWrapper.create()
.eq(ChatCoupon::getId, id)
.eq(ChatCoupon::getShopId, shopId)
);

View File

@@ -519,11 +519,10 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
public MkShopCouponRecord assembleRecord(Long chatCouponId, ShopCoupon coupon) {
MkShopCouponRecord record = new MkShopCouponRecord();
record.setShopId(coupon.getShopId());
record.setCouponName(coupon.getTitle());
record.setCouponId(coupon.getId());
record.setCouponSyncId(coupon.getSyncId());
record.setSourceId(chatCouponId);
record.setSource("群聊发放");
record.setStatus(0);
record.setType(coupon.getCouponType());

View File

@@ -339,11 +339,10 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
@Override
@Async
public Boolean use(List<Long> ids, Long shopUserId, Long orderId) {
public void use(List<Long> ids, Long shopUserId, Long orderId) {
List<MkShopCouponRecord> records = recordService.listByIds(ids);
if (records.isEmpty()) {
log.error("优惠券使用失败订单Id:{}", orderId);
return false;
}
Map<Long, Long> chatCouponIdCountMap = records.stream()
.filter(record -> "群聊发放".equals(record.getSource()))
@@ -389,7 +388,7 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
}
update(coupon1, recordQueryWrapper);
});
return recordService.updateChain()
recordService.updateChain()
.set(MkShopCouponRecord::getStatus, 1)
.set(MkShopCouponRecord::getTargetId, orderId)
.set(MkShopCouponRecord::getUseTime, LocalDateTime.now())

View File

@@ -500,9 +500,9 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
if (param.getVipDiscountAmount().compareTo(BigDecimal.ZERO) <= 0) {
param.setVipDiscountAmount(BigDecimal.ZERO);
} else {
BigDecimal discount = BigDecimal.valueOf(100).subtract(BigDecimal.valueOf(shopUser.getDiscount())).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);
BigDecimal discount = BigDecimal.valueOf(100).subtract(BigDecimal.valueOf(shopUser.getDiscount())).divide(BigDecimal.valueOf(100), 2, RoundingMode.DOWN);
BigDecimal discountAmount = newTotalAmount.multiply(discount);
discountAmount = discountAmount.setScale(2, RoundingMode.HALF_DOWN);
discountAmount = discountAmount.setScale(2, RoundingMode.DOWN);
if (discountAmount.compareTo(param.getVipDiscountAmount()) != 0) {
log.info("会员整单折扣金额不正确:传递为:{},计算为:{}", param.getVipDiscountAmount(), discountAmount);
throw new OrderValidateException("生成支付订单失败,会员整单折扣金额不正确");

View File

@@ -96,7 +96,7 @@
sum(statistic.refund_amount) AS refundAmount
FROM
tb_shop_prod_statistic statistic
INNER JOIN tb_product prod ON tb_shop_prod_statistic.prod_id = prod.id
INNER JOIN tb_product prod ON statistic.prod_id = prod.id
WHERE
statistic.shop_id = #{shopId}
AND statistic.create_day = #{day}