食品采购接口优化

This commit is contained in:
2026-07-18 12:00:59 +08:00
parent a8e1379fd1
commit b3494db4ec
43 changed files with 530 additions and 86 deletions

View File

@@ -51,6 +51,27 @@ public class RepoRecordController extends BaseController {
});
return getDataTable(list);
}
@GetMapping("/listByProductId")
public AjaxResult listByProductId(Long productId)
{
List<RepoRecordVO> list = repoRecordService.selectRepoRecordListByProductId(productId);
list.forEach(f -> {
if(f.getStatus() != null){
if(ObjectUtil.equal(f.getStatus(),1)){
f.setStatusName("入库");
} else{
f.setStatusName("出库");
}
}
if(f.getProductId() != null){
FoodProduct products = foodProductsService.getById(f.getProductId());
f.setFoodProducts(Arrays.asList(products));
}
});
return AjaxResult.success(list);
}
@GetMapping(value = "/{repoRecordId}")
public AjaxResult getInfo(@PathVariable("repoRecordId") Long repoRecordId)
{
@@ -64,9 +85,14 @@ public class RepoRecordController extends BaseController {
}
if(repoRecordVO.getProductId() != null){
FoodProduct products = foodProductsService.getById(repoRecordVO.getProductId());
repoRecordVO.setFoodProducts(Arrays.asList(products));
if(ObjectUtil.isNotNull( products)){
repoRecordVO.setFoodProductNum(products.getNum());
repoRecordVO.setFoodProductName(products.getName());
repoRecordVO.setUnitName(products.getUnitLabel());
repoRecordVO.setPrice(products.getPrice());
}
}
return success(repoRecordService.selectRepoRecordByRepoRecordId(repoRecordId));
return success(repoRecordVO);
}
/**

View File

@@ -11,6 +11,7 @@ import com.zf.foodpurchase.common.core.page.TableDataInfo;
import com.zf.foodpurchase.common.utils.DateUtils;
import com.zf.foodpurchase.fdsafe.entity.Repository;
import com.zf.foodpurchase.fdsafe.service.IRepositoryService;
import com.zf.foodpurchase.fdsafe.vo.RepositoryVO;
import com.zf.foodpurchase.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
@@ -51,7 +52,7 @@ public class RepositoryController extends BaseController {
repository.setMerchantId(null);
}
}
List<Repository> list = repositoryService.queryRepoList(repository);
List<RepositoryVO> list = repositoryService.queryRepoList(repository);
return AjaxResult.success("查询成功", list);
}
@@ -70,16 +71,17 @@ public class RepositoryController extends BaseController {
repository.setMerchantId(null);
}
}
List<Repository> list = repositoryService.queryRepoList(repository);
List<RepositoryVO> list = repositoryService.queryRepoList(repository);
return getDataTable(list);
}
@PostMapping("/addRepo")
public AjaxResult addRepo(@Validated @RequestBody Repository repository) {
SysUser sysUser = userService.getUser();
if (sysUser.isAdmin()) {
if(repository.getMerchantId() == null){
return error("必须指定要添加的仓库所属商户");
if(ObjectUtil.isNotNull(sysUser)){
if(!sysUser.isAdmin()){
Long deptId = sysUser.getDeptId();
repository.setMerchantId(deptId);
}
}
repository.setCreateTime(DateUtils.getNowDate());

View File

@@ -153,7 +153,7 @@ public class SchoolOrderController extends BaseController {
* 供货商接单
*/
@GetMapping("/supplierAcceptOrder")
public AjaxResult supplierAcceptOrder(@Validated SupplierAcceptOrderVO supplierAcceptOrderVO) {
public AjaxResult supplierAcceptOrder(String orderNo) {
// 填充学校id,教育局id等数据
SysUser user = userService.getUser();
if(!user.isAdmin()){
@@ -162,7 +162,7 @@ public class SchoolOrderController extends BaseController {
return error("非供货商账号无法接单");
}
}
return schoolOrderService.supplierAcceptOrder(supplierAcceptOrderVO);
return schoolOrderService.supplierAcceptOrder(orderNo);
}
/**

View File

@@ -42,10 +42,10 @@ public class FoodProductController extends BaseController {
@GetMapping("/pageList")
public TableDataInfo pageList(FoodProductVO foodProductVO) {
startPage();
SysUser user = userService.getUser();
startPage();
if(!user.isAdmin()){
foodProductVO.setSchoolId(user.getSchoolId());
foodProductVO.setDeptIds(user.getDeptIdList());
}
foodProductVO.setDelFlag(0);
List<FoodProductVO> list = foodProductService.queryFoodProductVO(foodProductVO);
@@ -68,6 +68,11 @@ public class FoodProductController extends BaseController {
return foodProductService.supplierUpdate(foodProductVO);
}
@PostMapping("/deleteLogic")
public AjaxResult deleteLogic(Long foodProductId) {
return foodProductService.supplierDelete(foodProductId);
}
/**
* 教育局审核商品
*/

View File

@@ -39,6 +39,13 @@ public class SysDeptController extends BaseController
return success(depts);
}
@GetMapping("/listSuppliers")
public AjaxResult listSuppliers()
{
List<SysDept> depts = deptService.selectSuppliers();
return success(depts);
}
/**
* 查询部门列表(排除节点)
*/

View File

@@ -63,6 +63,20 @@ public class SysUserController extends BaseController
return getDataTable(list);
}
@ApiOperation("查询仓库管理员列表")
@GetMapping("/listRepoUsers")
public AjaxResult listRepoUsers()
{
SysUser sysUser = userService.getUser();
SysUser user = new SysUser();
if(!sysUser.isAdmin()){
List<Long> deptIds = sysUser.getDeptIdList();
user.setDeptIdList(deptIds);
}
List<SysUser> list = userService.listRepoUsers(user);
return AjaxResult.success(list);
}
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:user:export')")
@PostMapping("/export")

