From c5b7b3f2fcb7c21b6ba66bf13270771dc1171486 Mon Sep 17 00:00:00 2001 From: hupeng Date: Thu, 20 Feb 2020 20:18:25 +0800 Subject: [PATCH] =?UTF-8?q?yshop1.9.10,=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=95=86=E5=93=81=E6=B5=B7=E6=8A=A5=E4=B8=8E?= =?UTF-8?q?=E6=89=8B=E6=9C=BA=E5=8F=B7=E7=BB=91=E5=AE=9A=EF=BC=8C=E6=B5=B7?= =?UTF-8?q?=E6=8A=A5=E7=94=9F=E6=88=90=E6=8B=86=E5=88=86=E4=B8=BAH5?= =?UTF-8?q?=E7=AB=AF=E4=B8=8E=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=AB=AF=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/StoreBargainController.java | 8 +++--- .../StoreCombinationController.java | 8 +++--- .../controller/StoreProductController.java | 27 ++++++++++++++----- .../web/controller/UserBillController.java | 10 ++++--- .../web/controller/WxMaUserController.java | 15 ++++++++--- 5 files changed, 48 insertions(+), 20 deletions(-) diff --git a/yshop-api/src/main/java/co/yixiang/modules/activity/web/controller/StoreBargainController.java b/yshop-api/src/main/java/co/yixiang/modules/activity/web/controller/StoreBargainController.java index d359ee63..3e0482a6 100644 --- a/yshop-api/src/main/java/co/yixiang/modules/activity/web/controller/StoreBargainController.java +++ b/yshop-api/src/main/java/co/yixiang/modules/activity/web/controller/StoreBargainController.java @@ -292,7 +292,9 @@ public class StoreBargainController extends BaseController { storeBargainUser.getPrice()).doubleValue(); YxUserQueryVo userInfo = yxUserService.getYxUserById(uid); - String name = bargainId+"_"+uid + "_"+userInfo.getIsPromoter()+"_bargain_share_wap.jpg"; + String userType = userInfo.getUserType(); + if(!userType.equals("routine")) userType = "H5"; + String name = bargainId+"_"+uid + "_"+userType+"_bargain_share_wap.jpg"; YxSystemAttachment attachment = systemAttachmentService.getInfo(name); String fileDir = path+"qrcode"+ File.separator; String qrcodeUrl = ""; @@ -300,7 +302,7 @@ public class StoreBargainController extends BaseController { //生成二维码 //判断用户是否小程序,注意小程序二维码生成路径要与H5不一样 不然会导致都跳转到小程序问题 File file = FileUtil.mkdir(new File(fileDir)); - if(userInfo.getUserType().equals("routine")){ + if(userType.equals("routine")){ siteUrl = siteUrl+"/bargain/"; QrCodeUtil.generate(siteUrl+"?bargainId="+bargainId+"&uid="+uid+"&spread="+uid, 180, 180, FileUtil.file(fileDir+name)); @@ -318,7 +320,7 @@ public class StoreBargainController extends BaseController { qrcodeUrl = attachment.getAttDir(); } - String spreadPicName = bargainId+"_"+uid + "_"+userInfo.getIsPromoter()+"_bargain_user_spread.jpg"; + String spreadPicName = bargainId+"_"+uid + "_"+userType+"_bargain_user_spread.jpg"; String spreadPicPath = fileDir+spreadPicName; YxSystemAttachment attachmentT = systemAttachmentService.getInfo(spreadPicName); diff --git a/yshop-api/src/main/java/co/yixiang/modules/activity/web/controller/StoreCombinationController.java b/yshop-api/src/main/java/co/yixiang/modules/activity/web/controller/StoreCombinationController.java index 59d07358..55a2b088 100644 --- a/yshop-api/src/main/java/co/yixiang/modules/activity/web/controller/StoreCombinationController.java +++ b/yshop-api/src/main/java/co/yixiang/modules/activity/web/controller/StoreCombinationController.java @@ -130,7 +130,9 @@ public class StoreCombinationController extends BaseController { int uid = SecurityUtils.getUserId().intValue(); YxUserQueryVo userInfo = yxUserService.getYxUserById(uid); - String name = pinkId+"_"+uid + "_"+userInfo.getIsPromoter()+"_pink_share_wap.jpg"; + String userType = userInfo.getUserType(); + if(!userType.equals("routine")) userType = "H5"; + String name = pinkId+"_"+uid + "_"+userType+"_pink_share_wap.jpg"; YxSystemAttachment attachment = systemAttachmentService.getInfo(name); String fileDir = path+"qrcode"+ File.separator; String qrcodeUrl = ""; @@ -138,7 +140,7 @@ public class StoreCombinationController extends BaseController { //生成二维码 //String fileDir = path+"qrcode"+File.separator; File file = FileUtil.mkdir(new File(fileDir)); - if(userInfo.getUserType().equals("routine")){ + if(userType.equals("routine")){ siteUrl = siteUrl+"/pink/"; QrCodeUtil.generate(siteUrl+"?pinkId="+pinkId+"&spread="+uid, 180, 180, FileUtil.file(fileDir+name)); @@ -156,7 +158,7 @@ public class StoreCombinationController extends BaseController { qrcodeUrl = attachment.getAttDir(); } - String spreadPicName = pinkId+"_"+uid + "_"+userInfo.getIsPromoter()+"_pink_user_spread.jpg"; + String spreadPicName = pinkId+"_"+uid + "_"+userType+"_pink_user_spread.jpg"; String spreadPicPath = fileDir+spreadPicName; YxSystemAttachment attachmentT = systemAttachmentService.getInfo(spreadPicName); diff --git a/yshop-api/src/main/java/co/yixiang/modules/shop/web/controller/StoreProductController.java b/yshop-api/src/main/java/co/yixiang/modules/shop/web/controller/StoreProductController.java index c61160d4..3cd9114a 100644 --- a/yshop-api/src/main/java/co/yixiang/modules/shop/web/controller/StoreProductController.java +++ b/yshop-api/src/main/java/co/yixiang/modules/shop/web/controller/StoreProductController.java @@ -137,14 +137,18 @@ public class StoreProductController extends BaseController { } YxUserQueryVo userInfo = yxUserService.getYxUserById(uid); - String name = id+"_"+uid + "_"+userInfo.getIsPromoter()+"_product_detail_wap.jpg"; + String userType = userInfo.getUserType(); + if(!userType.equals("routine")) userType = "H5"; + String name = id+"_"+uid + "_"+userType+"_product_detail_wap.jpg"; YxSystemAttachment attachment = systemAttachmentService.getInfo(name); String fileDir = path+"qrcode"+ File.separator; String qrcodeUrl = ""; + String routineQrcodeUrl = ""; if(ObjectUtil.isNull(attachment)){ //生成二维码 File file = FileUtil.mkdir(new File(fileDir)); - if(userInfo.getUserType().equals("routine")){ + if(userType.equals("routine")){ + //下载图片 siteUrl = siteUrl+"/product/"; QrCodeUtil.generate(siteUrl+"?productId="+id+"&spread="+uid, 180, 180, FileUtil.file(fileDir+name)); @@ -158,17 +162,26 @@ public class StoreProductController extends BaseController { fileDir+name,"qrcode/"+name); qrcodeUrl = fileDir+name; + routineQrcodeUrl = apiUrl + "/api/file/qrcode/"+name; + }else{ qrcodeUrl = attachment.getAttDir(); + routineQrcodeUrl = apiUrl + "/api/file/" + attachment.getSattDir(); } - try { - String base64CodeImg = co.yixiang.utils.FileUtil.fileToBase64(new File(qrcodeUrl)); - productDTO.getStoreInfo().setCodeBase("data:image/jpeg;base64," + base64CodeImg); - } catch (Exception e) { - e.printStackTrace(); + if(userType.equals("routine")){ + productDTO.getStoreInfo().setCodeBase(routineQrcodeUrl); + }else{ + try { + String base64CodeImg = co.yixiang.utils.FileUtil.fileToBase64(new File(qrcodeUrl)); + productDTO.getStoreInfo().setCodeBase("data:image/jpeg;base64," + base64CodeImg); + } catch (Exception e) { + e.printStackTrace(); + } } + + return ApiResult.ok(productDTO); } diff --git a/yshop-api/src/main/java/co/yixiang/modules/user/web/controller/UserBillController.java b/yshop-api/src/main/java/co/yixiang/modules/user/web/controller/UserBillController.java index 68fb99cc..74490c2e 100644 --- a/yshop-api/src/main/java/co/yixiang/modules/user/web/controller/UserBillController.java +++ b/yshop-api/src/main/java/co/yixiang/modules/user/web/controller/UserBillController.java @@ -133,7 +133,11 @@ public class UserBillController extends BaseController { if(StrUtil.isEmpty(siteUrl)){ return ApiResult.fail("未配置api地址"); } - String name = uid + "_"+userInfo.getIsPromoter()+"_user_wap.jpg"; + + String userType = userInfo.getUserType(); + if(!userType.equals("routine")) userType = "H5"; + + String name = uid + "_"+userType+"_user_wap.jpg"; YxSystemAttachment attachment = systemAttachmentService.getInfo(name); String fileDir = path+"qrcode"+File.separator; @@ -141,7 +145,7 @@ public class UserBillController extends BaseController { if(ObjectUtil.isNull(attachment)){ //生成二维码 //判断用户是否小程序,注意小程序二维码生成路径要与H5不一样 不然会导致都跳转到小程序问题 - if(userInfo.getUserType().equals("routine")){ + if(userType.equals("routine")){ siteUrl = siteUrl+"/distribution/"; } File file = FileUtil.mkdir(new File(fileDir)); @@ -157,7 +161,7 @@ public class UserBillController extends BaseController { } - String spreadPicName = uid + "_"+userInfo.getIsPromoter()+"_user_spread.jpg"; + String spreadPicName = uid + "_"+userType+"_user_spread.jpg"; String spreadPicPath = fileDir+spreadPicName; YxSystemAttachment attachmentT = systemAttachmentService.getInfo(spreadPicName); diff --git a/yshop-api/src/main/java/co/yixiang/modules/wechat/web/controller/WxMaUserController.java b/yshop-api/src/main/java/co/yixiang/modules/wechat/web/controller/WxMaUserController.java index 69cbf04b..88d3f9de 100644 --- a/yshop-api/src/main/java/co/yixiang/modules/wechat/web/controller/WxMaUserController.java +++ b/yshop-api/src/main/java/co/yixiang/modules/wechat/web/controller/WxMaUserController.java @@ -45,6 +45,9 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; +import java.util.LinkedHashMap; +import java.util.Map; + /** * @author hupeng * @date 2020/02/07 @@ -113,6 +116,7 @@ public class WxMaUserController { wxMaConfig.setAppid(appId); wxMaConfig.setSecret(secret); wxMaService.setWxMaConfig(wxMaConfig); + String phone = ""; try { WxMaJscode2SessionResult session = wxMaService.getUserService() .getSessionInfo(param.getCode()); @@ -121,16 +125,19 @@ public class WxMaUserController { WxMaPhoneNumberInfo phoneNoInfo = wxMaService.getUserService() .getPhoneNoInfo(session.getSessionKey(), param.getEncryptedData(), param.getIv()); + phone = phoneNoInfo.getPhoneNumber(); YxUser yxUser = new YxUser(); - yxUser.setPhone(phoneNoInfo.getPhoneNumber()); + yxUser.setPhone(phone); yxUser.setUid(uid); userService.updateById(yxUser); } catch (WxErrorException e) { - e.printStackTrace(); + return ApiResult.fail(e.getMessage()); + //e.printStackTrace(); } + Map map = new LinkedHashMap<>(); + map.put("phone",phone); - - return ApiResult.ok("绑定成功"); + return ApiResult.ok(map,"绑定成功"); }