master:档口客户接口添加;
parent
1f3e7400b1
commit
91a2509f75
|
|
@ -1,15 +1,25 @@
|
|||
package com.ruoyi.web.controller.xkt;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.XktBaseController;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.web.controller.xkt.vo.storeCustomer.StoreCusPageVO;
|
||||
import com.ruoyi.web.controller.xkt.vo.storeCustomer.StoreCusVO;
|
||||
import com.ruoyi.xkt.domain.StoreCustomer;
|
||||
import com.ruoyi.xkt.dto.storeCustomer.StoreCusDTO;
|
||||
import com.ruoyi.xkt.dto.storeCustomer.StoreCusPageDTO;
|
||||
import com.ruoyi.xkt.dto.storeCustomer.StoreCusPageResDTO;
|
||||
import com.ruoyi.xkt.service.IStoreCustomerService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
|
@ -21,23 +31,74 @@ import java.util.List;
|
|||
* @author ruoyi
|
||||
* @date 2025-03-26
|
||||
*/
|
||||
@Api(tags = "档口客户")
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/rest/v1/store-customers")
|
||||
public class StoreCustomerController extends XktBaseController {
|
||||
@Autowired
|
||||
private IStoreCustomerService storeCustomerService;
|
||||
|
||||
final IStoreCustomerService storeCusService;
|
||||
|
||||
/**
|
||||
* 新增档口客户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:customer:add')")
|
||||
@ApiOperation(value = "新增档口客户", httpMethod = "POST", response = R.class)
|
||||
@Log(title = "新增档口客户", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public R add(@Validated @RequestBody StoreCusVO storeCusVO) {
|
||||
return success(storeCusService.create(BeanUtil.toBean(storeCusVO, StoreCusDTO.class)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改档口客户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:customer:edit')")
|
||||
@ApiOperation(value = "修改档口客户", httpMethod = "PUT", response = R.class)
|
||||
@Log(title = "修改档口客户", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R edit(@Validated @RequestBody StoreCusVO storeCusVO) {
|
||||
return success(storeCusService.updateStoreCus(BeanUtil.toBean(storeCusVO, StoreCusDTO.class)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除档口客户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:customer:remove')")
|
||||
@ApiOperation(value = "删除档口客户", httpMethod = "DELETE", response = R.class)
|
||||
@Log(title = "删除档口客户", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{storeCusId}")
|
||||
public R remove(@PathVariable Long storeCusId) {
|
||||
storeCusService.deleteStoreCus(storeCusId);
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取档口客户详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:customer:query')")
|
||||
@ApiOperation(value = "获取档口客户详细信息", httpMethod = "GET", response = R.class)
|
||||
@GetMapping(value = "/{storeCusId}")
|
||||
public R getInfo(@PathVariable("storeCusId") Long storeCusId) {
|
||||
return success(BeanUtil.toBean(storeCusService.selectStoreCustomerByStoreCusId(storeCusId), StoreCusVO.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询档口客户列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:customer:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(StoreCustomer storeCustomer) {
|
||||
startPage();
|
||||
List<StoreCustomer> list = storeCustomerService.selectStoreCustomerList(storeCustomer);
|
||||
return getDataTable(list);
|
||||
@ApiOperation(value = "查询档口客户列表", httpMethod = "GET", response = R.class)
|
||||
@PostMapping("/page")
|
||||
// public TableDataInfo selectPage(@Validated @RequestBody StoreCusPageVO pageVO) {
|
||||
public List selectPage(@Validated @RequestBody StoreCusPageVO pageVO) {
|
||||
// startPage();
|
||||
List<StoreCusPageResDTO> list = storeCusService.selectPage(ObjectUtils.isEmpty(pageVO) ? null : BeanUtil.toBean(pageVO, StoreCusPageDTO.class));
|
||||
System.err.println(list);
|
||||
return list;
|
||||
// return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出档口客户列表
|
||||
*/
|
||||
|
|
@ -45,47 +106,10 @@ public class StoreCustomerController extends XktBaseController {
|
|||
@Log(title = "档口客户", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, StoreCustomer storeCustomer) {
|
||||
List<StoreCustomer> list = storeCustomerService.selectStoreCustomerList(storeCustomer);
|
||||
List<StoreCustomer> list = storeCusService.selectStoreCustomerList(storeCustomer);
|
||||
ExcelUtil<StoreCustomer> util = new ExcelUtil<StoreCustomer>(StoreCustomer.class);
|
||||
util.exportExcel(response, list, "档口客户数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取档口客户详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:customer:query')")
|
||||
@GetMapping(value = "/{storeCusId}")
|
||||
public R getInfo(@PathVariable("storeCusId") Long storeCusId) {
|
||||
return success(storeCustomerService.selectStoreCustomerByStoreCusId(storeCusId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增档口客户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:customer:add')")
|
||||
@Log(title = "档口客户", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public R add(@RequestBody StoreCustomer storeCustomer) {
|
||||
return success(storeCustomerService.insertStoreCustomer(storeCustomer));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改档口客户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:customer:edit')")
|
||||
@Log(title = "档口客户", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R edit(@RequestBody StoreCustomer storeCustomer) {
|
||||
return success(storeCustomerService.updateStoreCustomer(storeCustomer));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除档口客户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:customer:remove')")
|
||||
@Log(title = "档口客户", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{storeCusIds}")
|
||||
public R remove(@PathVariable Long[] storeCusIds) {
|
||||
return success(storeCustomerService.deleteStoreCustomerByStoreCusIds(storeCusIds));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ public class StoreProductController extends XktBaseController {
|
|||
* 模糊查询档口商品
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:product:query')")
|
||||
@ApiOperation(value = "模糊查询档口商品", httpMethod = "GET", response = R.class)
|
||||
@GetMapping(value = "/fuzzy")
|
||||
public R fuzzyQueryColorList(@RequestParam(value = "prodArtNum", required = false) String prodArtNum,
|
||||
@RequestParam("storeId") Long storeId) {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.ruoyi.common.enums.BusinessType;
|
|||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.xkt.domain.StoreSale;
|
||||
import com.ruoyi.xkt.service.IStoreSaleService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -22,10 +23,11 @@ import java.util.List;
|
|||
* @date 2025-03-26
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/rest/v1/store-sales")
|
||||
public class StoreSaleController extends XktBaseController {
|
||||
@Autowired
|
||||
private IStoreSaleService storeSaleService;
|
||||
|
||||
final IStoreSaleService storeSaleService;
|
||||
|
||||
/**
|
||||
* 查询档口销售出库列表
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
package com.ruoyi.web.controller.xkt.vo.storeCustomer;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("档口客户分页查询入参")
|
||||
@Data
|
||||
public class StoreCusPageVO {
|
||||
private long pageNum;
|
||||
private long pageSize;
|
||||
|
||||
@ApiModelProperty(name = "客户名称")
|
||||
private String cusName;
|
||||
@ApiModelProperty(name = "档口ID")
|
||||
@NotNull(message = "档口ID不能为空")
|
||||
private Long storeId;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package com.ruoyi.web.controller.xkt.vo.storeCustomer;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("档口客户")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class StoreCusVO {
|
||||
|
||||
@NotNull(message = "档口ID不能为空!")
|
||||
@ApiModelProperty(name = "档口ID")
|
||||
private Long storeId;
|
||||
@ApiModelProperty(name = "档口客户ID", notes = "新增为空,编辑必传")
|
||||
private Long storeCusId;
|
||||
@NotBlank(message = "客户名称不能为空!")
|
||||
@ApiModelProperty(name = "客户名称")
|
||||
private String cusName;
|
||||
@ApiModelProperty(name = "客户联系电话")
|
||||
private String phone;
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
|
@ -75,7 +75,7 @@ public class XktBaseController {
|
|||
*/
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
protected TableDataInfo getDataTable(List<?> list) {
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
/*PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
TableDataInfo rspData = new TableDataInfo();
|
||||
rspData.setCode(HttpStatus.SUCCESS);
|
||||
rspData.setMsg("查询成功");
|
||||
|
|
@ -84,8 +84,18 @@ public class XktBaseController {
|
|||
rspData.setPageSize(pageDomain.getPageSize());
|
||||
long total = new PageInfo(list).getTotal();
|
||||
rspData.setTotal(total);
|
||||
rspData.setTotalPage((long) Math.ceil((double) total / pageDomain.getPageSize()));
|
||||
rspData.setPages((long) Math.ceil((double) total / pageDomain.getPageSize()));
|
||||
return rspData;*/
|
||||
|
||||
TableDataInfo rspData = new TableDataInfo();
|
||||
rspData.setCode(HttpStatus.SUCCESS);
|
||||
rspData.setMsg("查询成功");
|
||||
rspData.setRows(list);
|
||||
PageInfo pageInfo = new PageInfo<>(list);
|
||||
System.err.println(pageInfo);
|
||||
rspData.setTotal(new PageInfo(list).getTotal());
|
||||
return rspData;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -12,18 +12,17 @@ public class TableDataInfo implements Serializable {
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 当前分页 页数
|
||||
* 分页当前页码
|
||||
*/
|
||||
private long pageNum;
|
||||
/**
|
||||
* 当前分页每页数量
|
||||
* 分页每页记录数
|
||||
*/
|
||||
private long pageSize;
|
||||
|
||||
/**
|
||||
* 总的页数
|
||||
*
|
||||
*/
|
||||
private long totalPage;
|
||||
private long pages;
|
||||
|
||||
/**
|
||||
* 总记录数
|
||||
|
|
@ -57,11 +56,35 @@ public class TableDataInfo implements Serializable {
|
|||
* @param list 列表数据
|
||||
* @param total 总记录数
|
||||
*/
|
||||
public TableDataInfo(List<?> list, long total) {
|
||||
public TableDataInfo(List<?> list, int total) {
|
||||
this.rows = list;
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public long getPageNum() {
|
||||
return pageNum;
|
||||
}
|
||||
|
||||
public void setPageNum(long pageNum) {
|
||||
this.pageNum = pageNum;
|
||||
}
|
||||
|
||||
public long getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public void setPageSize(long pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public long getPages() {
|
||||
return pages;
|
||||
}
|
||||
|
||||
public void setPages(long pages) {
|
||||
this.pages = pages;
|
||||
}
|
||||
|
||||
public long getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
|
@ -93,28 +116,4 @@ public class TableDataInfo implements Serializable {
|
|||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public long getPageNum() {
|
||||
return pageNum;
|
||||
}
|
||||
|
||||
public void setPageNum(long pageNum) {
|
||||
this.pageNum = pageNum;
|
||||
}
|
||||
|
||||
public long getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public void setPageSize(long pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public long getTotalPage() {
|
||||
return totalPage;
|
||||
}
|
||||
|
||||
public void setTotalPage(long totalPage) {
|
||||
this.totalPage = totalPage;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.ruoyi.common.annotation.Excel;
|
|||
import com.ruoyi.common.core.domain.XktBaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
|
|
@ -43,6 +44,13 @@ public class StoreCustomer extends XktBaseEntity {
|
|||
@Excel(name = "客户联系电话")
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 客户备注
|
||||
*/
|
||||
@Excel(name = "客户备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
package com.ruoyi.xkt.dto.storeCustomer;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("档口客户")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class StoreCusDTO {
|
||||
|
||||
@ApiModelProperty(name = "档口ID")
|
||||
private Long storeId;
|
||||
@ApiModelProperty(name = "档口客户ID")
|
||||
private Long storeCusId;
|
||||
@ApiModelProperty(name = "客户名称")
|
||||
private String cusName;
|
||||
@ApiModelProperty(name = "客户联系电话")
|
||||
private String phone;
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.ruoyi.xkt.dto.storeCustomer;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("档口客户分页查询入参")
|
||||
@Data
|
||||
public class StoreCusPageDTO {
|
||||
|
||||
private long pageNum;
|
||||
private long pageSize;
|
||||
@ApiModelProperty(name = "客户名称")
|
||||
private String cusName;
|
||||
@ApiModelProperty(name = "档口ID")
|
||||
private Long storeId;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.ruoyi.xkt.dto.storeCustomer;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("档口客户")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class StoreCusPageResDTO {
|
||||
|
||||
@ApiModelProperty(name = "档口ID")
|
||||
private Long storeId;
|
||||
@ApiModelProperty(name = "档口客户ID", notes = "新增为空,编辑必传")
|
||||
private Long storeCusId;
|
||||
@NotBlank(message = "客户名称不能为空!")
|
||||
@ApiModelProperty(name = "客户名称")
|
||||
private String cusName;
|
||||
@ApiModelProperty(name = "客户联系电话")
|
||||
private String phone;
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
@ApiModelProperty("创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,9 @@
|
|||
package com.ruoyi.xkt.service;
|
||||
|
||||
import com.ruoyi.xkt.domain.StoreCustomer;
|
||||
import com.ruoyi.xkt.dto.storeCustomer.StoreCusDTO;
|
||||
import com.ruoyi.xkt.dto.storeCustomer.StoreCusPageDTO;
|
||||
import com.ruoyi.xkt.dto.storeCustomer.StoreCusPageResDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -17,7 +20,7 @@ public interface IStoreCustomerService {
|
|||
* @param storeCusId 档口客户主键
|
||||
* @return 档口客户
|
||||
*/
|
||||
public StoreCustomer selectStoreCustomerByStoreCusId(Long storeCusId);
|
||||
public StoreCusDTO selectStoreCustomerByStoreCusId(Long storeCusId);
|
||||
|
||||
/**
|
||||
* 查询档口客户列表
|
||||
|
|
@ -38,10 +41,10 @@ public interface IStoreCustomerService {
|
|||
/**
|
||||
* 修改档口客户
|
||||
*
|
||||
* @param storeCustomer 档口客户
|
||||
* @param storeCusDTO 档口客户
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateStoreCustomer(StoreCustomer storeCustomer);
|
||||
public int updateStoreCus(StoreCusDTO storeCusDTO);
|
||||
|
||||
/**
|
||||
* 批量删除档口客户
|
||||
|
|
@ -58,4 +61,11 @@ public interface IStoreCustomerService {
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteStoreCustomerByStoreCusId(Long storeCusId);
|
||||
|
||||
int create(StoreCusDTO storeCusDTO);
|
||||
|
||||
void deleteStoreCus(Long storeCusId);
|
||||
|
||||
List<StoreCusPageResDTO> selectPage(StoreCusPageDTO storeCusPageDTO);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,27 @@
|
|||
package com.ruoyi.xkt.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.ruoyi.common.constant.HttpStatus;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.xkt.domain.StoreCustomer;
|
||||
import com.ruoyi.xkt.dto.storeCustomer.StoreCusDTO;
|
||||
import com.ruoyi.xkt.dto.storeCustomer.StoreCusPageDTO;
|
||||
import com.ruoyi.xkt.dto.storeCustomer.StoreCusPageResDTO;
|
||||
import com.ruoyi.xkt.mapper.StoreCustomerMapper;
|
||||
import com.ruoyi.xkt.service.IStoreCustomerService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 档口客户Service业务层处理
|
||||
|
|
@ -17,9 +30,56 @@ import java.util.List;
|
|||
* @date 2025-03-26
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class StoreCustomerServiceImpl implements IStoreCustomerService {
|
||||
@Autowired
|
||||
private StoreCustomerMapper storeCustomerMapper;
|
||||
|
||||
final StoreCustomerMapper storeCusMapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int create(StoreCusDTO storeCusDTO) {
|
||||
return this.storeCusMapper.insert(BeanUtil.toBean(storeCusDTO, StoreCustomer.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteStoreCus(Long storeCusId) {
|
||||
StoreCustomer storeCus = Optional.ofNullable(this.storeCusMapper.selectOne(new LambdaQueryWrapper<StoreCustomer>()
|
||||
.eq(StoreCustomer::getId, storeCusId).eq(StoreCustomer::getDelFlag, "0")))
|
||||
.orElseThrow(() -> new ServiceException("档口客户不存在!"));
|
||||
storeCus.setDelFlag("2");
|
||||
this.storeCusMapper.updateById(storeCus);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<StoreCusPageResDTO> selectPage(StoreCusPageDTO storeCusPageDTO) {
|
||||
LambdaQueryWrapper<StoreCustomer> queryWrapper = new LambdaQueryWrapper<StoreCustomer>()
|
||||
.eq(StoreCustomer::getStoreId, storeCusPageDTO.getStoreId()).eq(StoreCustomer::getDelFlag, "0");
|
||||
if (StringUtils.isNotBlank(storeCusPageDTO.getCusName())) {
|
||||
queryWrapper.like(StoreCustomer::getCusName, storeCusPageDTO.getCusName());
|
||||
}
|
||||
// PageHelper.startPage((int)storeCusPageDTO.getPageNum(), (int)storeCusPageDTO.getPageSize());
|
||||
Page<StoreCustomer> page = new Page<>(storeCusPageDTO.getPageNum(), storeCusPageDTO.getPageSize());
|
||||
Page<StoreCustomer> cusList = this.storeCusMapper.selectPage(page, queryWrapper);
|
||||
// List<StoreCusPageResDTO> cusPageResDTOS = this.storeCusMapper.selectList(cusList, StoreCusPageResDTO.class);
|
||||
// List<StoreCustomer> cusList = this.storeCusMapper.selectList(queryWrapper);
|
||||
// System.err.println(cusList);
|
||||
// return null;
|
||||
return CollectionUtils.isEmpty(cusList.getRecords()) ? new ArrayList<>() : BeanUtil.copyToList(cusList.getRecords(), StoreCusPageResDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int updateStoreCus(StoreCusDTO storeCusDTO) {
|
||||
Optional.ofNullable(storeCusDTO.getStoreCusId()).orElseThrow(() -> new ServiceException("档口客户ID不可为空!"));
|
||||
StoreCustomer storeCus = Optional.ofNullable(this.storeCusMapper.selectOne(new LambdaQueryWrapper<StoreCustomer>()
|
||||
.eq(StoreCustomer::getId, storeCusDTO.getStoreCusId()).eq(StoreCustomer::getDelFlag, "0")))
|
||||
.orElseThrow(() -> new ServiceException("档口客户不存在!"));
|
||||
BeanUtil.copyProperties(storeCusDTO, storeCus);
|
||||
return storeCusMapper.updateStoreCustomer(storeCus);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询档口客户
|
||||
|
|
@ -29,8 +89,11 @@ public class StoreCustomerServiceImpl implements IStoreCustomerService {
|
|||
*/
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public StoreCustomer selectStoreCustomerByStoreCusId(Long storeCusId) {
|
||||
return storeCustomerMapper.selectStoreCustomerByStoreCusId(storeCusId);
|
||||
public StoreCusDTO selectStoreCustomerByStoreCusId(Long storeCusId) {
|
||||
StoreCustomer storeCus = Optional.ofNullable(storeCusMapper.selectOne(new LambdaQueryWrapper<StoreCustomer>()
|
||||
.eq(StoreCustomer::getId, storeCusId).eq(StoreCustomer::getDelFlag, "0")))
|
||||
.orElseThrow(() -> new ServiceException("档口客户不存在!", HttpStatus.ERROR));
|
||||
return BeanUtil.toBean(storeCus, StoreCusDTO.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -42,7 +105,7 @@ public class StoreCustomerServiceImpl implements IStoreCustomerService {
|
|||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<StoreCustomer> selectStoreCustomerList(StoreCustomer storeCustomer) {
|
||||
return storeCustomerMapper.selectStoreCustomerList(storeCustomer);
|
||||
return storeCusMapper.selectStoreCustomerList(storeCustomer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -55,21 +118,9 @@ public class StoreCustomerServiceImpl implements IStoreCustomerService {
|
|||
@Transactional
|
||||
public int insertStoreCustomer(StoreCustomer storeCustomer) {
|
||||
storeCustomer.setCreateTime(DateUtils.getNowDate());
|
||||
return storeCustomerMapper.insertStoreCustomer(storeCustomer);
|
||||
return storeCusMapper.insertStoreCustomer(storeCustomer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改档口客户
|
||||
*
|
||||
* @param storeCustomer 档口客户
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int updateStoreCustomer(StoreCustomer storeCustomer) {
|
||||
storeCustomer.setUpdateTime(DateUtils.getNowDate());
|
||||
return storeCustomerMapper.updateStoreCustomer(storeCustomer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除档口客户
|
||||
|
|
@ -80,7 +131,7 @@ public class StoreCustomerServiceImpl implements IStoreCustomerService {
|
|||
@Override
|
||||
@Transactional
|
||||
public int deleteStoreCustomerByStoreCusIds(Long[] storeCusIds) {
|
||||
return storeCustomerMapper.deleteStoreCustomerByStoreCusIds(storeCusIds);
|
||||
return storeCusMapper.deleteStoreCustomerByStoreCusIds(storeCusIds);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -92,6 +143,8 @@ public class StoreCustomerServiceImpl implements IStoreCustomerService {
|
|||
@Override
|
||||
@Transactional
|
||||
public int deleteStoreCustomerByStoreCusId(Long storeCusId) {
|
||||
return storeCustomerMapper.deleteStoreCustomerByStoreCusId(storeCusId);
|
||||
return storeCusMapper.deleteStoreCustomerByStoreCusId(storeCusId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,60 +155,12 @@ public class StoreProductServiceImpl implements IStoreProductService {
|
|||
// 组装StoreProduct数据
|
||||
StoreProduct storeProd = BeanUtil.toBean(storeProdDTO, StoreProduct.class).setVoucherDate(DateUtils.getNowDate());
|
||||
int count = this.storeProdMapper.insert(storeProd);
|
||||
// 上传的文件列表
|
||||
final List<StoreProdFileDTO> fileDTOList = storeProdDTO.getFileList();
|
||||
// 将文件插入到SysFile表中
|
||||
List<SysFile> fileList = BeanUtil.copyToList(fileDTOList, SysFile.class);
|
||||
this.fileMapper.insert(fileList);
|
||||
// 将文件名称和文件ID映射到Map中
|
||||
Map<String, Long> fileMap = fileList.stream().collect(Collectors.toMap(SysFile::getFileName, SysFile::getId));
|
||||
// 档口文件(商品主图、主图视频、下载的商品详情)
|
||||
List<StoreProductFile> prodFileList = fileDTOList.stream()
|
||||
.map(x -> BeanUtil.toBean(x, StoreProductFile.class).setFileId(fileMap.get(x.getFileName()))
|
||||
.setStoreProdId(storeProd.getId()).setStoreId(storeProdDTO.getStoreId()))
|
||||
.collect(Collectors.toList());
|
||||
this.storeProdFileMapper.insert(prodFileList);
|
||||
// 档口类目属性列表
|
||||
List<StoreProductCategoryAttribute> cateAttrList = storeProdDTO.getCateAttrList().stream()
|
||||
.map(x -> BeanUtil.toBean(x, StoreProductCategoryAttribute.class)
|
||||
.setStoreProdId(storeProd.getId()))
|
||||
.collect(Collectors.toList());
|
||||
this.storeProdCateAttrMapper.insert(cateAttrList);
|
||||
// 档口颜色列表
|
||||
List<StoreProductColor> colorList = storeProdDTO.getColorList().stream()
|
||||
.map(x -> BeanUtil.toBean(x, StoreProductColor.class)
|
||||
.setStoreProdId(storeProd.getId()).setStoreId(storeProdDTO.getStoreId()))
|
||||
.collect(Collectors.toList());
|
||||
this.storeProdColorMapper.insert(colorList);
|
||||
// 档口颜色尺码列表
|
||||
List<StoreProductColorSize> sizeList = storeProdDTO.getSizeList().stream()
|
||||
.map(x -> BeanUtil.toBean(x, StoreProductColorSize.class)
|
||||
.setStoreProdId(storeProd.getId()))
|
||||
.collect(Collectors.toList());
|
||||
this.storeProdColorSizeMapper.insert(sizeList);
|
||||
// 档口颜色价格列表
|
||||
List<StoreProductColorPrice> priceList = storeProdDTO.getPriceList().stream()
|
||||
.map(x -> BeanUtil.toBean(x, StoreProductColorPrice.class)
|
||||
.setStoreProdId(storeProd.getId()))
|
||||
.collect(Collectors.toList());
|
||||
this.storeProdColorPriceMapper.insert(priceList);
|
||||
// 档口详情内容
|
||||
StoreProductDetail storeProdDetail = BeanUtil.toBean(storeProdDTO.getDetail(), StoreProductDetail.class)
|
||||
.setStoreProdId(storeProd.getId());
|
||||
this.storeProdDetailMapper.insert(storeProdDetail);
|
||||
// 档口服务承诺
|
||||
if (ObjectUtils.isNotEmpty(storeProdDTO.getSvc())) {
|
||||
this.storeProdSvcMapper.insert(BeanUtil.toBean(storeProdDTO.getSvc(), StoreProductService.class)
|
||||
.setStoreProdId(storeProd.getId()));
|
||||
}
|
||||
// 档口生产工艺信息
|
||||
if (ObjectUtils.isNotEmpty(storeProdDTO.getProcess())) {
|
||||
this.storeProdProcMapper.insert(BeanUtil.toBean(storeProdDTO.getProcess(), StoreProductProcess.class)
|
||||
.setStoreProdId(storeProd.getId()));
|
||||
}
|
||||
// 处理StoreProduct其它属性
|
||||
this.handleStoreProdProperties(storeProd, storeProdDTO);
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改档口商品
|
||||
*
|
||||
|
|
@ -221,9 +173,9 @@ public class StoreProductServiceImpl implements IStoreProductService {
|
|||
StoreProduct storeProd = Optional.ofNullable(this.storeProdMapper.selectOne(new LambdaQueryWrapper<StoreProduct>()
|
||||
.eq(StoreProduct::getId, storeProdId).eq(StoreProduct::getDelFlag, "0")))
|
||||
.orElseThrow(() -> new ServiceException("档口商品不存在!", HttpStatus.ERROR));
|
||||
// 将档口商品的del_flag置为2
|
||||
storeProd.setDelFlag("2");
|
||||
this.storeProdMapper.updateById(storeProd);
|
||||
// 更新档口商品信息
|
||||
BeanUtil.copyProperties(storeProdDTO, storeProd);
|
||||
int count = this.storeProdMapper.updateById(storeProd);
|
||||
// 档口文件(商品主图、主图视频、下载的商品详情)的del_flag置为2
|
||||
this.storeProdFileMapper.updateDelFlagByStoreProdId(storeProdId);
|
||||
// 档口类目属性列表的 del_flag置为2
|
||||
|
|
@ -240,8 +192,9 @@ public class StoreProductServiceImpl implements IStoreProductService {
|
|||
this.storeProdSvcMapper.updateDelFlagByStoreProdId(storeProdId);
|
||||
// 档口工艺信息的del_flag置为2
|
||||
this.storeProdProcMapper.updateDelFlagByStoreProdId(storeProdId);
|
||||
// 重新执行插入数据操作
|
||||
return this.insertStoreProduct(storeProdDTO);
|
||||
// 处理更新逻辑
|
||||
this.handleStoreProdProperties(storeProd, storeProdDTO);
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -337,4 +290,64 @@ public class StoreProductServiceImpl implements IStoreProductService {
|
|||
.setColorList(colorMap.getOrDefault(x.getId(), new ArrayList<>()))).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理档口商品属性
|
||||
*
|
||||
* @param storeProd 档口商品实体
|
||||
* @param storeProdDTO 档口商品数据传输对象
|
||||
*/
|
||||
private void handleStoreProdProperties(StoreProduct storeProd, StoreProdDTO storeProdDTO) {
|
||||
// 上传的文件列表
|
||||
final List<StoreProdFileDTO> fileDTOList = storeProdDTO.getFileList();
|
||||
// 将文件插入到SysFile表中
|
||||
List<SysFile> fileList = BeanUtil.copyToList(fileDTOList, SysFile.class);
|
||||
this.fileMapper.insert(fileList);
|
||||
// 将文件名称和文件ID映射到Map中
|
||||
Map<String, Long> fileMap = fileList.stream().collect(Collectors.toMap(SysFile::getFileName, SysFile::getId));
|
||||
// 档口文件(商品主图、主图视频、下载的商品详情)
|
||||
List<StoreProductFile> prodFileList = fileDTOList.stream()
|
||||
.map(x -> BeanUtil.toBean(x, StoreProductFile.class).setFileId(fileMap.get(x.getFileName()))
|
||||
.setStoreProdId(storeProd.getId()).setStoreId(storeProdDTO.getStoreId()))
|
||||
.collect(Collectors.toList());
|
||||
this.storeProdFileMapper.insert(prodFileList);
|
||||
// 档口类目属性列表
|
||||
List<StoreProductCategoryAttribute> cateAttrList = storeProdDTO.getCateAttrList().stream()
|
||||
.map(x -> BeanUtil.toBean(x, StoreProductCategoryAttribute.class)
|
||||
.setStoreProdId(storeProd.getId()))
|
||||
.collect(Collectors.toList());
|
||||
this.storeProdCateAttrMapper.insert(cateAttrList);
|
||||
// 档口颜色列表
|
||||
List<StoreProductColor> colorList = storeProdDTO.getColorList().stream()
|
||||
.map(x -> BeanUtil.toBean(x, StoreProductColor.class)
|
||||
.setStoreProdId(storeProd.getId()).setStoreId(storeProdDTO.getStoreId()))
|
||||
.collect(Collectors.toList());
|
||||
this.storeProdColorMapper.insert(colorList);
|
||||
// 档口颜色尺码列表
|
||||
List<StoreProductColorSize> sizeList = storeProdDTO.getSizeList().stream()
|
||||
.map(x -> BeanUtil.toBean(x, StoreProductColorSize.class)
|
||||
.setStoreProdId(storeProd.getId()))
|
||||
.collect(Collectors.toList());
|
||||
this.storeProdColorSizeMapper.insert(sizeList);
|
||||
// 档口颜色价格列表
|
||||
List<StoreProductColorPrice> priceList = storeProdDTO.getPriceList().stream()
|
||||
.map(x -> BeanUtil.toBean(x, StoreProductColorPrice.class)
|
||||
.setStoreProdId(storeProd.getId()))
|
||||
.collect(Collectors.toList());
|
||||
this.storeProdColorPriceMapper.insert(priceList);
|
||||
// 档口详情内容
|
||||
StoreProductDetail storeProdDetail = BeanUtil.toBean(storeProdDTO.getDetail(), StoreProductDetail.class)
|
||||
.setStoreProdId(storeProd.getId());
|
||||
this.storeProdDetailMapper.insert(storeProdDetail);
|
||||
// 档口服务承诺
|
||||
if (ObjectUtils.isNotEmpty(storeProdDTO.getSvc())) {
|
||||
this.storeProdSvcMapper.insert(BeanUtil.toBean(storeProdDTO.getSvc(), StoreProductService.class)
|
||||
.setStoreProdId(storeProd.getId()));
|
||||
}
|
||||
// 档口生产工艺信息
|
||||
if (ObjectUtils.isNotEmpty(storeProdDTO.getProcess())) {
|
||||
this.storeProdProcMapper.insert(BeanUtil.toBean(storeProdDTO.getProcess(), StoreProductProcess.class)
|
||||
.setStoreProdId(storeProd.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue