增加可用优惠券数量
This commit is contained in:
parent
75b451cdda
commit
7c5e40cd38
|
|
@ -34,6 +34,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
|
@ -79,6 +80,12 @@ public class UserContoller {
|
|||
TbShopUser shopUser = shopUserMapper.selectByUserIdAndShopId(userId,shopId);
|
||||
return Result.success(CodeEnum.SUCCESS,shopUser);
|
||||
}
|
||||
|
||||
@GetMapping("/userCoupon")
|
||||
public Result userCoupon(@RequestParam("userId") String userId ,@RequestParam("shopId") BigDecimal orderNum ) throws Exception {
|
||||
int num = userService.userCoupon(userId,orderNum);
|
||||
return Result.success(CodeEnum.SUCCESS,num);
|
||||
}
|
||||
@PostMapping("/modityIntegral")
|
||||
public JSONObject modityIntegral(@RequestHeader String token,@RequestBody IntegralVo integralVo ) throws Exception {
|
||||
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.chaozhanggui.system.cashierservice.dao;
|
|||
import com.chaozhanggui.system.cashierservice.entity.TbSystemCoupons;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
public interface TbSystemCouponsMapper {
|
||||
|
|
@ -19,4 +20,6 @@ public interface TbSystemCouponsMapper {
|
|||
int updateByPrimaryKey(TbSystemCoupons record);
|
||||
|
||||
List<TbSystemCoupons> selectAll(@Param("type") String type);
|
||||
|
||||
int selectByAmount(@Param("orderNum") BigDecimal orderNum);
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
|
|
@ -25,4 +26,6 @@ public interface TbUserCouponsMapper {
|
|||
List<TbUserCoupons> selectByUserId(@Param("userId") String userId,@Param("status") String status);
|
||||
|
||||
TbUserCoupons selectByOrderId(@Param("orderId") Integer orderId);
|
||||
|
||||
int selectByUserIdAndAmount(@Param("userId") String userId, @Param("orderNum") BigDecimal orderNum);
|
||||
}
|
||||
|
|
@ -36,6 +36,10 @@ public class UserService {
|
|||
@Autowired
|
||||
private TbUserInfoMapper userInfoMapper;
|
||||
@Autowired
|
||||
private TbUserCouponsMapper userCouponsMapper;
|
||||
@Autowired
|
||||
private TbSystemCouponsMapper systemCouponsMapper;
|
||||
@Autowired
|
||||
RedisUtils redisUtils;
|
||||
|
||||
public JSONObject modityIntegral(IntegralVo integralVo, String userSign) {
|
||||
|
|
@ -218,4 +222,10 @@ public class UserService {
|
|||
result.put("data", pageInfo);
|
||||
return result;
|
||||
}
|
||||
|
||||
public int userCoupon(String userId, BigDecimal orderNum) {
|
||||
int userNum = userCouponsMapper.selectByUserIdAndAmount(userId,orderNum);
|
||||
int sysNum = systemCouponsMapper.selectByAmount(orderNum);
|
||||
return userNum+sysNum;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@
|
|||
<select id="selectAll" resultType="com.chaozhanggui.system.cashierservice.entity.TbSystemCoupons">
|
||||
select * from tb_system_coupons where status = '0' and name = #{type}
|
||||
</select>
|
||||
<select id="selectByAmount" resultType="java.lang.Integer" parameterType="java.math.BigDecimal">
|
||||
select ifnull(count(*),0) from tb_system_coupons where status = '0' and coupons_amount >= #{orderNum}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||
delete from tb_system_coupons
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,10 @@
|
|||
<select id="selectByOrderId" resultType="com.chaozhanggui.system.cashierservice.entity.TbUserCoupons">
|
||||
select * from tb_user_coupons where order_id = #{orderId}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||
<select id="selectByUserIdAndAmount" resultType="java.lang.Integer">
|
||||
select ifnull(count(*),0) from tb_user_coupons where user_id = #{userId} and status = '0' and coupons_amount >= #{orderNum}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||
delete from tb_user_coupons
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</delete>
|
||||
|
|
|
|||
Loading…
Reference in New Issue