添加获取优惠券条件

This commit is contained in:
韩鹏辉
2024-05-27 10:15:43 +08:00
parent 1848230528
commit 5e1e721233
4 changed files with 24 additions and 5 deletions

View File

@@ -62,8 +62,10 @@ public class OrderController {
@GetMapping("/mineCoupons") @GetMapping("/mineCoupons")
private Result mineCoupons(@RequestHeader String token,@RequestParam("userId") String userId,@RequestParam("status") String status, private Result mineCoupons(@RequestHeader String token,@RequestParam("userId") String userId,@RequestParam("status") String status,
@RequestParam(value = "page", required = false, defaultValue = "1") Integer page, @RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
@RequestParam(value = "size", required = false, defaultValue = "1") Integer size) throws IOException { @RequestParam(value = "size", required = false, defaultValue = "1") Integer size,
return orderService.mineCoupons(userId,status,page,size); @RequestParam("orderId") String orderId
) throws IOException {
return orderService.mineCoupons(userId,orderId,status,page,size);
} }
@GetMapping("/findCoupons") @GetMapping("/findCoupons")
private Result findCoupons(@RequestHeader String token,String type, private Result findCoupons(@RequestHeader String token,String type,

View File

@@ -23,7 +23,7 @@ public interface TbUserCouponsMapper {
int updateByPrimaryKey(TbUserCoupons record); int updateByPrimaryKey(TbUserCoupons record);
List<TbUserCoupons> selectByUserId(@Param("userId") String userId,@Param("status") String status); List<TbUserCoupons> selectByUserId(@Param("userId") String userId,@Param("status") String status,@Param("amount") BigDecimal amount);
TbUserCoupons selectByOrderId(@Param("orderId") Integer orderId); TbUserCoupons selectByOrderId(@Param("orderId") Integer orderId);

View File

@@ -74,6 +74,10 @@ public class OrderService {
private TbYhqParamsMapper yhqParamsMapper; private TbYhqParamsMapper yhqParamsMapper;
@Autowired @Autowired
private TbShopUserMapper shopUserMapper; private TbShopUserMapper shopUserMapper;
@Autowired
private TbOrderInfoMapper tbOrderInfoMapper;
/** /**
* 创建订单 * 创建订单
* *
@@ -307,9 +311,16 @@ public class OrderService {
} }
public Result mineCoupons(String userId, String status, Integer page, Integer size) { public Result mineCoupons(String userId, String orderId,String status, Integer page, Integer size) {
BigDecimal amount=null;
if(ObjectUtil.isNotNull(orderId)&&ObjectUtil.isNotEmpty(orderId)){
TbOrderInfo orderInfo= tbOrderInfoMapper.selectByPrimaryKey(Integer.valueOf(orderId));
amount=orderInfo.getOriginAmount();
}
PageHelper.startPage(page, size); PageHelper.startPage(page, size);
List<TbUserCoupons> list = userCouponsMapper.selectByUserId(userId,status); List<TbUserCoupons> list = userCouponsMapper.selectByUserId(userId,status,amount);
PageInfo pageInfo = new PageInfo(list); PageInfo pageInfo = new PageInfo(list);
return Result.success(CodeEnum.SUCCESS, pageInfo); return Result.success(CodeEnum.SUCCESS, pageInfo);
} }

View File

@@ -26,6 +26,12 @@
<if test="status != null and status != ''"> <if test="status != null and status != ''">
and status = #{status} and status = #{status}
</if> </if>
<if test="amount != null and amount != ''">
and coupons_amount &lt;= #{amount}
</if>
</select> </select>
<select id="selectByOrderId" resultType="com.chaozhanggui.system.cashierservice.entity.TbUserCoupons"> <select id="selectByOrderId" resultType="com.chaozhanggui.system.cashierservice.entity.TbUserCoupons">
select * from tb_user_coupons where order_id = #{orderId} select * from tb_user_coupons where order_id = #{orderId}