Aslee 2 vuotta sitten
vanhempi
commit
3ecc46ac79

+ 1 - 1
src/main/java/com/caimei/controller/admin/auth/AuthProductApi.java

@@ -166,7 +166,7 @@ public class AuthProductApi {
         if (StringUtils.isEmpty(image)) {
             return ResponseJson.error("参数异常,图片不能为空");
         }
-        return authProductService.saveProductType(productTypeId, authUserId, name, image, createBy);
+        return authProductService.saveProductType(productTypeId, authUserId, name, image, createBy, 1);
     }
 
     @ApiOperation("删除设备分类")

+ 9 - 3
src/main/java/com/caimei/controller/admin/auth/LogisticsApi.java

@@ -2,6 +2,7 @@ package com.caimei.controller.admin.auth;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.aliyuncs.utils.StringUtils;
 import com.caimei.model.ResponseJson;
 import com.caimei.service.auth.LogisticsService;
 import io.swagger.annotations.Api;
@@ -29,16 +30,21 @@ public class LogisticsApi {
 
     @ApiOperation("寄送授权牌")
     @ApiImplicitParam(name = "params", value = "authId:授权id;companyId:物流公司id;logisticsNumber:快递单号;" +
-            "imageList:图片备注列表;remarks:备注", required = true)
+            "imageList:图片备注列表;remarks:备注;mobile:收货人手机号", required = true)
     @PostMapping("/certificate/send")
     public ResponseJson send(@RequestBody String params) {
         JSONObject paramsMap = JSONObject.parseObject(params);
         Integer authId = paramsMap.getInteger("authId");
         Integer companyId = paramsMap.getInteger("companyId");
         String logisticsNumber = paramsMap.getString("logisticsNumber");
-        JSONArray imageList = paramsMap.getJSONArray("imageList");
+        String imageParam = paramsMap.getString("imageList");
+        JSONArray imageList = null;
+        if (StringUtils.isNotEmpty(imageParam)) {
+            imageList = JSONObject.parseArray(imageParam);
+        }
         String remarks = paramsMap.getString("remarks");
-        return logisticsService.sendCertificate(authId, companyId, logisticsNumber, imageList, remarks);
+        String mobile = paramsMap.getString("mobile");
+        return logisticsService.sendCertificate(authId, companyId, logisticsNumber, imageList, remarks, mobile);
     }
 
     @ApiOperation("寄送授权牌物流详情")

+ 1 - 1
src/main/java/com/caimei/controller/wechat/WxAuthApi.java

@@ -241,7 +241,7 @@ public class WxAuthApi {
         auth.setEmpNum(empNum);
         auth.setLogo(logo);
         auth.setCreateBy(createBy);
-        auth.setCreateSource(1);
+        // 机构用户编辑授权
         return authService.saveAuth(auth, bannerList, false, 2);
     }
 

+ 2 - 2
src/main/java/com/caimei/mapper/cmMapper/AuthProductMapper.java

@@ -50,7 +50,7 @@ public interface AuthProductMapper {
 
     void updateImageByProductId(ProductPo product);
 
-    void updateProductAuditStatus(@Param("productId") Integer productId, @Param("status") Integer status, @Param("auditStatus") Integer auditStatus, @Param("invalidReason") String invalidReason, @Param("auditBy") Integer auditBy, @Param("auditTime") Date auditTime);
+    void updateProductAuditStatus(@Param("productId") Integer productId, @Param("productTypeId") Integer productTypeId, @Param("status") Integer status, @Param("auditStatus") Integer auditStatus, @Param("invalidReason") String invalidReason, @Param("auditBy") Integer auditBy, @Param("auditTime") Date auditTime);
 
     List<WxProductListVo> getWxProductList(@Param("listType") Integer listType, @Param("authId") Integer authId, @Param("productTypeId") Integer productTypeId, @Param("snCode") String snCode);
 
@@ -86,7 +86,7 @@ public interface AuthProductMapper {
 
     Integer getProductCountByTypeId(Integer productTypeId);
 
-    void updateProductShopAuditStatus(@Param("productId") Integer productId, @Param("productTypeId") Integer productTypeId, @Param("shopAuditStatus") Integer auditStatus, @Param("shopInvalidReason") String invalidReason, @Param("shopAuditBy") Integer auditBy, @Param("shopAuditTime") Date auditTime);
+    void updateProductShopAuditStatus(@Param("productId") Integer productId, @Param("shopAuditStatus") Integer auditStatus, @Param("shopInvalidReason") String invalidReason, @Param("shopAuditBy") Integer auditBy, @Param("shopAuditTime") Date auditTime);
 
     ProductPo getProductPo(Integer productId);
 

+ 5 - 0
src/main/java/com/caimei/model/po/CertificateLogisticsPo.java

@@ -54,4 +54,9 @@ public class CertificateLogisticsPo {
      * 最后更新时间
      */
     private Date updateDate;
+
+    /**
+     * 认证通机构收货人手机号
+     */
+    private String mobile;
 }

+ 5 - 0
src/main/java/com/caimei/model/po/ProductTypePo.java

@@ -61,4 +61,9 @@ public class ProductTypePo {
      * 创建人Id
      */
     private Integer createBy;
+
+    /**
+     * 创建人Id
+     */
+    private Integer createSource;
 }

+ 1 - 1
src/main/java/com/caimei/service/auth/AuthProductService.java

@@ -124,7 +124,7 @@ public interface AuthProductService {
     /**
      * 保存设备分类
      */
-    ResponseJson<ProductTypePo> saveProductType(Integer productTypeId, Integer authUserId, String name, String image, Integer createBy) throws IOException;
+    ResponseJson<ProductTypePo> saveProductType(Integer productTypeId, Integer authUserId, String name, String image, Integer createBy, Integer createSource) throws IOException;
 
     /**
      * 删除设备分类

+ 1 - 9
src/main/java/com/caimei/service/auth/LogisticsService.java

@@ -2,14 +2,6 @@ package com.caimei.service.auth;
 
 import com.alibaba.fastjson.JSONArray;
 import com.caimei.model.ResponseJson;
-import com.caimei.model.po.CmBrandAuthPo;
-import com.caimei.model.vo.AuthFormVo;
-import com.caimei.model.vo.AuthVo;
-import com.github.pagehelper.PageInfo;
-import org.springframework.web.multipart.MultipartFile;
-
-import javax.servlet.http.HttpServletResponse;
-import java.util.List;
 
 /**
  * Description
@@ -22,7 +14,7 @@ public interface LogisticsService {
     /**
      * 寄送机构授权牌
      */
-    ResponseJson sendCertificate(Integer authId, Integer companyId, String logisticsNumber, JSONArray imageList, String remarks);
+    ResponseJson sendCertificate(Integer authId, Integer companyId, String logisticsNumber, JSONArray imageList, String remarks, String mobile);
 
     /**
      * 寄送授权牌物流详情

+ 7 - 6
src/main/java/com/caimei/service/auth/impl/AuthProductServiceImpl.java

@@ -425,9 +425,6 @@ public class AuthProductServiceImpl implements AuthProductService {
             status = 1;
         }
         if (1 == source) {
-            authProductMapper.updateProductAuditStatus(productId, status, auditStatus, invalidReason, auditBy, auditTime);
-        }
-        if (2 == source) {
             // 获取设备信息
             ProductPo product = authProductMapper.getProductPo(productId);
             Integer productTypeId = product.getProductTypeId();
@@ -438,7 +435,7 @@ public class AuthProductServiceImpl implements AuthProductService {
                 ProductTypePo productType = authProductMapper.getProductType(null, product.getName(), authUserId);
                 if (null == productType) {
                     try {
-                        ResponseJson<ProductTypePo> result = saveProductType(null, authUserId, product.getName(), product.getImage(), null);
+                        ResponseJson<ProductTypePo> result = saveProductType(null, authUserId, product.getName(), product.getImage(), product.getCreateBy(), 2);
                         int code = result.getCode();
                         if (0 == code) {
                             productType = result.getData();
@@ -453,7 +450,10 @@ public class AuthProductServiceImpl implements AuthProductService {
                     productTypeId = productType.getProductTypeId();
                 }
             }
-            authProductMapper.updateProductShopAuditStatus(productId, productTypeId, auditStatus, invalidReason, auditBy, auditTime);
+            authProductMapper.updateProductAuditStatus(productId, productTypeId, status, auditStatus, invalidReason, auditBy, auditTime);
+        }
+        if (2 == source) {
+            authProductMapper.updateProductShopAuditStatus(productId, auditStatus, invalidReason, auditBy, auditTime);
         }
         return ResponseJson.success("审核商品成功");
     }
@@ -493,7 +493,7 @@ public class AuthProductServiceImpl implements AuthProductService {
     }
 
     @Override
-    public ResponseJson<ProductTypePo> saveProductType(Integer productTypeId, Integer authUserId, String name, String image, Integer createBy) throws IOException {
+    public ResponseJson<ProductTypePo> saveProductType(Integer productTypeId, Integer authUserId, String name, String image, Integer createBy, Integer createSource) throws IOException {
         // 是否为添加操作
         boolean insertFlag = null == productTypeId;
         /*
@@ -508,6 +508,7 @@ public class AuthProductServiceImpl implements AuthProductService {
         // 上线状态默认为“待上线”,审核状态为“待审核”
         productType.setStatus(2);
         productType.setAuditStatus(2);
+        productType.setCreateSource(createSource);
         if (insertFlag) {
             // 创建人id
             productType.setCreateBy(createBy);

+ 27 - 14
src/main/java/com/caimei/service/auth/impl/AuthServiceImpl.java

@@ -644,6 +644,7 @@ public class AuthServiceImpl implements AuthService {
                 auth.setAuthUserId(authUserId);
                 auth.setAuthParty(authParty);
                 auth.setCreateBy(createBy);
+                // 导入数据
                 ResponseJson responseJson = saveAuth(auth, null, true, 1);
                 CmBrandAuthPo authPo = (CmBrandAuthPo) responseJson.getData();
                 authId = authPo.getId();
@@ -717,6 +718,7 @@ public class AuthServiceImpl implements AuthService {
                 }
             }
             authPartySheet.setColumnWidth(0, (columnWidth + 4) * 256);
+            List<String> sheetNameList = new ArrayList<>();
 
             // 创建每个机构对应的商品表
             authPartyList.forEach(authParty -> {
@@ -725,6 +727,11 @@ public class AuthServiceImpl implements AuthService {
                 // 商品列表
                 List<ProductFormVo> productList = authParty.getProductList();
                 // 创建商品工作表
+                int k = 1;
+                while (sheetNameList.contains(productSheetName)) {
+                    productSheetName = productSheetName.replace("(" + (k-1) + ")", "") + "(" + k + ")";
+                }
+                sheetNameList.add(productSheetName);
                 HSSFSheet productSheet = workbook.createSheet(productSheetName);
                 // 创建列头行
                 HSSFRow productTopRow = productSheet.createRow(0);
@@ -768,20 +775,26 @@ public class AuthServiceImpl implements AuthService {
 //                            productSheet.addMergedRegion(new CellRangeAddress(j + 1,j + 1,j + 1,j + 1)) ;
                             // 头像
                             String imageUrl = productData.get(j);
-                            String fileType = imageUrl.substring(imageUrl.lastIndexOf(".") + 1);
-                            InputStream imageStream = getImageStream(imageUrl);
-                            if (null != imageStream) {
-                                try {
-                                    BufferedImage bufferedImage = ImageIO.read(imageStream);
-                                    ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
-                                    ImageIO.write(bufferedImage, fileType, byteArrayOut);
-                                    byte[] data = byteArrayOut.toByteArray();
-                                    HSSFPatriarch drawingPatriarch = productSheet.createDrawingPatriarch();
-                                    // 设置图片位置
-                                    HSSFClientAnchor anchor = new HSSFClientAnchor(30, 30, 700, 200, (short) j, productRowNum.get(), (short) j, productRowNum.get());
-                                    drawingPatriarch.createPicture(anchor, workbook.addPicture(data, HSSFWorkbook.PICTURE_TYPE_JPEG));
-                                } catch (Exception e) {
-                                    e.printStackTrace();
+                            if (StringUtils.isNotEmpty(imageUrl)) {
+
+                                String fileType = imageUrl.substring(imageUrl.lastIndexOf(".") + 1);
+                                InputStream imageStream = getImageStream(imageUrl);
+                                if (null != imageStream) {
+                                    try {
+                                        BufferedImage bufferedImage = ImageIO.read(imageStream);
+                                        ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
+                                        ImageIO.write(bufferedImage, fileType, byteArrayOut);
+                                        byte[] data = byteArrayOut.toByteArray();
+                                        HSSFPatriarch drawingPatriarch = productSheet.createDrawingPatriarch();
+                                        // 设置图片位置
+                                        HSSFClientAnchor anchor = new HSSFClientAnchor(30, 30, 700, 200, (short) j, productRowNum.get(), (short) j, productRowNum.get());
+                                        drawingPatriarch.createPicture(anchor, workbook.addPicture(data, HSSFWorkbook.PICTURE_TYPE_JPEG));
+                                    } catch (Exception e) {
+                                        e.printStackTrace();
+                                    }
+                                } else {
+                                    productCell.setCellType(CellType.valueOf("STRING"));
+                                    productCell.setCellValue("");
                                 }
                             } else {
                                 productCell.setCellType(CellType.valueOf("STRING"));

+ 2 - 22
src/main/java/com/caimei/service/auth/impl/LogisticsServiceImpl.java

@@ -1,40 +1,19 @@
 package com.caimei.service.auth.impl;
 
 import com.alibaba.fastjson.JSONArray;
-import com.caimei.config.FastDfsClient;
 import com.caimei.mapper.cmMapper.AuthMapper;
-import com.caimei.mapper.cmMapper.AuthProductMapper;
 import com.caimei.mapper.cmMapper.LogisticsMapper;
 import com.caimei.model.ResponseJson;
-import com.caimei.model.dto.ProductSaveDto;
 import com.caimei.model.po.*;
 import com.caimei.model.vo.*;
 import com.caimei.service.auth.*;
-import com.caimei.utils.ExcelOperateUtil;
-import com.github.pagehelper.PageHelper;
-import com.github.pagehelper.PageInfo;
-import com.github.tobato.fastdfs.service.FastFileStorageClient;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.poi.hssf.usermodel.*;
-import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.xssf.usermodel.*;
-import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
-import javax.imageio.ImageIO;
-import javax.servlet.http.HttpServletResponse;
-import java.awt.image.BufferedImage;
-import java.io.*;
-import java.math.BigDecimal;
-import java.net.HttpURLConnection;
-import java.net.URL;
 import java.util.*;
-import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * Description
@@ -59,7 +38,7 @@ public class LogisticsServiceImpl implements LogisticsService {
     private String imageDomain;
 
     @Override
-    public ResponseJson sendCertificate(Integer authId, Integer companyId, String logisticsNumber, JSONArray imageList, String remarks) {
+    public ResponseJson sendCertificate(Integer authId, Integer companyId, String logisticsNumber, JSONArray imageList, String remarks, String mobile) {
         List<LogisticsCompanyVo> logisticsCompanyList = logisticsMapper.getLogisticsCompanyList(companyId);
         if (null == logisticsCompanyList || logisticsCompanyList.size() == 0) {
             return ResponseJson.error("物流公司不存在");
@@ -83,6 +62,7 @@ public class LogisticsServiceImpl implements LogisticsService {
         logistics.setType(4);
         logistics.setState(1);
         logistics.setUpdateDate(new Date());
+        logistics.setMobile(mobile);
         logisticsMapper.sendCertificate(logistics);
         // 更改机构寄送状态
         authMapper.updateSendStatus(authId);

+ 22 - 18
src/main/resources/mapper/AuthProductMapper.xml

@@ -6,20 +6,20 @@
                                           `originalCertificateImage`, `certificateImage`, `pcCertificateImage`,
                                           `appletsCertificateImage`, `addQrCodeFlag`, `addTemplateType`,
                                           purchaseWay, invoiceImage, `status`,
-                                          `auditStatus`, shopAuditStatus, `createTime`, `createBy`)
+                                          `auditStatus`, shopAuditStatus, `createTime`, `createBy`, createSource)
         values (#{authId}, #{brandId}, #{productTypeId}, #{snCode}, #{name}, #{image},
                 #{originalCertificateImage}, #{certificateImage}, #{pcCertificateImage},
                 #{appletsCertificateImage}, #{addQrCodeFlag}, #{addTemplateType},
                 #{purchaseWay}, #{invoiceImage}, #{status},
-                #{auditStatus}, #{shopAuditStatus}, #{createTime}, #{createBy})
+                #{auditStatus}, #{shopAuditStatus}, #{createTime}, #{createBy}, #{createSource})
     </insert>
     <insert id="insertProductParam">
         insert into cm_brand_product_param (`productId`, `name`, `content`)
         values (#{productId}, #{paramName}, #{paramContent})
     </insert>
     <insert id="insertProductType" keyColumn="id" keyProperty="productTypeId" useGeneratedKeys="true" parameterType="com.caimei.model.po.ProductTypePo">
-        insert into cm_brand_product_type (authUserId, name, image, pcImage, appletsImage, status, auditStatus, createBy, createTime, delFlag)
-        values (#{authUserId}, #{name}, #{image}, #{pcImage}, #{appletsImage}, #{status}, #{auditStatus}, #{createBy}, #{createTime}, 0)
+        insert into cm_brand_product_type (authUserId, name, image, pcImage, appletsImage, status, auditStatus, createBy, createSource, createTime, delFlag)
+        values (#{authUserId}, #{name}, #{image}, #{pcImage}, #{appletsImage}, #{status}, #{auditStatus}, #{createBy}, #{createSource}, #{createTime}, 0)
     </insert>
 
     <update id="updateProductStatusByProductId">
@@ -67,11 +67,16 @@
     </update>
     <update id="updateProductAuditStatus">
         update cm_brand_auth_product
-        set status        = #{status},
-            auditStatus   = #{auditStatus},
-            invalidReason = #{invalidReason},
-            auditBy       = #{auditBy},
-            auditTime     = #{auditTime}
+        set status = #{status},
+        auditStatus = #{auditStatus},
+        invalidReason = #{invalidReason},
+        auditBy = #{auditBy},
+        <if test="productTypeId != null">
+            productTypeId = #{productTypeId},
+            name = null,
+            image = null,
+        </if>
+        auditTime = #{auditTime}
         where id = #{productId}
     </update>
     <update id="updateCertificateImage">
@@ -125,11 +130,6 @@
             auditStatus = #{shopAuditStatus},
         </if>
         shopInvalidReason = #{shopInvalidReason},
-        <if test="productTypeId != null">
-            productTypeId = #{productTypeId},
-            name = null,
-            image = null,
-        </if>
         shopAuditBy = #{shopAuditBy},
         shopAuditTime = #{shopAuditTime}
         where id = #{productId}
@@ -276,12 +276,14 @@
         select id from cm_brand where name = #{brand}
     </select>
     <select id="getAuthProductList" resultType="com.caimei.model.vo.ProductFormVo">
-        select p.id as productId,t.name as productName,snCode,cb.name as brandName,t.image as productImage,certificateImage
+        select p.id as productId,
+               if(p.productTypeId is null,p.name,t.name) as productName,snCode,cb.name as brandName,
+               if(p.productTypeId is null,p.image,t.image) as productImage,certificateImage
         from cm_brand_auth_product p
         left join cm_brand_product_type t on p.productTypeId = t.id and t.delFlag = 0
         left join cm_brand cb on p.brandId = cb.id
         where authId = #{authId}
-        order by createTime desc
+        order by p.createTime desc
     </select>
     <select id="getAuthProductByProductId" resultType="com.caimei.module.base.entity.vo.AuthProductVo">
         select t.name       as productName,
@@ -343,11 +345,13 @@
         order by p.createTime desc
     </select>
     <select id="getProductTypeList" resultType="com.caimei.model.vo.ProductTypeListVo">
-        select id as productTypeId,t.name,t.image,t.status,t.auditStatus,t.createTime,cu.name as createBy,
+        select t.id as productTypeId,t.name,t.image,t.status,t.auditStatus,t.createTime,
+        if(t.createSource = 1,cu.name,cbcu.mobile) as createBy,
         au.name as auditBy,t.auditTime,t.invalidReason
         from cm_brand_product_type t
         left join cm_brand_auth_user cu on t.createBy = cu.authUserId
         left join cm_brand_auth_user au on t.auditBy = au.authUserId
+        left join cm_brand_club_user cbcu on t.createBy = cbcu.id
         where t.authUserId = #{authUserId} and t.delFlag = 0
         <if test="name != null and name != ''">
             and t.name like CONCAT('%',#{name},'%')
@@ -397,7 +401,7 @@
         select count(*) from cm_brand_auth_product where productTypeId = #{productTypeId}
     </select>
     <select id="getProductPo" resultType="com.caimei.model.po.ProductPo">
-        select id as productId, productTypeId, name, image
+        select id as productId, productTypeId, name, image, createBy
         from cm_brand_auth_product
         where id = #{productId}
     </select>

+ 2 - 2
src/main/resources/mapper/LogisticsMapper.xml

@@ -3,9 +3,9 @@
 <mapper namespace="com.caimei.mapper.cmMapper.LogisticsMapper">
     <insert id="sendCertificate">
         insert into logistics_information (type, authId, nu, state, logisticsCompanyName, logisticsCompanyCode,
-                                           updateDate, remarks, remarksImage)
+                                           updateDate, remarks, remarksImage, mobile)
         values (#{type}, #{authId}, #{logisticsNumber}, #{state}, #{companyName}, #{companyCode}, #{updateDate},
-                #{remarks}, #{remarksImage})
+                #{remarks}, #{remarksImage}, #{mobile})
     </insert>
     <select id="getCertificateLogistics" resultType="com.caimei.model.vo.CertificateLogisticsVo">
         select a.authParty, logisticsCompanyName as companyName, logisticsCompanyCode as companyCode, nu as logisticsNumber,