|
@@ -1,5 +1,7 @@
|
|
|
package com.platform.yijia.controller;
|
|
|
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.google.gson.GsonBuilder;
|
|
|
import com.platform.yijia.config.YiJiaRequest;
|
|
@@ -192,23 +194,35 @@ public class CouponController {
|
|
|
@ResponseBody
|
|
|
@ApiOperation(value = "获取客户所拥有的优惠券", httpMethod = "GET", notes = "获取客户所拥有的优惠券")
|
|
|
public String selectUserCoupons(@ApiParam(value = "油站ID", required = true) @RequestParam Integer stationId,
|
|
|
- @ApiParam(value = "用户unionId", required = true) @RequestParam String unionId){
|
|
|
+ @ApiParam(value = "用户unionId", required = true) @RequestParam String unionId,
|
|
|
+ @ApiParam(value = "优惠券状态couponIsUsed", required = true) @RequestParam String couponIsUsed,
|
|
|
+ @RequestParam int pageNum, @RequestParam int pageSize){
|
|
|
Gson gson =new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
|
|
|
ResultData resultData = null;
|
|
|
try {
|
|
|
- if(stationId !=null && StringUtils.isNotBlank(unionId)){
|
|
|
+ if(stationId !=null && StringUtils.isNotBlank(unionId) && StringUtils.isNotBlank(couponIsUsed)){
|
|
|
StationInfo stationInfo = new StationInfo();
|
|
|
stationInfo.setStationId(stationId);
|
|
|
StationInfo stationInfos = stationService.selectStationInfo(stationInfo);
|
|
|
- if(stationInfos !=null && stationInfos.getCouponEnabledFlag().equals("1")){
|
|
|
+ if(stationInfos !=null && stationInfos.getCouponEnabledFlag().equals("1") && Integer.valueOf(pageNum) !=null && Integer.valueOf(pageSize) !=null){
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
UserCoupon userCoupon = new UserCoupon();
|
|
|
userCoupon.setStationId(stationId);
|
|
|
+ userCoupon.setCouponIsUsed(couponIsUsed);
|
|
|
+ userCoupon.setExpireFlag("0");
|
|
|
+ userCoupon.setCurrentTime(new Date());
|
|
|
+ //已过期
|
|
|
+ if(couponIsUsed.equals("2")){
|
|
|
+ userCoupon.setCouponIsUsed("0");
|
|
|
+ userCoupon.setExpireFlag("1");
|
|
|
+ }
|
|
|
if(stationInfos.getCouponFlag() !=null && stationInfos.getCouponFlag().equals("1")){
|
|
|
userCoupon.setStationId(stationInfos.getGroupId());
|
|
|
}
|
|
|
userCoupon.setUnionId(unionId);
|
|
|
List<UserCoupon> userCoupons = couponService.selectUserCoupons(userCoupon);
|
|
|
- resultData = ResultData.success(userCoupons);
|
|
|
+ PageInfo pageInfo = new PageInfo(userCoupons);
|
|
|
+ resultData = ResultData.success(pageInfo);
|
|
|
}else {
|
|
|
resultData = ResultData.error(CodeMsg.NO_ENABLE_COUPON);
|
|
|
}
|
|
@@ -217,8 +231,7 @@ public class CouponController {
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
- logger.error("获取客户所拥有的优惠券错误信息:" + e.getMessage());
|
|
|
- resultData = ResultData.error(CodeMsg.SEARCH_FAIL);
|
|
|
+ //logger.error("获取客户所拥有的优惠券错误信息:" + e.getMessage());
|
|
|
}
|
|
|
return gson.toJson(resultData);
|
|
|
}
|