package share.web.controller.system; import java.util.Date; import java.util.List; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang3.StringUtils; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import share.common.annotation.Log; import share.common.core.controller.BaseController; import share.common.core.domain.AjaxResult; import share.common.enums.BusinessType; import share.common.enums.CouponTypeEnum; import share.common.enums.RoomType; import share.common.enums.StoreType; import share.system.domain.SCoupon; import share.system.domain.vo.SCouponVo; import share.system.service.ISCouponService; import share.common.utils.poi.ExcelUtil; import share.common.core.page.TableDataInfo; /** * 优惠券Controller * * @author ruoyi * @date 2023-09-27 */ @RestController @RequestMapping("/system/coupon") public class SCouponController extends BaseController { @Autowired private ISCouponService sCouponService; /** * 查询优惠券列表 */ @PreAuthorize("@ss.hasPermi('system:coupon:list')") @GetMapping("/list") public TableDataInfo list(SCoupon sCoupon) { startPage(); List<SCoupon> list = sCouponService.selectSCouponList(sCoupon); return getDataTable(list); } /** * 查询时长劵列表 */ @PreAuthorize("@ss.hasPermi('system:coupon:list')") @GetMapping("/list/duration") public TableDataInfo listDuration(SCoupon sCoupon) { return sCouponService.listDuration(sCoupon); } /** * 查询时长劵列表 */ @PreAuthorize("@ss.hasPermi('system:coupon:list')") @GetMapping("/list/durationCoupon") public AjaxResult listDurationCoupon(SCoupon sCoupon) { return AjaxResult.success(sCouponService.listDurationCoupon(sCoupon)); } /** * 查询团购劵类别 */ @PreAuthorize("@ss.hasPermi('system:coupon:list')") @GetMapping("/list/group") public TableDataInfo listGroup(SCoupon sCoupon) { startPage(); sCoupon.setCouponType(CouponTypeEnum.CASH.getCode()); List<SCoupon> list = sCouponService.selectSCouponList(sCoupon); return getDataTable(list); } /** * 导出优惠券列表 */ @PreAuthorize("@ss.hasPermi('system:coupon:export')") @Log(title = "优惠券", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, SCoupon sCoupon) { List<SCoupon> list = sCouponService.selectSCouponList(sCoupon); ExcelUtil<SCoupon> util = new ExcelUtil<SCoupon>(SCoupon.class); util.exportExcel(response, list, "优惠券数据"); } /** * 获取优惠券详细信息 */ @PreAuthorize("@ss.hasPermi('system:coupon:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { return success(sCouponService.selectSCouponById(id)); } /** * 新增优惠券 */ @PreAuthorize("@ss.hasPermi('system:coupon:add')") @Log(title = "优惠券", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody SCoupon sCoupon) { return toAjax(sCouponService.insertSCoupon(sCoupon)); } /** * 修改优惠券 */ @PreAuthorize("@ss.hasPermi('system:coupon:edit')") @Log(title = "优惠券", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody SCoupon sCoupon) { return toAjax(sCouponService.updateSCoupon(sCoupon)); } /** * 删除优惠券 */ @PreAuthorize("@ss.hasPermi('system:coupon:remove')") @Log(title = "优惠券", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(sCouponService.deleteSCouponByIds(ids)); } /** * 查询美团所有优惠卷的适用门店 */ @GetMapping("/queryshopdeal") public AjaxResult queryShopDeal() { return success(sCouponService.queryShopDeal()); } @GetMapping("/querySkuPoiList") public AjaxResult querySkuPoiList() { return success(sCouponService.querySkuPoiList()); } }