添加耗材功能
This commit is contained in:
parent
e3f2d7fc64
commit
8076a2dbec
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package cn.ysk.cashier.cons.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.Data;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
|
@ -80,6 +81,10 @@ public class TbConsInfoFlow implements Serializable {
|
|||
@ApiModelProperty(value = "店铺id")
|
||||
private Integer shopId;
|
||||
|
||||
@Transient
|
||||
@TableField(exist = false)
|
||||
private String productName;
|
||||
|
||||
public void copy(TbConsInfoFlow source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,9 +50,13 @@ public class ViewProductSkuShop implements Serializable {
|
|||
private String shopName;
|
||||
|
||||
@Column(name = "`shop_id`")
|
||||
@ApiModelProperty(value = "自增id")
|
||||
private Integer shopId;
|
||||
|
||||
|
||||
@Column(name = "`product_id`")
|
||||
@ApiModelProperty(value = "商品id")
|
||||
private Integer productId;
|
||||
|
||||
public void copy(ViewProductSkuShop source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
package cn.ysk.cashier.cons.repository;
|
||||
|
||||
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.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
|
|
@ -10,4 +12,14 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|||
* @date 2024-06-22
|
||||
**/
|
||||
public interface TbConsInfoFlowRepository extends JpaRepository<TbConsInfoFlow, Integer>, JpaSpecificationExecutor<TbConsInfoFlow> {
|
||||
|
||||
|
||||
@Query(value = "SELECT\n" +
|
||||
"\tp.`name`\n" +
|
||||
"FROM\n" +
|
||||
" tb_prosku_con i \n" +
|
||||
"\tleft join tb_product_sku s on i.product_sku_id=s.id\n" +
|
||||
"\tleft join tb_product p on s.product_id=p.id\n" +
|
||||
"\twhere i.con_info_id=?1 limit 1",nativeQuery = true)
|
||||
String selectByPskId(Integer skuId);
|
||||
}
|
||||
|
|
@ -56,4 +56,6 @@ public class TbConsInfoFlowDto implements Serializable {
|
|||
|
||||
/** 店铺id */
|
||||
private Integer shopId;
|
||||
|
||||
private String productName;
|
||||
}
|
||||
|
|
@ -39,4 +39,6 @@ public class ViewProductSkuShopDto implements Serializable {
|
|||
|
||||
/** 自增id */
|
||||
private Integer shopId;
|
||||
|
||||
private Integer productId;
|
||||
}
|
||||
|
|
@ -26,4 +26,7 @@ public class ViewProductSkuShopQueryCriteria{
|
|||
/** 精确 */
|
||||
@Query
|
||||
private Integer shopId;
|
||||
|
||||
@Query
|
||||
private Integer productId;
|
||||
}
|
||||
|
|
@ -17,12 +17,10 @@ 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.util.*;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
|
|
@ -42,8 +40,15 @@ public class TbConsInfoFlowServiceImpl implements TbConsInfoFlowService {
|
|||
|
||||
Sort sort = Sort.by(Sort.Direction.DESC, "id");
|
||||
pageable = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), sort);
|
||||
|
||||
Page<TbConsInfoFlow> page = tbConsInfoFlowRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
|
||||
page.get().forEach(it->{
|
||||
String name= tbConsInfoFlowRepository.selectByPskId(it.getConsId());
|
||||
if(Objects.nonNull(name)){
|
||||
it.setProductName(name);
|
||||
}
|
||||
});
|
||||
|
||||
return PageUtil.toPage(page.map(tbConsInfoFlowMapper::toDto));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -72,8 +72,6 @@ public class TbProskuConServiceImpl implements TbProskuConService {
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public TbProskuConDto create(ProskuInfo resources) throws Exception {
|
||||
|
||||
|
||||
|
||||
TbProduct product= tbProductRepository.getById(resources.getProductId());
|
||||
if(Objects.isNull(product)){
|
||||
throw new Exception("对应的商品信息不存在");
|
||||
|
|
@ -107,13 +105,12 @@ public class TbProskuConServiceImpl implements TbProskuConService {
|
|||
}
|
||||
|
||||
}else {
|
||||
|
||||
for (ProskuInfo.SkuInfo skuInfo : resources.getSkuInfos()) {
|
||||
int count=tbProskuConRepository.countByConInfoIdAndProductSkuIdAndShopId(resources.getConsInfoId(), skuInfo.getSkuId(), skuInfo.getShopId(), resources.getProductId());
|
||||
if(count<=0){
|
||||
TbProskuCon tbProskuCon=new TbProskuCon();
|
||||
tbProskuCon.setShopId(Integer.valueOf(skuInfo.getShopId()));
|
||||
tbProskuCon.setConInfoId(resources.getConsInfoId());
|
||||
tbProskuCon.setConInfoId(skuInfo.getConInfoId());
|
||||
tbProskuCon.setProductId(resources.getProductId());
|
||||
tbProskuCon.setProductSkuId(skuInfo.getSkuId());
|
||||
tbProskuCon.setSurplusStock(skuInfo.getSurplusStock());
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ spring:
|
|||
redis:
|
||||
#数据库索引
|
||||
database: ${REDIS_DB:0}
|
||||
host: ${REDIS_HOST:127.0.0.1}
|
||||
host: ${REDIS_HOST:101.37.12.135}
|
||||
port: ${REDIS_PORT:6379}
|
||||
password: ${REDIS_PWD:111111}
|
||||
#连接超时时间
|
||||
|
|
|
|||
Loading…
Reference in New Issue