Commit 8e1e1242 authored by hezhen's avatar hezhen

修改使用优惠卷

parent b736781e
......@@ -6,6 +6,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
/**
......@@ -27,10 +28,12 @@ public interface ActivityFeign {
@ApiOperation("优惠卷使用")
@RequestMapping(value = "/user/use", method = RequestMethod.POST)
public ObjectRestResponse use(
public BigDecimal use(
@RequestParam(value = "userId") Integer userId,
@RequestParam(value = "TickerNo") String TickerNo,
@RequestParam(value = "orderNo") String orderNo);
@RequestParam(value = "orderNo") String orderNo,
@RequestParam(value = "channel") Integer channel,
@RequestParam(value = "orderNo") BigDecimal amout);
@ApiOperation("优惠卷取消使用")
@RequestMapping(value = "/user/cancelUse", method = RequestMethod.POST)
......
......@@ -17,6 +17,7 @@ import com.xxfc.platform.activity.mapper.UserCouponMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal;
import java.util.List;
/**
......@@ -127,23 +128,43 @@ public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
}
//支付后更新优惠卷状态
public void useTickerNo(Integer userId,String TickerNo,String orderNo){
public BigDecimal useTickerNo(Integer userId, String TickerNo, String orderNo,Integer channel,BigDecimal amout){
BigDecimal couponAmout=new BigDecimal("0.00");
if (userId==null||userId==0||StringUtils.isBlank(TickerNo)){
log.error("----参数不能为空");
return;
return couponAmout;
}
Example example=new Example(UserCoupon.class);
example.createCriteria().andEqualTo("TickerNo",TickerNo).andEqualTo("isDel",0);
List<UserCoupon> list=selectByExample(example);
if(list.size()==0){
log.error(userId+"----已领优惠卷");
return;
return couponAmout;
}
UserCoupon userCoupon=list.get(0);
userCoupon.setIsUse(1);
userCoupon.setOrderNo(orderNo);
userCoupon.setUseTime(System.currentTimeMillis());
updateSelectiveById(userCoupon);
return getCouponAmout(userCoupon.getCouponId(),channel,amout);
}
public BigDecimal getCouponAmout(Integer couponId,Integer channel,BigDecimal amout) {
BigDecimal couponAmout = new BigDecimal("0.00");
Coupon coupon = couponBiz.selectById(couponId);
if (coupon != null && coupon.getChannel() == channel) {
Integer type = coupon.getType();
if (type != null) {
BigDecimal useAmout = coupon.getUsedAmount();
if (amout.compareTo(useAmout) > 0) {
if (type == 3 || (type == 1 && (amout.compareTo(coupon.getWithAmount()) >= 0))) {
couponAmout = amout.subtract(useAmout);
}
}
}
}
return couponAmout;
}
//取消使用优惠卷
......
......@@ -10,6 +10,8 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
@RestController
@RequestMapping("user")
public class UserCouponController extends ActivityBaseController<UserCouponBiz> {
......@@ -45,13 +47,14 @@ public class UserCouponController extends ActivityBaseController<UserCouponBiz>
@ApiOperation("优惠卷使用")
@RequestMapping(value = "/use", method = RequestMethod.POST)
public ObjectRestResponse use(
public BigDecimal use(
@RequestParam(value = "userId",defaultValue ="0" ) Integer userId,
@RequestParam(value = "TickerNo",defaultValue ="" ) String TickerNo,
@RequestParam(value = "orderNo",defaultValue ="" ) String orderNo
@RequestParam(value = "orderNo",defaultValue ="" ) String orderNo,
@RequestParam(value = "channel",defaultValue ="1" ) Integer channel,
@RequestParam(value = "orderNo",defaultValue ="0.00" ) BigDecimal amout
) {
baseBiz.useTickerNo(userId,TickerNo,orderNo);
return ObjectRestResponse.succ();
return baseBiz.useTickerNo(userId,TickerNo,orderNo,channel,amout);
}
@ApiOperation("优惠卷取消使用")
......
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