| | |
| | | import com.jilongda.manage.service.TAppUserService; |
| | | import com.jilongda.manage.service.TCouponReceiveService; |
| | | import com.jilongda.manage.service.TCouponService; |
| | | import com.jilongda.manage.utils.OssUploadUtil; |
| | | import com.jilongda.manage.utils.QRCodeUtil; |
| | | import com.jilongda.manage.vo.TAppUserVO; |
| | | import com.jilongda.manage.vo.TCouponInfoVO; |
| | |
| | | @ApiOperation(value = "添加优惠券") |
| | | @PostMapping(value = "/add") |
| | | public ApiResult<String> add( @RequestBody TCoupon dto) throws Exception { |
| | | if (dto.getType()==1||dto.getType()==4)dto.setGrantStatus(1); |
| | | couponService.save(dto); |
| | | switch (dto.getType()){ |
| | | case 2: |
| | |
| | | String code = "{\"id\": "+dto.getId()+ "}"; |
| | | BufferedImage blueImage = QRCodeUtil.createImage(code); |
| | | MultipartFile blueFile = convert(blueImage, new Date().getTime() + UUIDUtil.getRandomCode(3) + ".PNG"); |
| | | // todo 没有云存储 |
| | | // String s = OssUploadUtil.ossUpload("img/", blueFile); |
| | | String s = OssUploadUtil.ossUpload("eyes/", blueFile); |
| | | dto.setQrCode(s); |
| | | couponService.updateById(dto); |
| | | break; |
| | | } |
| | | return ApiResult.success(); |
| | | } |
| | | @ApiOperation(value = "暂停发放 只有type为1和4的时候") |
| | | @PostMapping(value = "/stop") |
| | | public ApiResult stop(Integer id) throws Exception { |
| | | TCoupon byId = couponService.getById(id); |
| | | byId.setGrantStatus(2); |
| | | couponService.updateById(byId); |
| | | return ApiResult.success(); |
| | | } |
| | | @ApiOperation(value = "修改优惠券") |
| | | @PostMapping(value = "/update") |
| | | public ApiResult<String> update( @RequestBody TCoupon dto) throws Exception { |