Commit 05963319 authored by hezhen's avatar hezhen

123

parent 3e5dffe1
...@@ -91,6 +91,26 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> { ...@@ -91,6 +91,26 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
log.error(userId+"----已领优惠卷"); log.error(userId+"----已领优惠卷");
return null; return null;
} }
falg=checkLed(userId,couponId,coupon.getLimitCollar(),coupon.getQuota());
if(falg){
log.error(userId+"----已超过领取限制");
return null;
}
return led(coupon,userId);
}
//后台领劵(一个劵可以发多张)
public String adminUserLedCoupon(Integer userId,Integer couponId){
Coupon coupon=couponBiz.selectById(couponId);
if (coupon==null||coupon.getIsDel()!=0||coupon.getStatus()!=1){
log.error(userId+"----无可领取优惠卷");
return null;
}
boolean falg=checkLed(userId,couponId,coupon.getLimitCollar(),coupon.getQuota());
if(falg){
log.error(userId+"----已超过领取限制");
return null;
}
return led(coupon,userId); return led(coupon,userId);
} }
...@@ -123,7 +143,7 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> { ...@@ -123,7 +143,7 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
//检查用户是否领卷 //检查用户是否领卷
public boolean checkUserLed(Integer userId,Integer id){ public boolean checkUserLed(Integer userId,Integer id){
Example example=new Example(UserCoupon.class); Example example=new Example(UserCoupon.class);
example.createCriteria().andEqualTo("userId",userId).andEqualTo("couponId",id); example.createCriteria().andEqualTo("userId",userId).andEqualTo("couponId",id).andEqualTo("isDel",0);
List<UserCoupon> list=selectByExample(example); List<UserCoupon> list=selectByExample(example);
if(list.size()>0){ if(list.size()>0){
log.error(userId+"----已领优惠卷"); log.error(userId+"----已领优惠卷");
...@@ -132,6 +152,29 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> { ...@@ -132,6 +152,29 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
return false; return false;
} }
//检查用户是否可领卷
public boolean checkLed(Integer userId,Integer id,Integer limitCollar,Integer quota){
Example example=new Example(UserCoupon.class);
example.createCriteria().andEqualTo("userId",userId).andEqualTo("couponId",id).andEqualTo("isDel",0);
Integer num=selectCountByExample(example);
if(num==null||num==0){
log.error(userId+"----无领此优惠卷----couponid==="+id);
return false;
}
if (limitCollar==null||num>=limitCollar){
log.error(userId+"----此优惠卷超过每人限领次数----couponid==="+id+"----limitCollar==="+limitCollar);
return true;
}
example.clear();
example.createCriteria().andEqualTo("couponId",id).andEqualTo("isDel",0);
num=selectCountByExample(example);
if (quota==null||quota==0||(num!=null&&num>0&&num>=quota)){
log.error(userId+"----此优惠卷超过发券数量----couponid==="+id+"----quota==="+quota);
return true;
}
return false;
}
//获取我的优惠卷 //获取我的优惠卷
public ObjectRestResponse getCouponList(Integer userId,int type,Integer channel,BigDecimal amout){ public ObjectRestResponse getCouponList(Integer userId,int type,Integer channel,BigDecimal amout){
if (userId==null||userId==0){ if (userId==null||userId==0){
...@@ -206,7 +249,6 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> { ...@@ -206,7 +249,6 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
result.put("array",array); result.put("array",array);
return ObjectRestResponse.succ(result); return ObjectRestResponse.succ(result);
} }
//获取我的优惠卷 //获取我的优惠卷
public ObjectRestResponse getUserCouponList(Integer userId,int type,Integer channel,BigDecimal amout) { public ObjectRestResponse getUserCouponList(Integer userId,int type,Integer channel,BigDecimal amout) {
if (userId == null || userId == 0) { if (userId == null || userId == 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment