Merge remote-tracking branch 'origin/test' into zs
# Conflicts: # eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java # eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java
This commit is contained in:
commit
2252f4edcb
|
|
@ -0,0 +1,46 @@
|
|||
package cn.ysk.cashier.controller;
|
||||
|
||||
import cn.ysk.cashier.dto.TbMiniAppPagesDto;
|
||||
import cn.ysk.cashier.mybatis.service.TbMiniAppPagesService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/miniAppPages")
|
||||
public class TbMiniAppPagesController {
|
||||
|
||||
final private TbMiniAppPagesService tbMiniAppPagesService;
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation("新增/system/miniAppPages")
|
||||
public ResponseEntity<Object> createTbMiniAppPages(@Validated @RequestBody TbMiniAppPagesDto pagesDto) {
|
||||
return tbMiniAppPagesService.createTbMiniAppPages(pagesDto);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@ApiOperation("修改/system/miniAppPages")
|
||||
public ResponseEntity<Object> updateTbMiniAppPages(@Validated @RequestBody TbMiniAppPagesDto pagesDto) {
|
||||
return tbMiniAppPagesService.updateTbMiniAppPages(pagesDto);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{pagesId}")
|
||||
@ApiOperation("删除/system/miniAppPages")
|
||||
public ResponseEntity<Object> deleteTbMiniAppPages(@PathVariable Integer pagesId) {
|
||||
return tbMiniAppPagesService.deleteTbMiniAppPages(pagesId);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation("查询/system/miniAppPages")
|
||||
public ResponseEntity<Object> getTbMiniAppPages(@RequestParam Map<String, Object> params) {
|
||||
return tbMiniAppPagesService.getTbMiniAppPages(params);
|
||||
}
|
||||
}
|
||||
|
|
@ -179,6 +179,16 @@ public class TbPlaceController {
|
|||
) {
|
||||
return ResponseEntity.ok(tbShopTableService.pay(payDTO));
|
||||
}
|
||||
@AnonymousAccess
|
||||
|
||||
@DeleteMapping("/order")
|
||||
@Log("代客下单 删除订单")
|
||||
@ApiOperation("代客下单 查询购物车 /shop/table")
|
||||
public ResponseEntity<Object> delete(
|
||||
@Validated @RequestBody DeleteOrderDTO deleteOrderDTO
|
||||
) {
|
||||
return ResponseEntity.ok(tbShopTableService.deleteOrder(deleteOrderDTO));
|
||||
}
|
||||
|
||||
@AnonymousAccess
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
package cn.ysk.cashier.controller.shop;
|
||||
|
||||
import cn.ysk.cashier.dto.shop.TbShopAdDto;
|
||||
import cn.ysk.cashier.mybatis.service.TbShopAdService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/ad")
|
||||
public class TbShopAdController {
|
||||
final private TbShopAdService tbShopAdService;
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<Object> createTbShopAd(@RequestBody TbShopAdDto adDto) {
|
||||
return tbShopAdService.createTbShopAd(adDto);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public ResponseEntity<Object> updateTbShopAd(@RequestBody TbShopAdDto adDto) {
|
||||
return tbShopAdService.updateTbShopAd(adDto);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{adId}")
|
||||
public ResponseEntity<Object> deleteTbShopAd(@PathVariable Integer adId) {
|
||||
return tbShopAdService.deleteTbShopAd(adId);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<Object> getTbShopAd(@RequestParam Map<String, Object> params) {
|
||||
return tbShopAdService.getTbShopAd(params);
|
||||
}
|
||||
}
|
||||
|
|
@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
|
|
@ -96,4 +97,12 @@ public class TbShopUserController {
|
|||
public void rechargeListDownload(HttpServletResponse response, @RequestBody TbShopRechargeListDto criteria) throws IOException {
|
||||
tbShopUserService.rechargeListDownload(response, criteria);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("midfiyAccount")
|
||||
@ApiOperation("增加扣减会员余额")
|
||||
public ResponseEntity<Object> midfiyAccount(Map<String,Object> map){
|
||||
tbShopUserService.modfiyAccount(map);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
package cn.ysk.cashier.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
@Data
|
||||
public class TbMiniAppPagesDto {
|
||||
private Integer id;
|
||||
private Integer shopId;
|
||||
private String name;
|
||||
private String path;
|
||||
private String icon;
|
||||
private String description;
|
||||
private Integer sort;
|
||||
private Integer status;
|
||||
private Date createTime;
|
||||
private Date updateTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package cn.ysk.cashier.dto.shop;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopAd;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
@Data
|
||||
public class TbShopAdDto {
|
||||
private Integer id;
|
||||
private Integer shopId;
|
||||
private String imgUrl;
|
||||
private String linkPath;
|
||||
private Integer borderRadius;
|
||||
private String showPosition;
|
||||
private String frequency;
|
||||
private Integer status;
|
||||
private Integer sort;
|
||||
private Date createTime;
|
||||
private Date updateTime;
|
||||
|
||||
public TbShopAd convertToTbShopAd() {
|
||||
TbShopAd tbShopAd = new TbShopAd();
|
||||
tbShopAd.setId(this.id);
|
||||
tbShopAd.setShopId(this.shopId);
|
||||
tbShopAd.setImgUrl(this.imgUrl);
|
||||
tbShopAd.setLinkPath(this.linkPath);
|
||||
tbShopAd.setBorderRadius(this.borderRadius);
|
||||
tbShopAd.setShowPosition(this.showPosition);
|
||||
tbShopAd.setFrequency(this.frequency);
|
||||
tbShopAd.setStatus(this.status);
|
||||
tbShopAd.setSort(this.sort);
|
||||
tbShopAd.setCreateTime(this.createTime);
|
||||
tbShopAd.setUpdateTime(this.updateTime);
|
||||
return tbShopAd;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package cn.ysk.cashier.mybatis.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("tb_mini_app_pages")
|
||||
public class TbMiniAppPages extends Model<TbMiniAppPages> {
|
||||
private Integer id;
|
||||
private String icon;
|
||||
private String name;
|
||||
private String path;
|
||||
private String description;
|
||||
private Integer status;
|
||||
private Integer sort;
|
||||
private Date createTime;
|
||||
private Date updateTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package cn.ysk.cashier.mybatis.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("tb_shop_ad")
|
||||
public class TbShopAd extends Model<TbShopAd> {
|
||||
private Integer id;
|
||||
private Integer shopId;
|
||||
private String imgUrl;
|
||||
private String linkPath;
|
||||
private Integer borderRadius;
|
||||
private String showPosition;
|
||||
private String frequency;
|
||||
private Integer status;
|
||||
private Integer sort;
|
||||
private Date createTime;
|
||||
private Date updateTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbMiniAppPages;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
public interface TbMiniAppPagesMapper extends BaseMapper<TbMiniAppPages> {
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopAd;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
public interface TbShopAdMapper extends BaseMapper<TbShopAd> {
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import cn.ysk.cashier.dto.TbMiniAppPagesDto;
|
||||
import cn.ysk.cashier.mybatis.entity.TbMiniAppPages;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
public interface TbMiniAppPagesService extends IService<TbMiniAppPages> {
|
||||
|
||||
ResponseEntity<Object> createTbMiniAppPages(TbMiniAppPagesDto pagesDto);
|
||||
|
||||
ResponseEntity<Object> updateTbMiniAppPages(TbMiniAppPagesDto pagesDto);
|
||||
|
||||
ResponseEntity<Object> deleteTbMiniAppPages(Integer pagesId);
|
||||
|
||||
ResponseEntity<Object> getTbMiniAppPages(Map<String, Object> params);
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import cn.ysk.cashier.dto.shop.TbShopAdDto;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopAd;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
public interface TbShopAdService extends IService<TbShopAd> {
|
||||
|
||||
ResponseEntity<Object> createTbShopAd(TbShopAdDto adDto);
|
||||
|
||||
ResponseEntity<Object> updateTbShopAd(TbShopAdDto adDto);
|
||||
|
||||
ResponseEntity<Object> deleteTbShopAd(Integer adId);
|
||||
|
||||
ResponseEntity<Object> getTbShopAd(Map<String, Object> params);
|
||||
}
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import cn.ysk.cashier.dto.TbMiniAppPagesDto;
|
||||
import cn.ysk.cashier.mybatis.entity.TbMiniAppPages;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbMiniAppPagesMapper;
|
||||
import cn.ysk.cashier.mybatis.service.TbMiniAppPagesService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TbMiniAppPagesServiceImpl extends ServiceImpl<TbMiniAppPagesMapper, TbMiniAppPages> implements TbMiniAppPagesService {
|
||||
@Override
|
||||
public ResponseEntity<Object> createTbMiniAppPages(TbMiniAppPagesDto pagesDto) {
|
||||
if (pagesDto == null) {
|
||||
return ResponseEntity.badRequest().body("参数不能为空");
|
||||
}
|
||||
if (pagesDto.getName() == null || pagesDto.getPath() == null) {
|
||||
return ResponseEntity.badRequest().body("页面名称和路径不能为空");
|
||||
}
|
||||
QueryWrapper<TbMiniAppPages> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("name", pagesDto.getName());
|
||||
TbMiniAppPages tbMiniAppPages = baseMapper.selectOne(wrapper);
|
||||
if (tbMiniAppPages != null) {
|
||||
return ResponseEntity.badRequest().body("页面已存在");
|
||||
}
|
||||
|
||||
tbMiniAppPages = new TbMiniAppPages();
|
||||
tbMiniAppPages.setName(pagesDto.getName());
|
||||
tbMiniAppPages.setPath(pagesDto.getPath());
|
||||
tbMiniAppPages.setIcon(pagesDto.getIcon());
|
||||
tbMiniAppPages.setSort(pagesDto.getSort());
|
||||
tbMiniAppPages.setDescription(pagesDto.getDescription());
|
||||
tbMiniAppPages.setStatus(pagesDto.getStatus());
|
||||
tbMiniAppPages.setCreateTime(new Date());
|
||||
tbMiniAppPages.setUpdateTime(new Date());
|
||||
|
||||
baseMapper.insert(tbMiniAppPages);
|
||||
|
||||
return ResponseEntity.ok().body("新增成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Object> updateTbMiniAppPages(TbMiniAppPagesDto pagesDto) {
|
||||
TbMiniAppPages appPages = baseMapper.selectById(pagesDto.getId());
|
||||
if (appPages == null) {
|
||||
return ResponseEntity.badRequest().body("页面不存在");
|
||||
}
|
||||
|
||||
if (pagesDto.getName() == null || pagesDto.getPath() == null) {
|
||||
return ResponseEntity.badRequest().body("页面名称和路径不能为空");
|
||||
}
|
||||
|
||||
if (!appPages.getName().equals(pagesDto.getName())) {
|
||||
QueryWrapper<TbMiniAppPages> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("name", pagesDto.getName());
|
||||
TbMiniAppPages tbMiniAppPages = baseMapper.selectOne(wrapper);
|
||||
if (tbMiniAppPages != null) {
|
||||
return ResponseEntity.badRequest().body("页面已存在");
|
||||
}
|
||||
}
|
||||
|
||||
if (pagesDto.getName() != null) {
|
||||
appPages.setName(pagesDto.getName());
|
||||
}
|
||||
if (pagesDto.getPath() != null) {
|
||||
appPages.setPath(pagesDto.getPath());
|
||||
}
|
||||
if (pagesDto.getIcon() != null) {
|
||||
appPages.setIcon(pagesDto.getIcon());
|
||||
}
|
||||
if (pagesDto.getSort() != null) {
|
||||
appPages.setSort(pagesDto.getSort());
|
||||
}
|
||||
if (pagesDto.getDescription() != null) {
|
||||
appPages.setDescription(pagesDto.getDescription());
|
||||
}
|
||||
if (pagesDto.getStatus() != null) {
|
||||
appPages.setStatus(pagesDto.getStatus());
|
||||
}
|
||||
appPages.setUpdateTime(new Date());
|
||||
|
||||
baseMapper.updateById(appPages);
|
||||
|
||||
return ResponseEntity.ok().body("更新成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Object> deleteTbMiniAppPages(Integer pagesId) {
|
||||
TbMiniAppPages appPages = baseMapper.selectById(pagesId);
|
||||
if (appPages == null) {
|
||||
return ResponseEntity.badRequest().body("页面不存在");
|
||||
}
|
||||
|
||||
baseMapper.deleteById(pagesId);
|
||||
|
||||
return ResponseEntity.ok().body("删除成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Object> getTbMiniAppPages(Map<String, Object> params) {
|
||||
QueryWrapper<TbMiniAppPages> wrapper = new QueryWrapper<>();
|
||||
if (params.get("status") != null) {
|
||||
wrapper.eq("status", params.get("status"));
|
||||
}
|
||||
wrapper.orderByDesc("sort");
|
||||
return ResponseEntity.ok().body(baseMapper.selectList(wrapper));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.ysk.cashier.dto.shop.TbShopAdDto;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopAd;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbShopAdMapper;
|
||||
import cn.ysk.cashier.mybatis.service.TbShopAdService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TbShopAdServiceImpl extends ServiceImpl<TbShopAdMapper, TbShopAd> implements TbShopAdService {
|
||||
@Override
|
||||
public ResponseEntity<Object> createTbShopAd(TbShopAdDto adDto) {
|
||||
if (adDto.getShopId() == null || adDto.getShopId() == 0) {
|
||||
return ResponseEntity.badRequest().body("店铺ID不能为空");
|
||||
}
|
||||
if (StrUtil.isBlank(adDto.getImgUrl())) {
|
||||
return ResponseEntity.badRequest().body("图片地址不能为空");
|
||||
}
|
||||
TbShopAd shopAd = adDto.convertToTbShopAd();
|
||||
shopAd.setCreateTime(new Date());
|
||||
shopAd.setUpdateTime(new Date());
|
||||
baseMapper.insert(shopAd);
|
||||
return ResponseEntity.ok().body("新增成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Object> updateTbShopAd(TbShopAdDto adDto) {
|
||||
if (adDto.getShopId() == null || adDto.getShopId() == 0) {
|
||||
return ResponseEntity.badRequest().body("店铺ID不能为空");
|
||||
}
|
||||
if (StrUtil.isBlank(adDto.getImgUrl())) {
|
||||
return ResponseEntity.badRequest().body("图片地址不能为空");
|
||||
}
|
||||
TbShopAd shopAd = baseMapper.selectById(adDto.getId());
|
||||
if (shopAd == null) {
|
||||
return ResponseEntity.badRequest().body("广告不存在");
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(adDto.getImgUrl())) {
|
||||
shopAd.setImgUrl(adDto.getImgUrl());
|
||||
}
|
||||
if (StrUtil.isNotBlank(adDto.getLinkPath())) {
|
||||
shopAd.setLinkPath(adDto.getLinkPath());
|
||||
}
|
||||
if (adDto.getBorderRadius() != null) {
|
||||
shopAd.setBorderRadius(adDto.getBorderRadius());
|
||||
}
|
||||
if (StrUtil.isNotBlank(adDto.getShowPosition())) {
|
||||
shopAd.setShowPosition(adDto.getShowPosition());
|
||||
}
|
||||
if (StrUtil.isNotBlank(adDto.getFrequency())) {
|
||||
shopAd.setFrequency(adDto.getFrequency());
|
||||
}
|
||||
if (adDto.getStatus() != null) {
|
||||
shopAd.setStatus(adDto.getStatus());
|
||||
}
|
||||
if (adDto.getSort() != null) {
|
||||
shopAd.setSort(adDto.getSort());
|
||||
}
|
||||
shopAd.setUpdateTime(new Date());
|
||||
|
||||
baseMapper.updateById(shopAd);
|
||||
|
||||
return ResponseEntity.ok().body("修改成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Object> deleteTbShopAd(Integer adId) {
|
||||
TbShopAd shopAd = baseMapper.selectById(adId);
|
||||
if (shopAd == null) {
|
||||
return ResponseEntity.badRequest().body("广告不存在");
|
||||
}
|
||||
|
||||
baseMapper.deleteById(adId);
|
||||
|
||||
return ResponseEntity.ok().body("删除成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Object> getTbShopAd(Map<String, Object> params) {
|
||||
QueryWrapper<TbShopAd> wrapper = new QueryWrapper<>();
|
||||
|
||||
if (StrUtil.isBlank((String) params.get("shopId"))) {
|
||||
return ResponseEntity.badRequest().body("店铺ID不能为空");
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank((String) params.get("status"))) {
|
||||
wrapper.eq("status", params.get("status"));
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank((String) params.get("showPosition"))) {
|
||||
wrapper.eq("show_position", params.get("showPosition"));
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank((String) params.get("frequency"))) {
|
||||
wrapper.eq("frequency", params.get("frequency"));
|
||||
}
|
||||
|
||||
wrapper.orderByDesc("sort");
|
||||
|
||||
return ResponseEntity.ok().body(baseMapper.selectList(wrapper));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +1,15 @@
|
|||
package cn.ysk.cashier.service.impl.shopimpl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.ysk.cashier.dto.shop.TbShopRechargeListDto;
|
||||
import cn.ysk.cashier.dto.shop.TbShopRechargeRespDto;
|
||||
import cn.ysk.cashier.dto.shop.TbShopUserDto;
|
||||
import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mapper.shop.TbShopUserMapper;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopUserFlow;
|
||||
import cn.ysk.cashier.mybatis.mapper.ShopUserMapper;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbShopUserFlowMapper;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopUser;
|
||||
|
|
@ -31,6 +34,7 @@ import java.io.IOException;
|
|||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
|
|
@ -50,6 +54,10 @@ public class TbShopUserServiceImpl implements TbShopUserService {
|
|||
@Autowired
|
||||
private ShopUserMapper shopUserMapper;
|
||||
|
||||
@Autowired
|
||||
private TbShopUserFlowMapper tbShopUserFlowMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryShopUser(TbShopUserQueryCriteria criteria) {
|
||||
IPage<ShopUserInfoVo> iPage = shopUserMapper.queryUser(criteria, criteria.getIsVip(),
|
||||
|
|
@ -183,4 +191,66 @@ public class TbShopUserServiceImpl implements TbShopUserService {
|
|||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modfiyAccount(Map<String, Object> map) {
|
||||
if(ObjectUtil.isNull(map)||ObjectUtil.isEmpty(map)||!map.containsKey("id")||!map.containsKey("type")||!map.containsKey("amount")
|
||||
||ObjectUtil.isEmpty(map.get("id"))||ObjectUtil.isNull(map.get("id"))||ObjectUtil.isNull(map.get("type"))||ObjectUtil.isEmpty(map.get("type"))
|
||||
||ObjectUtil.isEmpty(map.get("amount"))||ObjectUtil.isNull(map.get("amount"))
|
||||
|
||||
){
|
||||
throw new BadRequestException("参数错误");
|
||||
|
||||
}
|
||||
|
||||
String regex = "^(([1-9][0-9]*)|(([0]\\.\\d{1,2}|[1-9][0-9]*\\.\\d{1,2})))$";
|
||||
if(!map.get("amount").toString().matches(regex)){
|
||||
throw new BadRequestException("请输入正确的数字");
|
||||
}
|
||||
|
||||
|
||||
|
||||
TbShopUser tbShopUser= tbShopUserRepository.getById(Integer.valueOf(map.get("id")+""));
|
||||
if(ObjectUtil.isNull(tbShopUser)){
|
||||
throw new BadRequestException("不存在的会员信息");
|
||||
}
|
||||
|
||||
BigDecimal amount=new BigDecimal(map.get("amount").toString());
|
||||
if(amount.compareTo(tbShopUser.getAmount())>0){
|
||||
throw new BadRequestException("账户余额不足,请输入正确的金额");
|
||||
}
|
||||
|
||||
String type=map.get("type").toString();
|
||||
TbShopUserFlow flow=new TbShopUserFlow();
|
||||
|
||||
if("in".equals(type)){
|
||||
flow.setType("+");
|
||||
flow.setBizName("充值退款");
|
||||
flow.setBizCode("manualIn");
|
||||
tbShopUser.setAmount(tbShopUser.getAmount().add(amount));
|
||||
}else if("out".equals(type)){
|
||||
flow.setBizCode("manualOut");
|
||||
flow.setBizName("消费");
|
||||
flow.setType("-");
|
||||
tbShopUser.setAmount(tbShopUser.getAmount().subtract(amount));
|
||||
}else {
|
||||
throw new BadRequestException("错误的请求类型");
|
||||
}
|
||||
|
||||
tbShopUser.setUpdatedAt(System.currentTimeMillis());
|
||||
tbShopUserRepository.save(tbShopUser);
|
||||
|
||||
|
||||
flow.setShopUserId(tbShopUser.getId());
|
||||
flow.setAmount(amount);
|
||||
flow.setBalance(tbShopUser.getAmount());
|
||||
flow.setCreateTime(new Date());
|
||||
|
||||
tbShopUserFlowMapper.insert(flow);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,4 +89,6 @@ public interface TbShopUserService {
|
|||
|
||||
void rechargeListDownload(HttpServletResponse response, TbShopRechargeListDto criteria) throws IOException;
|
||||
|
||||
void modfiyAccount(Map<String,Object> map);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue