Merge branch 'dev'

This commit is contained in:
wangw 2024-07-23 10:11:44 +08:00
commit fe05a3ae7d
43 changed files with 1235 additions and 67 deletions

View File

@ -0,0 +1,30 @@
package cn.ysk.cashier.config;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class RabbitConfig {
public static final String QUEUE_STOCK_RECORD_SALE = "queue.stock.record.sale";
public static final String EXCHANGE_STOCK_RECORD = "exchange.stock.record";
public static final String ROUTING_STOCK_RECORD_SALE = "routing.stock.record.sale";
@Bean
Queue stockRecordSaleQueue() {
return new Queue(QUEUE_STOCK_RECORD_SALE);
}
@Bean
DirectExchange stockRecordExchange() {
return new DirectExchange(EXCHANGE_STOCK_RECORD);
}
@Bean
Binding binding(Queue stockRecordSaleQueue, DirectExchange stockRecordExchange) {
return BindingBuilder.bind(stockRecordSaleQueue).to(stockRecordExchange).with(ROUTING_STOCK_RECORD_SALE);
}
}

View File

@ -72,6 +72,11 @@ public class TbConCheck implements Serializable {
@ApiModelProperty(value = "createTime") @ApiModelProperty(value = "createTime")
private Timestamp createTime; private Timestamp createTime;
@Column(name = "`remark`")
@ApiModelProperty(value = "备注")
private String remark;
public void copy(TbConCheck source){ public void copy(TbConCheck source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
} }

View File

@ -87,6 +87,17 @@ public class TbConsInfoFlow implements Serializable {
@ApiModelProperty(value = "店铺id") @ApiModelProperty(value = "店铺id")
private Integer shopId; private Integer shopId;
@Column(name = "`order_id`")
@ApiModelProperty(value = "订单id")
private Integer orderId;
@Column(name = "`order_no`")
@ApiModelProperty(value = "订单编号")
private String orderNo;
@Transient @Transient
@TableField(exist = false) @TableField(exist = false)
private String productName; private String productName;

View File

@ -0,0 +1,92 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.ysk.cashier.cons.domain;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.math.BigDecimal;
import java.io.Serializable;
/**
* @author admin
* @date 2024-07-17
**/
@Entity
@Data
@Table(name="view_con_info_flow")
public class ViewConInfoFlow implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "`cons_id`")
@ApiModelProperty(value = "耗材id")
private Integer consId;
@Column(name = "`con_name`")
@ApiModelProperty(value = "耗材名称")
private String conName;
@Column(name = "`shop_id`")
@ApiModelProperty(value = "店铺id")
private Integer shopId;
@Column(name = "`con_return`",nullable = false)
@NotNull
@ApiModelProperty(value = "con_return")
private BigDecimal conReturn;
@Column(name = "`con_in`",nullable = false)
@NotNull
@ApiModelProperty(value = "con_in")
private BigDecimal conIn;
@Column(name = "`con_consume`",nullable = false)
@NotNull
@ApiModelProperty(value = "con_consume")
private BigDecimal conConsume;
@Column(name = "`con_out`",nullable = false)
@NotNull
@ApiModelProperty(value = "con_out")
private BigDecimal conOut;
@Column(name = "`balance`",nullable = false)
@NotNull
@ApiModelProperty(value = "balance")
private BigDecimal balance;
@Column(name = "`product_id`")
@ApiModelProperty(value = "商品id")
private String productId;
@Column(name = "`product_name`")
@ApiModelProperty(value = "商品名称")
private String productName;
public void copy(ViewConInfoFlow source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -1,7 +1,6 @@
package cn.ysk.cashier.cons.repository; package cn.ysk.cashier.cons.repository;
import cn.ysk.cashier.cons.domain.TbConsInfoFlow; import cn.ysk.cashier.cons.domain.TbConsInfoFlow;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
@ -17,9 +16,10 @@ public interface TbConsInfoFlowRepository extends JpaRepository<TbConsInfoFlow,
@Query(value = "SELECT\n" + @Query(value = "SELECT\n" +
"\tp.`name` \n" + "\tp.`name` \n" +
"FROM\n" + "FROM\n" +
"\ttb_cons_info_flow i\n" + "\ttb_product_sku s\n" +
"\tLEFT JOIN tb_product_sku s ON i.pro_sku_id = s.id\n" + "\tLEFT JOIN tb_product p ON s.product_id = p.id \n" +
"\tLEFT JOIN tb_product p ON s.product_id = p.id\n" + "WHERE\n" +
"\twhere i.pro_sku_id=?1 limit 1",nativeQuery = true) "\ts.id = ?1",nativeQuery = true)
String selectByPskId(Integer skuId); String selectByPskId(Integer skuId);
} }

View File

@ -0,0 +1,13 @@
package cn.ysk.cashier.cons.repository;
import cn.ysk.cashier.cons.domain.ViewConInfoFlow;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @website https://eladmin.vip
* @author admin
* @date 2024-07-17
**/
public interface ViewConInfoFlowRepository extends JpaRepository<ViewConInfoFlow, Integer>, JpaSpecificationExecutor<ViewConInfoFlow> {
}

View File

@ -16,6 +16,7 @@ import io.swagger.annotations.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.IOException; import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
/** /**
@ -47,14 +48,14 @@ public class TbConsInfoController {
@PostMapping @PostMapping
@Log("新增耗材信息") @Log("新增耗材信息")
@ApiOperation("新增耗材信息") @ApiOperation("新增耗材信息")
public ResponseEntity<Object> createTbConsInfo(@Validated @RequestBody TbConsInfo resources) throws Exception { public ResponseEntity<Object> createTbConsInfo(@Validated @RequestBody List<TbConsInfo> resources) throws Exception {
return new ResponseEntity<>(tbConsInfoService.create(resources),HttpStatus.CREATED); return new ResponseEntity<>(tbConsInfoService.create(resources),HttpStatus.CREATED);
} }
@PutMapping @PutMapping
@Log("修改耗材信息") @Log("修改耗材信息")
@ApiOperation("修改耗材信息") @ApiOperation("修改耗材信息")
public ResponseEntity<Object> updateTbConsInfo(@Validated @RequestBody TbConsInfo resources) throws Exception { public ResponseEntity<Object> updateTbConsInfo(@Validated @RequestBody List<TbConsInfo> resources) throws Exception {
tbConsInfoService.update(resources); tbConsInfoService.update(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT); return new ResponseEntity<>(HttpStatus.NO_CONTENT);
} }

View File

@ -0,0 +1,65 @@
package cn.ysk.cashier.cons.rest;
import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.cons.domain.ViewConInfoFlow;
import cn.ysk.cashier.cons.service.ViewConInfoFlowService;
import cn.ysk.cashier.cons.service.dto.ViewConInfoFlowQueryCriteria;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author admin
* @date 2024-07-17
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "获取耗材流水信息管理")
@RequestMapping("/api/viewConInfoFlow")
public class ViewConInfoFlowController {
private final ViewConInfoFlowService viewConInfoFlowService;
@Log("导出数据")
@ApiOperation("导出数据")
@GetMapping(value = "/download")
public void exportViewConInfoFlow(HttpServletResponse response, ViewConInfoFlowQueryCriteria criteria) throws IOException {
viewConInfoFlowService.download(viewConInfoFlowService.queryAll(criteria), response);
}
@GetMapping
@Log("查询获取耗材流水信息")
@ApiOperation("查询获取耗材流水信息")
public ResponseEntity<Object> queryViewConInfoFlow(ViewConInfoFlowQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(viewConInfoFlowService.queryAll(criteria,pageable),HttpStatus.OK);
}
@PostMapping
@Log("新增获取耗材流水信息")
@ApiOperation("新增获取耗材流水信息")
public ResponseEntity<Object> createViewConInfoFlow(@Validated @RequestBody ViewConInfoFlow resources){
return new ResponseEntity<>(viewConInfoFlowService.create(resources),HttpStatus.CREATED);
}
@PutMapping
@Log("修改获取耗材流水信息")
@ApiOperation("修改获取耗材流水信息")
public ResponseEntity<Object> updateViewConInfoFlow(@Validated @RequestBody ViewConInfoFlow resources){
viewConInfoFlowService.update(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@DeleteMapping
@Log("删除获取耗材流水信息")
@ApiOperation("删除获取耗材流水信息")
public ResponseEntity<Object> deleteViewConInfoFlow(@RequestBody Integer[] ids) {
viewConInfoFlowService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@ -47,13 +47,13 @@ public interface TbConsInfoService {
* @param resources / * @param resources /
* @return TbConsInfoDto * @return TbConsInfoDto
*/ */
TbConsInfoDto create(TbConsInfo resources) throws Exception; TbConsInfoDto create(List<TbConsInfo> resources) throws Exception;
/** /**
* 编辑 * 编辑
* @param resources / * @param resources /
*/ */
void update(TbConsInfo resources) throws Exception; void update(List<TbConsInfo> resources) throws Exception;
/** /**
* 多选删除 * 多选删除

View File

@ -0,0 +1,66 @@
package cn.ysk.cashier.cons.service;
import cn.ysk.cashier.cons.domain.ViewConInfoFlow;
import cn.ysk.cashier.cons.service.dto.ViewConInfoFlowDto;
import cn.ysk.cashier.cons.service.dto.ViewConInfoFlowQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
/**
* @author admin
* @date 2024-07-17
**/
public interface ViewConInfoFlowService {
/**
* 查询数据分页
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(ViewConInfoFlowQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<ViewConInfoFlowDto>
*/
List<ViewConInfoFlowDto> queryAll(ViewConInfoFlowQueryCriteria criteria);
/**
* 根据ID查询
* @param consId ID
* @return ViewConInfoFlowDto
*/
ViewConInfoFlowDto findById(Integer consId);
/**
* 创建
* @param resources /
* @return ViewConInfoFlowDto
*/
ViewConInfoFlowDto create(ViewConInfoFlow resources);
/**
* 编辑
* @param resources /
*/
void update(ViewConInfoFlow resources);
/**
* 多选删除
* @param ids /
*/
void deleteAll(Integer[] ids);
/**
* 导出数据
* @param all 待导出的数据
* @param response /
* @throws IOException /
*/
void download(List<ViewConInfoFlowDto> all, HttpServletResponse response) throws IOException;
}

View File

@ -44,4 +44,6 @@ public class TbConCheckDto implements Serializable {
private BigDecimal acStockNumber; private BigDecimal acStockNumber;
private Timestamp createTime; private Timestamp createTime;
private String remark;
} }

View File

@ -15,7 +15,10 @@
*/ */
package cn.ysk.cashier.cons.service.dto; package cn.ysk.cashier.cons.service.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.persistence.Column;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.io.Serializable; import java.io.Serializable;
@ -60,4 +63,9 @@ public class TbConsInfoFlowDto implements Serializable {
private Integer shopId; private Integer shopId;
private String productName; private String productName;
private Integer orderId;
private String orderNo;
} }

View File

@ -1,6 +1,8 @@
package cn.ysk.cashier.cons.service.dto; package cn.ysk.cashier.cons.service.dto;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import cn.ysk.cashier.annotation.Query; import cn.ysk.cashier.annotation.Query;
@ -22,4 +24,12 @@ public class TbConsInfoFlowQueryCriteria{
/** 精确 */ /** 精确 */
@Query @Query
private Integer shopId; private Integer shopId;
@Query
private String orderNo;
@Query(type = Query.Type.NOT_EQUAL)
private BigDecimal amount;
} }

View File

@ -0,0 +1,52 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.ysk.cashier.cons.service.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
import java.math.BigDecimal;
import java.io.Serializable;
/**
* @author admin
* @date 2024-07-17
**/
@Data
public class ViewConInfoFlowDto implements Serializable {
/** 耗材id */
private Integer consId;
/** 耗材名称 */
private String conName;
private BigDecimal conReturn;
private BigDecimal conIn;
private BigDecimal conConsume;
private BigDecimal conOut;
private BigDecimal balance;
private String productId;
private String productName;
}

View File

@ -0,0 +1,21 @@
package cn.ysk.cashier.cons.service.dto;
import lombok.Data;
import java.util.List;
import cn.ysk.cashier.annotation.Query;
/**
* @author admin
* @date 2024-07-17
**/
@Data
public class ViewConInfoFlowQueryCriteria{
/** 模糊 */
@Query(type = Query.Type.INNER_LIKE)
private String conName;
@Query
private String shopId;
}

View File

@ -82,6 +82,7 @@ public class TbConCheckServiceImpl implements TbConCheckService {
conCheck.setLpNum(resources.getLpNum()); conCheck.setLpNum(resources.getLpNum());
conCheck.setLpAmount(consInfo.getPrice().multiply(resources.getLpNum())); conCheck.setLpAmount(consInfo.getPrice().multiply(resources.getLpNum()));
conCheck.setCreateTime(new Timestamp(System.currentTimeMillis())); conCheck.setCreateTime(new Timestamp(System.currentTimeMillis()));
conCheck.setRemark(resources.getRemark());
return tbConCheckMapper.toDto(tbConCheckRepository.save(conCheck)); return tbConCheckMapper.toDto(tbConCheckRepository.save(conCheck));
} }

View File

