| | |
| | | package com.dsh.activity.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.activity.entity.Coupon; |
| | | import com.dsh.activity.entity.CouponStore; |
| | | import com.dsh.activity.entity.UserCoupon; |
| | | import com.dsh.activity.feignclient.model.CouponStuAvailableVo; |
| | | import com.dsh.activity.feignclient.model.QueryUserCouponByIdAndUserId; |
| | | import com.dsh.activity.model.CouponListVo; |
| | | import com.dsh.activity.model.SendCouponReq; |
| | | import com.dsh.activity.service.CouponStoreService; |
| | | import com.dsh.activity.service.ICouponService; |
| | | import com.dsh.activity.service.UserCouponService; |
| | |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | |
| | | return availableVos; |
| | | } |
| | | |
| | | @PostMapping("/base/userConpon/queryCouponRules") |
| | | public Map<String,Object> getCouponRules(@RequestBody Integer couponId){ |
| | | return cService.queryConponRuleOfJson(couponId); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/userConpon/getCoupons") |
| | | public List<Coupon> getCoupons(@RequestBody String couponIds){ |
| | | ArrayList<Integer> integers = new ArrayList<>(); |
| | | for (String s : couponIds.split(",")) { |
| | | Integer integer = Integer.valueOf(s); |
| | | integers.add(integer); |
| | | } |
| | | return cService.list(new LambdaQueryWrapper<Coupon>().in(Coupon::getId,integers)); |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/coupon/querySiteCouponList") |
| | | @ApiOperation(value = "获取场地支付页面可用优惠券列表", tags = {"APP-预约场地", ""}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "场地id", name = "siteId", dataType = "int", required = true), |
| | | @ApiImplicitParam(value = "支付金额", name = "price", dataType = "double", required = true), |
| | | @ApiImplicitParam(value = "经度", name = "lon", dataType = "string", required = true), |
| | | @ApiImplicitParam(value = "纬度", name = "lat", dataType = "string", required = true), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<List<CouponListVo>> querySiteCouponList(Integer siteId, Double price, String lon, String lat){ |
| | | try { |
| | | Integer uid = tokenUtil.getUserIdFormRedis(); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | List<CouponListVo> listVos = userCouponService.querySiteCouponList(uid, siteId, price, lon, lat); |
| | | return ResultUtil.success(listVos); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据id获取用户优惠券数据 |
| | | * @param id |
| | |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/userCoupon/queryUserCouponById") |
| | | public UserCoupon queryUserCouponById(@RequestBody Long id){ |
| | | public UserCoupon queryUserCouponById(@RequestBody QueryUserCouponByIdAndUserId userCouponByIdAndUserId){ |
| | | try { |
| | | UserCoupon userCoupon = userCouponService.getById(id); |
| | | UserCoupon userCoupon = userCouponService.getOne(new LambdaQueryWrapper<UserCoupon>().eq(UserCoupon::getCouponId,userCouponByIdAndUserId.getId()).eq(UserCoupon::getUserId,userCouponByIdAndUserId.getUserId())); |
| | | return userCoupon; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/userCoupon/sendUserCoupon") |
| | | public void sendUserCoupon(@RequestBody SendCouponReq sendCouponReq){ |
| | | try { |
| | | String couponIds = sendCouponReq.getCouponIds(); |
| | | for (String s : couponIds.split(",")) { |
| | | UserCoupon userCoupon = new UserCoupon(); |
| | | userCoupon.setCouponId(Integer.valueOf(s)); |
| | | userCoupon.setUserId(sendCouponReq.getUserId()); |
| | | userCoupon.setStatus(1); |
| | | userCoupon.setInsertTime(new Date()); |
| | | userCouponService.save(userCoupon); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改优惠券数据 |
| | | * @param userCoupon |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/userCoupon/updateUserCoupon") |
| | | public void updateUserCoupon(@RequestBody UserCoupon userCoupon){ |
| | | try { |
| | | userCouponService.updateById(userCoupon); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/userCoupon/queryCouponOfStore") |
| | | public List<Integer> getCouponStoreIds(@RequestBody Integer couponId){ |
| | | try { |
| | |
| | | if (list.size() > 0 ){ |
| | | storeIds = list.stream().map(CouponStore::getStoreId).collect(Collectors.toList()); |
| | | } |
| | | if(storeIds.size()==0){ |
| | | storeIds.add(-1); |
| | | } |
| | | return storeIds; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |