Browse Source

Merge remote-tracking branch 'origin/xiaoman' into xiaoman

openHj 1 năm trước cách đây
mục cha
commit
866cfdaf3f

+ 4 - 1
hx-customer/src/main/java/com/fjhx/customer/entity/xiaoman/po/XiaomanCustomerInfoJson.java

@@ -1,5 +1,7 @@
 package com.fjhx.customer.entity.xiaoman.po;
 
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
 import com.ruoyi.common.core.domain.BaseIdPo;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Getter;
@@ -16,11 +18,12 @@ import lombok.Setter;
 @Getter
 @Setter
 @TableName("xiaoman_customer_info_json")
-public class XiaomanCustomerInfoJson extends BaseIdPo {
+public class XiaomanCustomerInfoJson {
 
     /**
      * 公司客户ID
      */
+    @TableId(value = "company_id", type = IdType.ASSIGN_ID)
     private Long companyId;
 
     /**

+ 17 - 1
hx-customer/src/main/java/com/fjhx/customer/entity/xiaoman/vo/CustomerInfoVo.java

@@ -223,7 +223,7 @@ public class CustomerInfoVo {
         private String post;
 
         @JsonProperty("image_list")
-        private List<String> imageList;
+        private List<ImageInfo> imageList;
 
         @JsonProperty("contact")
         private List<String> contact;
@@ -239,5 +239,21 @@ public class CustomerInfoVo {
 
     }
 
+    @Data
+    public static class ImageInfo {
+        @JsonProperty("file_id")
+        private long fileId;
+
+        @JsonProperty("file_name")
+        private String fileName;
+
+        @JsonProperty("file_size")
+        private String fileSize;
 
+        @JsonProperty("file_path")
+        private String filePath;
+
+        @JsonProperty("file_preview_url")
+        private String filePreviewUrl;
+    }
 }

+ 14 - 1
hx-customer/src/main/java/com/fjhx/customer/handle/HandleXiaomanData.java

@@ -54,18 +54,31 @@ public class HandleXiaomanData {
         }
     }
 
+    /**
+     * 处理-小满用户
+     * @param res
+     * @param allCustomer
+     * @return
+     */
     public static CustomerListApiVo handleAllCustomer(String res,Set<Long> allCustomer){
         //反序列化对象
         CustomerListApiVo customerListApiVo = handleDate(res, new TypeReference<R<CustomerListApiVo>>() { });
         //判断列表是否为空
         if (!customerListApiVo.getList().isEmpty()){
+            //保存或修改
             xiaomanCustomerService.handleSaveOrUpdate(customerListApiVo.getList(),allCustomer);
         }
         return customerListApiVo;
     }
 
 
-
+    /**
+     * 反序列化
+     * @param res
+     * @param typeReference
+     * @param <T>
+     * @return
+     */
     public static <T> T handleDate(String res, TypeReference<R<T>> typeReference) {
         ObjectMapper objectMapper = new ObjectMapper();
         try {

+ 1 - 1
hx-customer/src/main/java/com/fjhx/customer/service/xiaoman/XiaomanCustomerInfoJsonService.java

@@ -16,7 +16,7 @@ import com.fjhx.customer.entity.xiaoman.dto.XiaomanCustomerInfoJsonDto;
  * @author lqh
  * @since 2024-04-06
  */
-public interface XiaomanCustomerInfoJsonService extends BaseService<XiaomanCustomerInfoJson> {
+public interface XiaomanCustomerInfoJsonService  {
 
     /**
      * 小满客户详情表分页

+ 3 - 1
hx-customer/src/main/java/com/fjhx/customer/service/xiaoman/impl/XiaomanCustomerInfoJsonServiceImpl.java

@@ -12,6 +12,8 @@ import com.ruoyi.common.utils.wrapper.IWrapper;
 import com.fjhx.customer.entity.xiaoman.dto.XiaomanCustomerInfoJsonDto;
 import cn.hutool.core.bean.BeanUtil;
 
+import static com.ruoyi.common.utils.wrapper.IWrapper.getWrapper;
+
 
 /**
  * <p>
@@ -27,7 +29,7 @@ public class XiaomanCustomerInfoJsonServiceImpl extends ServiceImpl<XiaomanCusto
     @Override
     public Page<XiaomanCustomerInfoJsonVo> getPage(XiaomanCustomerInfoJsonSelectDto dto) {
         IWrapper<XiaomanCustomerInfoJson> wrapper = getWrapper();
-        wrapper.orderByDesc("xcij", XiaomanCustomerInfoJson::getId);
+        wrapper.orderByDesc("xcij", XiaomanCustomerInfoJson::getCompanyId);
         Page<XiaomanCustomerInfoJsonVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
         return page;
     }

+ 22 - 8
hx-customer/src/main/java/com/fjhx/customer/service/xiaoman/impl/XiaomanCustomerServiceImpl.java

@@ -1,9 +1,13 @@
 package com.fjhx.customer.service.xiaoman.impl;
 
+import com.fasterxml.jackson.core.type.TypeReference;
 import com.fjhx.customer.entity.xiaoman.po.XiaomanCustomer;
 import com.fjhx.customer.entity.xiaoman.po.XiaomanCustomerInfoJson;
 import com.fjhx.customer.entity.xiaoman.vo.CustomerApiVo;
+import com.fjhx.customer.entity.xiaoman.vo.CustomerInfoVo;
 import com.fjhx.customer.entity.xiaoman.vo.CustomerListApiVo;
+import com.fjhx.customer.handle.HandleXiaomanData;
+import com.fjhx.customer.handle.R;
 import com.fjhx.customer.mapper.xiaoman.XiaomanCustomerMapper;
 import com.fjhx.customer.service.xiaoman.XiaomanCustomerInfoJsonService;
 import com.fjhx.customer.service.xiaoman.XiaomanCustomerService;
@@ -15,6 +19,7 @@ import com.fjhx.customer.entity.xiaoman.dto.XiaomanCustomerSelectDto;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import com.fjhx.customer.entity.xiaoman.dto.XiaomanCustomerDto;
 import cn.hutool.core.bean.BeanUtil;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
@@ -35,7 +40,7 @@ import static com.ruoyi.common.utils.wrapper.IWrapper.getWrapper;
 public class XiaomanCustomerServiceImpl extends ServiceImpl<XiaomanCustomerMapper, XiaomanCustomer> implements XiaomanCustomerService {
 
     @Resource
-    private XiaomanCustomerInfoJsonService xiaomanCustomerInfoJsonService;
+    private XiaomanCustomerInfoJsonServiceImpl xiaomanCustomerInfoJsonService;
 
     @Override
     public List<XiaomanCustomerVo> getList(XiaomanCustomerSelectDto dto) {
@@ -76,26 +81,35 @@ public class XiaomanCustomerServiceImpl extends ServiceImpl<XiaomanCustomerMappe
     }
 
     @Override
+    @Transactional
     public void handleSaveOrUpdate(List<CustomerApiVo> customerApiVoList, Set<Long> allCustomer) {
         List<XiaomanCustomer> xiaomanCustomerList = new ArrayList<>(customerApiVoList);
-
         for (XiaomanCustomer customer : xiaomanCustomerList){
             if (allCustomer.contains(customer.getCompanyId())){
                 updateById(customer);
                 //TODO 获取详情
-
+                String customerDetailJson = HandleXiaomanData.getCustomerDetail(customer.getCompanyId());
                 XiaomanCustomerInfoJson xiaomanCustomerInfoJson = new XiaomanCustomerInfoJson();
-                xiaomanCustomerInfoJsonService.save(xiaomanCustomerInfoJson);
+                xiaomanCustomerInfoJson.setCompanyId(customer.getCompanyId());
+                xiaomanCustomerInfoJson.setJson(customerDetailJson);
+                xiaomanCustomerInfoJsonService.updateById(xiaomanCustomerInfoJson);
                 //TODO 更新数据
-
+                CustomerInfoVo infoVo = HandleXiaomanData.handleDate(customerDetailJson, new TypeReference<R<CustomerInfoVo>>() {
+                });
+                System.out.println("1");
             }else {
                 save(customer);
                 //TODO 获取详情
-
+                String customerDetailJson = HandleXiaomanData.getCustomerDetail(customer.getCompanyId());
+                XiaomanCustomerInfoJson xiaomanCustomerInfoJson = new XiaomanCustomerInfoJson();
+                xiaomanCustomerInfoJson.setCompanyId(customer.getCompanyId());
+                xiaomanCustomerInfoJson.setJson(customerDetailJson);
+                xiaomanCustomerInfoJsonService.save(xiaomanCustomerInfoJson);
 
                 //TODO 更新数据
-
-
+                CustomerInfoVo infoVo = HandleXiaomanData.handleDate(customerDetailJson, new TypeReference<R<CustomerInfoVo>>() {
+                });
+                System.out.println("2");
             }