Explorar el Código

4/2 添加产品查询产品

lwhhszx hace 1 año
padre
commit
bf04cc562c
Se han modificado 22 ficheros con 360 adiciones y 56 borrados
  1. 1 1
      src/main/java/com/example/xiaoshiweixinback/business/utils/BatchNoUtil.java
  2. 17 4
      src/main/java/com/example/xiaoshiweixinback/controller/ProductController.java
  3. 12 3
      src/main/java/com/example/xiaoshiweixinback/controller/TicketController.java
  4. 1 0
      src/main/java/com/example/xiaoshiweixinback/domain/Person.java
  5. 1 1
      src/main/java/com/example/xiaoshiweixinback/domain/Product.java
  6. 12 7
      src/main/java/com/example/xiaoshiweixinback/domain/Ticket.java
  7. 1 0
      src/main/java/com/example/xiaoshiweixinback/entity/dto/ProductCategoryDTO.java
  8. 1 6
      src/main/java/com/example/xiaoshiweixinback/entity/dto/ticket/TicketAddDTO.java
  9. 9 0
      src/main/java/com/example/xiaoshiweixinback/entity/dto/ticket/TicketPriceUpDTO.java
  10. 9 0
      src/main/java/com/example/xiaoshiweixinback/entity/dto/ticket/TicketProcessUpDTO.java
  11. 10 0
      src/main/java/com/example/xiaoshiweixinback/entity/dto/ticket/TicketQueryDTO.java
  12. 44 0
      src/main/java/com/example/xiaoshiweixinback/entity/product/ProductAddDTO.java
  13. 1 1
      src/main/java/com/example/xiaoshiweixinback/entity/dto/ProductDTO.java
  14. 1 0
      src/main/java/com/example/xiaoshiweixinback/entity/vo/PersonnelVO.java
  15. 10 0
      src/main/java/com/example/xiaoshiweixinback/entity/vo/TicketVO.java
  16. 3 2
      src/main/java/com/example/xiaoshiweixinback/mapper/ProductMapper.java
  17. 9 4
      src/main/java/com/example/xiaoshiweixinback/service/AssoPersonCategoryService.java
  18. 55 4
      src/main/java/com/example/xiaoshiweixinback/service/AssoProductFileService.java
  19. 1 0
      src/main/java/com/example/xiaoshiweixinback/service/ProductCategoryService.java
  20. 45 6
      src/main/java/com/example/xiaoshiweixinback/service/ProductService.java
  21. 99 1
      src/main/java/com/example/xiaoshiweixinback/service/TicketService.java
  22. 18 16
      src/main/resources/mapper/ProductMapper.xml

+ 1 - 1
src/main/java/com/example/xiaoshiweixinback/business/utils/BatchNoUtil.java

@@ -7,7 +7,7 @@ import java.util.Random;
 
 public class BatchNoUtil {
 
-    private static String getBatchNo(){
+    public static String getBatchNo(){
         // 批次号第一部分:时间
         DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
         String currentTimeStr = dateFormat.format(new Date());

+ 17 - 4
src/main/java/com/example/xiaoshiweixinback/controller/ProductController.java

@@ -4,9 +4,11 @@ package com.example.xiaoshiweixinback.controller;
 import com.example.xiaoshiweixinback.business.common.Constants;
 import com.example.xiaoshiweixinback.business.common.Response;
 import com.example.xiaoshiweixinback.business.common.base.Records;
-import com.example.xiaoshiweixinback.entity.dto.ProductDTO;
+import com.example.xiaoshiweixinback.entity.product.ProductAddDTO;
+import com.example.xiaoshiweixinback.entity.product.ProductDTO;
 import com.example.xiaoshiweixinback.service.ProductService;
 import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.models.security.SecurityScheme;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -19,12 +21,23 @@ import org.springframework.web.bind.annotation.RestController;
 @RestController
 @RequiredArgsConstructor
 public class ProductController {
-private  final ProductService productService;
+    private final ProductService productService;
+
     @Operation(summary = "查询爆款产品")
     @PostMapping("/queryHotProduct")
-    public Response queryHotProduct(@RequestBody ProductDTO productDTO){
-        Records records =productService.queryHotProduct(productDTO);
+    public Response queryHotProduct(@RequestBody ProductDTO productDTO) {
+        Records records = productService.queryHotProduct(productDTO);
         return Response.success(records);
     }
 
+    @Operation(summary = "添加或更新产品")
+    @PostMapping("/addOrUpdateProduct")
+    public Response addOrUpdateProduct(@RequestBody ProductAddDTO productAddDTO) {
+        Records records = new Records();
+        Integer id = productService.addOrUpdateProduct(productAddDTO);
+        records.setData(id);
+        return Response.success(records);
+    }
+
+
 }

+ 12 - 3
src/main/java/com/example/xiaoshiweixinback/controller/TicketController.java

@@ -4,7 +4,7 @@ package com.example.xiaoshiweixinback.controller;
 import com.example.xiaoshiweixinback.business.common.Constants;
 import com.example.xiaoshiweixinback.business.common.Response;
 import com.example.xiaoshiweixinback.business.common.base.Records;
-import com.example.xiaoshiweixinback.entity.dto.ProductDTO;
+import com.example.xiaoshiweixinback.entity.product.ProductDTO;
 import com.example.xiaoshiweixinback.entity.dto.ticket.TicketAddDTO;
 import com.example.xiaoshiweixinback.service.TicketService;
 import io.swagger.v3.oas.annotations.Operation;
@@ -24,8 +24,10 @@ public class TicketController {
     @Operation(summary = "添加工单")
     @PostMapping("/addTicket")
     public Response addTicket(@RequestBody TicketAddDTO ticketAddDTO){
-//        Records records =ticketService.add(productDTO);
-        return Response.success("records");
+        Integer id  =ticketService.addorUpdateTicket(ticketAddDTO);
+        Records records =new Records();
+        records.setData(id);
+        return Response.success(records);
     }
 
 
@@ -33,4 +35,11 @@ public class TicketController {
 //        Records records =productService.queryHotProduct(productDTO);
         return Response.success("records");
     }
+
+    @Operation(summary = "更新工单进度")
+    @PostMapping("/updateTicketProcess")
+    public Response updateTicketProcess(@RequestBody ProductDTO productDTO){
+//        Records records =productService.queryHotProduct(productDTO);
+        return Response.success("records");
+    }
 }

+ 1 - 0
src/main/java/com/example/xiaoshiweixinback/domain/Person.java

@@ -68,4 +68,5 @@ public class Person extends BaseEntity<Person> {
 
     private String openId;
 
+    private Integer personType;
 }

+ 1 - 1
src/main/java/com/example/xiaoshiweixinback/domain/Product.java

@@ -57,7 +57,7 @@ public class Product extends BaseEntity<Product> {
     /**
      *  是否自定义
      */
-    private Integer ifCustomized;
+    private Boolean ifCustomized;
 
     /**
      * 

+ 12 - 7
src/main/java/com/example/xiaoshiweixinback/domain/Ticket.java

@@ -4,15 +4,18 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+
 import java.io.Serializable;
 import java.util.Date;
+
 import lombok.Data;
 
 /**
  * 工单
+ *
  * @TableName ticket
  */
-@TableName(value ="ticket")
+@TableName(value = "ticket")
 @Data
 public class Ticket extends BaseEntity<Ticket> {
     /**
@@ -21,12 +24,12 @@ public class Ticket extends BaseEntity<Ticket> {
     private Integer id;
 
     /**
-     * 
+     *
      */
-    private Integer name;
+    private String name;
 
     /**
-     * 
+     *
      */
     private String contentText;
 
@@ -36,18 +39,20 @@ public class Ticket extends BaseEntity<Ticket> {
     private Integer ticketType;
 
     /**
-     * 
+     *
      */
     private Integer ticketProgress;
 
     /**
-     * 
+     *
      */
     private String createId;
 
     /**
-     * 
+     *
      */
     private Date createTime;
 
+    private Double price;
+    private String num;
 }

+ 1 - 0
src/main/java/com/example/xiaoshiweixinback/entity/dto/ProductCategoryDTO.java

@@ -8,4 +8,5 @@ public class ProductCategoryDTO {
     private Long current;
     private Long size;
     private Integer parentId;
+    private Boolean ifConcern;
 }

+ 1 - 6
src/main/java/com/example/xiaoshiweixinback/entity/dto/ticket/TicketAddDTO.java

@@ -15,7 +15,7 @@ public class TicketAddDTO {
     /**
      *
      */
-    private Integer name;
+    private String name;
 
     /**
      *
@@ -27,10 +27,6 @@ public class TicketAddDTO {
      */
     private Integer ticketType;
 
-    /**
-     *
-     */
-    private Double ticketProgress;
 
     private String num;
 
@@ -43,5 +39,4 @@ public class TicketAddDTO {
      *
      */
     private Date createTime;
-
 }

+ 9 - 0
src/main/java/com/example/xiaoshiweixinback/entity/dto/ticket/TicketPriceUpDTO.java

@@ -0,0 +1,9 @@
+package com.example.xiaoshiweixinback.entity.dto.ticket;
+
+import lombok.Data;
+
+@Data
+public class TicketPriceUpDTO {
+private Integer id;
+private Double price;
+}

+ 9 - 0
src/main/java/com/example/xiaoshiweixinback/entity/dto/ticket/TicketProcessUpDTO.java

@@ -0,0 +1,9 @@
+package com.example.xiaoshiweixinback.entity.dto.ticket;
+
+import lombok.Data;
+
+@Data
+public class TicketProcessUpDTO {
+private Integer id;
+private Integer process;
+}

+ 10 - 0
src/main/java/com/example/xiaoshiweixinback/entity/dto/ticket/TicketQueryDTO.java

@@ -0,0 +1,10 @@
+package com.example.xiaoshiweixinback.entity.dto.ticket;
+
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class TicketQueryDTO {
+
+}

+ 44 - 0
src/main/java/com/example/xiaoshiweixinback/entity/product/ProductAddDTO.java

@@ -0,0 +1,44 @@
+package com.example.xiaoshiweixinback.entity.product;
+
+import lombok.Data;
+import org.joda.time.DateTime;
+
+import java.util.List;
+
+@Data
+public class ProductAddDTO {
+
+    /**
+     * ID
+     */
+    private Integer id;
+
+    /**
+     *
+     */
+    private String name;
+
+    /**
+     *
+     */
+    private String description;
+
+    /**
+     * 检索条件
+     */
+    private String searchCondition;
+
+    /**
+     * 来源
+     */
+    private String sourceFrom;
+
+    /**
+     * 售卖平台
+     */
+    private String sellPlatform;
+
+
+    private List<String> fileGuids;
+
+}

+ 1 - 1
src/main/java/com/example/xiaoshiweixinback/entity/dto/ProductDTO.java

@@ -1,4 +1,4 @@
-package com.example.xiaoshiweixinback.entity.dto;
+package com.example.xiaoshiweixinback.entity.product;
 
 import lombok.Data;
 

+ 1 - 0
src/main/java/com/example/xiaoshiweixinback/entity/vo/PersonnelVO.java

@@ -6,4 +6,5 @@ import lombok.Data;
 public class PersonnelVO {
     private String uuid;
     private Integer id;
+    private Integer personType;
 }

+ 10 - 0
src/main/java/com/example/xiaoshiweixinback/entity/vo/TicketVO.java

@@ -0,0 +1,10 @@
+package com.example.xiaoshiweixinback.entity.vo;
+
+import lombok.Data;
+
+@Data
+public class TicketVO {
+    private String uuid;
+    private Integer id;
+    private Integer personType;
+}

+ 3 - 2
src/main/java/com/example/xiaoshiweixinback/mapper/ProductMapper.java

@@ -4,6 +4,7 @@ import com.example.xiaoshiweixinback.domain.Product;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.example.xiaoshiweixinback.entity.dto.GetProductDTO;
 import com.example.xiaoshiweixinback.entity.vo.ProductVO;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
@@ -17,8 +18,8 @@ import java.util.List;
 @Repository
 public interface ProductMapper extends BaseMapper<Product> {
 
-    public List<ProductVO> getProductByCategory(GetProductDTO getProductDTO);
-    public Long getProductCount(GetProductDTO getProductDTO);
+    public List<ProductVO> getProductByCategory(@Param("getProductDTO") GetProductDTO getProductDTO);
+    public Long getProductCount(@Param("getProductDTO") GetProductDTO getProductDTO);
 }
 
 

+ 9 - 4
src/main/java/com/example/xiaoshiweixinback/service/AssoPersonCategoryService.java

@@ -31,16 +31,21 @@ public class AssoPersonCategoryService extends ServiceImpl<AssoPersonCategoryMap
 
     public List<Integer> getChoosedProductCategoryIds() {
         List<Integer> ids = new ArrayList<>();
-        //PersonnelVO personnelVO =cacheUtil.getLoginUser(loginUtils.getId());
-        PersonnelVO personnelVO = new PersonnelVO();
-        personnelVO.setId(1);
-        personnelVO.setUuid("123");
+        try {
+            //PersonnelVO personnelVO =cacheUtil.getLoginUser(loginUtils.getId());
+            PersonnelVO personnelVO = new PersonnelVO();
+            personnelVO.setId(1);
+            personnelVO.setUuid("123");
         LambdaQueryWrapper<AssoPersonCategory> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(AssoPersonCategory::getPersonUuid, personnelVO.getUuid());
         List<AssoPersonCategory> assoPersonCategories = this.list(queryWrapper);
         if (assoPersonCategories.size() > 0) {
             ids = assoPersonCategories.stream().map(AssoPersonCategory::getProductCategoryId).collect(Collectors.toList());
         }
+        }
+        catch (Exception e){
+            return ids;
+        }
         return ids;
     }
 

+ 55 - 4
src/main/java/com/example/xiaoshiweixinback/service/AssoProductFileService.java

@@ -1,18 +1,69 @@
 package com.example.xiaoshiweixinback.service;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.example.xiaoshiweixinback.domain.AssoPersonCategory;
 import com.example.xiaoshiweixinback.domain.AssoProductFile;
+import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
 import com.example.xiaoshiweixinback.mapper.AssoProductFileMapper;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
-* @author admin
-* @description 针对表【asso_product_file(产品文件关联表)】的数据库操作Service实现
-* @createDate 2024-03-29 15:34:38
-*/
+ * @author admin
+ * @description 针对表【asso_product_file(产品文件关联表)】的数据库操作Service实现
+ * @createDate 2024-03-29 15:34:38
+ */
 @Service
 public class AssoProductFileService extends ServiceImpl<AssoProductFileMapper, AssoProductFile> {
+    @Transactional
+    public void addOrUpdateProductFile(Integer productId, List<String> guids) {
+        if(guids==null){
+            guids=new ArrayList<>();
+        }
+        //PersonnelVO personnelVO =cacheUtil.getLoginUser(loginUtils.getId());
+        PersonnelVO personnelVO = new PersonnelVO();
+        personnelVO.setId(1);
+        personnelVO.setUuid("123");
+
+        LambdaQueryWrapper<AssoProductFile> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(AssoProductFile::getProductId, productId);
+        List<AssoProductFile> assoProductFiles = this.list(queryWrapper);
+        List<String> oldGuids = new ArrayList<>();
+        if (assoProductFiles.size() > 0) {
+            oldGuids = assoProductFiles.stream().map(AssoProductFile::getFileGuid).collect(Collectors.toList());
+        }
+        List<String> addGuids = new ArrayList<>(guids);
+        addGuids.removeAll(oldGuids);
+        List<String> remGuids = new ArrayList<>(oldGuids);
+        remGuids.removeAll(guids);
+        if (remGuids.size() > 0) {
+            LambdaQueryWrapper<AssoProductFile> remWrapper = new LambdaQueryWrapper<>();
+            remWrapper.in(AssoProductFile::getFileGuid, guids);
+            this.remove(remWrapper);
+        }
+
+        List<AssoProductFile> assoProductFileList = new ArrayList<>();
+        if (addGuids.size() > 0) {
+            addGuids.forEach(item -> {
+                AssoProductFile assoProductFile = new AssoProductFile();
+                assoProductFile.setFileGuid(item);
+                assoProductFile.setProductId(productId);
+                assoProductFileList.add(assoProductFile);
+            });
+        }
+        if (assoProductFileList.size() > 0) {
+            this.saveBatch(assoProductFileList);
+        }
+
+        return;
+
 
+    }
 }
 
 

+ 1 - 0
src/main/java/com/example/xiaoshiweixinback/service/ProductCategoryService.java

@@ -45,6 +45,7 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
      * @return
      */
     public Records queryProductCategory(ProductCategoryDTO productCategoryDTO) {
+
         Records records = new Records();
         Long size = productCategoryDTO.getSize();
         Long current = productCategoryDTO.getCurrent();

+ 45 - 6
src/main/java/com/example/xiaoshiweixinback/service/ProductService.java

@@ -1,26 +1,27 @@
 package com.example.xiaoshiweixinback.service;
 
-import co.elastic.clients.elasticsearch._types.aggregations.Aggregation;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.example.xiaoshiweixinback.business.common.base.Records;
 import com.example.xiaoshiweixinback.business.common.base.SystemFile;
+import com.example.xiaoshiweixinback.business.utils.BatchNoUtil;
 import com.example.xiaoshiweixinback.business.utils.CacheUtil;
 import com.example.xiaoshiweixinback.business.utils.LoginUtils;
 import com.example.xiaoshiweixinback.domain.AssoProductFile;
 import com.example.xiaoshiweixinback.domain.Product;
-import com.example.xiaoshiweixinback.domain.ProductCategory;
+import com.example.xiaoshiweixinback.domain.Ticket;
 import com.example.xiaoshiweixinback.entity.dto.GetProductDTO;
-import com.example.xiaoshiweixinback.entity.dto.ProductDTO;
+import com.example.xiaoshiweixinback.entity.product.ProductAddDTO;
+import com.example.xiaoshiweixinback.entity.product.ProductDTO;
 import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
 import com.example.xiaoshiweixinback.entity.vo.ProductVO;
 import com.example.xiaoshiweixinback.mapper.ProductMapper;
 import com.example.xiaoshiweixinback.service.common.FileManagerService;
 import lombok.RequiredArgsConstructor;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -77,7 +78,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
     private void loadProduct(List<ProductVO> productVOS) {
         List<AssoProductFile> assoProductFiles = new ArrayList<>();
         List<String> guids = new ArrayList<>();
-        if (productVOS == null||productVOS.size()==0) {
+        if (productVOS == null || productVOS.size() == 0) {
             return;
         }
         List<Integer> ids = productVOS.stream().map(ProductVO::getId).collect(Collectors.toList());
@@ -118,6 +119,44 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
             }
         }
     }
+
+    @Transactional(rollbackFor = Exception.class)
+    public Integer addOrUpdateProduct(ProductAddDTO productAddDTO) {
+        Product product = new Product();
+        if (productAddDTO.getId() == null) {
+            product = this.addProduct(productAddDTO);
+
+        } else {
+            product = this.updateProduct(productAddDTO);
+        }
+        assoProductFileService.addOrUpdateProductFile(product.getId(), productAddDTO.getFileGuids());
+        return product.getId();
+
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public Product addProduct(ProductAddDTO productAddDTO) {
+        Product product = new Product();
+        BeanUtils.copyProperties(productAddDTO, product);
+        PersonnelVO personnelVO = cacheUtil.getLoginUser(loginUtils.getId());
+        product.setCreateId(personnelVO.getUuid());
+        product.setIfCustomized(true);
+        product.insert();
+        return product;
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public Product updateProduct(ProductAddDTO productAddDTO) {
+        Product product = new Product();
+        product=this.getById(productAddDTO.getId());
+        product.setName(productAddDTO.getName());
+        product.setDescription(productAddDTO.getDescription());
+        product.setSearchCondition(productAddDTO.getSearchCondition());
+        product.setSellPlatform(productAddDTO.getSellPlatform());
+        product.setSourceFrom(productAddDTO.getSourceFrom());
+        product.updateById();
+        return product;
+    }
 }
 
 

+ 99 - 1
src/main/java/com/example/xiaoshiweixinback/service/TicketService.java

@@ -1,11 +1,15 @@
 package com.example.xiaoshiweixinback.service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.example.xiaoshiweixinback.business.utils.BatchNoUtil;
 import com.example.xiaoshiweixinback.business.utils.CacheUtil;
 import com.example.xiaoshiweixinback.business.utils.LoginUtils;
 import com.example.xiaoshiweixinback.domain.Person;
 import com.example.xiaoshiweixinback.domain.Ticket;
 import com.example.xiaoshiweixinback.entity.dto.ticket.TicketAddDTO;
+import com.example.xiaoshiweixinback.entity.dto.ticket.TicketPriceUpDTO;
+import com.example.xiaoshiweixinback.entity.dto.ticket.TicketProcessUpDTO;
+import com.example.xiaoshiweixinback.entity.dto.ticket.TicketQueryDTO;
 import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
 import com.example.xiaoshiweixinback.mapper.TicketMapper;
 import lombok.RequiredArgsConstructor;
@@ -27,14 +31,108 @@ public class TicketService extends ServiceImpl<TicketMapper, Ticket> {
     @Transactional(rollbackFor = Exception.class)
     public Integer addorUpdateTicket(TicketAddDTO ticketAddDTO) {
         Ticket ticket = new Ticket();
+        if (ticketAddDTO.getId() == null) {
+            BeanUtils.copyProperties(ticketAddDTO, ticket);
+            PersonnelVO personnelVO = cacheUtil.getLoginUser(loginUtils.getId());
+            ticket.setCreateId(personnelVO.getUuid());
+            ticket.setTicketProgress(0);
+        String num =    BatchNoUtil.getBatchNo();
+        ticket.setNum(num);
+        } else {
+            ticket = this.getById(ticket.getId());
+            ticket.setName(ticketAddDTO.getName());
+            ticket.setContentText(ticketAddDTO.getContentText());
+        }
+        ticket.insertOrUpdate();
+        return ticket.getId();
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public Integer queryTickets(TicketAddDTO ticketAddDTO) {
+        Ticket ticket = new Ticket();
         BeanUtils.copyProperties(ticketAddDTO, ticket);
         if (ticket.getId() == null) {
-            PersonnelVO personnelVO =cacheUtil.getLoginUser(loginUtils.getId());
+            PersonnelVO personnelVO = cacheUtil.getLoginUser(loginUtils.getId());
             ticket.setCreateId(personnelVO.getUuid());
 
+        } else {
+            Ticket oldTicket = this.getById(ticket.getId());
+            ticket.setCreateId(oldTicket.getCreateId());
+            ticket.setTicketType(oldTicket.getTicketType());
+            ticket.setTicketProgress(oldTicket.getTicketProgress());
+        }
+        ticket.insertOrUpdate();
+        return ticket.getId();
+    }
+
+    /**
+     * 更新工单状态
+     *
+     * @param ticketProcessUpDTO
+     * @return
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public Integer updateProcess(TicketProcessUpDTO ticketProcessUpDTO) {
+        Integer id = ticketProcessUpDTO.getId();
+        Integer process = ticketProcessUpDTO.getProcess();
+        Ticket ticket = this.getById(id);
+
+        Boolean flag = this.ifHavePermission(ticket.getCreateId());
+        if (!flag) {
+            return 0;
+        }
+        ticket.setTicketProgress(process);
+        ticket.updateById();
+        return ticket.getId();
+    }
+
+
+    /**
+     * 更新价格
+     *
+     * @param ticketPriceUpDTO
+     * @return
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public Integer updatePrice(TicketPriceUpDTO ticketPriceUpDTO) {
+        Integer id = ticketPriceUpDTO.getId();
+        Double price = ticketPriceUpDTO.getPrice();
+        Ticket ticket = this.getById(id);
+
+        Boolean flag = this.ifHavePermission(null);
+        if (!flag) {
+            return 0;
+        }
+        ticket.setPrice(price);
+        ticket.updateById();
+        return ticket.getId();
+    }
+
+    /**
+     * 查询我的工单
+     *
+     * @param ticketQueryDTO
+     * @return
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public Integer queryTickets(TicketQueryDTO ticketQueryDTO) {
+        PersonnelVO personnelVO = cacheUtil.getLoginUser(loginUtils.getId());
+        Integer personType = personnelVO.getPersonType();
+        if (personType != null && personType.equals(0)) {
+
         }
         return 1;
     }
+
+    private Boolean ifHavePermission(String id) {
+        PersonnelVO personnelVO = cacheUtil.getLoginUser(loginUtils.getId());
+        personnelVO.getPersonType();
+        if (personnelVO.getPersonType().equals(0) || (id!=null&&personnelVO.getId().equals(id))) {
+            return true;
+        }
+        return false;
+    }
+
 }
 
 

+ 18 - 16
src/main/resources/mapper/ProductMapper.xml

@@ -3,17 +3,19 @@
 <mapper namespace="com.example.xiaoshiweixinback.mapper.ProductMapper">
 
     <select id="getProductByCategory" resultType="com.example.xiaoshiweixinback.entity.vo.ProductVO">
-        select distinct p.id as id,p.name as name,p.description as description,p.sell_platform as sellPlatform,pe.name as createName p.create_time as createTime from product as p left join
-        asso_product_category as apc on p.id =product_id
+        select distinct p.id as id,p.name as name,p.description as description,p.sell_platform as sellPlatform,pe.name
+        as createName ,p.create_time as createTime
+        from product as p
+        left join asso_product_category as apc on p.id =product_id
         left join person as pe on p.create_id =pe.uuid
         <where>
-       p.if_hot = true and p.if_show =true
-        <if test="getProductDTO.name!=null and getProductDTO.name.trim().equal('')">
-           and p.name like CONCAT('%',#{getProductDTO.name},'%')
-        </if>
-            <if test="getProductDTO.getProductByCategory!=null and getProductDTO.getProductByCategory.size()>0">
-              and  apc.product_category_id in
-                <foreach collection="getProductDTO.getProductByCategory" item="item" open="(" close=")" separator=",">
+            p.if_hot = true and p.if_show =true
+            <if test="getProductDTO.name!=null and getProductDTO.name!=''">
+                and p.name like CONCAT('%',#{getProductDTO.name},'%')
+            </if>
+            <if test="getProductDTO.categoryIds!=null and getProductDTO.categoryIds.size()>0">
+                and apc.product_category_id in
+                <foreach collection="getProductDTO.categoryIds" item="item" open="(" close=")" separator=",">
                     #{item}
                 </foreach>
             </if>
@@ -26,22 +28,22 @@
 
 
     <select id="getProductCount" resultType="java.lang.Long">
-      select count(*) from (select distinct p.id as id from product as p left join
+        select count(*) from (select distinct p.id as id from product as p left join
         asso_product_category as apc on p.id =product_id
         left join person as pe on p.create_id =pe.uuid
         <where>
             p.if_hot = true and p.if_show =true
-            <if test="getProductDTO.name!=null and getProductDTO.name.trim().equal('')">
-               and  p.name like CONCAT('%',#{getProductDTO.name},'%')
+            <if test="getProductDTO.name!=null and getProductDTO.name!=''">
+                and p.name like CONCAT('%',#{getProductDTO.name},'%')
             </if>
-            <if test="getProductDTO.getProductByCategory!=null and getProductDTO.getProductByCategory.size()>0">
-                and  apc.product_category_id in
-                <foreach collection="getProductDTO.getProductByCategory" item="item" open="(" close=")" separator=",">
+            <if test="getProductDTO.categoryIds!=null and getProductDTO.categoryIds.size()>0">
+                and apc.product_category_id in
+                <foreach collection="getProductDTO.categoryIds" item="item" open="(" close=")" separator=",">
                     #{item}
                 </foreach>
             </if>
         </where>
-          )  as c
+        ) as c
 
     </select>
 </mapper>