@ -18,6 +18,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.io.IOException; import java.io.IOException;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -38,12 +39,13 @@ public class TbConsInfoFlowServiceImpl implements TbConsInfoFlowService {
@Override @Override
public Map<String,Object> queryAll(TbConsInfoFlowQueryCriteria criteria, Pageable pageable){ public Map<String,Object> queryAll(TbConsInfoFlowQueryCriteria criteria, Pageable pageable){
criteria.setAmount(BigDecimal.ZERO);
Sort sort = Sort.by(Sort.Direction.DESC, "id"); Sort sort = Sort.by(Sort.Direction.DESC, "id");
pageable = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), sort); pageable = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), sort);
Page<TbConsInfoFlow> page = tbConsInfoFlowRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); Page<TbConsInfoFlow> page = tbConsInfoFlowRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
page.get().forEach(it->{ page.get().forEach(it->{
String name= tbConsInfoFlowRepository.selectByPskId(it.getConsId()); String name= tbConsInfoFlowRepository.selectByPskId(it.getProSkuId());
if(Objects.nonNull(name)){ if(Objects.nonNull(name)){
it.setProductName(name); it.setProductName(name);
} }

View File

@ -99,14 +99,14 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public TbConsInfoDto create(TbConsInfo resources) throws Exception { public TbConsInfoDto create(List<TbConsInfo> resources) throws Exception {
TbConsType tbConsType = tbConsTypeRepository.getById(resources.getConTypeId()); for (TbConsInfo resource : resources) {
if (Objects.isNull(tbConsType)) { TbConsType tbConsType = tbConsTypeRepository.getById(resource.getConTypeId());
throw new Exception("不存在的耗材类型"); if (Objects.isNull(tbConsType)) {
} throw new Exception("不存在的耗材类型");
}
// int count = tbConsInfoRepository.countByConCode(resources.getConCode()); // int count = tbConsInfoRepository.countByConCode(resources.getConCode());
// if (count > 0) { // if (count > 0) {
@ -114,33 +114,37 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
// } // }
resources.setConCode(StringCodeUtil.getRandom(8,LETTER_CAPITAL_NUMBER)); resource.setConCode(StringCodeUtil.getRandom(8,LETTER_CAPITAL_NUMBER));
resources.setConTypeName(tbConsType.getConTypeName()); resource.setConTypeName(tbConsType.getConTypeName());
resources.setLasterInStock(BigDecimal.ZERO); resource.setLasterInStock(BigDecimal.ZERO);
resources.setStockNumber(BigDecimal.ZERO); resource.setStockNumber(BigDecimal.ZERO);
resources.setStatus("1"); resource.setStatus("1");
resources.setStockConsume(BigDecimal.ZERO); resource.setStockConsume(BigDecimal.ZERO);
resources.setCreateTime(new Timestamp(System.currentTimeMillis())); resource.setCreateTime(new Timestamp(System.currentTimeMillis()));
return tbConsInfoMapper.toDto(tbConsInfoRepository.save(resources)); tbConsInfoRepository.save(resource);
}
return tbConsInfoMapper.toDto(new TbConsInfo());
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void update(TbConsInfo resources) throws Exception { public void update(List<TbConsInfo> resources) throws Exception {
TbConsInfo tbConsInfo = tbConsInfoRepository.findById(resources.getId()).orElseGet(TbConsInfo::new); for (TbConsInfo resource : resources) {
TbConsInfo tbConsInfo = tbConsInfoRepository.findById(resource.getId()).orElseGet(TbConsInfo::new);
if (Objects.isNull(tbConsInfo)) { if (Objects.isNull(tbConsInfo)) {
throw new Exception("耗材信息不存在"); throw new Exception("耗材信息不存在");
}
tbConsInfo.setConName(resource.getConName());
tbConsInfo.setPrice(resource.getPrice());
tbConsInfo.setConUnit(resource.getConUnit());
tbConsInfo.setConWarning(resource.getConWarning());
tbConsInfo.setStatus(resource.getStatus());
tbConsInfo.setUpdateTime(new Timestamp(System.currentTimeMillis()));
tbConsInfoRepository.save(tbConsInfo);
} }
tbConsInfo.setConName(resources.getConName());
tbConsInfo.setPrice(resources.getPrice());
tbConsInfo.setConUnit(resources.getConUnit());
tbConsInfo.setConWarning(resources.getConWarning());
tbConsInfo.setStatus(resources.getStatus());
tbConsInfo.setUpdateTime(new Timestamp(System.currentTimeMillis()));
tbConsInfoRepository.save(tbConsInfo);
} }
@Override @Override

View File

@ -0,0 +1,94 @@
package cn.ysk.cashier.cons.service.impl;
import cn.ysk.cashier.cons.domain.ViewConInfoFlow;
import cn.ysk.cashier.utils.FileUtil;
import cn.ysk.cashier.utils.PageUtil;
import cn.ysk.cashier.utils.QueryHelp;
import cn.ysk.cashier.utils.ValidationUtil;
import lombok.RequiredArgsConstructor;
import cn.ysk.cashier.cons.repository.ViewConInfoFlowRepository;
import cn.ysk.cashier.cons.service.ViewConInfoFlowService;
import cn.ysk.cashier.cons.service.dto.ViewConInfoFlowDto;
import cn.ysk.cashier.cons.service.dto.ViewConInfoFlowQueryCriteria;
import cn.ysk.cashier.cons.service.mapstruct.ViewConInfoFlowMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
/**
* @website https://eladmin.vip
* @description 服务实现
* @author admin
* @date 2024-07-17
**/
@Service
@RequiredArgsConstructor
public class ViewConInfoFlowServiceImpl implements ViewConInfoFlowService {
private final ViewConInfoFlowRepository viewConInfoFlowRepository;
private final ViewConInfoFlowMapper viewConInfoFlowMapper;
@Override
public Map<String,Object> queryAll(ViewConInfoFlowQueryCriteria criteria, Pageable pageable){
Page<ViewConInfoFlow> page = viewConInfoFlowRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(viewConInfoFlowMapper::toDto));
}
@Override
public List<ViewConInfoFlowDto> queryAll(ViewConInfoFlowQueryCriteria criteria){
return viewConInfoFlowMapper.toDto(viewConInfoFlowRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
@Transactional
public ViewConInfoFlowDto findById(Integer consId) {
ViewConInfoFlow viewConInfoFlow = viewConInfoFlowRepository.findById(consId).orElseGet(ViewConInfoFlow::new);
ValidationUtil.isNull(viewConInfoFlow.getConsId(),"ViewConInfoFlow","consId",consId);
return viewConInfoFlowMapper.toDto(viewConInfoFlow);
}
@Override
@Transactional(rollbackFor = Exception.class)
public ViewConInfoFlowDto create(ViewConInfoFlow resources) {
return viewConInfoFlowMapper.toDto(viewConInfoFlowRepository.save(resources));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(ViewConInfoFlow resources) {
ViewConInfoFlow viewConInfoFlow = viewConInfoFlowRepository.findById(resources.getConsId()).orElseGet(ViewConInfoFlow::new);
ValidationUtil.isNull( viewConInfoFlow.getConsId(),"ViewConInfoFlow","id",resources.getConsId());
viewConInfoFlow.copy(resources);
viewConInfoFlowRepository.save(viewConInfoFlow);
}
@Override
public void deleteAll(Integer[] ids) {
for (Integer consId : ids) {
viewConInfoFlowRepository.deleteById(consId);
}
}
@Override
public void download(List<ViewConInfoFlowDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (ViewConInfoFlowDto viewConInfoFlow : all) {
Map<String,Object> map = new LinkedHashMap<>();
map.put("耗材名称", viewConInfoFlow.getConName());
map.put(" conreturn", viewConInfoFlow.getConReturn());
map.put(" conin", viewConInfoFlow.getConIn());
map.put(" conconsume", viewConInfoFlow.getConConsume());
map.put(" conout", viewConInfoFlow.getConOut());
map.put(" balance", viewConInfoFlow.getBalance());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
}

View File

@ -0,0 +1,16 @@
package cn.ysk.cashier.cons.service.mapstruct;
import cn.ysk.cashier.base.BaseMapper;
import cn.ysk.cashier.cons.domain.ViewConInfoFlow;
import cn.ysk.cashier.cons.service.dto.ViewConInfoFlowDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author admin
* @date 2024-07-17
**/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface ViewConInfoFlowMapper extends BaseMapper<ViewConInfoFlowDto, ViewConInfoFlow> {
}

View File

@ -16,6 +16,7 @@
package cn.ysk.cashier.controller.order; package cn.ysk.cashier.controller.order;
import cn.ysk.cashier.annotation.Log; import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
import cn.ysk.cashier.dto.order.TbOrderInfoDto; import cn.ysk.cashier.dto.order.TbOrderInfoDto;
import cn.ysk.cashier.dto.order.TbOrderInfoQueryCriteria; import cn.ysk.cashier.dto.order.TbOrderInfoQueryCriteria;
import cn.ysk.cashier.dto.order.TbPayCountQueryCriteria; import cn.ysk.cashier.dto.order.TbPayCountQueryCriteria;
@ -55,6 +56,7 @@ public class TbOrderInfoController {
@PostMapping("/date") @PostMapping("/date")
@ApiOperation("查询订单") @ApiOperation("查询订单")
@AnonymousPostMapping
public ResponseEntity<Object> queryTbOrderInfo(@RequestBody TbOrderInfoQueryCriteria criteria){ public ResponseEntity<Object> queryTbOrderInfo(@RequestBody TbOrderInfoQueryCriteria criteria){
return new ResponseEntity<>(tbOrderInfoService.queryAllPage(criteria),HttpStatus.OK); return new ResponseEntity<>(tbOrderInfoService.queryAllPage(criteria),HttpStatus.OK);
} }

View File

@ -1,6 +1,7 @@
package cn.ysk.cashier.controller.product; package cn.ysk.cashier.controller.product;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.ysk.cashier.annotation.AnonymousAccess;
import cn.ysk.cashier.annotation.Log; import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.annotation.rest.AnonymousPostMapping; import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
import cn.ysk.cashier.dto.product.StockQueryDto; import cn.ysk.cashier.dto.product.StockQueryDto;
@ -112,6 +113,18 @@ public class StockController {
return new ResponseEntity<>(dataMap, HttpStatus.OK); return new ResponseEntity<>(dataMap, HttpStatus.OK);
} }
@AnonymousAccess
@PutMapping("/grounding")
@ApiOperation("上下架商品")
public ResponseEntity<Object> grounding(
@RequestParam Integer shopId,
@RequestParam Integer skuId,
@RequestParam Boolean isGrounding
){
stockService.grounding(shopId,skuId, isGrounding);
return ResponseEntity.ok("success");
}
@GetMapping("/sku") @GetMapping("/sku")
@ApiOperation("查询库存") @ApiOperation("查询库存")
public ResponseEntity<Object> queryProductSku(String productId){ public ResponseEntity<Object> queryProductSku(String productId){

View File

@ -15,6 +15,7 @@
*/ */
package cn.ysk.cashier.controller.product; package cn.ysk.cashier.controller.product;
import cn.ysk.cashier.annotation.AnonymousAccess;
import cn.ysk.cashier.annotation.Log; import cn.ysk.cashier.annotation.Log;
import cn.ysk.cashier.pojo.product.TbProductStockDetail; import cn.ysk.cashier.pojo.product.TbProductStockDetail;
import cn.ysk.cashier.service.product.TbProductStockDetailService; import cn.ysk.cashier.service.product.TbProductStockDetailService;

View File

@ -0,0 +1,75 @@
package cn.ysk.cashier.controller.shop;
import cn.ysk.cashier.annotation.rest.AnonymousDeleteMapping;
import cn.ysk.cashier.annotation.rest.AnonymousGetMapping;
import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
import cn.ysk.cashier.annotation.rest.AnonymousPutMapping;
import cn.ysk.cashier.mybatis.entity.TbShopExtend;
import cn.ysk.cashier.mybatis.service.TbShopExtendService;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import cn.ysk.cashier.dto.shop.TbShopExtendQueryCriteria;
import javax.annotation.Resource;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 店铺扩展信息(TbShopExtend)表控制层
*
* @author ww
* @since 2024-07-18 11:10:16
*/
@RestController
@RequestMapping("tbShopExtend")
public class TbShopExtendController {
/**
* 服务对象
*/
@Resource
private TbShopExtendService tbShopExtendService;
@GetMapping
@ApiOperation("分页查询")
@AnonymousGetMapping
public ResponseEntity<Object> selectAll(TbShopExtendQueryCriteria criteria) {
return new ResponseEntity<>(tbShopExtendService.queryAll(criteria), HttpStatus.OK);
}
@GetMapping("{id}")
@ApiOperation("通过Id查询详情")
@AnonymousGetMapping
public TbShopExtend selectOne(@PathVariable Serializable id) {
return tbShopExtendService.getById(id);
}
@PostMapping
@ApiOperation("新增")
@AnonymousPostMapping
public ResponseEntity<Object> insert(@RequestBody TbShopExtend tbShopExtend) {
tbShopExtend.setCreateTime(new Date());
return new ResponseEntity<>(tbShopExtendService.save(tbShopExtend), HttpStatus.CREATED);
}
@PutMapping
@ApiOperation("通过id修改")
@AnonymousPutMapping
public ResponseEntity<Object> update(@RequestBody TbShopExtend tbShopExtend) {
tbShopExtend.setUpdateTime(new Date());
tbShopExtendService.updateById(tbShopExtend);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@DeleteMapping
@ApiOperation("删除")
@AnonymousDeleteMapping
public ResponseEntity<Object> delete(@RequestParam("idList") List<Long> idList) {
tbShopExtendService.removeByIds(idList);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@ -72,4 +72,6 @@ public class TbOrderInfoQueryCriteria{
@Query @Query
private String tableName; private String tableName;
private String productName;
} }

View File

@ -0,0 +1,36 @@
package cn.ysk.cashier.dto.shop;
import lombok.Data;
/**
* 店铺扩展信息(TbShopExtend)表查询类
*
* @author ww
* @since 2024-07-18 10:46:57
*/
@Data
public class TbShopExtendQueryCriteria {
private Integer shopId;
//img:图片text:文本
private String type;
//自定义key
private String autokey;
//
private String value;
private long page = 1;
private long size = 10;
public void setPage(long page) {
if (page != 0) {
this.page = page;
}
}
public void setSize(long size) {
if (size != 0) {
this.size = size;
}
}
}

View File

@ -0,0 +1,88 @@
package cn.ysk.cashier.mybatis.entity;
import java.util.Date;
import com.baomidou.mybatisplus.extension.activerecord.Model;
/**
* 店铺扩展信息(TbShopExtend)表实体类
*
* @author ww
* @since 2024-07-18 11:10:16
*/
@SuppressWarnings("serial")
public class TbShopExtend extends Model<TbShopExtend> {
//自增id
private Integer id;
//商户Id
private Integer shopId;
//img:图片text:文本
private String type;
//自定义key
private String autokey;
//
private String value;
//更新时间
private Date updateTime;
//创建时间
private Date createTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getShopId() {
return shopId;
}
public void setShopId(Integer shopId) {
this.shopId = shopId;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getAutokey() {
return autokey;
}
public void setAutokey(String autokey) {
this.autokey = autokey;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}

View File

@ -0,0 +1,15 @@
package cn.ysk.cashier.mybatis.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.ysk.cashier.mybatis.entity.TbShopExtend;
/**
* 店铺扩展信息(TbShopExtend)表数据库访问层
*
* @author ww
* @since 2024-07-18 11:10:16
*/
public interface TbShopExtendMapper extends BaseMapper<TbShopExtend> {
}

View File

@ -0,0 +1,20 @@
package cn.ysk.cashier.mybatis.service;
import com.baomidou.mybatisplus.extension.service.IService;
import cn.ysk.cashier.mybatis.entity.TbShopExtend;
import cn.ysk.cashier.dto.shop.TbShopExtendQueryCriteria;
import java.util.Map;
/**
* 店铺扩展信息(TbShopExtend)表服务接口
*
* @author ww
* @since 2024-07-18 11:10:16
*/
public interface TbShopExtendService extends IService<TbShopExtend> {
Map<String, Object> queryAll(TbShopExtendQueryCriteria criteria);
}

View File

@ -0,0 +1,45 @@
package cn.ysk.cashier.mybatis.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.ysk.cashier.mybatis.mapper.TbShopExtendMapper;
import cn.ysk.cashier.mybatis.entity.TbShopExtend;
import cn.ysk.cashier.mybatis.service.TbShopExtendService;
import org.springframework.stereotype.Service;
import org.apache.commons.lang3.StringUtils;
import cn.ysk.cashier.dto.shop.TbShopExtendQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import cn.ysk.cashier.utils.PageUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.Map;
/**
* 店铺扩展信息(TbShopExtend)表服务实现类
*
* @author ww
* @since 2024-07-18 10:57:39
*/
@Service("tbShopExtendService")
public class TbShopExtendServiceImpl extends ServiceImpl<TbShopExtendMapper, TbShopExtend> implements TbShopExtendService {
@Autowired
private TbShopExtendMapper tbShopExtendmapper;
@Override
public Map<String, Object> queryAll(TbShopExtendQueryCriteria criteria) {
Page<TbShopExtend> page = new Page<>(criteria.getPage(), criteria.getSize());
QueryWrapper<TbShopExtend> wrapper = new QueryWrapper<>();
wrapper.eq("shop_id", criteria.getShopId());
if (StringUtils.isNotBlank(criteria.getType())) {
wrapper.eq("type",criteria.getType());
}
if (StringUtils.isNotBlank(criteria.getAutokey())) {
wrapper.like("autokey",criteria.getAutokey());
}
wrapper.orderByDesc("create_time");
Page<TbShopExtend> ipage = tbShopExtendmapper.selectPage(page, wrapper);
return PageUtil.toPage(ipage.getRecords(), ipage.getTotal());
}
}

View File

@ -127,6 +127,10 @@ public class TbProductSku implements Serializable {
@ApiModelProperty(value = "是否暂停销售") @ApiModelProperty(value = "是否暂停销售")
private Integer isPauseSale = 0; private Integer isPauseSale = 0;
@Column(name = "`is_grounding`")
@ApiModelProperty(value = "是否上架")
private Integer isGrounding = 0;
public void setIsDel(Integer isDel) { public void setIsDel(Integer isDel) {
if(isDel!=null){ if(isDel!=null){
this.isDel = isDel; this.isDel = isDel;

View File

@ -0,0 +1,36 @@
package cn.ysk.cashier.rabbit;
import cn.ysk.cashier.config.RabbitConfig;
import cn.ysk.cashier.pojo.product.TbProductStockDetail;
import cn.ysk.cashier.service.product.TbProductStockDetailService;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class StockListener {
private final TbProductStockDetailService productStockDetailService;
public StockListener(TbProductStockDetailService productStockDetailService) {
this.productStockDetailService = productStockDetailService;
}
@RabbitListener(queues = RabbitConfig.QUEUE_STOCK_RECORD_SALE)
public void recordSaleHandler(String message) {
log.info("接收到下单保存库存信息mq消息消息内容: {}", message);
JSONObject jsonObject = JSONObject.parseObject(message);
if (!jsonObject.containsKey("orderId")) {
log.info("mq消息体有误确实orderId");
return;
}
try {
productStockDetailService.addSaleRecord(jsonObject.getInteger("orderId"));
}catch (Exception e) {
log.error("执行保存库存mq失败", e);
}
}
}

View File

@ -2,6 +2,7 @@ package cn.ysk.cashier.repository.order;
import cn.ysk.cashier.dto.product.StockCountDTO; import cn.ysk.cashier.dto.product.StockCountDTO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
@ -32,4 +33,36 @@ public interface StockCountRepository extends JpaRepository<StockCountDTO, Integ
"info.product_id ",nativeQuery = true) "info.product_id ",nativeQuery = true)
List<StockCountDTO> countStock( @Param("startTime") String startTime, @Param("endTime") String endTime); List<StockCountDTO> countStock( @Param("startTime") String startTime, @Param("endTime") String endTime);
@Query(value = "SELECT \n" +
" pro.shop_id AS shop_id, \n" +
" pro.id AS pro_id, \n" +
" info.product_name AS pro_name, \n" +
" pro.is_stock, \n" +
" info.product_sku_name AS sku_name, \n" +
" unit.NAME AS unit_name, \n" +
" SUM(CASE WHEN orders.order_type != 'return' THEN info.num ELSE 0 END) \n" +
" - SUM(CASE WHEN orders.order_type = 'return' THEN info.num ELSE 0 END) AS stock_count, \n" +
" CASE WHEN pro.is_distribute = '0' THEN sku.stock_number ELSE pro.stock_number END AS stock_number \n" +
"FROM \n" +
" tb_order_info orders \n" +
"LEFT JOIN \n" +
" tb_order_detail info ON orders.id = info.order_id \n" +
"LEFT JOIN \n" +
" tb_product pro ON info.product_id = pro.id \n" +
"LEFT JOIN \n" +
" (SELECT product_id, SUM(stock_number) AS stock_number FROM tb_product_sku GROUP BY product_id) sku ON info.product_id = sku.product_id \n" +
"LEFT JOIN \n" +
" tb_shop_unit unit ON unit.id = pro.unit_id \n" +
"WHERE \n" +
" orders.id = :orderId \n" +
" AND (info.STATUS = 'closed' OR info.STATUS = 'refund') \n" +
"GROUP BY \n" +
" info.product_id, \n" +
" pro.shop_id, \n" +
" pro.id, \n" +
" info.product_name, \n" +
" pro.is_stock, \n" +
" info.product_sku_name, \n" +
" unit.NAME",nativeQuery = true)
List<StockCountDTO> countStockById(Integer orderId);
} }

View File

@ -136,4 +136,13 @@ public interface TbOrderDetailRepository extends JpaRepository<TbOrderDetail, In
"\t) AS total ", nativeQuery = true) "\t) AS total ", nativeQuery = true)
Tuple searchCount(@Param("shopId") Integer shopId, @Param("startTime") Date startTime, @Param("endTime") Date endTime); Tuple searchCount(@Param("shopId") Integer shopId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
@Query(value = "SELECT d.order_id \n" +
" FROM tb_order_detail d \n" +
" WHERE d.product_name LIKE %:productName% \n" +
" AND d.shop_id = :shopId \n" +
" AND d.create_time BETWEEN :startTime AND :endTime \n" +
" GROUP BY d.order_id", nativeQuery = true)
List<Integer> findOrderIdsByProductNameLike(@Param("productName") String productName, @Param("shop_id") String shopId,
@Param("startTime") Date startTime, @Param("endTime") Date endTime);
} }

View File

@ -55,4 +55,7 @@ public interface TbProductRepository extends JpaRepository<TbProduct, Integer>,
@Modifying @Modifying
@Query("update TbProduct set stockNumber=stockNumber+:num where id=:id") @Query("update TbProduct set stockNumber=stockNumber+:num where id=:id")
void incrStock(@Param("id") Integer id, @Param("num") Integer num); void incrStock(@Param("id") Integer id, @Param("num") Integer num);
@Query("select product from TbProduct product where product.id=:id and product.shopId=:shopId")
TbProduct selectByShopIdAndId(Integer id, String shopId);
} }

View File

@ -3,6 +3,7 @@ package cn.ysk.cashier.repository.product;
import cn.ysk.cashier.pojo.product.TbProductSku; import cn.ysk.cashier.pojo.product.TbProductSku;
import cn.ysk.cashier.vo.StockV2Vo; import cn.ysk.cashier.vo.StockV2Vo;
import cn.ysk.cashier.vo.StockVo; import cn.ysk.cashier.vo.StockVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update; import org.apache.ibatis.annotations.Update;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
@ -10,7 +11,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import javax.transaction.Transactional; import javax.transaction.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -63,7 +63,7 @@ public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Inte
@Query("SELECT new cn.ysk.cashier.vo.StockV2Vo(" + @Query("SELECT new cn.ysk.cashier.vo.StockV2Vo(" +
"sku.id,pro.id,pro.coverImg,pro.name,unit.name,pro.typeEnum,sku.specSnap,pro.isStock, " + "sku.id,pro.id,pro.coverImg,pro.name,unit.name,pro.typeEnum,sku.specSnap,pro.isStock, " +
"CASE WHEN pro.isDistribute = 1 THEN IFNULL(pro.stockNumber, 0) ELSE SUM(sku.stockNumber) END as number" + "CASE WHEN pro.isDistribute = 1 THEN IFNULL(pro.stockNumber, 0) ELSE SUM(sku.stockNumber) END as number" +
", pro.isDistribute, pro.isPauseSale, true, sku.warnLine, pro.lowPrice) " + ", pro.isDistribute, pro.isPauseSale, true, sku.warnLine, pro.lowPrice, CASE WHEN sku.isGrounding=1 THEN true ELSE false END as isGrounding) " +
"from " + "from " +
"TbProduct pro " + "TbProduct pro " +
"LEFT JOIN TbProductSku sku on pro.id = sku.productId " + "LEFT JOIN TbProductSku sku on pro.id = sku.productId " +
@ -106,7 +106,8 @@ public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Inte
@Query("SELECT new cn.ysk.cashier.vo.StockV2Vo(" + @Query("SELECT new cn.ysk.cashier.vo.StockV2Vo(" +
"sku.id,pro.id,pro.coverImg,pro.name,unit.name,pro.typeEnum,sku.specSnap,pro.isStock,sku.stockNumber, 1, sku.isPauseSale, false, 0, sku.salePrice" + "sku.id,pro.id,pro.coverImg,pro.name," +
"unit.name,pro.typeEnum,sku.specSnap,pro.isStock,sku.stockNumber, 1, sku.isPauseSale, false, 0, sku.salePrice, CASE WHEN sku.isGrounding=1 THEN true ELSE false END" +
") " + ") " +
"from " + "from " +
"TbProductSku sku " + "TbProductSku sku " +
@ -170,4 +171,14 @@ public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Inte
@Modifying @Modifying
@Query("update TbProductSku set stockNumber=stockNumber+:num where id=:productId") @Query("update TbProductSku set stockNumber=stockNumber+:num where id=:productId")
void incrStock(@Param("productId") Integer productId, @Param("num") Double num); void incrStock(@Param("productId") Integer productId, @Param("num") Double num);
@Transactional
@Modifying
@Query("update TbProductSku set isGrounding=:isGrounding where productId=:productId")
void updateGroundingByProId(@Param("productId") String productId, @Param("isGrounding") Integer isGrounding);
@Transactional
@Modifying
@Query("update TbProductSku set isGrounding=:isGrounding where id=:skuId")
void updateGrounding(Integer skuId,int isGrounding);
} }

View File

@ -1,10 +1,12 @@
package cn.ysk.cashier.service.impl.order; package cn.ysk.cashier.service.impl.order;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.ysk.cashier.cons.rabbit.RabbitConstants; import cn.ysk.cashier.cons.rabbit.RabbitConstants;
import cn.ysk.cashier.dto.order.TbOrderInfoDto; import cn.ysk.cashier.dto.order.TbOrderInfoDto;
import cn.ysk.cashier.dto.order.TbOrderInfoQueryCriteria; import cn.ysk.cashier.dto.order.TbOrderInfoQueryCriteria;
import cn.ysk.cashier.dto.order.TbPayCountQueryCriteria; import cn.ysk.cashier.dto.order.TbPayCountQueryCriteria;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mapper.order.TbOrderInfoMapper; import cn.ysk.cashier.mapper.order.TbOrderInfoMapper;
import cn.ysk.cashier.mapper.product.TbProductMapper; import cn.ysk.cashier.mapper.product.TbProductMapper;
import cn.ysk.cashier.mapper.product.TbProductSkuMapper; import cn.ysk.cashier.mapper.product.TbProductSkuMapper;
@ -96,6 +98,36 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
if (StringUtils.isBlank(criteria.getStatus()) && StringUtils.isBlank(criteria.getSource())) { if (StringUtils.isBlank(criteria.getStatus()) && StringUtils.isBlank(criteria.getSource())) {
predicate = criteriaBuilder.and(predicate, criteriaBuilder.notEqual(root.get("orderType"), "return")); predicate = criteriaBuilder.and(predicate, criteriaBuilder.notEqual(root.get("orderType"), "return"));
} }
if (StringUtils.isNotBlank(criteria.getProductName())) {
Date startTime, endTime;
DateTime offsetMonth = cn.hutool.core.date.DateUtil.offsetMonth(new Date(), 3);
if (criteria.getCreatedAt() != null && criteria.getCreatedAt().size() == 2) {
Long startLong = criteria.getCreatedAt().get(0);
Long endLong = criteria.getCreatedAt().get(1);
startTime = new Date(startLong);
endTime = new Date(endLong);
// 如果开始时间小于三个月前不查询
if (startTime.before(offsetMonth)) {
throw new BadRequestException("查询时间范围不能超过三个月");
}
} else {
startTime = offsetMonth;
endTime = new Date();
}
List<Integer> productIds = tbOrderDetailRepository.findOrderIdsByProductNameLike(criteria.getProductName(),
criteria.getShopId(), startTime, endTime);
if (productIds.isEmpty()) {
predicate = criteriaBuilder.and(predicate, criteriaBuilder.equal(root.get("id"), 0));
} else {
predicate = criteriaBuilder.and(predicate, root.get("id").in(productIds));
}
}
return predicate; return predicate;
}, pageable); }, pageable);
@ -121,7 +153,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
detail.setRefundNumber(refundNumber); detail.setRefundNumber(refundNumber);
} }
}); });
}else { } else {
details.parallelStream().forEach(detail -> { details.parallelStream().forEach(detail -> {
detail.setRefundNumber(detail.getNum()); detail.setRefundNumber(detail.getNum());
}); });
@ -151,10 +183,10 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
end = createdAt.get(1); end = createdAt.get(1);
} }
} }
if(ObjectUtil.isEmpty(criteria.getTableName())){ if (ObjectUtil.isEmpty(criteria.getTableName())) {
criteria.setTableName(null); criteria.setTableName(null);
} }
List<TbOrderPayCountVo> payCountVoList = tbOrderInfoRepository.queryTbOrderPayCount(criteria.getShopId(),criteria.getTableName(), start, end); List<TbOrderPayCountVo> payCountVoList = tbOrderInfoRepository.queryTbOrderPayCount(criteria.getShopId(), criteria.getTableName(), start, end);
BigDecimal totalPayAmount = BigDecimal.ZERO; BigDecimal totalPayAmount = BigDecimal.ZERO;
for (TbOrderPayCountVo payCount : payCountVoList) { for (TbOrderPayCountVo payCount : payCountVoList) {
totalPayAmount = totalPayAmount.add(new BigDecimal(payCount.getPayAmount().toString())); totalPayAmount = totalPayAmount.add(new BigDecimal(payCount.getPayAmount().toString()));
@ -171,7 +203,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
result.add(payCount); result.add(payCount);
} }
} }
TbOrderPayCountVo payRufund = tbOrderInfoRepository.queryTbOrderRefund(criteria.getShopId(),criteria.getTableName(), start, end); TbOrderPayCountVo payRufund = tbOrderInfoRepository.queryTbOrderRefund(criteria.getShopId(), criteria.getTableName(), start, end);
if (payRufund != null) { if (payRufund != null) {
totalPayAmount = totalPayAmount.subtract(new BigDecimal(payRufund.getPayAmount().toString())); totalPayAmount = totalPayAmount.subtract(new BigDecimal(payRufund.getPayAmount().toString()));
payRufund.setPayType("退单"); payRufund.setPayType("退单");
@ -231,7 +263,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
dto.setIsRefund(0); dto.setIsRefund(0);
dto.setRefundAmount(BigDecimal.ZERO); dto.setRefundAmount(BigDecimal.ZERO);
List<TbOrderInfo> tbOrderInfos = tbOrderInfoRepository.selTbOrdersBysource(tbOrderInfo.getId(), tbOrderInfo.getShopId()); List<TbOrderInfo> tbOrderInfos = tbOrderInfoRepository.selTbOrdersBysource(tbOrderInfo.getId(), tbOrderInfo.getShopId());
if(!CollectionUtils.isEmpty(tbOrderInfos)){ if (!CollectionUtils.isEmpty(tbOrderInfos)) {
dto.setIsRefund(1); dto.setIsRefund(1);
dto.setRefundAmount(tbOrderInfos.stream().map(TbOrderInfo::getOrderAmount).reduce(BigDecimal.ZERO, BigDecimal::add)); dto.setRefundAmount(tbOrderInfos.stream().map(TbOrderInfo::getOrderAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
} }
@ -250,15 +282,15 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void expired(String orderId) { public void expired(String orderId) {
//修改耗材数据 //修改耗材数据
JSONObject jsonObject1=new JSONObject(); JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("type","delete"); jsonObject1.put("type", "delete");
Optional<TbOrderInfo> byId = tbOrderInfoRepository.findById(Integer.valueOf(orderId)); Optional<TbOrderInfo> byId = tbOrderInfoRepository.findById(Integer.valueOf(orderId));
if (byId != null && byId.isPresent()) { if (byId != null && byId.isPresent()) {
TbOrderInfo tbOrderInfo = byId.get(); TbOrderInfo tbOrderInfo = byId.get();
if (tbOrderInfo.getStatus().equals("unpaid")) { if (tbOrderInfo.getStatus().equals("unpaid")) {
upOrderStatus(tbOrderInfo); upOrderStatus(tbOrderInfo);
jsonObject1.put("orderId",tbOrderInfo.getId()); jsonObject1.put("orderId", tbOrderInfo.getId());
// 发送取消订单mq消息 // 发送取消订单mq消息
rabbitTemplate.convertAndSend(RabbitConstants.CONS_COLLECT_PUT, RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT, rabbitTemplate.convertAndSend(RabbitConstants.CONS_COLLECT_PUT, RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT,
jsonObject1.toJSONString(), new CorrelationData(UUID.randomUUID().toString())); jsonObject1.toJSONString(), new CorrelationData(UUID.randomUUID().toString()));
@ -274,7 +306,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
redisUtils.set(CacheKey.ORDER_EXPIRED + tbOrderInfo.getId(), tbOrderInfo.getId(), 60 * 2); redisUtils.set(CacheKey.ORDER_EXPIRED + tbOrderInfo.getId(), tbOrderInfo.getId(), 60 * 2);
} else { } else {
upOrderStatus(tbOrderInfo); upOrderStatus(tbOrderInfo);
jsonObject1.put("orderId",tbOrderInfo.getId()); jsonObject1.put("orderId", tbOrderInfo.getId());
// 发送取消订单mq消息 // 发送取消订单mq消息
rabbitTemplate.convertAndSend(RabbitConstants.CONS_COLLECT_PUT, RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT, rabbitTemplate.convertAndSend(RabbitConstants.CONS_COLLECT_PUT, RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT,
@ -360,7 +392,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
public void download(List<TbOrderInfoDto> all, HttpServletResponse response) throws IOException { public void download(List<TbOrderInfoDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>(); List<Map<String, Object>> list = new ArrayList<>();
all=all.stream().sorted(Comparator.comparing(TbOrderInfoDto::getId).reversed()).collect(Collectors.toList()); all = all.stream().sorted(Comparator.comparing(TbOrderInfoDto::getId).reversed()).collect(Collectors.toList());
for (TbOrderInfoDto tbOrderInfo : all) { for (TbOrderInfoDto tbOrderInfo : all) {
Map<String, Object> map = new LinkedHashMap<>(); Map<String, Object> map = new LinkedHashMap<>();
map.put("订单编号", tbOrderInfo.getOrderNo()); map.put("订单编号", tbOrderInfo.getOrderNo());
@ -408,8 +440,8 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
map.put("商品信息", productNames); map.put("商品信息", productNames);
// //
if(ObjectUtil.isNotEmpty(tbOrderInfo.getPayType())&&ObjectUtil.isNotNull(tbOrderInfo.getPayType())){ if (ObjectUtil.isNotEmpty(tbOrderInfo.getPayType()) && ObjectUtil.isNotNull(tbOrderInfo.getPayType())) {
switch (tbOrderInfo.getPayType()){ switch (tbOrderInfo.getPayType()) {
case "scanCode": case "scanCode":
tbOrderInfo.setPayType("收款码支付"); tbOrderInfo.setPayType("收款码支付");
break; break;
@ -424,7 +456,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
break; break;
} }
}else { } else {
tbOrderInfo.setPayType(""); tbOrderInfo.setPayType("");
} }
@ -471,7 +503,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
map.put("状态", tbOrderInfo.getStatus()); map.put("状态", tbOrderInfo.getStatus());
map.put("创建日期", DateUtil.timeStampFormatyMdHms(tbOrderInfo.getCreatedAt())); map.put("创建日期", DateUtil.timeStampFormatyMdHms(tbOrderInfo.getCreatedAt()));
map.put("备注", tbOrderInfo.getRemark()); map.put("备注", tbOrderInfo.getRemark());
map.put("台桌",tbOrderInfo.getTableName()); map.put("台桌", tbOrderInfo.getTableName());
list.add(map); list.add(map);
} }
FileUtil.downloadExcel(list, response); FileUtil.downloadExcel(list, response);

View File

@ -4,10 +4,12 @@ import cn.ysk.cashier.dto.product.OutAndOnDto;
import cn.ysk.cashier.dto.product.StockQueryDto; import cn.ysk.cashier.dto.product.StockQueryDto;
import cn.ysk.cashier.dto.product.TbProductDto; import cn.ysk.cashier.dto.product.TbProductDto;
import cn.ysk.cashier.exception.BadRequestException; import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.pojo.product.TbProduct;
import cn.ysk.cashier.pojo.product.TbProductSku; import cn.ysk.cashier.pojo.product.TbProductSku;
import cn.ysk.cashier.pojo.product.TbProductStockDetail; import cn.ysk.cashier.pojo.product.TbProductStockDetail;
import cn.ysk.cashier.pojo.shop.TbShopInfo; import cn.ysk.cashier.pojo.shop.TbShopInfo;
import cn.ysk.cashier.pojo.shop.TbShopUnit; import cn.ysk.cashier.pojo.shop.TbShopUnit;
import cn.ysk.cashier.repository.product.TbProductRepository;
import cn.ysk.cashier.repository.product.TbProductSkuRepository; import cn.ysk.cashier.repository.product.TbProductSkuRepository;
import cn.ysk.cashier.repository.product.TbProductStockDetailRepository; import cn.ysk.cashier.repository.product.TbProductStockDetailRepository;
import cn.ysk.cashier.repository.shop.TbShopInfoRepository; import cn.ysk.cashier.repository.shop.TbShopInfoRepository;
@ -15,7 +17,6 @@ import cn.ysk.cashier.repository.shop.TbShopUnitRepository;
import cn.ysk.cashier.service.TbProductStockOperateService; import cn.ysk.cashier.service.TbProductStockOperateService;
import cn.ysk.cashier.service.product.StockService; import cn.ysk.cashier.service.product.StockService;
import cn.ysk.cashier.service.product.TbProductService; import cn.ysk.cashier.service.product.TbProductService;
import cn.ysk.cashier.service.product.TbProductStockDetailService;
import cn.ysk.cashier.utils.CacheKey; import cn.ysk.cashier.utils.CacheKey;
import cn.ysk.cashier.utils.FileUtil; import cn.ysk.cashier.utils.FileUtil;
import cn.ysk.cashier.utils.RedisUtils; import cn.ysk.cashier.utils.RedisUtils;
@ -60,6 +61,7 @@ public class StockServiceImpl implements StockService {
private final TbShopInfoRepository tbShopInfoRepository; private final TbShopInfoRepository tbShopInfoRepository;
private final TbShopUnitRepository shopUnitRepository; private final TbShopUnitRepository shopUnitRepository;
private final TbProductStockDetailRepository tbProductStockDetailRepository; private final TbProductStockDetailRepository tbProductStockDetailRepository;
private final TbProductRepository tbProductRepository;
@PersistenceContext @PersistenceContext
private EntityManager em; private EntityManager em;
@ -384,4 +386,19 @@ public class StockServiceImpl implements StockService {
} }
tbProductSkuRepository.updateWarnLineByShopId(stockUpdateWarnLineVO.getWarnLine(), stockUpdateWarnLineVO.getShopId()); tbProductSkuRepository.updateWarnLineByShopId(stockUpdateWarnLineVO.getWarnLine(), stockUpdateWarnLineVO.getShopId());
} }
@Override
public void grounding(Integer shopId, Integer skuId, Boolean isGrounding) {
TbProductSku tbProductSku = skuRepository.findById(skuId).orElse(null);
if (tbProductSku == null) {
throw new BadRequestException("商品不存在skuId: " + skuId);
}
TbProduct product = tbProductRepository.selectByShopIdAndId(Integer.parseInt(tbProductSku.getProductId()), String.valueOf(shopId));
// 共享库存下架所有sku
if (product.getIsDistribute().equals(1)) {
tbProductSkuRepository.updateGroundingByProId(product.getId().toString(), isGrounding ? 1 : 0);
}else {
tbProductSkuRepository.updateGrounding(skuId, isGrounding ? 1 : 0);
}
}
} }

View File

@ -15,27 +15,31 @@
*/ */
package cn.ysk.cashier.service.impl.productimpl; package cn.ysk.cashier.service.impl.productimpl;
import cn.hutool.core.util.StrUtil;
import cn.ysk.cashier.dto.product.StockCountDTO;
import cn.ysk.cashier.pojo.order.TbOrderInfo;
import cn.ysk.cashier.pojo.product.TbProductStockDetail; import cn.ysk.cashier.pojo.product.TbProductStockDetail;
import cn.ysk.cashier.utils.ValidationUtil; import cn.ysk.cashier.repository.order.StockCountRepository;
import cn.ysk.cashier.utils.FileUtil; import cn.ysk.cashier.repository.order.TbOrderInfoRepository;
import cn.ysk.cashier.utils.*;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import cn.ysk.cashier.repository.product.TbProductStockDetailRepository; import cn.ysk.cashier.repository.product.TbProductStockDetailRepository;
import cn.ysk.cashier.service.product.TbProductStockDetailService; import cn.ysk.cashier.service.product.TbProductStockDetailService;
import cn.ysk.cashier.dto.product.TbProductStockDetailDto; import cn.ysk.cashier.dto.product.TbProductStockDetailDto;
import cn.ysk.cashier.dto.product.TbProductStockDetailQueryCriteria; import cn.ysk.cashier.dto.product.TbProductStockDetailQueryCriteria;
import cn.ysk.cashier.mapper.product.TbProductStockDetailMapper; import cn.ysk.cashier.mapper.product.TbProductStockDetailMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import cn.ysk.cashier.utils.PageUtil;
import cn.ysk.cashier.utils.QueryHelp;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.io.IOException; import java.io.IOException;
import javax.persistence.EntityManager;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
/** /**
@ -46,11 +50,17 @@ import javax.servlet.http.HttpServletResponse;
**/ **/
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
@Slf4j
public class TbProductStockDetailServiceImpl implements TbProductStockDetailService { public class TbProductStockDetailServiceImpl implements TbProductStockDetailService {
private final TbProductStockDetailRepository tbProductStockDetailRepository; private final TbProductStockDetailRepository tbProductStockDetailRepository;
private final TbProductStockDetailMapper tbProductStockDetailMapper; private final TbProductStockDetailMapper tbProductStockDetailMapper;
private final StockCountRepository stockCountRepository;
private final EntityManager entityManager;
private final TbOrderInfoRepository tbOrderInfoRepository;
@Override @Override
public Map<String,Object> queryAll(TbProductStockDetailQueryCriteria criteria, Pageable pageable){ public Map<String,Object> queryAll(TbProductStockDetailQueryCriteria criteria, Pageable pageable){
Page<TbProductStockDetail> page = tbProductStockDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); Page<TbProductStockDetail> page = tbProductStockDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
@ -66,10 +76,24 @@ public class TbProductStockDetailServiceImpl implements TbProductStockDetailServ
Page<TbProductStockDetail> page = tbProductStockDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) Page<TbProductStockDetail> page = tbProductStockDetailRepository.findAll((root, criteriaQuery, criteriaBuilder)
-> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
Page<TbProductStockDetailDto> map = page.map(tbProductStockDetailMapper::toDto); Page<TbProductStockDetailDto> map = page.map(tbProductStockDetailMapper::toDto);
ArrayList<Map<String, Object>> contents = new ArrayList<>();
for (TbProductStockDetailDto tbProductStockDetailDto : map.getContent()) { for (TbProductStockDetailDto tbProductStockDetailDto : map.getContent()) {
Map<String, Object> map1 = BeanUtil.transBean2Map(tbProductStockDetailDto);
if (StrUtil.isNotBlank(tbProductStockDetailDto.getOrderId())) {
TbOrderInfo tbOrderInfo = tbOrderInfoRepository.findById(Integer.valueOf(tbProductStockDetailDto.getOrderId())).orElse(null);
if (tbOrderInfo != null) {
map1.put("orderNo", tbOrderInfo.getOrderNo());
}
}
contents.add(map1);
tbProductStockDetailDto.setTypes(); tbProductStockDetailDto.setTypes();
} }
return PageUtil.toPage(map); Map<String,Object> info = new LinkedHashMap<>(2);
info.put("content",contents);
info.put("totalElements",page.getTotalElements());
return info;
} }
@ -152,4 +176,33 @@ public class TbProductStockDetailServiceImpl implements TbProductStockDetailServ
} }
FileUtil.downloadExcel(list, response); FileUtil.downloadExcel(list, response);
} }
@Override
public void addSaleRecord(Integer orderId) {
List<StockCountDTO> stockCountDTOS = stockCountRepository.countStockById(orderId);
log.info("查询到订单id: {}的所有库存数据: {}", orderId, stockCountDTOS);
stockCountDTOS.forEach(s->{
if (s.getStockCount() > 0) {
TbProductStockDetail productStockDetail = new TbProductStockDetail();
productStockDetail.setCreatedAt(System.currentTimeMillis());
productStockDetail.setUpdatedAt(System.currentTimeMillis());
productStockDetail.setShopId(s.getShopId());
productStockDetail.setProductId(s.getProId().toString());
productStockDetail.setProductName(s.getProName());
productStockDetail.setOrderId(orderId.toString());
// productStockDetail.setSkuId(s.getSkuId().toString());
productStockDetail.setIsStock(s.getIsStock());//是否开启库存
productStockDetail.setLeftNumber(s.getStockNumber()+s.getStockCount());//原库存
// productStockDetail.setSpecSnap(s.getSkuName());
productStockDetail.setUnitName(s.getUnitName());
productStockDetail.setStockNumber(-Double.valueOf(s.getStockCount()));
productStockDetail.setSourcePath("NORMAL");
productStockDetail.setType("售出记录");
productStockDetail.setRemark("售出记录:" + orderId);
productStockDetail.setSubType(-1);
tbProductStockDetailRepository.save(productStockDetail);
}
});
}
} }

View File

@ -44,4 +44,13 @@ public interface StockService {
* @param stockUpdateWarnLineVO 警戒线 * @param stockUpdateWarnLineVO 警戒线
*/ */
void updateProductWarnLine(StockUpdateWarnLineVO stockUpdateWarnLineVO); void updateProductWarnLine(StockUpdateWarnLineVO stockUpdateWarnLineVO);
/**
* 上下架商品
*
* @param shopId 店铺id
* @param skuId ski
* @param isGrounding
*/
void grounding(Integer shopId, Integer skuId, Boolean isGrounding);
} }

View File

@ -86,4 +86,6 @@ public interface TbProductStockDetailService {
* @throws IOException / * @throws IOException /
*/ */
void download(List<TbProductStockDetailDto> all, HttpServletResponse response) throws IOException; void download(List<TbProductStockDetailDto> all, HttpServletResponse response) throws IOException;
void addSaleRecord(Integer orderId);
} }

View File

@ -0,0 +1,18 @@
package cn.ysk.cashier.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.function.Supplier;
public class Utils {
private static final Logger log = LoggerFactory.getLogger(Utils.class);
public static <T> void catchErrNoReturn(Supplier<T> supplier) {
try {
supplier.get();
}catch (Exception e) {
log.error("执行方法出现异常", e);
}
}
}

View File

@ -8,7 +8,6 @@ import java.util.List;
/** /**
* @author GYJ * @author GYJ
*/ */
@Data
public class StockV2Vo { public class StockV2Vo {
private String id; private String id;
private Integer skuId; private Integer skuId;
@ -25,6 +24,7 @@ public class StockV2Vo {
private Object number; private Object number;
private Integer warnLine; private Integer warnLine;
private BigDecimal salePrice; private BigDecimal salePrice;
private boolean isGrounding;
public StockV2Vo(Integer proId, Integer skuId, String name, String unitName,String specSnap, Object number,Object stockNumber, Integer isDistribute) { public StockV2Vo(Integer proId, Integer skuId, String name, String unitName,String specSnap, Object number,Object stockNumber, Integer isDistribute) {
this.proId = proId; this.proId = proId;
@ -80,6 +80,7 @@ public class StockV2Vo {
this.warnLine = warnLine; this.warnLine = warnLine;
} }
public StockV2Vo(Integer id, Integer proId,String img,String name,String unitName, String type, String specSnap, public StockV2Vo(Integer id, Integer proId,String img,String name,String unitName, String type, String specSnap,
Object isStock, Object number, Integer isDistribute, Integer isPauseSale, boolean isPro, Integer warnLine, BigDecimal sellPrice) { Object isStock, Object number, Integer isDistribute, Integer isPauseSale, boolean isPro, Integer warnLine, BigDecimal sellPrice) {
this.id = id.toString() + "-" + proId.toString(); this.id = id.toString() + "-" + proId.toString();
@ -103,6 +104,156 @@ public class StockV2Vo {
this.salePrice = sellPrice; this.salePrice = sellPrice;
} }
public StockV2Vo(Integer id, Integer proId,String img,String name,String unitName, String type, String specSnap,
Object isStock, Object number, Integer isDistribute, Integer isPauseSale, boolean isPro, Integer warnLine, BigDecimal sellPrice, boolean isGrounding) {
this.skuId = id;
this.id = id.toString() + "-" + proId.toString();
if (isPro) {
this.id += proId;
} else {
this.id += id;
}
this.proId = proId;
this.img = img;
this.name = name;
this.unitName = unitName;
setType(type);
this.specSnap = specSnap;
this.isStock = isStock;
this.stockNumber = number;
this.isDistribute = isDistribute;
this.isPauseSale = isPauseSale;
this.warnLine = warnLine;
this.salePrice = sellPrice;
this.isGrounding = isGrounding;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Integer getSkuId() {
return skuId;
}
public void setSkuId(Integer skuId) {
this.skuId = skuId;
}
public Integer getProId() {
return proId;
}
public void setProId(Integer proId) {
this.proId = proId;
}
public String getImg() {
return img;
}
public void setImg(String img) {
this.img = img;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUnitName() {
return unitName;
}
public void setUnitName(String unitName) {
this.unitName = unitName;
}
public String getType() {
return type;
}
public String getSpecSnap() {
return specSnap;
}
public void setSpecSnap(String specSnap) {
this.specSnap = specSnap;
}
public Object getIsStock() {
return isStock;
}
public void setIsStock(Object isStock) {
this.isStock = isStock;
}
public Object getStockNumber() {
return stockNumber;
}
public void setStockNumber(Object stockNumber) {
this.stockNumber = stockNumber;
}
public Integer getIsDistribute() {
return isDistribute;
}
public void setIsDistribute(Integer isDistribute) {
this.isDistribute = isDistribute;
}
public Integer getIsPauseSale() {
return isPauseSale;
}
public void setIsPauseSale(Integer isPauseSale) {
this.isPauseSale = isPauseSale;
}
public Object getNumber() {
return number;
}
public void setNumber(Object number) {
this.number = number;
}
public Integer getWarnLine() {
return warnLine;
}
public void setWarnLine(Integer warnLine) {
this.warnLine = warnLine;
}
public BigDecimal getSalePrice() {
return salePrice;
}
public void setSalePrice(BigDecimal salePrice) {
this.salePrice = salePrice;
}
public boolean getIsGrounding() {
return isGrounding;
}
public void setIsGrounding(boolean grounding) {
isGrounding = grounding;
}
public void setType(String type) { public void setType(String type) {
switch (type) { switch (type) {
case "normal": case "normal":