Merge branch 'gyj' into dev

This commit is contained in:
2024-07-09 16:13:12 +08:00
8 changed files with 159 additions and 20 deletions

View File

@@ -2,6 +2,9 @@ package cn.ysk.cashier.controller.shop;
import cn.hutool.core.util.StrUtil;
import cn.ysk.cashier.annotation.AnonymousAccess;
import cn.ysk.cashier.annotation.rest.AnonymousGetMapping;
import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
import cn.ysk.cashier.dto.shop.TbShopRechargeListDto;
import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mybatis.service.TbMShopUserService;
@@ -20,10 +23,10 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @website https://eladmin.vip
* @author lyf
* @date 2024-03-01
**/
* @author lyf
* @website https://eladmin.vip
* @date 2024-03-01
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "/shop/user管理")
@@ -41,35 +44,35 @@ public class TbShopUserController {
@GetMapping
@ApiOperation("查询/shop/user")
public ResponseEntity<Object> queryTbShopUser(TbShopUserQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(tbShopUserService.queryAll(criteria,pageable),HttpStatus.OK);
public ResponseEntity<Object> queryTbShopUser(TbShopUserQueryCriteria criteria, Pageable pageable) {
return new ResponseEntity<>(tbShopUserService.queryAll(criteria, pageable), HttpStatus.OK);
}
@GetMapping("queryAllShopUser")
@ApiOperation("查询商家用户")
public ResponseEntity<Object> queryAllShopUser(TbShopUserQueryCriteria criteria){
return new ResponseEntity<>(tbShopUserService.queryShopUser(criteria),HttpStatus.OK);
public ResponseEntity<Object> queryAllShopUser(TbShopUserQueryCriteria criteria) {
return new ResponseEntity<>(tbShopUserService.queryShopUser(criteria), HttpStatus.OK);
}
@GetMapping("summary")
@ApiOperation("查询会员概述")
public ResponseEntity<Object> summary(TbShopUserQueryCriteria criteria){
public ResponseEntity<Object> summary(TbShopUserQueryCriteria criteria) {
if (StrUtil.isBlank(criteria.getShopId())) {
throw new BadRequestException("店铺id不为空");
}
return new ResponseEntity<>(tbMShopUserService.summary(criteria),HttpStatus.OK);
return new ResponseEntity<>(tbMShopUserService.summary(criteria), HttpStatus.OK);
}
@PostMapping
@ApiOperation("新增/shop/user")
public ResponseEntity<Object> createTbShopUser(@Validated @RequestBody TbShopUser resources){
return new ResponseEntity<>(tbShopUserService.create(resources),HttpStatus.CREATED);
public ResponseEntity<Object> createTbShopUser(@Validated @RequestBody TbShopUser resources) {
return new ResponseEntity<>(tbShopUserService.create(resources), HttpStatus.CREATED);
}
@PutMapping
@ApiOperation("修改/shop/user")
public ResponseEntity<Object> updateTbShopUser(@Validated @RequestBody TbShopUser resources){
public ResponseEntity<Object> updateTbShopUser(@Validated @RequestBody TbShopUser resources) {
tbShopUserService.update(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@@ -80,4 +83,16 @@ public class TbShopUserController {
tbShopUserService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
@GetMapping("/recharge")
@ApiOperation("充值记录")
public ResponseEntity<Object> rechargeList(TbShopRechargeListDto criteria, Pageable pageable) {
return new ResponseEntity<>(tbShopUserService.rechargeList(criteria, pageable), HttpStatus.OK);
}
@PostMapping("/recharge/download")
@ApiOperation("导出充值记录")
public void rechargeListDownload(HttpServletResponse response, @RequestBody TbShopRechargeListDto criteria) throws IOException {
tbShopUserService.rechargeListDownload(response, criteria);
}
}

View File

@@ -0,0 +1,18 @@
package cn.ysk.cashier.dto.shop;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* @author GYJ
*/
@Data
public class TbShopRechargeListDto {
private String shopId;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startTime;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date endTime;
}

View File

@@ -0,0 +1,36 @@
package cn.ysk.cashier.dto.shop;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* @author GYJ
*/
@Data
public class TbShopRechargeRespDto {
private Integer id;
private String shopId;
private String shopName;
private String userId;
private String userName;
private String userPhone;
private Object rechargeAmount;
private String rechargeType;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date rechargeTime;
public TbShopRechargeRespDto(Integer id, String shopId, String shopName, String userId, String userName, String userPhone,
String rechargeAmount, String rechargeType, Date rechargeTime) {
this.id = id;
this.shopId = shopId;
this.shopName = shopName;
this.userId = userId;
this.userName = userName;
this.userPhone = userPhone;
this.rechargeAmount = rechargeAmount;
this.rechargeType = rechargeType;
this.rechargeTime = rechargeTime;
}
}

View File

@@ -5,16 +5,22 @@ import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author GYJ
*/
@Entity
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("tb_shop_user_flow")
@Table(name="tb_shop_user_flow")
public class TbShopUserFlow extends Model<TbShopUserFlow> {
@Id
private Integer id;
private Integer shopUserId;

View File

@@ -1,5 +1,7 @@
package cn.ysk.cashier.mybatis.mapper;
import cn.ysk.cashier.dto.shop.TbShopRechargeListDto;
import cn.ysk.cashier.dto.shop.TbShopRechargeRespDto;
import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria;
import cn.ysk.cashier.pojo.shop.TbShopUser;
import cn.ysk.cashier.vo.ShopUserInfoVo;
@@ -30,5 +32,25 @@ public interface ShopUserMapper extends BaseMapper<TbShopUser> {
"</where>" +
"</script>")
IPage<ShopUserInfoVo> queryUser(TbShopUserQueryCriteria param, Page pageInfo);
@Select("<script> " +
"select " +
"tsuf.id as id, " +
"tsu.shop_id as shop_id, " +
"tsi.shop_name, " +
"tsu.id as user_id, " +
"tsu.telephone as user_phone, " +
"tsu.`name` as user_name, " +
"tsuf.amount as recharge_amount, " +
"tsuf.biz_name as recharge_type, " +
"tsuf.create_time as recharge_time " +
" from tb_shop_user_flow tsuf " +
" left join tb_shop_user as tsu on tsuf.shop_user_id = tsu.id " +
"left join tb_shop_info as tsi on tsi.id = tsu.shop_id " +
"where tsuf.create_time BETWEEN #{param.startTime} and #{param.endTime} and tsuf.biz_code in ('cashMemberIn', 'scanMemberIn') " +
" and tsu.shop_id = #{param.shopId} " +
"order by tsuf.create_time desc " +
"</script>")
IPage<TbShopRechargeRespDto> queryRechargeList(TbShopRechargeListDto param, Page pageInfo);
}

View File

@@ -16,10 +16,7 @@
package cn.ysk.cashier.repository.shop;
import cn.ysk.cashier.pojo.shop.TbShopUser;
import cn.ysk.cashier.vo.ShopUserInfoVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
@@ -27,7 +24,6 @@ import org.springframework.data.jpa.repository.Query;
import javax.persistence.Tuple;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @website https://eladmin.vip
@@ -48,6 +44,4 @@ public interface TbShopUserRepository extends JpaRepository<TbShopUser, Integer>
@Query("SELECT user.userId from TbShopUser user where user.shopId = :shopId")
List<Integer> getUserIdByShopId(String shopId);
}

View File

@@ -1,5 +1,8 @@
package cn.ysk.cashier.service.impl.shopimpl;
import cn.hutool.core.date.DateUtil;
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.mapper.shop.TbShopUserMapper;
@@ -22,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.time.Instant;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
@@ -47,7 +51,7 @@ public class TbShopUserServiceImpl implements TbShopUserService {
public Map<String, Object> queryShopUser(TbShopUserQueryCriteria criteria) {
IPage<ShopUserInfoVo> iPage = shopUserMapper.queryUser(criteria,
new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(criteria.getPage(), criteria.getSize()));
return PageUtil.toPlusPage(iPage.getRecords(),Integer.valueOf(iPage.getTotal()+""));
return PageUtil.toPlusPage(iPage.getRecords(), Integer.valueOf(iPage.getTotal() + ""));
}
@Override
@@ -129,4 +133,34 @@ public class TbShopUserServiceImpl implements TbShopUserService {
FileUtil.downloadExcel(list, response);
}
@Override
public IPage<TbShopRechargeRespDto> rechargeList(TbShopRechargeListDto criteria, Pageable pageable) {
if (criteria.getStartTime() == null) {
criteria.setStartTime(DateUtil.parseDate("2024-01-01 00:00:00"));
}
if (criteria.getEndTime() == null) {
criteria.setEndTime(DateUtil.date(Instant.now()));
}
return shopUserMapper.queryRechargeList(criteria,
new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(pageable == null ? 0 : pageable.getPageNumber(), pageable == null ? 1000000 : pageable.getPageSize()));
}
@Override
public void rechargeListDownload(HttpServletResponse response, TbShopRechargeListDto criteria) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
IPage<TbShopRechargeRespDto> page = rechargeList(criteria, null);
for (TbShopRechargeRespDto tbShopRechargeRespDto : page.getRecords()) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("id", tbShopRechargeRespDto.getId());
map.put("门店", tbShopRechargeRespDto.getShopName());
map.put("用户手机号", tbShopRechargeRespDto.getUserPhone());
map.put("用户名", tbShopRechargeRespDto.getUserName());
map.put("充值金额", tbShopRechargeRespDto.getRechargeAmount());
map.put("充值类型", tbShopRechargeRespDto.getRechargeType());
map.put("充值时间", tbShopRechargeRespDto.getRechargeTime());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
}

View File

@@ -1,8 +1,12 @@
package cn.ysk.cashier.service.shop;
import cn.ysk.cashier.dto.shop.TbShopRechargeListDto;
import cn.ysk.cashier.dto.shop.TbShopRechargeRespDto;
import cn.ysk.cashier.pojo.shop.TbShopUser;
import cn.ysk.cashier.dto.shop.TbShopUserDto;
import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
@@ -75,4 +79,14 @@ public interface TbShopUserService {
*/
void download(List<TbShopUserDto> all, HttpServletResponse response) throws IOException;
/**
* 充值记录
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
IPage<TbShopRechargeRespDto> rechargeList(TbShopRechargeListDto criteria, Pageable pageable);
void rechargeListDownload(HttpServletResponse response, TbShopRechargeListDto criteria) throws IOException;
}