View File

@@ -271,4 +271,14 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
System.out.println(getStartOfDay(now).getTime());
}
public static String getShortYearMonth(Date date) {
String dateTime = DateFormatUtils.format(date, "yyMM");
return dateTime;
}
public static String getShortYearMonthDay(Date date) {
String dateTime = DateFormatUtils.format(date, "yyMMdd");
return dateTime;
}
}

View File

@@ -694,4 +694,12 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
.collect(Collectors.toList()); // 收集为List<Long>
}
public static String formatNumTwo(int num) {
return String.format("%02d", num);
}
public static String formatNumThree(int num) {
return String.format("%03d", num);
}
}

View File

@@ -111,4 +111,8 @@ public class FoodProduct implements Serializable {
* 有效标志
*/
private Integer delFlag;
private Long deptId;
private String imageUrl;
}

View File

@@ -68,7 +68,9 @@ public class RepoRecord extends BaseEntity {
private String orderNo;
private Long schoolId;
private Long deptId;
private List<Long> deptIds;
private Long operId;
}

View File

@@ -90,7 +90,6 @@ public class Repository implements Serializable {
private Long manager;
@TableField
@NotNull(message = "仓库编号不能为空")
private String repoNum;
@TableField

View File

@@ -0,0 +1,14 @@
package com.zf.foodpurchase.fdsafe.entity;
import lombok.Data;
@Data
public class XhCreate {
private Integer id;
private Integer deptNum;
private Long deptId;
private String timeStr;
private Integer xh;
}

View File

@@ -19,5 +19,5 @@ public interface FoodProductMapper extends BaseMapper<FoodProduct> {
List<FoodProductVO> queryFoodProductVO(FoodProductVO foodProductVO);
List<FoodProductCKVO> pageCKList(Integer repoId);
void updateDelFlag(Long foodProductId);
}

View File

@@ -14,5 +14,7 @@ public interface RepoRecordMapper extends BaseMapper<RepoRecord> {
public RepoRecordVO selectRepoRecordByRepoRecordId(@Param("repoRecordId") Long repoRecordId);
public List<RepoRecordVO> selectRepoRecordList(@Param("productName") String productName, @Param("categoryId") Integer categoryId, @Param("repoId") Integer repoId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
public List<RepoRecordVO> selectRepoRecordList(@Param("productName") String productName, @Param("status") Integer status, @Param("repoId") Integer repoId, @Param("startTime") Date startTime, @Param("endTime") Date endTime,@Param("deptIds") List<Long> deptIds);
public List<RepoRecordVO> selectRepoRecordListByProductId(Long productId);
}

View File

@@ -2,6 +2,7 @@ package com.zf.foodpurchase.fdsafe.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zf.foodpurchase.fdsafe.entity.Repository;
import com.zf.foodpurchase.fdsafe.vo.RepositoryVO;
import java.util.List;
@@ -15,5 +16,5 @@ import java.util.List;
*/
public interface RepositoryMapper extends BaseMapper<Repository> {
List<Repository> queryRepoList(Repository queryRepository);
List<RepositoryVO> queryRepoList(Repository queryRepository);
}

View File

@@ -0,0 +1,26 @@
package com.zf.foodpurchase.fdsafe.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zf.foodpurchase.fdsafe.entity.XhCreate;
import com.zf.foodpurchase.fdsafe.vo.XhCreateVO;
import java.util.List;
/**
* <p>
* 食材表 Mapper 接口
* </p>
*
* @author lilj
* @since 2025-04-17
*/
public interface XhMapper {
XhCreate queryXhCreate(XhCreateVO xhCreateVO);
int insertXhCreate(XhCreate xhCreate);
int updateXhCreate(XhCreate xhCreate);
int selectMaxDeptNum();
}

View File

@@ -24,6 +24,8 @@ public interface IFoodProductService extends IService<FoodProduct> {
AjaxResult supplierUpdate(FoodProductVO foodProductVO);
AjaxResult supplierDelete(Long foodProductId);
AjaxResult eduCheck(FoodProductVO foodProductVO);
List<FoodProductCKVO> pageCKList(Integer repoId);

View File

@@ -19,4 +19,6 @@ public interface IRepoRecordService extends IService<RepoRecord> {
RepoRecordVO selectRepoRecordByRepoRecordId(Long repoRecordId);
List<RepoRecordVO> selectRepoRecordList(RepoRecord repoRecord);
List<RepoRecordVO> selectRepoRecordListByProductId(Long productId);
}

View File

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.zf.foodpurchase.common.core.domain.AjaxResult;
import com.zf.foodpurchase.fdsafe.entity.Repository;
import com.zf.foodpurchase.fdsafe.vo.ProductCountVO;
import com.zf.foodpurchase.fdsafe.vo.RepositoryVO;
import java.util.List;
@@ -17,7 +18,7 @@ import java.util.List;
*/
public interface IRepositoryService extends IService<Repository> {
List<Repository> queryRepoList(Repository quryRepository);
List<RepositoryVO> queryRepoList(Repository quryRepository);
AjaxResult saveRepo(Repository repository);

View File

@@ -28,7 +28,7 @@ public interface ISchoolOrderService extends IService<SchoolOrder> {
AjaxResult updateOrderRemark(@Valid SchoolModifyOrderRemarkVO remarkVO);
AjaxResult supplierAcceptOrder(SupplierAcceptOrderVO supplierAcceptOrderVO);
AjaxResult supplierAcceptOrder(String orderNo);
boolean updateOrderStatus(SchoolOrder schoolOrder);

View File

@@ -32,11 +32,10 @@ import java.util.List;
*/
@Service
public class FoodProductServiceImpl extends ServiceImpl<FoodProductMapper, FoodProduct> implements IFoodProductService {
@Autowired
private FoodMapper foodMapper;
@Autowired
private ISysUserService sysUserService;
@Autowired
private FoodProductMapper foodProductMapper;
@Override
public List<FoodProductVO> queryFoodProductVO(FoodProductVO foodProductVO) {
@@ -90,6 +89,12 @@ public class FoodProductServiceImpl extends ServiceImpl<FoodProductMapper, FoodP
return update ? AjaxResult.success("商品修改成功") : AjaxResult.error("商品修改失败");
}
@Override
public AjaxResult supplierDelete(Long foodProductId) {
foodProductMapper.updateDelFlag(foodProductId);
return AjaxResult.success();
}
@Override
public AjaxResult eduCheck(FoodProductVO foodProductVO) {
FoodProduct foodProduct = dealEduProductCheck(foodProductVO);
@@ -107,19 +112,19 @@ public class FoodProductServiceImpl extends ServiceImpl<FoodProductMapper, FoodP
if (foodProductVO == null) {
return null;
}
LambdaQueryWrapper<Food> queryWrapper = new LambdaQueryWrapper<>();
/*LambdaQueryWrapper<Food> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Food::getFoodId, foodProductVO.getFoodId());
Food food = foodMapper.selectOne(queryWrapper);
if(food == null){
throw new RuntimeException("商品关联食材不存在,无法添加");
}
}*/
SysUser user = sysUserService.getUser();
FoodProduct foodProduct = new FoodProduct();
BeanUtils.copyProperties(foodProductVO, foodProduct);
if(!user.isAdmin()){
foodProduct.setSupplierId(user.getSchoolId());
foodProduct.setDeptId(user.getDeptId());
}
foodProduct.setEduId(food.getEduId());
//foodProduct.setEduId(food.getEduId());
// 审核项置空.
foodProduct.setCheckStatus(FoodStatusConstants.PRODUCT_WAIT_CHECK);
foodProduct.setCheckRemark(null);

View File

@@ -63,11 +63,12 @@ public class RepoRecordServiceImpl extends ServiceImpl<RepoRecordMapper, RepoRec
repoRecord.setProductNum(productNum);
repoRecord.setCategoryId(categoryId);
repoRecord.setStatus(1);
repoRecord.setOperId(user.getUserId());
BigDecimal price = inRepoVO.getPrice() == null ? BigDecimal.ZERO : inRepoVO.getPrice();
BigDecimal totalCost = price.multiply(new BigDecimal(productNum));
repoRecord.setTotalCost(totalCost);
if(!user.isAdmin()){
repoRecord.setSchoolId(user.getSchoolId().longValue());
repoRecord.setDeptId(user.getDeptId());
}
repoRecordMapper.insertRepoRecord(repoRecord);
@@ -119,11 +120,12 @@ public class RepoRecordServiceImpl extends ServiceImpl<RepoRecordMapper, RepoRec
repoRecord.setProductNum(productNum);
repoRecord.setCategoryId(categoryId);
repoRecord.setStatus(1);
repoRecord.setOperId(user.getUserId());
BigDecimal price = foodProductCKVO.getPrice() == null ? BigDecimal.ZERO : foodProductCKVO.getPrice();
BigDecimal totalCost = price.multiply(new BigDecimal(productNum));
repoRecord.setTotalCost(totalCost);
if(!user.isAdmin()){
repoRecord.setSchoolId(user.getSchoolId().longValue());
repoRecord.setDeptId(user.getDeptId());
}
repoRecordMapper.insertRepoRecord(repoRecord);
FoodRepo oldFoodRepo = foodRepoMapper.selectByProductIdAndRepoId(productId.longValue(),repoId.longValue());
@@ -142,11 +144,17 @@ public class RepoRecordServiceImpl extends ServiceImpl<RepoRecordMapper, RepoRec
@Override
public List<RepoRecordVO> selectRepoRecordList(RepoRecord repoRecord) {
String productName = repoRecord.getProductName();
Integer categoryId = repoRecord.getCategoryId();
Integer status = repoRecord.getStatus();
Integer repoId = repoRecord.getRepoId();
Date startTime = repoRecord.getStartTime();
Date endTime = repoRecord.getEndTime();
return repoRecordMapper.selectRepoRecordList(productName, categoryId, repoId, startTime, endTime);
List<Long> deptIds = repoRecord.getDeptIds();
return repoRecordMapper.selectRepoRecordList(productName, status, repoId, startTime, endTime,deptIds);
}
@Override
public List<RepoRecordVO> selectRepoRecordListByProductId(Long productId) {
return repoRecordMapper.selectRepoRecordListByProductId(productId);
}
}

View File

@@ -1,17 +1,26 @@
package com.zf.foodpurchase.fdsafe.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zf.foodpurchase.common.constant.Constants;
import com.zf.foodpurchase.common.core.domain.AjaxResult;
import com.zf.foodpurchase.common.core.domain.entity.SysUser;
import com.zf.foodpurchase.common.utils.DateUtils;
import com.zf.foodpurchase.common.utils.StringUtils;
import com.zf.foodpurchase.fdsafe.entity.Repository;
import com.zf.foodpurchase.fdsafe.entity.XhCreate;
import com.zf.foodpurchase.fdsafe.mapper.RepositoryMapper;
import com.zf.foodpurchase.fdsafe.mapper.XhMapper;
import com.zf.foodpurchase.fdsafe.service.IRepositoryService;
import com.zf.foodpurchase.fdsafe.vo.RepositoryVO;
import com.zf.foodpurchase.fdsafe.vo.XhCreateVO;
import com.zf.foodpurchase.system.service.ISysUserService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
/**
@@ -27,14 +36,51 @@ import java.util.List;
public class RepositoryServiceImpl extends ServiceImpl<RepositoryMapper, Repository> implements IRepositoryService {
@Autowired
private RepositoryMapper repositoryMapper;
@Autowired
private XhMapper xhMapper;
@Autowired
private ISysUserService userService;
@Override
public List<Repository> queryRepoList(Repository quryRepository) {
public List<RepositoryVO> queryRepoList(Repository quryRepository) {
return repositoryMapper.queryRepoList(quryRepository);
}
@Override
public AjaxResult saveRepo(Repository repository) {
SysUser user = userService.getUser();
if(ObjectUtil.isNull(user.getDeptId())){
throw new RuntimeException("登录人员部门为空,不能生成订单编号");
}
Date date = DateUtils.getNowDate();
String repoNo = "";
String dateStr = DateUtils.getShortYearMonthDay( date);
Long deptId = user.getDeptId();
XhCreate xhCreate = new XhCreate();
xhCreate.setDeptId(deptId);
xhCreate.setTimeStr(dateStr);
XhCreateVO xhCreateVO = new XhCreateVO();
BeanUtils.copyProperties(xhCreate,xhCreateVO);
XhCreate xhCreateNew = xhMapper.queryXhCreate(xhCreateVO);
if(ObjectUtil.isNull(xhCreateNew)){
Integer deptNum = xhMapper.selectMaxDeptNum();
Integer num = 1;
if(ObjectUtil.isNotNull(deptNum)){
num = deptNum+1;
}
xhCreate.setDeptNum(num);
xhCreate.setXh(1);
xhMapper.insertXhCreate(xhCreate);
repoNo = StringUtils.formatNumThree(deptNum)+dateStr+"001";
}else{
Integer deptNum = xhCreateNew.getDeptNum();
Integer xhNum = xhCreateNew.getXh()+1;
String xhNumStr = StringUtils.formatNumThree(xhNum);
repoNo = StringUtils.formatNumThree(deptNum)+dateStr+xhNumStr;
xhCreateNew.setXh(xhNum);
xhMapper.updateXhCreate(xhCreateNew);
}
repository.setRepoNum(repoNo);
if (checkRepoNameUnique(repository)) {
return AjaxResult.error("仓库名称已存在请更换仓库名称");
}

View File

@@ -43,20 +43,20 @@ public class SchoolCartItemServiceImpl extends ServiceImpl<SchoolCartItemMapper,
// 设置购物项是否可提交
Integer checkStatus = cartItemVO.getCheckStatus();
// 检查食材是否存在
if(cartItemVO.getFoodDelFlag()==1){
/*if(cartItemVO.getFoodDelFlag()==1){
cartItemVO.setItemStatus(false);
cartItemVO.setStatusRemark("商品关联食材不存在,无法购买");
//cartItemVO.setStatusRemark("商品关联食材不存在,无法购买");
return;
}
}*/
if(checkStatus==1){
cartItemVO.setItemStatus(true);
}else {
cartItemVO.setItemStatus(false);
if(cartItemVO.getDelFlag() == 0 ){
/*if(cartItemVO.getDelFlag() == 0 ){
cartItemVO.setStatusRemark("该食材商品审核暂未通过,无法购买");
}else{
cartItemVO.setStatusRemark("该食材商品不存在,无法购买");
}
}*/
}
});
}
@@ -122,9 +122,9 @@ public class SchoolCartItemServiceImpl extends ServiceImpl<SchoolCartItemMapper,
if (foodProduct == null) {
throw new ServiceException("商品不存在,加入购物车失败");
}
if(foodProduct.getCheckStatus()!=1){
/*if(foodProduct.getCheckStatus()!=1){
throw new ServiceException("商品审核未通过,加入购物车失败");
}
}*/
// 审核通过设置信息
SchoolCartItem item = new SchoolCartItem();
BeanUtils.copyProperties(schoolCartItemVO, item);

View File

@@ -1,18 +1,25 @@
package com.zf.foodpurchase.fdsafe.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zf.foodpurchase.common.constant.FoodStatusConstants;
import com.zf.foodpurchase.common.constant.OrderStatusConstants;
import com.zf.foodpurchase.common.constant.RefundStatusConstants;
import com.zf.foodpurchase.common.constant.WxAPPAccountConstants;
import com.zf.foodpurchase.common.core.domain.AjaxResult;
import com.zf.foodpurchase.common.core.domain.entity.SysUser;
import com.zf.foodpurchase.common.exception.ServiceException;
import com.zf.foodpurchase.common.utils.DateUtils;
import com.zf.foodpurchase.common.utils.StringUtils;
import com.zf.foodpurchase.fdsafe.entity.*;
import com.zf.foodpurchase.fdsafe.mapper.SchoolOrderMapper;
import com.zf.foodpurchase.fdsafe.mapper.SchoolRefundMapper;
import com.zf.foodpurchase.fdsafe.mapper.XhMapper;
import com.zf.foodpurchase.fdsafe.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zf.foodpurchase.fdsafe.utils.NoUtils;
import com.zf.foodpurchase.fdsafe.vo.*;
import com.zf.foodpurchase.system.service.ISysUserService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -48,7 +55,11 @@ public class SchoolOrderServiceImpl extends ServiceImpl<SchoolOrderMapper, Schoo
private SchoolRefundMapper schoolRefundMapper;
@Autowired
private SchoolOrderMapper schoolOrderMapper;
@Autowired
private ISysUserService userService;
@Autowired
private XhMapper xhMapper;
@Override
public List<SchoolOrderVO> querySupplierOrderVO(SchoolOrderVO schoolOrderVO) {
@@ -82,6 +93,10 @@ public class SchoolOrderServiceImpl extends ServiceImpl<SchoolOrderMapper, Schoo
@Transactional
@Override
public AjaxResult submitOrder(SchoolSubmitOrderVO submitOrderVO) {
SysUser user = userService.getUser();
if(ObjectUtil.isNull(user.getDeptId())){
throw new RuntimeException("登录人员部门为空,不能生成订单编号");
}
List<Long> schoolCartItemIds = submitOrderVO.getSchoolCartItemIds();
if (CollectionUtils.isEmpty(schoolCartItemIds)) {
throw new RuntimeException("购物车项不能为空");
@@ -107,14 +122,14 @@ public class SchoolOrderServiceImpl extends ServiceImpl<SchoolOrderMapper, Schoo
totalMoney = totalMoney.add(foodProduct.getPrice().multiply(new BigDecimal(schoolCartItem.getProductNum())));
// 设置子单项目信息
// 食材信息
Food food = foodService.getById(foodProduct.getFoodId());
/*Food food = foodService.getById(foodProduct.getFoodId());
if (food == null) {
throw new RuntimeException("部分商品关联食材不存在,请刷新页面后,确认提交的商品状态正常后重新提交订单");
}
}*/
SchoolOrderItem schoolOrderItem = new SchoolOrderItem();
BeanUtils.copyProperties(schoolCartItem, schoolOrderItem);
BeanUtils.copyProperties(foodProduct, schoolOrderItem);
BeanUtils.copyProperties(food, schoolOrderItem);
//BeanUtils.copyProperties(food, schoolOrderItem);
schoolOrderItem.setOrderItemStatus(OrderStatusConstants.WAIT_ACCEPT);
// 将备注信息保存到子订单中.
schoolOrderItem.setOrderItemRemark(schoolCartItem.getItemRemark());
@@ -138,13 +153,42 @@ public class SchoolOrderServiceImpl extends ServiceImpl<SchoolOrderMapper, Schoo
}
List<SchoolOrder> schoolOrders = new ArrayList<>();
Date date = new Date();
// 根据供货商id合并订单项:
for (Map.Entry<Integer, List<SchoolOrderItem>> entry : schoolOrderItemMap.entrySet()) {
List<SchoolOrderItem> schoolOrderItemList = entry.getValue();
SchoolOrder schoolOrder = new SchoolOrder();
BeanUtils.copyProperties(submitOrderVO, schoolOrder);
schoolOrder.setOrderStatus(OrderStatusConstants.WAIT_ACCEPT);
String orderNo = NoUtils.generateNo();
//String orderNo = NoUtils.generateNo();
String orderNo = "";
String dateStr = DateUtils.getShortYearMonth( date);
Long deptId = user.getDeptId();
XhCreate xhCreate = new XhCreate();
xhCreate.setDeptId(deptId);
xhCreate.setTimeStr(dateStr);
XhCreateVO xhCreateVO = new XhCreateVO();
BeanUtils.copyProperties(xhCreate,xhCreateVO);
XhCreate xhCreateNew = xhMapper.queryXhCreate(xhCreateVO);
if(ObjectUtil.isNull(xhCreateNew)){
Integer deptNum = xhMapper.selectMaxDeptNum();
Integer num = 1;
if(ObjectUtil.isNotNull(deptNum)){
num = deptNum+1;
}
xhCreate.setDeptNum(num);
xhCreate.setXh(1);
xhMapper.insertXhCreate(xhCreate);
orderNo = StringUtils.formatNumThree(num)+dateStr+"001";
}else{
Integer deptNum = xhCreateNew.getDeptNum();
Integer xhNum = xhCreateNew.getXh()+1;
String xhNumStr = StringUtils.formatNumThree(xhNum);
orderNo = StringUtils.formatNumThree(deptNum)+dateStr+xhNumStr;
xhCreateNew.setXh(xhNum);
xhMapper.updateXhCreate(xhCreateNew);
}
schoolOrder.setOrderNo(orderNo);
// 计算订单总金额
BigDecimal orderTotalMoney = new BigDecimal(0);
@@ -239,22 +283,20 @@ public class SchoolOrderServiceImpl extends ServiceImpl<SchoolOrderMapper, Schoo
@Transactional
@Override
public AjaxResult supplierAcceptOrder(SupplierAcceptOrderVO supplierAcceptOrderVO) {
public AjaxResult supplierAcceptOrder(String orderNo) {
// 校验
SchoolOrder byId = this.getById(supplierAcceptOrderVO.getOrderNo());
SchoolOrder byId = this.getById(orderNo);
if (byId == null) {
return AjaxResult.error("订单不存在");
}
if (!OrderStatusConstants.WAIT_ACCEPT.equals(byId.getOrderStatus())) {
return AjaxResult.error("订单为非待接单状态,无法接单");
}
if (!byId.getSupplierId().equals(supplierAcceptOrderVO.getSupplierId())) {
return AjaxResult.error("当前供货商与订单所属供货商不一致,无法接单");
}
SchoolOrder update = new SchoolOrder();
update.setOrderStatus(OrderStatusConstants.ACCEPTED);
update.setOrderNo(supplierAcceptOrderVO.getOrderNo());
update.setOrderNo(orderNo);
boolean update1 = this.updateOrderStatus(update);
if (!update1) {
throw new ServiceException("订单接单失败");

View File

@@ -21,5 +21,5 @@ public class FoodProductCKVO {
private Long deptId;
private BigDecimal price;
private String msg;
private String supplierName;
}

View File

@@ -10,6 +10,7 @@ import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* @author:lilj
@@ -29,7 +30,7 @@ public class FoodProductVO extends CommonVO implements Serializable {
/**
* 食材id
*/
@NotNull(message = "食材id不能为空", groups = { AddGroup.class})
//@NotNull(message = "食材id不能为空", groups = { AddGroup.class})
private Integer foodId;
@@ -85,13 +86,13 @@ public class FoodProductVO extends CommonVO implements Serializable {
/**
* 审核意见
*/
@NotNull(message = "审核意见不能为空", groups = {CheckGroup.class})
//@NotNull(message = "审核意见不能为空", groups = {CheckGroup.class})
private String checkRemark;
/**
* 审核状态:0 待审核 1 审核通过 2 审核不通过
*/
@NotNull(message = "审核状态不能为空", groups = {CheckGroup.class})
//@NotNull(message = "审核状态不能为空", groups = {CheckGroup.class})
private Integer checkStatus;
/**
@@ -118,4 +119,10 @@ public class FoodProductVO extends CommonVO implements Serializable {
private Integer totalProductNum;
private Integer repoId;
private Long deptId;
private List<Long> deptIds;
private String imageUrl;
}

View File

@@ -69,4 +69,16 @@ public class RepoRecordVO {
* 说明
*/
private String msg;
private Long operId;
private String operName;
private String foodProductNum;
private String foodProductName;
private String unitName;
private BigDecimal price;
}

View File

@@ -0,0 +1,67 @@
package com.zf.foodpurchase.fdsafe.vo;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
public class RepositoryVO {
private Integer id;
private String repoName;
/**
* 所属商户id
*/
private Long merchantId;
/**
* 所属商户名称
*/
private String merchantName;
/**
* 区划编码
*/
private String areaCode;
/**
* 详细地址
*/
private String detailAddress;
/**
* 是否是默认仓库:0 否 1 是
*/
private String defaultRepo;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 操作人
*/
private Long operId;
private Long manager;
private String repoNum;
private Integer orderNum;
private List<Long> deptIds;
private Integer wpCount;
private Integer spCount;
private String managerName;
}

View File

@@ -109,4 +109,8 @@ public class SchoolOrderItemVO extends CommonVO implements Serializable {
*/
private String foodProductRemark;
private String supplierName;
private String modelName;
}

View File

@@ -0,0 +1,14 @@
package com.zf.foodpurchase.fdsafe.vo;
import lombok.Data;
@Data
public class XhCreateVO {
private Integer id;
private Integer deptNum;
private Long deptId;
private String timeStr;
private Integer xh;
}

View File

@@ -19,6 +19,8 @@ public interface SysUserMapper
*/
public List<SysUser> selectUserList(SysUser sysUser);
public List<SysUser> selectRepoUsers(SysUser sysUser);
/**
* 根据条件分页查询已配用户角色列表
*

View File

@@ -121,4 +121,6 @@ public interface ISysDeptService
* @return 结果
*/
public int deleteDeptById(Long deptId);
public List<SysDept> selectSuppliers();
}

View File

@@ -18,6 +18,8 @@ public interface ISysUserService
*/
public List<SysUser> selectUserList(SysUser user);
public List<SysUser> listRepoUsers(SysUser user);
/**
* 根据条件分页查询已分配用户角色列表
*

View File

@@ -293,6 +293,13 @@ public class SysDeptServiceImpl implements ISysDeptService
return deptMapper.deleteDeptById(deptId);
}
@Override
public List<SysDept> selectSuppliers() {
SysDept t = new SysDept();
t.setMerchantFlag("1");
return deptMapper.selectDeptList(t);
}
/**
* 递归列表
*/

View File

@@ -90,6 +90,11 @@ public class SysUserServiceImpl implements ISysUserService
return userMapper.selectUserList(user);
}
@Override
public List<SysUser> listRepoUsers(SysUser user) {
return userMapper.selectRepoUsers(user);
}
/**
* 根据条件分页查询已分配用户角色列表
*

View File

@@ -5,7 +5,7 @@
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
fp.food_product_id, fp.food_id, fp.price, fp.supplier_id, fp.edu_id, fp.remark, fp.check_remark, fp.check_status, fp.create_time, fp.update_time, fp.check_time,
fp.num, fp.name, fp.type_id,fp.unit_id,fp.spec_id
fp.num, fp.name, fp.type_id,fp.unit_id,fp.spec_id,fp.image_url
</sql>
<select id="queryFoodProductVO" resultType="com.zf.foodpurchase.fdsafe.vo.FoodProductVO">
SELECT
@@ -13,7 +13,7 @@
ed.edu_name,sp.supplier_name,sp.del_flag,fp.food_product_id,
fp.food_id,fp.price,fp.supplier_id,fp.edu_id,fp.remark,
fp.check_remark,fp.check_status,fp.create_time,fp.update_time,
fp.check_time,fp.num,fp.name,fp.type_id,fp.unit_id,fp.spec_id,
fp.check_time,fp.num,fp.name,fp.type_id,fp.unit_id,fp.spec_id,fp.dept_id,fp.image_url,
IFNULL(r.totalProductNum, 0) AS totalProductNum
FROM food_product fp
LEFT JOIN edu ed ON ed.edu_id = fp.edu_id
@@ -23,8 +23,6 @@
-- 供货商过滤条件移到ON,保留无供货商商品
LEFT JOIN supplier sp
ON sp.supplier_id = fp.supplier_id
AND sp.status = 1
AND sp.del_flag = 0
LEFT JOIN (
SELECT
food_product_id,
@@ -39,7 +37,7 @@
) r ON r.food_product_id = fp.food_product_id
<where>
<if test="foodProductId != null">
fp.food_product_id = #{foodProductId}
and fp.food_product_id = #{foodProductId}
</if>
<if test="foodId != null">
and fp.food_id = #{foodId}
@@ -63,21 +61,32 @@
<if test="delFlag != null">
and fp.del_flag = #{delFlag}
</if>
<if test="deptIds != null and deptIds.size() > 0">
and fp.dept_id in
<foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
</if>
</where>
order by fp.create_time desc
</select>
<select id="pageCKList" resultType="com.zf.foodpurchase.fdsafe.vo.FoodProductCKVO">
select a.food_product_id,a.num,a.name,c.repo_name repoName,d.spec_label specName,
b.food_product_num foodProductNum,e.unit_label unitName,a.supplier_id supplierId,
a.type_id typeId,b.repo_id repoId,c.merchant_id deptId,a.price
select a.food_product_id,a.num,a.name,a.dept_id,c.repo_name repoName,d.spec_label specName,
b.food_product_num foodProductNum,e.unit_label unitName,a.supplier_id supplierId,a.image_url imageUrl,
a.type_id typeId,b.repo_id repoId,c.merchant_id deptId,a.price,sup.supplier_name supplierName
from food_product a
left join food_repo b on a.food_product_id=b.food_product_id
left join repository c on b.repo_id=c.id
left join food_spec d on a.spec_id=d.spec_id
left join food_unit e on a.unit_id=e.unit_id
where b.repo_id=#{repoId}
left join supplier sup on a.supplier_id=sup.supplier_id
where b.repo_id=#{repoId} and a.del_flag=0
</select>
<update id="updateDelFlag">
update food_product set del_flag = 1 where food_product_id = #{foodProductId}
</update>
</mapper>

View File

@@ -15,17 +15,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result column="total_cost" property="totalCost"/>
<result column="status" property="status"/>
<result column="msg" property="msg"/>
<result column="school_id" property="schoolId"/>
<result column="dept_id" property="deptId"/>
<result column="oper_id" property="operId"/>
</resultMap>
<select id="selectRepoRecordByRepoRecordId" resultType="com.zf.foodpurchase.fdsafe.vo.RepoRecordVO">
select re.id,re.apply_date,re.supplier_id,re.category_id,re.repo_id,re.product_id,
re.product_num,p.name,re.total_cost,re.status,re.msg,fd.type_label categoryName,
sd.dept_name merchantName, rep.repo_name repoName,re.total_cost totalCost from repo_record re
sd.dept_name merchantName, rep.repo_name repoName,re.total_cost totalCost,re.oper_id operId,su.user_name operName from repo_record re
left join food_type fd on re.category_id=fd.type_id
left join sys_dept sd on re.supplier_id=sd.dept_id
left join repository rep on re.repo_id = rep.id
left join sys_user su on re.oper_id=su.user_id
left join food_product p on re.product_id=p.food_product_id WHERE re.id = #{repoRecordId}
</select>
@@ -41,7 +43,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="totalCost != null">total_cost,</if>
<if test="status != null">status,</if>
<if test="msg != null and msg != ''">msg,</if>
<if test="schoolId != null">school_id,</if>
<if test="deptId != null">dept_id,</if>
<if test="operId != null">oper_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="applyDate != null">#{applyDate},</if>
@@ -53,18 +56,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="totalCost != null">#{totalCost},</if>
<if test="status != null">#{status,jdbcType=INTEGER},</if>
<if test="msg != null and msg != ''">#{msg,jdbcType=VARCHAR},</if>
<if test="schoolId != null">#{schoolId,jdbcType=BIGINT},</if>
<if test="deptId != null">#{deptId,jdbcType=BIGINT},</if>
<if test="operId != null">#{operId,jdbcType=BIGINT},</if>
</trim>
</insert>
<select id="selectRepoRecordList" resultType="com.zf.foodpurchase.fdsafe.vo.RepoRecordVO">
select re.id,re.apply_date,re.supplier_id,re.category_id,re.repo_id,re.product_id,
re.product_num,p.name,re.total_cost,re.status,re.msg,fd.type_label categoryName,
sd.dept_name merchantName, rep.repo_name repoName,re.total_cost totalCost from repo_record re
sd.dept_name merchantName, rep.repo_name repoName,re.total_cost totalCost,re.oper_id operId,su.user_name operName from repo_record re
left join food_type fd on re.category_id=fd.type_id
left join sys_dept sd on re.supplier_id=sd.dept_id
left join repository rep on re.repo_id = rep.id
left join food_product p on re.product_id=p.food_product_id
left join sys_user su on re.oper_id=su.user_id
<where>
<if test="repoId != null">
AND re.repo_id = #{repoId,jdbcType=INTEGER}
@@ -72,15 +77,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="productName != null and productName != ''">
AND p.name LIKE CONCAT('%', #{productName,jdbcType=VARCHAR}, '%')
</if>
<if test="categoryId != null">
AND fd.type_id = #{categoryId,jdbcType=INTEGER}
<if test="status != null">
AND re.status = #{status,jdbcType=INTEGER}
</if>
<if test="startTime != null">
AND re.apply_date &gt;= #{startTime,jdbcType=DATETIME}
AND re.apply_date &gt;= #{startTime,jdbcType=TIMESTAMP}
</if>
<if test="endTime != null">
AND re.apply_date &lt;= #{endTime,jdbcType=DATETIME}
AND re.apply_date &lt;= #{endTime,jdbcType=TIMESTAMP}
</if>
<if test="deptIds != null and deptIds.size() > 0">
and re.dept_id in
<foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
</if>
</where>
</select>
<select id="selectRepoRecordListByProductId" resultType="com.zf.foodpurchase.fdsafe.vo.RepoRecordVO">
select re.id,re.apply_date,re.supplier_id,re.category_id,re.repo_id,re.product_id,
re.product_num,p.name,re.total_cost,re.status,re.msg,fd.type_label categoryName,
sd.dept_name merchantName, rep.repo_name repoName,re.total_cost totalCost,re.oper_id operId,su.user_name operName from repo_record re
left join food_type fd on re.category_id=fd.type_id
left join sys_dept sd on re.supplier_id=sd.dept_id
left join repository rep on re.repo_id = rep.id
left join food_product p on re.product_id=p.food_product_id
left join sys_user su on re.oper_id=su.user_id
where re.product_id = #{productId}
</select>
</mapper>

View File

@@ -23,9 +23,13 @@
r.manager, r.order_num, d.dept_name as merchant_name
from repository r left join sys_dept d on r.merchant_id = d.dept_id
</sql>
<select id="queryRepoList" resultType="com.zf.foodpurchase.fdsafe.entity.Repository"
<select id="queryRepoList" resultType="com.zf.foodpurchase.fdsafe.vo.RepositoryVO"
parameterType="com.zf.foodpurchase.fdsafe.entity.Repository">
<include refid="joinColumn"/>
select r.id,r.merchant_id,r.repo_num,r.repo_name,r.area_code,r.detail_address,r.default_repo,r.create_time,r.update_time,r.oper_id,r.manager,r.order_num,d.dept_name merchant_name,count(fr.food_product_num) spCount,ifnull(sum(fr.food_product_num),0) wpCount,su.user_name managerName
from repository r
left join sys_dept d on r.merchant_id=d.dept_id
left join food_repo fr on r.id=fr.repo_id
left join sys_user su on r.manager=su.user_id
<where>
<if test="id != null ">and r.id = #{id}</if>
<if test="merchantId != null ">and r.merchant_id = #{merchantId}</if>
@@ -46,6 +50,7 @@
</foreach>
</if>
</where>
group by r.id,r.merchant_id,r.repo_num,r.repo_name,r.area_code,r.detail_address,r.default_repo,r.create_time,r.update_time,r.oper_id,r.manager,r.order_num,d.dept_name;
</select>
</mapper>

View File

@@ -8,15 +8,13 @@
</sql>
<select id="querySchoolCartItemVO" resultType="com.zf.foodpurchase.fdsafe.vo.SchoolCartItemVO"
parameterType="com.zf.foodpurchase.fdsafe.vo.SchoolCartItemVO">
select
<include refid="Base_Column_List"/>,
f.food_name, ft.type_id , ft.type_label , fp.price , fu.unit_id , fu.unit_label , su.supplier_name,
fp.check_status,fp.del_flag,fp.remark,f.del_flag as foodDelFlag
select ci.cart_item_id, ci.school_id, ci.food_product_id, ci.product_num, ci.supplier_id, ci.item_remark, ci.create_time, ci.update_time,
fp.name foodName, ft.type_id , ft.type_label , fp.price , fu.unit_id , fu.unit_label , su.supplier_name,
fp.check_status,fp.del_flag,fp.remark
from school_cart_item ci
left join food_product fp on ci.food_product_id = fp.food_product_id
left join food f on fp.food_id = f.food_id
left join food_type ft on f.type_id = ft.type_id
left join food_unit fu on f.unit_id = fu.unit_id
left join food_type ft on fp.type_id = ft.type_id
left join food_unit fu on fp.unit_id = fu.unit_id
left join supplier su on ci.supplier_id = su.supplier_id
left join school s on ci.school_id = s.school_id
@@ -31,7 +29,7 @@
and ci.food_product_id = #{foodProductId}
</if>
<if test="foodName != null and foodName !='' ">
and f.food_name like concat('%',#{foodName},'%')
and fp.name like concat('%',#{foodName},'%')
</if>
<if test="supplierId != null">
and ci.supplier_id = #{supplierId}

View File

@@ -8,14 +8,14 @@
</sql>
<select id="querySchoolOrderItemVO" resultType="com.zf.foodpurchase.fdsafe.vo.SchoolOrderItemVO"
parameterType="com.zf.foodpurchase.fdsafe.vo.SchoolOrderItemVO">
select<include refid="Base_Column_List"/>,
ft.type_label,fu.unit_label,fp.remark as food_product_remark
select soi.order_item_no, soi.order_no,soi.food_id, soi.school_id, soi.edu_id, soi.supplier_id, soi.food_product_id, soi.food_name, soi.price, soi.product_num, soi.type_id, soi.unit_id, soi.order_item_status, soi.create_time, soi.update_time, soi.order_item_remark,soi.refund_num,
ft.type_label,fu.unit_label,fp.remark as food_product_remark,sup.supplier_name supplierName,fu.unit_label modelName
from school_order_item soi
left join supplier sup on soi.supplier_id=sup.supplier_id
left join school_order so on soi.order_no = so.order_no
left join food_product fp on soi.food_product_id = fp.food_product_id
left join food f on f.food_id = fp.food_id
left join food_type ft on ft.type_id = f.type_id
left join food_unit fu on fu.unit_id = f.unit_id
left join food_type ft on ft.type_id = fp.type_id
left join food_unit fu on fu.unit_id = fp.unit_id
<where>
<if test="orderItemNo != null and orderItemNo != ''">
and soi.order_item_no = #{orderItemNo}

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zf.foodpurchase.fdsafe.mapper.XhMapper">
<select id="queryXhCreate" resultType="com.zf.foodpurchase.fdsafe.entity.XhCreate">
select id, dept_num as deptNum, dept_id as deptId, time_str as timeStr, xh
from xh_create
where dept_id=#{deptId} and time_str=#{timeStr}
</select>
<select id="selectMaxDeptNum" resultType="INTEGER">
select MAX(dept_num)
from xh_create
</select>
<insert id="insertXhCreate">
insert into xh_create(dept_num, dept_id, time_str, xh)
values(#{deptNum}, #{deptId}, #{timeStr}, #{xh})
</insert>
<update id="updateXhCreate">
update xh_create
set xh=#{xh}
where dept_id=#{deptId} and time_str=#{timeStr}
</update>
</mapper>

View File

@@ -94,6 +94,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
${params.dataScope}
</select>
<select id="selectRepoUsers" parameterType="SysUser" resultMap="SysUserResult">
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, u.account_type ,u.account_dept_id,d.dept_name, d.leader from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
where u.del_flag = '0'
<if test="userId != null and userId != 0">
AND u.user_id = #{userId}
</if>
<if test="userName != null and userName != ''">
AND u.user_name like concat('%', #{userName}, '%')
</if>
<if test="status != null and status != ''">
AND u.status = #{status}
</if>
<if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber like concat('%', #{phonenumber}, '%')
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
AND date_format(u.create_time,'%Y%m%d') &gt;= date_format(#{params.beginTime},'%Y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
AND date_format(u.create_time,'%Y%m%d') &lt;= date_format(#{params.endTime},'%Y%m%d')
</if>
<if test="deptIdList != null and deptIdList.size() > 0">
and u.dept_id in
<foreach collection="deptIdList" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
</if>
</select>
<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time, u.account_type,u.account_dept_id
from sys_user u