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