Merge branch 'ww' into test
This commit is contained in:
commit
9207ebfd03
|
|
@ -1,5 +1,6 @@
|
|||
package cn.ysk.cashier.controller;
|
||||
|
||||
import cn.ysk.cashier.dto.QueryReceiveDto;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopCoupon;
|
||||
import cn.ysk.cashier.mybatis.service.TbShopCouponService;
|
||||
|
|
@ -7,6 +8,7 @@ import cn.ysk.cashier.mybatis.vo.TbShopCouponVo;
|
|||
import cn.ysk.cashier.utils.SecurityUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
|
@ -69,10 +71,24 @@ public class TbShopCouponController {
|
|||
}
|
||||
|
||||
@DeleteMapping
|
||||
@ApiOperation("删除")
|
||||
@ApiOperation("删除优惠券")
|
||||
public ResponseEntity<Object> delete(@RequestBody Integer[] ids) {
|
||||
tbShopCouponService.delete(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/queryReceive")
|
||||
@ApiOperation("领取详情")
|
||||
public ResponseEntity<Object> queryReceive(@Validated @RequestBody QueryReceiveDto param) {
|
||||
return new ResponseEntity<>(tbShopCouponService.queryReceive(param), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@DeleteMapping("receive")
|
||||
@ApiOperation("删除用户的券")
|
||||
public ResponseEntity<Object> deleteReceive(@RequestBody Integer[] ids) {
|
||||
tbShopCouponService.deleteReceive(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
package cn.ysk.cashier.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@Data
|
||||
public class QueryReceiveDto extends BaseQueryDto{
|
||||
@NotBlank(message = "优惠券id 不可为空")
|
||||
private String couponId;
|
||||
//用户昵称 手机号 模糊
|
||||
private String value;
|
||||
//状态 0 未使用 1 已使用
|
||||
private Integer status;
|
||||
|
||||
private Integer page = 1;
|
||||
|
||||
private Integer size = 10;
|
||||
}
|
||||
|
|
@ -1,7 +1,15 @@
|
|||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import cn.ysk.cashier.dto.QueryReceiveDto;
|
||||
import cn.ysk.cashier.pojo.shop.TbFullShopId;
|
||||
import cn.ysk.cashier.vo.QueryReceiveVo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopCoupon;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 优惠券(TbShopCoupon)表数据库访问层
|
||||
|
|
@ -11,5 +19,34 @@ import cn.ysk.cashier.mybatis.entity.TbShopCoupon;
|
|||
*/
|
||||
public interface TbShopCouponMapper extends BaseMapper<TbShopCoupon> {
|
||||
|
||||
@Select("<script>" +
|
||||
" SELECT" +
|
||||
" record.id, vip.id as userId ,vip.`name`,vip.telephone as phone,record.create_time as receiveTime," +
|
||||
" record.update_time as useTime, record.num ,record.over_num as overNum" +
|
||||
" FROM" +
|
||||
" tb_activate_in_record record" +
|
||||
" LEFT JOIN tb_shop_user vip " +
|
||||
" ON record.vip_user_id = vip.id AND vip.shop_id = #{param.shopId} " +
|
||||
" WHERE" +
|
||||
" record.coupon_id = #{param.couponId} " +
|
||||
" and record.shop_id = #{param.shopId} " +
|
||||
" <if test=\"param.value != null and param.value != '' \">" +
|
||||
" and (vip.name like concat('%', #{param.value}, '%') or vip.telephone like concat('%', #{param.value}, '%')) " +
|
||||
" </if>" +
|
||||
" <if test=\"param.status != null and param.status = 1\">" +
|
||||
" and record.over_num != record.num " +
|
||||
" </if>" +
|
||||
" <if test=\"param.status != null and param.status = 0\">" +
|
||||
" and record.over_num = record.num " +
|
||||
" </if>" +
|
||||
" <if test=\"param.startTime != null \">" +
|
||||
" and record.create_time > #{param.startTime} " +
|
||||
" </if>" +
|
||||
" <if test=\"param.endTime != null \">" +
|
||||
" and record.create_time < #{param.endTime} " +
|
||||
" </if>" +
|
||||
" order by record.create_time desc" +
|
||||
"</script>")
|
||||
Page<QueryReceiveVo> queryReceive(QueryReceiveDto param ,Page<QueryReceiveVo> page);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import cn.ysk.cashier.dto.CouponDto;
|
||||
import cn.ysk.cashier.dto.QueryReceiveDto;
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord;
|
||||
import cn.ysk.cashier.mybatis.entity.TbCouponProduct;
|
||||
import cn.ysk.cashier.mybatis.vo.TbShopCouponVo;
|
||||
import cn.ysk.cashier.vo.QueryReceiveVo;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopCoupon;
|
||||
import cn.ysk.cashier.dto.TbShopCouponQueryCriteria;
|
||||
|
|
@ -22,11 +25,12 @@ public interface TbShopCouponService extends IService<TbShopCoupon> {
|
|||
|
||||
Map<String, Object> queryAll(TbShopCouponQueryCriteria criteria);
|
||||
|
||||
|
||||
Map<String, Object> queryReceive(QueryReceiveDto param);
|
||||
TbShopCoupon findById (Integer id);
|
||||
|
||||
boolean update(TbShopCouponVo param);
|
||||
boolean delete(Integer[] ids);
|
||||
boolean deleteReceive(Integer[] ids);
|
||||
|
||||
ResponseEntity<Object> find(CouponDto param);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,9 @@ import cn.hutool.core.bean.copier.CopyOptions;
|
|||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.ysk.cashier.dto.CouponDto;
|
||||
import cn.ysk.cashier.dto.QueryReceiveDto;
|
||||
import cn.ysk.cashier.dto.TbShopCouponQueryCriteria;
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivateInRecord;
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord;
|
||||
import cn.ysk.cashier.mybatis.entity.TbCouponProduct;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopCoupon;
|
||||
import cn.ysk.cashier.mybatis.entity.*;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbActivateInRecordMapper;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbActivateOutRecordMapper;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbShopCouponMapper;
|
||||
|
|
@ -27,6 +25,7 @@ import cn.ysk.cashier.repository.product.TbProductRepository;
|
|||
import cn.ysk.cashier.repository.shop.TbShopUserRepository;
|
||||
import cn.ysk.cashier.service.shop.TbShopUserService;
|
||||
import cn.ysk.cashier.utils.PageUtil;
|
||||
import cn.ysk.cashier.vo.QueryReceiveVo;
|
||||
import cn.ysk.cashier.vo.TbUserCouponVo;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
|
@ -86,6 +85,13 @@ public class TbShopCouponServiceImpl extends ServiceImpl<TbShopCouponMapper, TbS
|
|||
return PageUtil.toPage(ipage.getRecords(), ipage.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryReceive(QueryReceiveDto param) {
|
||||
Page<QueryReceiveVo> page = new Page<>(param.getPage(), param.getSize());
|
||||
Page<QueryReceiveVo> ipage = tbShopCouponmapper.queryReceive(param, page);
|
||||
return PageUtil.toPage(ipage.getRecords(), ipage.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TbShopCouponVo findById(Integer id) {
|
||||
TbShopCouponVo tbShopCouponVo = new TbShopCouponVo();
|
||||
|
|
@ -128,6 +134,12 @@ public class TbShopCouponServiceImpl extends ServiceImpl<TbShopCouponMapper, TbS
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteReceive(Integer[] ids) {
|
||||
inRecordMapper.deleteBatchIds(Arrays.asList(ids));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delete(Integer[] ids) {
|
||||
tbShopCouponmapper.deleteBatchIds(Arrays.asList(ids));
|
||||
|
|
@ -137,6 +149,7 @@ public class TbShopCouponServiceImpl extends ServiceImpl<TbShopCouponMapper, TbS
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Object> find(CouponDto param) {
|
||||
TbShopUser tbShopUser = shopUserRepository.selectByUserIdAndShopId(param.getUserId().toString(), param.getShopId().toString());
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
package cn.ysk.cashier.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class QueryReceiveVo {
|
||||
|
||||
private Integer id;
|
||||
private Integer userId;
|
||||
private String name;
|
||||
private String phone;
|
||||
private Date receiveTime;
|
||||
private Date useTime;
|
||||
private String num;
|
||||
private String overNum;
|
||||
private String source;
|
||||
private String status;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue