package com.cweb.controller; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; import com.hai.common.utils.ResponseMsgUtil; import com.hai.entity.BsCompany; import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.util.*; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/11 22:16 */ @Controller @RequestMapping(value = "/coupon") @Api(value = "卡卷接口") public class HighCouponController { private static Logger log = LoggerFactory.getLogger(HighCouponController.class); @Autowired private UserCenter userCenter; @Resource private HighMerchantService highMerchantService; @Resource private HighCouponService highCouponService; @Resource private HighCouponHandselService highCouponHandselService; @Resource private BsCompanyService bsCompanyService; @Resource private HighCouponCodeService highCouponCodeService; @Resource private HighApproveService highApproveService; @RequestMapping(value="/getCouponList",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "卡卷列表") public ResponseData getCouponList(@RequestParam(name = "regionId", required = true) String regionId, @RequestParam(name = "merchantId", required = false) Long merchantId, @RequestParam(name = "couponName", required = false) String couponName, @RequestParam(name = "couponType", required = false) Integer couponType, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize) { try { BsCompany bsCompany = bsCompanyService.selectCompanyByRegion(regionId); if (bsCompany != null) { Map map = new HashMap<>(); map.put("companyId", bsCompany.getRegionId()); map.put("merchantId", merchantId); map.put("couponName", couponName); map.put("couponType", couponType); map.put("status", 2); PageHelper.startPage(pageNum, pageSize); return ResponseMsgUtil.success(new PageInfo<>(highCouponService.getCouponList(map))); } return ResponseMsgUtil.success(new PageInfo<>()); } catch (Exception e) { log.error("HighCouponController -> getCouponList() error!",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/getCouponById",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "卡卷信息") public ResponseData getCouponById(@RequestParam(name = "couponId", required = true) Long couponId) { try { return ResponseMsgUtil.success(highCouponService.getCouponById(couponId)); } catch (Exception e) { log.error("HighCouponController -> getCouponById() error!",e); return ResponseMsgUtil.exception(e); } } }