Browse Source

Merge branch 'dev' into 'mp-server-test'

Dev

See merge request quanshu/mp-server!61
zhong chunping 3 năm trước cách đây
mục cha
commit
6d45c4c964

+ 2 - 1
mp-admin/src/main/java/com/qs/mp/web/controller/api/admin/ChannelMgrController.java

@@ -11,6 +11,7 @@ import com.qs.mp.channel.service.IChannelUserRelService;
 import com.qs.mp.common.constant.UserConstants;
 import com.qs.mp.common.core.domain.AjaxResult;
 import com.qs.mp.common.core.page.TableDataInfo;
+import com.qs.mp.common.enums.ChannelRoleEnum;
 import com.qs.mp.common.enums.ErrorCodeEnum;
 import com.qs.mp.system.domain.SysUser;
 import com.qs.mp.system.service.ISysUserService;
@@ -187,7 +188,7 @@ public class ChannelMgrController extends BaseApiController {
 		}
 		// 3.插入数据
 		try {
-			channelService.saveChannel(channel,"channel");
+			channelService.saveChannel(channel,ChannelRoleEnum.CHANNEL);
 		} catch (Exception e) {
 			return AjaxResult.error("渠道'" + channel.getName() + "'新增失败" + e.getMessage());
 		}

+ 2 - 1
mp-admin/src/main/java/com/qs/mp/web/controller/api/admin/CouponMgrController.java

@@ -11,6 +11,7 @@ import com.qs.mp.channel.service.IChannelUserRelService;
 import com.qs.mp.common.constant.UserConstants;
 import com.qs.mp.common.core.domain.AjaxResult;
 import com.qs.mp.common.core.page.TableDataInfo;
+import com.qs.mp.common.enums.ChannelRoleEnum;
 import com.qs.mp.common.enums.ErrorCodeEnum;
 import com.qs.mp.system.domain.SysUser;
 import com.qs.mp.system.service.ISysUserService;
@@ -136,7 +137,7 @@ public class CouponMgrController extends BaseApiController {
 		}
 		// 3.插入数据
 		try {
-			channelService.saveChannel(channel,"channel");
+			channelService.saveChannel(channel,ChannelRoleEnum.CHANNEL);
 		} catch (Exception e) {
 			return AjaxResult.error("渠道'" + channel.getName() + "'新增失败" + e.getMessage());
 		}

+ 2 - 1
mp-admin/src/main/java/com/qs/mp/web/controller/api/admin/SaleSiteMgrController.java

@@ -11,6 +11,7 @@ import com.qs.mp.channel.service.IChannelUserRelService;
 import com.qs.mp.common.constant.UserConstants;
 import com.qs.mp.common.core.domain.AjaxResult;
 import com.qs.mp.common.core.page.TableDataInfo;
+import com.qs.mp.common.enums.ChannelRoleEnum;
 import com.qs.mp.common.enums.ErrorCodeEnum;
 import com.qs.mp.system.domain.SysUser;
 import com.qs.mp.system.service.ISysUserService;
@@ -140,7 +141,7 @@ public class SaleSiteMgrController extends BaseApiController {
 		}
 		// 3.插入数据
 		try {
-			channelService.saveChannel(channel,"channel");
+			channelService.saveChannel(channel,ChannelRoleEnum.SALESITE);
 		} catch (Exception e) {
 			return AjaxResult.error("经销商'" + channel.getName() + "'新增失败" + e.getMessage());
 		}

+ 7 - 3
mp-admin/src/main/java/com/qs/mp/web/controller/api/channel/ChannelInviteController.java

@@ -75,6 +75,10 @@ public class ChannelInviteController extends BaseApiController {
 	@PostMapping("invite/generate")
 	public AjaxResult listChannel(@RequestBody  JSONObject jsonObject) {
 		Long channelId = SecurityUtils.getLoginUser().getChannelId();
+		Channel channel = channelService.getById(channelId);
+		if (StringUtils.isNotBlank(channel.getInvitePic())){
+			return AjaxResult.success(channel.getChannelId());
+		}
 		String type = jsonObject.getString("type");
 		String rst = wxUrlLinkService.generateCode("", "id=" + channelId + ",type=" + type);
 		return AjaxResult.success(rst);
@@ -101,11 +105,11 @@ public class ChannelInviteController extends BaseApiController {
 		// 创建经销商
 		Channel channel = new Channel();
 		channel.setChannelNo(parent.getChannelNo() + ".");
-		if (ChannelRoleEnum.CHANNEL.getValue().equals(param.getType())) {
+		//if (ChannelRoleEnum.CHANNEL.getValue().equals(param.getType())) {
 			channel.setLevel(0);
-		} else if (ChannelRoleEnum.SALESITE.getValue().equals(param.getType())) {
+		/*} else if (ChannelRoleEnum.SALESITE.getValue().equals(param.getType())) {
 			channel.setLevel(parent.getLevel() + 1);
-		}
+		}*/
 		channel.setParentId(parent.getChannelId());
 		channel.setMobile(param.getMobile());
 		channel.setName(param.getMobile());

+ 8 - 7
mp-common/src/main/java/com/qs/mp/common/utils/http/HttpUtils.java

@@ -187,7 +187,7 @@ public class HttpUtils
      * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
      * @return 所代表远程资源的响应结果
      */
-    public static String sendImagePost(String url, String param)
+    public static InputStream sendImagePost(String url, String param)
     {
         PrintWriter out = null;
         InputStream in = null;
@@ -209,7 +209,8 @@ public class HttpUtils
             out.print(param);
             out.flush();
             in = conn.getInputStream();
-            byte[] data = null;
+            return in;
+            /*byte[] data = null;
             // 读取图片字节数组
             ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
             byte[] buff = new byte[100];
@@ -218,7 +219,7 @@ public class HttpUtils
                 swapStream.write(buff, 0, rc);
             }
             data = swapStream.toByteArray();
-            return new String(Base64.encodeBase64(data));
+            return new String(Base64.encodeBase64(data));*/
         }
         catch (ConnectException e)
         {
@@ -244,17 +245,17 @@ public class HttpUtils
                 {
                     out.close();
                 }
-                if (in != null)
+                /*if (in != null)
                 {
                     in.close();
-                }
+                }*/
             }
-            catch (IOException ex)
+            catch (Exception ex)
             {
                 log.error("调用in.close Exception, url=" + url + ",param=" + param, ex);
             }
         }
-        return result;
+        return null;
     }
 
     public static String sendSSLPost(String url, String param)

+ 6 - 0
mp-service/src/main/java/com/qs/mp/channel/domain/Channel.java

@@ -173,6 +173,12 @@ public class Channel implements Serializable {
   @TableField("memo")
   private String memo;
 
+  /**
+   * 邀请码图片
+   */
+  @TableField("invite_pic")
+  private String invitePic;
+
   /**
    * 状态,启用、停用
    */

+ 27 - 7
mp-service/src/main/java/com/qs/mp/framework/service/impl/WxUrlLinkServiceImpl.java

@@ -2,12 +2,17 @@ package com.qs.mp.framework.service.impl;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.qs.mp.common.exception.ServiceException;
+import com.qs.mp.common.qcloud.QcloudFileUtils;
 import com.qs.mp.common.utils.LogUtil;
+import com.qs.mp.common.utils.UUIDUtils;
 import com.qs.mp.common.utils.http.HttpUtils;
 import com.qs.mp.framework.service.IAppTokenService;
 import com.qs.mp.framework.service.IWxUrlLinkService;
+import java.io.InputStream;
 import java.util.HashMap;
 import java.util.Map;
+import org.apache.http.entity.ContentType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -31,6 +36,12 @@ public class WxUrlLinkServiceImpl implements IWxUrlLinkService {
   @Value("${wx-channel.appId}")
   private String channelAppId;
 
+  /**
+   * 公开
+   */
+  @Value("${cloud.public-bucket-name}")
+  private String publicBucketName;
+
   @Override
   public String generate(String path, String query) {
     Map<String, Object> param = new HashMap<String, Object>();
@@ -66,16 +77,25 @@ public class WxUrlLinkServiceImpl implements IWxUrlLinkService {
     param.put("env_version", "trial");
     // 获取access_token
     String accessToken = appTokenService.getAccessToken(channelAppId);
-    String res = HttpUtils.sendImagePost(
+    InputStream in = HttpUtils.sendImagePost(
         "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + accessToken,
         JSON.toJSONString(param));
-    LogUtil.info(logger, "小程序链接获取,path:{0},scene:{1},res:{2}",
-        new Object[]{path, scene, res});
-    JSONObject jsonObject = JSON.parseObject(res);
-    if (jsonObject.getIntValue("errcode") != 0) {
-      LogUtil.error(logger, "小程序码获取错误,res:{0}", res);
+    LogUtil.info(logger, "小程序链接获取,path:{0},scene:{1}",
+        new Object[]{path, scene});
+//    JSONObject jsonObject = JSON.parseObject(res);
+    if (null == in) {
+      LogUtil.error(logger, "小程序码获取错误");
+      return null;
+    }
+    // 上传图片
+    String uuid = UUIDUtils.newId();
+    try {
+
+      QcloudFileUtils.putStream(in, uuid, publicBucketName, ContentType.IMAGE_JPEG.getMimeType());
+    } catch (Exception e) {
+      LogUtil.error(logger, e, "小程序码获取错误");
       return null;
     }
-    return res;
+    return uuid;
   }
 }

+ 2 - 1
mp-service/src/main/resources/mapper/channel/ChannelMapper.xml

@@ -28,6 +28,7 @@
         <result column="biz_license_pic" property="bizLicensePic" />
         <result column="door_pic" property="doorPic" />
         <result column="memo" property="memo" />
+        <result column="invite_pic" property="invitePic" />
         <result column="status" property="status" />
         <result column="created_time" property="createdTime" />
         <result column="updated_time" property="updatedTime" />
@@ -35,7 +36,7 @@
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        channel_id, channel_no, name, parent_id, level, site_type, comm_rate, province, province_id, city, city_id, area, area_id, address, contact, mobile, user_id, money, frozen_money, certify_status, verify_status, biz_license_pic, door_pic, memo, status, created_time, updated_time
+        channel_id, channel_no, name, parent_id, level, site_type, comm_rate, province, province_id, city, city_id, area, area_id, address, contact, mobile, user_id, money, frozen_money, certify_status, verify_status, biz_license_pic, door_pic, memo, invite_pic, status, created_time, updated_time
     </sql>
 
     <!-- 查询子渠道信息 -->