| @@ -4,6 +4,7 @@ import java.util.List; | |||||
| import com.simple.common.CommonMapper; | import com.simple.common.CommonMapper; | ||||
| import com.simple.domain.po.WxCUserTags; | import com.simple.domain.po.WxCUserTags; | ||||
| import org.apache.ibatis.annotations.Param; | |||||
| public interface WxCUserTagsMapper extends CommonMapper<WxCUserTags, String> { | public interface WxCUserTagsMapper extends CommonMapper<WxCUserTags, String> { | ||||
| @@ -12,5 +13,9 @@ public interface WxCUserTagsMapper extends CommonMapper<WxCUserTags, String> { | |||||
| long findCountByTag(List<Long> tagIds); | long findCountByTag(List<Long> tagIds); | ||||
| List<Long> findUserByTag(List<Long> tagIds); | List<Long> findUserByTag(List<Long> tagIds); | ||||
| long findCountByTags(@Param("tagIds")String tagIds); | |||||
| List<Long> findUserByTags(@Param("tagIds")String tagIds); | |||||
| } | } | ||||
| @@ -90,6 +90,9 @@ public class CouponInjectServiceImpl implements CouponInjectService { | |||||
| record.setStatus(0); | record.setStatus(0); | ||||
| } | } | ||||
| List<WxCUser> cUsers = wxCUserTagsService.findUserByTag(tagids); | List<WxCUser> cUsers = wxCUserTagsService.findUserByTag(tagids); | ||||
| if(cUsers.isEmpty()){ | |||||
| return new ResultData(Result.ERROR,"标签下没有用户"); | |||||
| } | |||||
| int inventory = wxCoupon.getRemainInventory();//库存数量 | int inventory = wxCoupon.getRemainInventory();//库存数量 | ||||
| if(cUsers.size()>inventory){ | if(cUsers.size()>inventory){ | ||||
| return new ResultData(Result.ERROR,"库存不足"); | return new ResultData(Result.ERROR,"库存不足"); | ||||
| @@ -5,6 +5,7 @@ import java.util.HashMap; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| import com.alibaba.fastjson.JSON; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| @@ -62,12 +63,14 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||||
| @Override | @Override | ||||
| public long findCountByTag(List<Long> tagIds) { | public long findCountByTag(List<Long> tagIds) { | ||||
| return wxCUserTagsMapper.findCountByTag(tagIds); | |||||
| String str = JSON.toJSONString(tagIds); | |||||
| return wxCUserTagsMapper.findCountByTags(str); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public List<WxCUser> findUserByTag(List<Long> tagIds) { | public List<WxCUser> findUserByTag(List<Long> tagIds) { | ||||
| List<Long> userIds = wxCUserTagsMapper.findUserByTag(tagIds); | |||||
| String str = JSON.toJSONString(tagIds); | |||||
| List<Long> userIds = wxCUserTagsMapper.findUserByTags(str); | |||||
| if(userIds.size()==0) { | if(userIds.size()==0) { | ||||
| return new ArrayList<>(); | return new ArrayList<>(); | ||||
| } | } | ||||
| @@ -67,5 +67,13 @@ | |||||
| <select id ="findUserByTag" resultType="java.lang.Long"> | <select id ="findUserByTag" resultType="java.lang.Long"> | ||||
| select user_id from wx_c_user_tags where JSON_CONTAINS(tags,JSON_ARRAY(#{list}) ); | select user_id from wx_c_user_tags where JSON_CONTAINS(tags,JSON_ARRAY(#{list}) ); | ||||
| </select> | </select> | ||||
| <select id ="findCountByTags" resultType="java.lang.Long"> | |||||
| select count(user_id) from wx_c_user_tags where JSON_CONTAINS(tags,#{tagIds} ); | |||||
| </select> | |||||
| <select id ="findUserByTags" resultType="java.lang.Long"> | |||||
| select user_id from wx_c_user_tags where JSON_CONTAINS(tags,#{tagIds} ); | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||