Przeglądaj źródła

bugfix-机构授权牌生成

Aslee 3 lat temu
rodzic
commit
7987479da5

+ 6 - 0
pom.xml

@@ -314,6 +314,12 @@
             <version>0.9.1</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.twelvemonkeys.imageio</groupId>
+            <artifactId>imageio-jpeg</artifactId>
+            <version>3.4.1</version>
+        </dependency>
+
     </dependencies>
 
     <profiles>

+ 0 - 4
src/main/java/com/caimei/controller/admin/auth/AuthTemplateApi.java

@@ -83,10 +83,6 @@ public class AuthTemplateApi {
                 return ResponseJson.error("模板图片不能为空");
             }
         }
-        if (StringUtils.isEmpty(qrPosition)) {
-            // 默认左上角
-            qrPosition = "0,0";
-        }
         return authTemplateService.saveTemplate(templateId, templateImage, authUserId, status, qrPosition, qrSize, logoSize, authFlag, productFlag);
     }
 

+ 1 - 1
src/main/java/com/caimei/mapper/cmMapper/AuthTemplateMapper.java

@@ -24,7 +24,7 @@ public interface AuthTemplateMapper {
 
     void insertTemplate(@Param("templateImage") String templateImage, @Param("authUserId") Integer authUserId, @Param("templateSize") String templateSize, @Param("qrPosition") String qrPosition, @Param("qrSize") Integer qrSize, @Param("logoSize") String logoSize);
 
-    void updateSelective(@Param("templateId") Integer templateId, @Param("templateImage") String templateImage, @Param("authUserId") Integer authUserId, @Param("status") Integer status, @Param("qrPosition") String qrPosition, @Param("qrSize") Integer qrSize, String logoSize, @Param("authFlag") Integer authFlag, @Param("productFlag") Integer productFlag);
+    void updateSelective(@Param("templateId") Integer templateId, @Param("templateImage") String templateImage, @Param("templateSize") String templateSize, @Param("authUserId") Integer authUserId, @Param("status") Integer status, @Param("qrPosition") String qrPosition, @Param("qrSize") Integer qrSize, String logoSize, @Param("authFlag") Integer authFlag, @Param("productFlag") Integer productFlag);
 
     void clearAuthFlag(Integer authUserId);
 

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

@@ -395,7 +395,7 @@ public class AuthServiceImpl implements AuthService {
                 map.put("addWord1_style", Font.BOLD);
                 map.put("addWord1_size", (int) Math.round(90 * rate));
                 map.put("addWord1_x", (int) Math.round(2168 * rate));
-                map.put("addWord1_y", (int) Math.round(3150 * rate));
+                map.put("addWord1_y", (int) Math.round(3165 * rate));
             }
             // 添加认证日期信息
             if (null != auth.getAuthDate()) {
@@ -406,7 +406,7 @@ public class AuthServiceImpl implements AuthService {
                 map.put("addWord2_style", Font.PLAIN);
                 map.put("addWord2_size", (int) Math.round(90 * rate));
                 map.put("addWord2_x", (int) Math.round(2085 * rate));
-                map.put("addWord2_y", (int) Math.round(3277 * rate));
+                map.put("addWord2_y", (int) Math.round(3292 * rate));
             }
             // 添加二维码信息
             if (StringUtils.isNotEmpty(template.getQrPosition())) {

+ 21 - 5
src/main/java/com/caimei/service/auth/impl/AuthTemplateServiceImpl.java

@@ -7,6 +7,7 @@ import com.caimei.service.auth.AuthTemplateService;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -45,9 +46,10 @@ public class AuthTemplateServiceImpl implements AuthTemplateService {
     @Override
     public ResponseJson saveTemplate(Integer templateId, String templateImage, Integer authUserId, Integer status, String qrPosition, Integer qrSize, String logoSize, Integer authFlag, Integer productFlag) {
         boolean insertFlag = null == templateId;
-        if (insertFlag) {
-            Integer width = null;
-            Integer height = null;
+        Integer width = null;
+        Integer height = null;
+        String templateSize = null;
+        if (StringUtils.isNotEmpty(templateImage)) {
             try {
                 BufferedImage image = ImageIO.read(new URL(templateImage));
                 width = image.getWidth();
@@ -55,16 +57,30 @@ public class AuthTemplateServiceImpl implements AuthTemplateService {
             } catch (Exception e) {
                 e.printStackTrace();
             }
-            String templateSize = (null == width ? 0 : width) + "," + (null == height ? 0 : height);
+            templateSize = (null == width ? 0 : width) + "," + (null == height ? 0 : height);
+        }
+        if (insertFlag) {
+            if (StringUtils.isEmpty(qrPosition)) {
+                // 默认左上角
+                qrPosition = "0,0";
+            }
             authTemplateMapper.insertTemplate(templateImage, authUserId, templateSize, qrPosition, qrSize, logoSize);
         } else {
+            TemplateVo dbTemplate = authTemplateMapper.getTemplateFormData(templateId, null, null, null, null);
             if (null != authFlag && 1 == authFlag) {
                 authTemplateMapper.clearAuthFlag(authUserId);
             }
             if (null != productFlag && 1 == productFlag) {
                 authTemplateMapper.clearProductFlag(authUserId);
             }
-            authTemplateMapper.updateSelective(templateId, templateImage, authUserId, status, qrPosition, qrSize, logoSize, authFlag, productFlag);
+            if (null != dbTemplate) {
+                if (null != authUserId && !dbTemplate.getAuthUserId().equals(authUserId)) {
+                    // 更新了供应商,不选中位置
+                    authFlag = 0;
+                    productFlag = 0;
+                }
+                authTemplateMapper.updateSelective(templateId, templateImage, templateSize, authUserId, status, qrPosition, qrSize, logoSize, authFlag, productFlag);
+            }
         }
         return ResponseJson.success();
     }

+ 9 - 6
src/main/resources/mapper/AuthTemplateMapper.xml

@@ -8,12 +8,15 @@
     <update id="updateSelective">
         update cm_brand_auth_template
         <set>
-            <if test="authUserId != null and null == authFlag and null == productFlag">
-                authUserId = #{authUserId}, authFlag = 0, productFlag = 0,
+            <if test="authUserId != null">
+                authUserId = #{authUserId},
             </if>
             <if test="templateImage != null and templateImage != ''">
                 templateImage = #{templateImage},
             </if>
+            <if test="templateSize != null and templateSize != ''">
+                templateSize = #{templateSize},
+            </if>
             <if test="status != null">
                 status = #{status},
             </if>
@@ -26,11 +29,11 @@
             <if test="logoSize != null and logoSize != ''">
                 logoSize = #{logoSize},
             </if>
-            <if test="authFlag != null and authFlag == 1">
-                authFlag = 1,
+            <if test="authFlag != null">
+                authFlag = #{authFlag},
             </if>
-            <if test="productFlag != null and productFlag == 1">
-                productFlag = 1,
+            <if test="productFlag != null">
+                productFlag = #{productFlag},
             </if>
         </set>
         where id = #{templateId}

+ 1 - 1
src/main/resources/mapper/ClubMapper.xml

@@ -99,7 +99,7 @@
         <if test="townId != null">
             and a.townId = #{townId}
         </if>
-        order by distance
+        order by if(a.authImage is not null,1,0) desc, distance
     </select>
     <select id="checkMobile" resultType="java.lang.Integer">
         select cu.id as clubUserId from cm_brand_club_user cu