退货增加订单Id

优惠券
This commit is contained in:
wangw 2025-03-04 09:41:48 +08:00
parent 23f4e36bda
commit fed28278d8
9 changed files with 32 additions and 18 deletions

View File

@ -4,6 +4,7 @@ import com.czg.account.dto.QueryReceiveDto;
import com.czg.account.dto.ShopCouponDTO;
import com.czg.account.service.ShopCouponService;
import com.czg.account.vo.CouponReceiveVo;
import com.czg.account.vo.UserCouponVo;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
@ -71,5 +72,15 @@ public class ShopCouponController {
return CzgResult.success(couponService.queryReceive(param));
}
/**
* 生成订单后使用
* 通过用户Id 查找优惠券
*
* @param shopUserId 店铺用户Id
*/
@GetMapping("/findCoupon")
public CzgResult<List<UserCouponVo>> findCoupon(@RequestParam Long shopUserId, @RequestParam(required = false) Integer type) {
return CzgResult.success(couponService.findCoupon(StpKit.USER.getShopId(), shopUserId, type));
}
}

View File

@ -43,7 +43,7 @@ public class UserShopCouponController {
* @param shopUserId 店铺用户Id
*/
@GetMapping("/findCoupon")
public CzgResult<List<UserCouponVo>> findCoupon(@RequestHeader String shopId, @RequestParam Long shopUserId) {
return CzgResult.success(couponService.findCoupon(Long.parseLong(shopId), shopUserId));
public CzgResult<List<UserCouponVo>> findCoupon(@RequestHeader String shopId, @RequestParam Long shopUserId, @RequestParam(required = false) Integer type) {
return CzgResult.success(couponService.findCoupon(Long.parseLong(shopId), shopUserId, type));
}
}

View File

@ -21,5 +21,5 @@ public interface ShopActivateCouponRecordService extends IService<ShopActivateCo
List<ShopActivateCouponRecord> findByUser(List<Long> shopUserIds, Integer status);
List<UserCouponVo> queryByVipIdAndShopId(Long shopId, Long shopUserId);
List<UserCouponVo> queryByVipIdAndShopId(Long shopId, Long shopUserId, Integer type);
}

View File

@ -37,7 +37,7 @@ public interface ShopCouponService extends IService<ShopCoupon> {
Page<ShopActivateCouponRecord> find(Long userId,Long shopId, Integer status);
List<UserCouponVo> findCoupon(Long shopId, Long shopUserId);
List<UserCouponVo> findCoupon(Long shopId, Long shopUserId, Integer type);
Boolean use(List<Long> ids, Long shopUserId, Long orderId);

View File

@ -19,5 +19,5 @@ public interface ShopActivateCouponRecordMapper extends BaseMapper<ShopActivateC
List<CouponReceiveVo> queryReceive(QueryReceiveDto param);
List<ShopActivateCouponRecord> findByUser(List<Long> shopUserIds, Integer status);
List<UserCouponVo> queryByVipIdAndShopId(Long shopId, Long shopUserId);
List<UserCouponVo> queryByVipIdAndShopId(Long shopId, Long shopUserId,Integer type);
}

View File

@ -31,7 +31,7 @@ public class ShopActivateCouponRecordServiceImpl extends ServiceImpl<ShopActivat
}
@Override
public List<UserCouponVo> queryByVipIdAndShopId(Long shopId, Long shopUserId) {
return getMapper().queryByVipIdAndShopId(shopId, shopUserId);
public List<UserCouponVo> queryByVipIdAndShopId(Long shopId, Long shopUserId, Integer type) {
return getMapper().queryByVipIdAndShopId(shopId, shopUserId, type);
}
}

View File

@ -83,7 +83,7 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
@Override
public Page<CouponReceiveVo> queryReceive(QueryReceiveDto param) {
Page<Object> page = PageUtil.buildPage();
PageHelper.startPage(Math.toIntExact(page.getPageNumber()),Math.toIntExact(page.getPageSize()));
PageHelper.startPage(Math.toIntExact(page.getPageNumber()), Math.toIntExact(page.getPageSize()));
return PageUtil.convert(new PageInfo<>(couponRecordService.queryReceive(param)));
}
@ -96,15 +96,15 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
.eq(ShopUser::getShopId, shopId)
.select(ShopUser::getId).listAs(Long.class);
if (CollectionUtil.isNotEmpty(shopUserIds)) {
PageHelper.startPage(Math.toIntExact(page.getPageNumber()),Math.toIntExact(page.getPageSize()));
PageHelper.startPage(Math.toIntExact(page.getPageNumber()), Math.toIntExact(page.getPageSize()));
return PageUtil.convert(new PageInfo<>(couponRecordService.findByUser(shopUserIds, status)));
}
return new Page<>();
}
@Override
public List<UserCouponVo> findCoupon(Long shopId, Long shopUserId) {
List<UserCouponVo> tbUserCouponVos = couponRecordService.queryByVipIdAndShopId(shopId, shopUserId);
public List<UserCouponVo> findCoupon(Long shopId, Long shopUserId, Integer type) {
List<UserCouponVo> tbUserCouponVos = couponRecordService.queryByVipIdAndShopId(shopId, shopUserId,type);
if (CollectionUtil.isNotEmpty(tbUserCouponVos)) {
String week = DateUtil.dayOfWeekEnum(new Date()).toChinese("");
LocalTime now = LocalTime.now();

View File

@ -63,7 +63,7 @@
inRecord.over_num as num,
inRecord.use_end_time as endTime
FROM
tb_activate_in_record inRecord
tb_shop_activate_coupon_record inRecord
LEFT JOIN tb_shop_info shop ON inRecord.shop_id = shop.id
LEFT JOIN tb_product pro ON inRecord.pro_id = pro.id and pro.shop_id = #{shopId}
WHERE
@ -74,7 +74,10 @@
<if test="shopId != null and shopId != ''">
and inRecord.shop_id = #{shopId}
</if>
and inRecord.over_num != 0
<if test="type != null ">
and inRecord.type = #{type}
</if>
and inRecord.status = 0
and inRecord.use_start_time &lt; now()
and inRecord.use_end_time &gt; now()
order by inRecord.use_end_time

View File

@ -317,10 +317,10 @@ public class PayServiceImpl implements PayService {
if (isFree) {
shopUserMoneyEditDTO.setBizEnum(ShopUserFlowBizEnum.FREE_IN);
orderInfoService.updateChain().eq(OrderInfo::getId, payParam.getOrderId())
.set(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode())
.set(OrderInfo::getIsFreeDine, 1)
.set(OrderInfo::getPayAmount, 0)
.update();
.set(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode())
.set(OrderInfo::getIsFreeDine, 1)
.set(OrderInfo::getPayAmount, 0)
.update();
}
//更新会员余额 并生成流水
Long flowId = shopUserService.updateMoney(shopUser.getShopId(), shopUserMoneyEditDTO);
@ -635,7 +635,7 @@ public class PayServiceImpl implements PayService {
orderInfo.setRefundRemark(orderInfo.getRefundRemark() + param.getRefundReason());
orderInfoService.updateById(orderInfo);
//退款返还库存
rabbitPublisher.sendOrderRefundMsg(JSONObject.toJSONString(returnProMap));
rabbitPublisher.sendOrderRefundMsg(JSONObject.toJSONString(Map.of("orderId", orderInfo.getId(), "returnProMap", returnProMap)));
return CzgResult.success();
}