2024年6月15日 新增接口,完善技师物料包维护
This commit is contained in:
parent
8c6f523bac
commit
9f63624196
|
@ -10,16 +10,19 @@ import com.sqx.modules.artificerselfgoods.service.BlArtificerSelfGoodsService;
|
||||||
import com.sqx.modules.artificerselfgoods.service.BlArtificerSelfGoodsService;
|
import com.sqx.modules.artificerselfgoods.service.BlArtificerSelfGoodsService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author bai
|
* @author bai
|
||||||
* @date 2024/06/08
|
* @date 2024/06/08
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@Api(value = "v3-技师与物料关系表", tags = { "v3-技师与物料关系表" })
|
@Api(value = "v3-技师与物料关系表", tags = { "v3-技师与物料关系表" })
|
||||||
@RequestMapping(value = "/blArtificerSelfGoods")
|
@RequestMapping(value = "/blArtificerSelfGoods")
|
||||||
|
@ -33,35 +36,39 @@ public class BlArtificerSelfGoodsController {
|
||||||
public Result list(BlArtificerSelfGoods entity, Integer page,Integer limit){
|
public Result list(BlArtificerSelfGoods entity, Integer page,Integer limit){
|
||||||
QueryWrapper<BlArtificerSelfGoods> qw = new QueryWrapper<>();
|
QueryWrapper<BlArtificerSelfGoods> qw = new QueryWrapper<>();
|
||||||
|
|
||||||
// if(entity != null) {
|
if(entity != null) {
|
||||||
//价格类型
|
//技师
|
||||||
// qw.lambda().eq(entity.getPricingType() != null, BlArtificerSelfGoods::getPricingType, entity.getPricingType());
|
qw.lambda().eq(entity.getArtificerId() != null, BlArtificerSelfGoods::getArtificerId, entity.getArtificerId());
|
||||||
// //出行方式
|
}
|
||||||
// qw.lambda().eq(entity.getTravelType() != null, BlArtificerSelfGoods::getTravelType, entity.getTravelType());
|
|
||||||
// //时令
|
|
||||||
// qw.lambda().eq(entity.getSeasonsType() != null, BlArtificerSelfGoods::getSeasonsType, entity.getSeasonsType());
|
|
||||||
// //时段
|
|
||||||
// qw.lambda().eq(entity.getTimeIntervalType() != null, BlArtificerSelfGoods::getTimeIntervalType, entity.getTimeIntervalType());
|
|
||||||
// }
|
|
||||||
|
|
||||||
// qw.orderByAsc("sort");
|
qw.orderByAsc("create_time", "update_time");
|
||||||
IPage<BlArtificerSelfGoods> pageList = service.page(new Page<>(page,limit),qw);
|
IPage<BlArtificerSelfGoods> pageList = service.page(new Page<>(page,limit),qw);
|
||||||
return Result.success().put("data",pageList);
|
return Result.success().put("data",pageList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/add")
|
@PostMapping(value = "/addList")
|
||||||
@ApiOperation("新增")
|
@ApiOperation("新增")
|
||||||
public Result add(@RequestBody BlArtificerSelfGoods entity){
|
public Result add(@RequestBody List<BlArtificerSelfGoods> list){
|
||||||
entity.setCreateTime(DateUtil.now());
|
try {
|
||||||
entity.setUpdateTime(DateUtil.now());
|
service.editWarehouse(list);
|
||||||
return Result.success().put("data",service.save(entity));
|
return Result.success();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
|
return Result.error(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/update")
|
@PostMapping(value = "/update")
|
||||||
@ApiOperation("修改")
|
@ApiOperation("修改")
|
||||||
public Result update(@RequestBody BlArtificerSelfGoods entity){
|
public Result update(@RequestBody BlArtificerSelfGoods entity){
|
||||||
entity.setUpdateTime(DateUtil.now());
|
entity.setUpdateTime(DateUtil.now());
|
||||||
return Result.success().put("data",service.updateById(entity));
|
try {
|
||||||
|
service.editWarehouseById(entity.getId(), entity.getChangeNum(), entity.getRemark());
|
||||||
|
return Result.success();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
|
return Result.error(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/info/{id}")
|
@RequestMapping("/info/{id}")
|
||||||
|
@ -70,22 +77,22 @@ public class BlArtificerSelfGoodsController {
|
||||||
return Result.success().put("data", data);
|
return Result.success().put("data", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping(value = "/deleteById")
|
// @DeleteMapping(value = "/deleteById")
|
||||||
@ApiOperation("删除")
|
// @ApiOperation("删除")
|
||||||
public Result deleteById(Long id){
|
// public Result deleteById(Long id){
|
||||||
service.removeById(id);
|
// service.removeById(id);
|
||||||
return Result.success();
|
// return Result.success();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@DeleteMapping(value = "/deleteByIds")
|
// @DeleteMapping(value = "/deleteByIds")
|
||||||
@ApiOperation("批量删除")
|
// @ApiOperation("批量删除")
|
||||||
public Result deleteByIds(String id){
|
// public Result deleteByIds(String id){
|
||||||
if(StringUtils.isNotBlank(id)){
|
// if(StringUtils.isNotBlank(id)){
|
||||||
String[] ids = StringUtils.split(id,",");
|
// String[] ids = StringUtils.split(id,",");
|
||||||
service.removeByIds(Arrays.asList(ids));
|
// service.removeByIds(Arrays.asList(ids));
|
||||||
}
|
// }
|
||||||
return Result.success();
|
// return Result.success();
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.sqx.common.utils.Result;
|
import com.sqx.common.utils.Result;
|
||||||
|
import com.sqx.modules.artificerselfgoods.entity.BlArtificerSelfGoods;
|
||||||
import com.sqx.modules.artificerselfgoods.entity.BlArtificerSelfGoodsEntryExitRecords;
|
import com.sqx.modules.artificerselfgoods.entity.BlArtificerSelfGoodsEntryExitRecords;
|
||||||
import com.sqx.modules.artificerselfgoods.service.BlArtificerSelfGoodsEntryExitRecordsService;
|
import com.sqx.modules.artificerselfgoods.service.BlArtificerSelfGoodsEntryExitRecordsService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
@ -32,18 +33,13 @@ public class BlArtificerSelfGoodsEntryExitRecordsController {
|
||||||
public Result list(BlArtificerSelfGoodsEntryExitRecords entity, Integer page,Integer limit){
|
public Result list(BlArtificerSelfGoodsEntryExitRecords entity, Integer page,Integer limit){
|
||||||
QueryWrapper<BlArtificerSelfGoodsEntryExitRecords> qw = new QueryWrapper<>();
|
QueryWrapper<BlArtificerSelfGoodsEntryExitRecords> qw = new QueryWrapper<>();
|
||||||
|
|
||||||
// if(entity != null) {
|
if(entity != null) {
|
||||||
//价格类型
|
//技师
|
||||||
// qw.lambda().eq(entity.getPricingType() != null, BlArtificerSelfGoodsEntryExitRecords::getPricingType, entity.getPricingType());
|
qw.lambda().eq(entity.getArtificerId() != null, BlArtificerSelfGoodsEntryExitRecords::getArtificerId, entity.getArtificerId());
|
||||||
// //出行方式
|
qw.lambda().eq(entity.getSelfGoodsId() != null, BlArtificerSelfGoodsEntryExitRecords::getSelfGoodsId, entity.getSelfGoodsId());
|
||||||
// qw.lambda().eq(entity.getTravelType() != null, BlArtificerSelfGoodsEntryExitRecords::getTravelType, entity.getTravelType());
|
}
|
||||||
// //时令
|
|
||||||
// qw.lambda().eq(entity.getSeasonsType() != null, BlArtificerSelfGoodsEntryExitRecords::getSeasonsType, entity.getSeasonsType());
|
|
||||||
// //时段
|
|
||||||
// qw.lambda().eq(entity.getTimeIntervalType() != null, BlArtificerSelfGoodsEntryExitRecords::getTimeIntervalType, entity.getTimeIntervalType());
|
|
||||||
// }
|
|
||||||
|
|
||||||
// qw.orderByAsc("sort");
|
qw.orderByAsc("create_time");
|
||||||
IPage<BlArtificerSelfGoodsEntryExitRecords> pageList = service.page(new Page<>(page,limit),qw);
|
IPage<BlArtificerSelfGoodsEntryExitRecords> pageList = service.page(new Page<>(page,limit),qw);
|
||||||
return Result.success().put("data",pageList);
|
return Result.success().put("data",pageList);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.sqx.modules.shopping.entity.SelfGoods;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
@ -108,4 +109,10 @@ public class BlArtificerSelfGoods implements Serializable {
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品对象
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private SelfGoods goods;
|
||||||
|
|
||||||
}
|
}
|
|
@ -95,7 +95,21 @@ public interface BlArtificerSelfGoodsService extends IService<BlArtificerSelfGoo
|
||||||
* @param changeNum
|
* @param changeNum
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
boolean editWarehouse(Long artificerSelfGoodsId, int changeNum, String remark);
|
boolean editWarehouseById(Long artificerSelfGoodsId, int changeNum, String remark);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量修改库
|
||||||
|
* @param artificerSelfGoodsList
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean editWarehouseById(List<BlArtificerSelfGoods> artificerSelfGoodsList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改库
|
||||||
|
* @param artificerSelfGoods
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean editWarehouse(BlArtificerSelfGoods artificerSelfGoods);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量修改库
|
* 批量修改库
|
||||||
|
@ -104,5 +118,4 @@ public interface BlArtificerSelfGoodsService extends IService<BlArtificerSelfGoo
|
||||||
*/
|
*/
|
||||||
boolean editWarehouse(List<BlArtificerSelfGoods> artificerSelfGoodsList);
|
boolean editWarehouse(List<BlArtificerSelfGoods> artificerSelfGoodsList);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,21 @@
|
||||||
package com.sqx.modules.artificerselfgoods.service.impl;
|
package com.sqx.modules.artificerselfgoods.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.sqx.common.exception.SqxException;
|
||||||
import com.sqx.modules.artificerselfgoods.dao.BlArtificerSelfGoodsDao;
|
import com.sqx.modules.artificerselfgoods.dao.BlArtificerSelfGoodsDao;
|
||||||
import com.sqx.modules.artificerselfgoods.entity.BlArtificerSelfGoods;
|
import com.sqx.modules.artificerselfgoods.entity.BlArtificerSelfGoods;
|
||||||
import com.sqx.modules.artificerselfgoods.service.BlArtificerSelfGoodsEntryExitRecordsService;
|
import com.sqx.modules.artificerselfgoods.service.BlArtificerSelfGoodsEntryExitRecordsService;
|
||||||
import com.sqx.modules.artificerselfgoods.service.BlArtificerSelfGoodsService;
|
import com.sqx.modules.artificerselfgoods.service.BlArtificerSelfGoodsService;
|
||||||
|
import com.sqx.modules.shopping.dao.GoodsTypeJpaRepository;
|
||||||
|
import com.sqx.modules.shopping.entity.GoodsType;
|
||||||
import com.sqx.modules.sys.entity.SysUserEntity;
|
import com.sqx.modules.sys.entity.SysUserEntity;
|
||||||
import org.apache.shiro.SecurityUtils;
|
import org.apache.shiro.SecurityUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -25,6 +30,10 @@ public class BlArtificerSelfGoodsServiceImpl extends ServiceImpl<BlArtificerSelf
|
||||||
@Autowired
|
@Autowired
|
||||||
private BlArtificerSelfGoodsService artificerSelfGoodsService;
|
private BlArtificerSelfGoodsService artificerSelfGoodsService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GoodsTypeJpaRepository goodsJpaTypeRepository;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private BlArtificerSelfGoodsEntryExitRecordsService artificerSelfGoodsEntryExitRecordsService;
|
private BlArtificerSelfGoodsEntryExitRecordsService artificerSelfGoodsEntryExitRecordsService;
|
||||||
|
|
||||||
|
@ -56,35 +65,39 @@ public class BlArtificerSelfGoodsServiceImpl extends ServiceImpl<BlArtificerSelf
|
||||||
return getOne(qw);
|
return getOne(qw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional( rollbackFor = {Exception.class} )
|
||||||
@Override
|
@Override
|
||||||
public boolean addOrInWarehouse(BlArtificerSelfGoods artificerSelfGoods) {
|
public boolean addOrInWarehouse(BlArtificerSelfGoods artificerSelfGoods) {
|
||||||
if(artificerSelfGoods.getId() == null){
|
if(artificerSelfGoods.getId() == null){
|
||||||
addWarehouse(artificerSelfGoods);
|
artificerSelfGoodsService.addWarehouse(artificerSelfGoods);
|
||||||
} else {
|
} else {
|
||||||
inWarehouse(artificerSelfGoods.getId(),artificerSelfGoods.getPurchasePrice(), artificerSelfGoods.getChangeNum());
|
artificerSelfGoodsService.inWarehouse(artificerSelfGoods.getId(),artificerSelfGoods.getPurchasePrice(), artificerSelfGoods.getChangeNum());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional( rollbackFor = {Exception.class} )
|
||||||
@Override
|
@Override
|
||||||
public boolean addOrInWarehouse(List<BlArtificerSelfGoods> artificerSelfGoodsList) {
|
public boolean addOrInWarehouse(List<BlArtificerSelfGoods> artificerSelfGoodsList) {
|
||||||
artificerSelfGoodsList.forEach(this::addOrInWarehouse);
|
artificerSelfGoodsList.forEach(this::addOrInWarehouse);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional( rollbackFor = {Exception.class} )
|
||||||
@Override
|
@Override
|
||||||
public boolean addWarehouse(BlArtificerSelfGoods artificerSelfGoods) {
|
public boolean addWarehouse(BlArtificerSelfGoods artificerSelfGoods) {
|
||||||
save(artificerSelfGoods);
|
save(artificerSelfGoods);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional( rollbackFor = {Exception.class} )
|
||||||
@Override
|
@Override
|
||||||
public boolean addWarehouse(List<BlArtificerSelfGoods> artificerSelfGoodsList) {
|
public boolean addWarehouse(List<BlArtificerSelfGoods> artificerSelfGoodsList) {
|
||||||
artificerSelfGoodsService.saveBatch(artificerSelfGoodsList);
|
artificerSelfGoodsService.saveBatch(artificerSelfGoodsList);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional( rollbackFor = {Exception.class} )
|
||||||
@Override
|
@Override
|
||||||
public boolean inWarehouse(Long artificerSelfGoodsId, BigDecimal purchasePrice, int changeNum) {
|
public boolean inWarehouse(Long artificerSelfGoodsId, BigDecimal purchasePrice, int changeNum) {
|
||||||
BlArtificerSelfGoods e = getById(artificerSelfGoodsId);
|
BlArtificerSelfGoods e = getById(artificerSelfGoodsId);
|
||||||
|
@ -92,7 +105,10 @@ public class BlArtificerSelfGoodsServiceImpl extends ServiceImpl<BlArtificerSelf
|
||||||
Integer afterTheChangeNum = e.getNum();
|
Integer afterTheChangeNum = e.getNum();
|
||||||
e.setLastTimeChangeNum(changeNum);
|
e.setLastTimeChangeNum(changeNum);
|
||||||
e.setLastTimeNum(e.getNum());
|
e.setLastTimeNum(e.getNum());
|
||||||
Integer beforeTheChangeNum = afterTheChangeNum - changeNum;
|
Integer beforeTheChangeNum = afterTheChangeNum + changeNum;
|
||||||
|
if(beforeTheChangeNum < 0){
|
||||||
|
throw new SqxException("不可修改为负库存!");
|
||||||
|
}
|
||||||
e.setNum(beforeTheChangeNum);
|
e.setNum(beforeTheChangeNum);
|
||||||
updateById(e);
|
updateById(e);
|
||||||
//记录日志
|
//记录日志
|
||||||
|
@ -100,12 +116,14 @@ public class BlArtificerSelfGoodsServiceImpl extends ServiceImpl<BlArtificerSelf
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional( rollbackFor = {Exception.class} )
|
||||||
@Override
|
@Override
|
||||||
public boolean inWarehouse(List<BlArtificerSelfGoods> artificerSelfGoodsList) {
|
public boolean inWarehouse(List<BlArtificerSelfGoods> artificerSelfGoodsList) {
|
||||||
artificerSelfGoodsList.forEach(x -> inWarehouse(x.getId(), x.getPurchasePrice(), x.getChangeNum()));
|
artificerSelfGoodsList.forEach(x -> artificerSelfGoodsService.inWarehouse(x.getId(), x.getPurchasePrice(), x.getChangeNum()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional( rollbackFor = {Exception.class} )
|
||||||
@Override
|
@Override
|
||||||
public boolean outWarehouse(Long artificerSelfGoodsId, int changeNum, String userId) {
|
public boolean outWarehouse(Long artificerSelfGoodsId, int changeNum, String userId) {
|
||||||
BlArtificerSelfGoods e = getById(artificerSelfGoodsId);
|
BlArtificerSelfGoods e = getById(artificerSelfGoodsId);
|
||||||
|
@ -114,6 +132,9 @@ public class BlArtificerSelfGoodsServiceImpl extends ServiceImpl<BlArtificerSelf
|
||||||
e.setLastTimeChangeNum(changeNum);
|
e.setLastTimeChangeNum(changeNum);
|
||||||
e.setLastTimeNum(e.getNum());
|
e.setLastTimeNum(e.getNum());
|
||||||
Integer beforeTheChangeNum = afterTheChangeNum - changeNum;
|
Integer beforeTheChangeNum = afterTheChangeNum - changeNum;
|
||||||
|
if(beforeTheChangeNum < 0){
|
||||||
|
throw new SqxException("不可修改为负库存!");
|
||||||
|
}
|
||||||
e.setNum(beforeTheChangeNum);
|
e.setNum(beforeTheChangeNum);
|
||||||
updateById(e);
|
updateById(e);
|
||||||
//记录日志
|
//记录日志
|
||||||
|
@ -121,20 +142,87 @@ public class BlArtificerSelfGoodsServiceImpl extends ServiceImpl<BlArtificerSelf
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional( rollbackFor = {Exception.class} )
|
||||||
@Override
|
@Override
|
||||||
public boolean outWarehouse(List<BlArtificerSelfGoods> artificerSelfGoodsList) {
|
public boolean outWarehouse(List<BlArtificerSelfGoods> artificerSelfGoodsList) {
|
||||||
artificerSelfGoodsList.forEach(x -> outWarehouse(x.getId(), x.getChangeNum(), x.getUserId()));
|
artificerSelfGoodsList.forEach(x -> artificerSelfGoodsService.outWarehouse(x.getId(), x.getChangeNum(), x.getUserId()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional( rollbackFor = {Exception.class} )
|
||||||
@Override
|
@Override
|
||||||
public boolean editWarehouse(Long artificerSelfGoodsId, int changeNum, String remark) {
|
public boolean editWarehouse(BlArtificerSelfGoods artificerSelfGoods) {
|
||||||
|
Integer changeNum = artificerSelfGoods.getChangeNum();
|
||||||
|
String remark = artificerSelfGoods.getRemark();
|
||||||
|
|
||||||
|
BlArtificerSelfGoods e = findArtificerSelfGoodsByArtificerIdAndGoodsId(artificerSelfGoods.getArtificerId(), String.valueOf(artificerSelfGoods.getSelfGoodsId()));
|
||||||
|
if(e == null) {
|
||||||
|
//新增
|
||||||
|
//查询type的pid
|
||||||
|
// Specification<GoodsType> goodsTypeQc = (root, criteriaQuery, criteriaBuilder) -> {
|
||||||
|
// List<Predicate> predicateList = new ArrayList<>();
|
||||||
|
// predicateList.add(criteriaBuilder.equal(root.get("parentId"), "56"),criteriaBuilder.equal(root.get("id"), "56")));
|
||||||
|
// return criteriaBuilder.and(predicateList.toArray(new Predicate[0]));
|
||||||
|
// };
|
||||||
|
GoodsType materialTypes = goodsJpaTypeRepository.getById(Long.valueOf(artificerSelfGoods.getGoods().getTypeId()));
|
||||||
|
|
||||||
|
|
||||||
|
BlArtificerSelfGoods addData = new BlArtificerSelfGoods();
|
||||||
|
|
||||||
|
addData.setCreateTime(DateUtil.now());
|
||||||
|
addData.setUpdateTime(DateUtil.now());
|
||||||
|
addData.setCreateAt(getUser().getUsername());
|
||||||
|
addData.setUpdateAt(getUser().getUsername());
|
||||||
|
|
||||||
|
addData.setSelfGoodsId(artificerSelfGoods.getGoods().getId());
|
||||||
|
addData.setSelfGoodsTitle(artificerSelfGoods.getGoods().getTitle());
|
||||||
|
addData.setSelfGoodsTypeId(artificerSelfGoods.getGoods().getTypeId());
|
||||||
|
addData.setSelfGoodsTypeParentId(String.valueOf(materialTypes.getParentId()));
|
||||||
|
addData.setArtificerId(artificerSelfGoods.getArtificerId());
|
||||||
|
addData.setNum(artificerSelfGoods.getChangeNum());
|
||||||
|
addData.setChangeNum(artificerSelfGoods.getChangeNum());
|
||||||
|
addData.setRemark(artificerSelfGoods.getRemark());
|
||||||
|
|
||||||
|
save(addData);
|
||||||
|
artificerSelfGoodsEntryExitRecordsService.editLog(addData, getUser().getUsername(), null, null, changeNum, remark);
|
||||||
|
} else {
|
||||||
|
e.setUpdateTime(DateUtil.now());
|
||||||
|
e.setUpdateAt(getUser().getUsername());
|
||||||
|
//修改
|
||||||
|
Integer afterTheChangeNum = e.getNum();
|
||||||
|
e.setLastTimeChangeNum(changeNum);
|
||||||
|
e.setLastTimeNum(e.getNum());
|
||||||
|
Integer beforeTheChangeNum = afterTheChangeNum + changeNum;
|
||||||
|
if(beforeTheChangeNum < 0){
|
||||||
|
throw new SqxException("不可修改为负库存!");
|
||||||
|
}
|
||||||
|
e.setNum(beforeTheChangeNum);
|
||||||
|
updateById(e);
|
||||||
|
//记录日志
|
||||||
|
artificerSelfGoodsEntryExitRecordsService.editLog(e, getUser().getUsername(), afterTheChangeNum, beforeTheChangeNum, changeNum, remark);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional( rollbackFor = {Exception.class} )
|
||||||
|
@Override
|
||||||
|
public boolean editWarehouse(List<BlArtificerSelfGoods> artificerSelfGoodsList) {
|
||||||
|
artificerSelfGoodsList.forEach(this::editWarehouse);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional( rollbackFor = {Exception.class} )
|
||||||
|
@Override
|
||||||
|
public boolean editWarehouseById(Long artificerSelfGoodsId, int changeNum, String remark) {
|
||||||
BlArtificerSelfGoods e = getById(artificerSelfGoodsId);
|
BlArtificerSelfGoods e = getById(artificerSelfGoodsId);
|
||||||
if(e == null) return false;
|
if(e == null) return false;
|
||||||
Integer afterTheChangeNum = e.getNum();
|
Integer afterTheChangeNum = e.getNum();
|
||||||
e.setLastTimeChangeNum(changeNum);
|
e.setLastTimeChangeNum(changeNum);
|
||||||
e.setLastTimeNum(e.getNum());
|
e.setLastTimeNum(e.getNum());
|
||||||
Integer beforeTheChangeNum = afterTheChangeNum - changeNum;
|
Integer beforeTheChangeNum = afterTheChangeNum + changeNum;
|
||||||
|
if(beforeTheChangeNum < 0){
|
||||||
|
throw new SqxException("不可修改为负库存!");
|
||||||
|
}
|
||||||
e.setNum(beforeTheChangeNum);
|
e.setNum(beforeTheChangeNum);
|
||||||
updateById(e);
|
updateById(e);
|
||||||
//记录日志
|
//记录日志
|
||||||
|
@ -142,9 +230,11 @@ public class BlArtificerSelfGoodsServiceImpl extends ServiceImpl<BlArtificerSelf
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional( rollbackFor = {Exception.class} )
|
||||||
@Override
|
@Override
|
||||||
public boolean editWarehouse(List<BlArtificerSelfGoods> artificerSelfGoodsList) {
|
public boolean editWarehouseById(List<BlArtificerSelfGoods> artificerSelfGoodsList) {
|
||||||
artificerSelfGoodsList.forEach(x -> editWarehouse(x.getId(), x.getChangeNum(), x.getRemark()));
|
artificerSelfGoodsList.forEach(x -> artificerSelfGoodsService.editWarehouseById(x.getId(), x.getChangeNum(), x.getRemark()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,9 +49,9 @@ public enum CommonEnum {
|
||||||
this.defValue = defValue;
|
this.defValue = defValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean defValueIsEmpty() {
|
// private boolean defValueIsEmpty() {
|
||||||
return CommonConfigUtil.defValueIsEmpty(this.defValue);
|
// return CommonConfigUtil.defValueIsEmpty(this.defValue);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
public Integer getIntValue() {
|
public Integer getIntValue() {
|
||||||
|
@ -148,7 +148,7 @@ public enum CommonEnum {
|
||||||
|
|
||||||
V3_TRAVEL_CONF("v3_travel_conf");
|
V3_TRAVEL_CONF("v3_travel_conf");
|
||||||
|
|
||||||
private String value;
|
private final String value;
|
||||||
GroupConditionEnum(String value){
|
GroupConditionEnum(String value){
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.sqx.modules.common.entity.ArtificerPartitioningDetails;
|
||||||
import com.sqx.modules.common.entity.CommonInfo;
|
import com.sqx.modules.common.entity.CommonInfo;
|
||||||
import com.sqx.modules.common.enums.CommonEnum;
|
import com.sqx.modules.common.enums.CommonEnum;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -77,19 +78,20 @@ public interface CommonInfoService {
|
||||||
|
|
||||||
boolean updateGroup(List<CommonInfo> infos);
|
boolean updateGroup(List<CommonInfo> infos);
|
||||||
|
|
||||||
|
Map<Integer, CommonInfo> getMapByCondition(String condition);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否可以修改订单
|
* 是否可以修改订单
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
boolean isCheckChangeOrder();
|
CommonInfo isCheckChangeOrder(Date businessTime, Date nowTime);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否可以编辑订单
|
* 是否可以编辑订单
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
boolean isCheckEditOrder();
|
boolean isCheckEditOrder(Date businessTime, Date nowTime);
|
||||||
|
|
||||||
List<CommonInfo> getV3OrderForm();
|
List<CommonInfo> getV3OrderForm();
|
||||||
|
|
||||||
Map<Integer, CommonInfo> getMaoByCondition(String condition);
|
|
||||||
}
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
package com.sqx.modules.common.service.impl;
|
package com.sqx.modules.common.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUnit;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
@ -12,6 +14,7 @@ import com.sqx.modules.common.entity.ArtificerPartitioningDetails;
|
||||||
import com.sqx.modules.common.entity.CommonInfo;
|
import com.sqx.modules.common.entity.CommonInfo;
|
||||||
import com.sqx.modules.common.enums.CommonEnum;
|
import com.sqx.modules.common.enums.CommonEnum;
|
||||||
import com.sqx.modules.common.service.CommonInfoService;
|
import com.sqx.modules.common.service.CommonInfoService;
|
||||||
|
import com.sqx.modules.common.utils.CommonConfigUtil;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -130,7 +133,7 @@ public class CommonInfoServiceImpl extends ServiceImpl<CommonInfoDao, CommonInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Integer, CommonInfo> getMaoByCondition(String condition) {
|
public Map<Integer, CommonInfo> getMapByCondition(String condition) {
|
||||||
List<CommonInfo> commonInfoList = commonInfoDao.findByCondition(condition);
|
List<CommonInfo> commonInfoList = commonInfoDao.findByCondition(condition);
|
||||||
Map<Integer, CommonInfo> commonInfoMap = Maps.newHashMap();
|
Map<Integer, CommonInfo> commonInfoMap = Maps.newHashMap();
|
||||||
commonInfoList.forEach(x -> commonInfoMap.put(x.getType(), x));
|
commonInfoList.forEach(x -> commonInfoMap.put(x.getType(), x));
|
||||||
|
@ -138,13 +141,86 @@ public class CommonInfoServiceImpl extends ServiceImpl<CommonInfoDao, CommonInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCheckChangeOrder() {
|
public CommonInfo isCheckChangeOrder(Date businessTime, Date nowTime) {
|
||||||
return false;
|
long bnDiffDay = DateUtil.between(businessTime, nowTime, DateUnit.DAY, false);
|
||||||
|
Map<Integer, CommonInfo> configMap = getMapByCondition(CommonEnum.GroupConditionEnum.V3_ORDER_FORM.getValue());
|
||||||
|
|
||||||
|
CommonInfo defCommonInfo = new CommonInfo();
|
||||||
|
|
||||||
|
if(bnDiffDay >= 0) {
|
||||||
|
//正数 开始前
|
||||||
|
//距离服务开始n个小时以上免费取消 - 4
|
||||||
|
CommonInfo v3OrderFormCancelNotStart01 = configMap.getOrDefault(CommonEnum.V3_ORDER_FORM_CANCEL_NOT_START_01.getKey(), defCommonInfo);
|
||||||
|
Double v3OrderFormCancelNotStart01D = CommonConfigUtil.getDoubleValue(v3OrderFormCancelNotStart01.getValue());
|
||||||
|
if(v3OrderFormCancelNotStart01D == null) v3OrderFormCancelNotStart01D = -1D;
|
||||||
|
//距离服务开始前取消n-n个小时内,收取n元 - 1.5,4,10
|
||||||
|
CommonInfo v3OrderFormCancelNotStart02 = configMap.getOrDefault(CommonEnum.V3_ORDER_FORM_CANCEL_NOT_START_02.getKey(), defCommonInfo);
|
||||||
|
String[] v3OrderFormCancelNotStart02A = CommonConfigUtil.getArrayValue(v3OrderFormCancelNotStart01.getValue());
|
||||||
|
if(v3OrderFormCancelNotStart02A == null) v3OrderFormCancelNotStart02A = new String[]{ "-1","4","10" };
|
||||||
|
double v3OrderFormCancelNotStart02D = Double.parseDouble(v3OrderFormCancelNotStart02A[0]);
|
||||||
|
//距离服务开始前取消少于n个小时内,收取n元 -1.5,30
|
||||||
|
CommonInfo v3OrderFormCancelNotStart03 = configMap.getOrDefault(CommonEnum.V3_ORDER_FORM_CANCEL_NOT_START_03.getKey(), defCommonInfo);
|
||||||
|
String[] v3OrderFormCancelNotStart03A = CommonConfigUtil.getArrayValue(v3OrderFormCancelNotStart01.getValue());
|
||||||
|
if(v3OrderFormCancelNotStart03A == null) v3OrderFormCancelNotStart03A = new String[]{ "-1","30" };
|
||||||
|
double v3OrderFormCancelNotStart03D = Double.parseDouble(v3OrderFormCancelNotStart03A[0]);
|
||||||
|
|
||||||
|
if(bnDiffDay > v3OrderFormCancelNotStart01D && v3OrderFormCancelNotStart01D != -1){
|
||||||
|
//外面的
|
||||||
|
return v3OrderFormCancelNotStart01;
|
||||||
|
} else if(bnDiffDay <= v3OrderFormCancelNotStart01D && bnDiffDay >= v3OrderFormCancelNotStart02D && v3OrderFormCancelNotStart02D != -1){
|
||||||
|
return v3OrderFormCancelNotStart02;
|
||||||
|
} else if(bnDiffDay < v3OrderFormCancelNotStart02D && bnDiffDay >= v3OrderFormCancelNotStart03D && v3OrderFormCancelNotStart03D != -1){
|
||||||
|
return v3OrderFormCancelNotStart03;
|
||||||
|
} else if(v3OrderFormCancelNotStart03D > bnDiffDay){
|
||||||
|
return v3OrderFormCancelNotStart03;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//负数,开始后
|
||||||
|
long bnDiffMinute = DateUtil.between(businessTime, nowTime, DateUnit.MINUTE, false);
|
||||||
|
//服务开始n分钟内取消订单,扣项目费用n%,车费全扣n%; - 15,50,100
|
||||||
|
CommonInfo v3OrderFormCancelStart01 = configMap.getOrDefault(CommonEnum.V3_ORDER_FORM_CANCEL_START_01.getKey(), defCommonInfo);
|
||||||
|
String[] v3OrderFormCancelStart01A = CommonConfigUtil.getArrayValue(v3OrderFormCancelStart01.getValue());
|
||||||
|
if(v3OrderFormCancelStart01A == null) v3OrderFormCancelStart01A = new String[]{ "-1","0","0" };
|
||||||
|
double v3OrderFormCancelStart01I = Double.parseDouble(v3OrderFormCancelStart01A[0]);
|
||||||
|
//服务开始n分钟后不可以取消订单 - 15
|
||||||
|
CommonInfo v3OrderFormCancelStart02 = configMap.getOrDefault(CommonEnum.V3_ORDER_FORM_CANCEL_START_02.getKey(), defCommonInfo);
|
||||||
|
Double v3OrderFormCancelStart02I = CommonConfigUtil.getDoubleValue(v3OrderFormCancelStart02.getValue());
|
||||||
|
if(v3OrderFormCancelStart02I == null) v3OrderFormCancelStart02I = -1D;
|
||||||
|
|
||||||
|
if(bnDiffMinute <= v3OrderFormCancelStart01I) {
|
||||||
|
return v3OrderFormCancelStart01;
|
||||||
|
} else if(bnDiffMinute >= v3OrderFormCancelStart02I){
|
||||||
|
return v3OrderFormCancelStart02;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defCommonInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCheckEditOrder() {
|
public boolean isCheckEditOrder(Date businessTime, Date nowTime) {
|
||||||
return false;
|
long bnDiffDay = DateUtil.between(businessTime, nowTime, DateUnit.DAY, false);
|
||||||
|
Map<Integer, CommonInfo> configMap = getMapByCondition(CommonEnum.GroupConditionEnum.V3_ORDER_FORM.getValue());
|
||||||
|
|
||||||
|
//距离服务开始前n个小时可修改 - 2
|
||||||
|
CommonInfo v3OrderFormEditNotStart01 = configMap.get(CommonEnum.V3_ORDER_FORM_EDIT_NOT_START_01.getKey());
|
||||||
|
//距离服务开始n个小时内不可修改 - 2
|
||||||
|
CommonInfo v3OrderFormEditNotStart02 = configMap.get(CommonEnum.V3_ORDER_FORM_EDIT_NOT_START_02.getKey());
|
||||||
|
|
||||||
|
Double v3OrderFormEditNotStart01I = CommonConfigUtil.getDoubleValue(v3OrderFormEditNotStart01.getValue());
|
||||||
|
if(v3OrderFormEditNotStart01I == null) v3OrderFormEditNotStart01I = -1D;
|
||||||
|
Double v3OrderFormEditNotStart02I = CommonConfigUtil.getDoubleValue(v3OrderFormEditNotStart02.getValue());
|
||||||
|
if(v3OrderFormEditNotStart02I == null) v3OrderFormEditNotStart02I = -1D;
|
||||||
|
|
||||||
|
if(bnDiffDay >= 0) {
|
||||||
|
//正数,服务开始前
|
||||||
|
if(v3OrderFormEditNotStart01I == -1) return true;
|
||||||
|
return bnDiffDay >= v3OrderFormEditNotStart01I;
|
||||||
|
} else {
|
||||||
|
//负数,服务开始后
|
||||||
|
if(v3OrderFormEditNotStart02I == -1) return true;
|
||||||
|
double burdenV3OrderFormEditNotStart02I = - v3OrderFormEditNotStart02I;
|
||||||
|
return burdenV3OrderFormEditNotStart02I >= bnDiffDay;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class CommonConfigUtil {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转为Long类型
|
* 转为Integer类型
|
||||||
* @param value 转换的值
|
* @param value 转换的值
|
||||||
* @return 转换后的值
|
* @return 转换后的值
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -27,9 +27,10 @@ public class GoodsController {
|
||||||
public Result findAll(Integer page, Integer size,
|
public Result findAll(Integer page, Integer size,
|
||||||
@ApiParam("商品标题:可搜索")@RequestParam(required = false) String title,
|
@ApiParam("商品标题:可搜索")@RequestParam(required = false) String title,
|
||||||
@ApiParam("商品类型:类型名称")@RequestParam(required = false) String type,
|
@ApiParam("商品类型:类型名称")@RequestParam(required = false) String type,
|
||||||
|
@ApiParam("商品类型:一级类型类型id")@RequestParam(required = false) String pTypeId,
|
||||||
@ApiParam("商品状态:0全部 1上架 2下架")@RequestParam(required = false) Integer status,
|
@ApiParam("商品状态:0全部 1上架 2下架")@RequestParam(required = false) Integer status,
|
||||||
@ApiParam("是否积分商品:1积分商城商品")@RequestParam(required = false) Integer isJiFenGoods) {
|
@ApiParam("是否积分商品:1积分商城商品")@RequestParam(required = false) Integer isJiFenGoods) {
|
||||||
return service.findAll(page, size, title, type, status, isJiFenGoods);
|
return service.findAll(page, size, title, type, pTypeId, status, isJiFenGoods);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/selectListByType")
|
@GetMapping("/selectListByType")
|
||||||
|
|
|
@ -8,6 +8,8 @@ public interface GoodsService {
|
||||||
//后台管理商品列表
|
//后台管理商品列表
|
||||||
Result findAll(Integer page, Integer size, String title, String type, Integer status, Integer isJiFenGoods);
|
Result findAll(Integer page, Integer size, String title, String type, Integer status, Integer isJiFenGoods);
|
||||||
|
|
||||||
|
Result findAll(Integer page, Integer size, String title, String type, String pTypeId, Integer status, Integer isJiFenGoods);
|
||||||
|
|
||||||
//虚拟商品列表
|
//虚拟商品列表
|
||||||
Result goodsVirtualList(Integer page, Integer size, String title, String type, Integer status, Integer isExpress, Integer isJiFenGoods);
|
Result goodsVirtualList(Integer page, Integer size, String title, String type, Integer status, Integer isExpress, Integer isJiFenGoods);
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,6 @@ public class SelfGoodsServiceImpl implements GoodsService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SelfGoodsBrandJpaRepository selfGoodsBrandJpaRepository;
|
private SelfGoodsBrandJpaRepository selfGoodsBrandJpaRepository;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 后台管理商品列表、创建时间排序
|
* 后台管理商品列表、创建时间排序
|
||||||
* @param page 页数
|
* @param page 页数
|
||||||
|
@ -58,32 +57,68 @@ public class SelfGoodsServiceImpl implements GoodsService {
|
||||||
* @param status 状态
|
* @param status 状态
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public Result findAll(Integer page, Integer size, String title, String type, Integer status, Integer isJiFenGoods) {
|
public Result findAll(Integer page, Integer size, String title, String type, Integer status, Integer isJiFenGoods) {
|
||||||
//按照时间排序
|
return findAll(page, size, title, type, null, status, isJiFenGoods);
|
||||||
Pageable pageable = PageRequest.of(page, size, Sort.by(new Sort.Order(Sort.Direction.DESC, "createAt")));
|
}
|
||||||
//构造自定义查询条件
|
|
||||||
Specification<SelfGoods> queryCondition = new Specification<SelfGoods>() {
|
/**
|
||||||
@Override
|
* 后台管理商品列表、创建时间排序
|
||||||
public Predicate toPredicate(Root<SelfGoods> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
|
* @param page 页数
|
||||||
|
* @param size 条数
|
||||||
|
* @param title 标题:模糊查询
|
||||||
|
* @param type 类型
|
||||||
|
* @param pTypeId 一级类型
|
||||||
|
* @param status 状态
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result findAll(Integer page, Integer size, String title, String type, String pTypeId, Integer status, Integer isJiFenGoods) {
|
||||||
|
//先查询类型
|
||||||
|
List<GoodsType> goodsTypeList;
|
||||||
|
if(StringUtils.isNotBlank(pTypeId)){
|
||||||
|
Specification<GoodsType> goodsTypeQc = (root, criteriaQuery, criteriaBuilder) -> {
|
||||||
List<Predicate> predicateList = new ArrayList<>();
|
List<Predicate> predicateList = new ArrayList<>();
|
||||||
if (StringUtils.isNotEmpty(title)) {
|
predicateList.add(criteriaBuilder.or(criteriaBuilder.equal(root.get("parentId"), pTypeId),criteriaBuilder.equal(root.get("id"), pTypeId)));
|
||||||
predicateList.add(criteriaBuilder.like(root.get("title"), "%"+title+"%"));
|
return criteriaBuilder.and(predicateList.toArray(new Predicate[0]));
|
||||||
|
};
|
||||||
|
goodsTypeList = goodsJpaTypeRepository.findAll(goodsTypeQc);
|
||||||
|
} else {
|
||||||
|
goodsTypeList = null;
|
||||||
|
}
|
||||||
|
//按照时间排序
|
||||||
|
Pageable pageable;
|
||||||
|
if(size == -1){
|
||||||
|
pageable = PageRequest.of(page, Integer.MAX_VALUE, Sort.by(new Sort.Order(Sort.Direction.DESC, "createAt")));
|
||||||
|
} else {
|
||||||
|
pageable = PageRequest.of(page, size, Sort.by(new Sort.Order(Sort.Direction.DESC, "createAt")));
|
||||||
|
}
|
||||||
|
//构造自定义查询条件
|
||||||
|
Specification<SelfGoods> queryCondition = (root, criteriaQuery, criteriaBuilder) -> {
|
||||||
|
List<Predicate> predicateList = new ArrayList<>();
|
||||||
|
if (StringUtils.isNotEmpty(title)) {
|
||||||
|
predicateList.add(criteriaBuilder.like(root.get("title"), "%"+title+"%"));
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotEmpty(type)) {
|
||||||
|
predicateList.add(criteriaBuilder.equal(root.get("typeId"), type));
|
||||||
|
}
|
||||||
|
if(StringUtils.isNotBlank(pTypeId)) {
|
||||||
|
//goodsTypeList
|
||||||
|
CriteriaBuilder.In<Object> in = criteriaBuilder.in(root.get("typeId"));
|
||||||
|
if(goodsTypeList != null && !goodsTypeList.isEmpty()) {
|
||||||
|
goodsTypeList.forEach(x -> in.value(x.getId()));
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(type)) {
|
predicateList.add(in);
|
||||||
predicateList.add(criteriaBuilder.equal(root.get("typeId"), type));
|
|
||||||
}
|
|
||||||
if (status != 0) {
|
|
||||||
predicateList.add(criteriaBuilder.equal(root.get("status"), status));
|
|
||||||
}
|
|
||||||
if (isJiFenGoods != null) {
|
|
||||||
predicateList.add(criteriaBuilder.equal(root.get("isJiFenGoods"), isJiFenGoods));
|
|
||||||
}else {
|
|
||||||
predicateList.add(criteriaBuilder.isNull(root.get("isJiFenGoods")));
|
|
||||||
}
|
|
||||||
return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()]));
|
|
||||||
}
|
}
|
||||||
};
|
if (status != 0) {
|
||||||
|
predicateList.add(criteriaBuilder.equal(root.get("status"), status));
|
||||||
|
}
|
||||||
|
if (isJiFenGoods != null) {
|
||||||
|
predicateList.add(criteriaBuilder.equal(root.get("isJiFenGoods"), isJiFenGoods));
|
||||||
|
}else {
|
||||||
|
predicateList.add(criteriaBuilder.isNull(root.get("isJiFenGoods")));
|
||||||
|
}
|
||||||
|
return criteriaBuilder.and(predicateList.toArray(new Predicate[0]));
|
||||||
|
};
|
||||||
//处理数据:商品分类
|
//处理数据:商品分类
|
||||||
Page<SelfGoods> all = jpaRepository.findAll(queryCondition, pageable);
|
Page<SelfGoods> all = jpaRepository.findAll(queryCondition, pageable);
|
||||||
List<SelfGoods> list = all.getContent();
|
List<SelfGoods> list = all.getContent();
|
||||||
|
@ -102,38 +137,32 @@ public class SelfGoodsServiceImpl implements GoodsService {
|
||||||
@Override
|
@Override
|
||||||
public Result selectListByType(String title, String type, Integer status, Integer isJiFenGoods) {
|
public Result selectListByType(String title, String type, Integer status, Integer isJiFenGoods) {
|
||||||
//构造自定义查询条件
|
//构造自定义查询条件
|
||||||
Specification<GoodsType> queryCondition1 = new Specification<GoodsType>() {
|
Specification<GoodsType> queryCondition1 = (root, criteriaQuery, criteriaBuilder) -> {
|
||||||
@Override
|
List<Predicate> predicateList = new ArrayList<>();
|
||||||
public Predicate toPredicate(Root<GoodsType> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
|
predicateList.add(criteriaBuilder.or(criteriaBuilder.equal(root.get("parentId"), "56"),criteriaBuilder.equal(root.get("id"), "56")));
|
||||||
List<Predicate> predicateList = new ArrayList<>();
|
return criteriaBuilder.and(predicateList.toArray(new Predicate[0]));
|
||||||
predicateList.add(criteriaBuilder.or(criteriaBuilder.equal(root.get("parentId"), "56"),criteriaBuilder.equal(root.get("id"), "56")));
|
};
|
||||||
return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()]));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
List<GoodsType> materialTypes = goodsJpaTypeRepository.findAll(queryCondition1);
|
List<GoodsType> materialTypes = goodsJpaTypeRepository.findAll(queryCondition1);
|
||||||
Specification<SelfGoods> queryCondition = new Specification<SelfGoods>() {
|
Specification<SelfGoods> queryCondition = (root, criteriaQuery, criteriaBuilder) -> {
|
||||||
@Override
|
List<Predicate> predicateList = new ArrayList<>();
|
||||||
public Predicate toPredicate(Root<SelfGoods> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
|
if (StringUtils.isNotEmpty(title)) {
|
||||||
List<Predicate> predicateList = new ArrayList<>();
|
predicateList.add(criteriaBuilder.like(root.get("title"), "%"+title+"%"));
|
||||||
if (StringUtils.isNotEmpty(title)) {
|
}
|
||||||
predicateList.add(criteriaBuilder.like(root.get("title"), "%"+title+"%"));
|
CriteriaBuilder.In<Object> in = criteriaBuilder.in(root.get("typeId"));
|
||||||
}
|
for(GoodsType goodsType:materialTypes) {
|
||||||
CriteriaBuilder.In<Object> in = criteriaBuilder.in(root.get("typeId"));
|
in.value(goodsType.getId());
|
||||||
for(GoodsType goodsType:materialTypes) {
|
}
|
||||||
in.value(goodsType.getId());
|
predicateList.add(in);
|
||||||
}
|
if (ObjectUtil.isNotEmpty(status)) {
|
||||||
predicateList.add(in);
|
predicateList.add(criteriaBuilder.equal(root.get("status"), status));
|
||||||
if (ObjectUtil.isNotEmpty(status)) {
|
}
|
||||||
predicateList.add(criteriaBuilder.equal(root.get("status"), status));
|
if (ObjectUtil.isNotEmpty(isJiFenGoods)) {
|
||||||
}
|
predicateList.add(criteriaBuilder.equal(root.get("isJiFenGoods"), isJiFenGoods));
|
||||||
if (ObjectUtil.isNotEmpty(isJiFenGoods)) {
|
}else {
|
||||||
predicateList.add(criteriaBuilder.equal(root.get("isJiFenGoods"), isJiFenGoods));
|
predicateList.add(criteriaBuilder.isNull(root.get("isJiFenGoods")));
|
||||||
}else {
|
}
|
||||||
predicateList.add(criteriaBuilder.isNull(root.get("isJiFenGoods")));
|
return criteriaBuilder.and(predicateList.toArray(new Predicate[0]));
|
||||||
}
|
};
|
||||||
return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()]));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
//处理数据:商品分类
|
//处理数据:商品分类
|
||||||
List<SelfGoods> all = jpaRepository.findAll(queryCondition);
|
List<SelfGoods> all = jpaRepository.findAll(queryCondition);
|
||||||
for (SelfGoods g : all) {
|
for (SelfGoods g : all) {
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class TravelConfServiceImpl extends ServiceImpl<TravelConfDao, TravelConf
|
||||||
Integer timeIntervalType = null;
|
Integer timeIntervalType = null;
|
||||||
|
|
||||||
//从配置文件中取出时间配置(包含很多个)
|
//从配置文件中取出时间配置(包含很多个)
|
||||||
Map<Integer,CommonInfo> commonInfoMap = commonInfoService.getMaoByCondition(CommonEnum.GroupConditionEnum.V3_TRAVEL_CONF.getValue());
|
Map<Integer,CommonInfo> commonInfoMap = commonInfoService.getMapByCondition(CommonEnum.GroupConditionEnum.V3_TRAVEL_CONF.getValue());
|
||||||
|
|
||||||
//夏令时段
|
//夏令时段
|
||||||
CommonInfo daylightSavingTime = commonInfoMap.get(CommonEnum.V3_TRAVEL_CONF_DAYLIGHT_SAVING_TIME.getKey());
|
CommonInfo daylightSavingTime = commonInfoMap.get(CommonEnum.V3_TRAVEL_CONF_DAYLIGHT_SAVING_TIME.getKey());
|
||||||
|
|
Loading…
Reference in New Issue