From b1b7773779cc5e6e2def6daa055ec4a027aaa960 Mon Sep 17 00:00:00 2001 From: hupeng Date: Mon, 30 Sep 2019 10:38:42 +0800 Subject: [PATCH 1/6] =?UTF-8?q?[C=E7=AB=AF][=E4=BF=AE=E6=94=B9]:=E6=A5=BC?= =?UTF-8?q?=E5=B1=82=E6=A5=BC=E5=BA=A7=E6=8E=A5=E5=8F=A3=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?api=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/iformall/controller/WxMallBuildingController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxMallBuildingController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxMallBuildingController.java index a62b9c07b..073b51d5f 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxMallBuildingController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxMallBuildingController.java @@ -11,7 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @RestController -@RequestMapping("wxMallBuilding") +@RequestMapping("/api/wxMallBuilding") public class WxMallBuildingController extends BaseController { private final Logger logger = LoggerFactory.getLogger(this.getClass()); From d03cfc79aefff8db901df9bb3f6436d89a6d9819 Mon Sep 17 00:00:00 2001 From: gongbiao Date: Mon, 30 Sep 2019 11:01:37 +0800 Subject: [PATCH 2/6] =?UTF-8?q?[=E6=B5=AE=E5=B1=82=E5=B9=BF=E5=91=8A][?= =?UTF-8?q?=E4=BF=AE=E6=94=B9][=E4=B8=8B=E7=BA=BF]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/market/WxFloatingLayerController.java | 12 ++++++++---- .../com/iformall/service/WxFloatingLayerService.java | 2 ++ .../impl/WxCuserFloatingLayerServiceImpl.java | 8 +++++--- .../service/impl/WxFloatingLayerServiceImpl.java | 8 ++++++++ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxFloatingLayerController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxFloatingLayerController.java index 96162ee9a..dad3572c2 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxFloatingLayerController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxFloatingLayerController.java @@ -2,6 +2,7 @@ package com.iformall.controller.market; import com.github.pagehelper.PageInfo; import com.iformall.annotation.SystemControllerLog; +import com.iformall.common.ErrorCode; import com.iformall.common.Result; import com.iformall.common.ResultData; import com.iformall.controller.base.BaseController; @@ -62,13 +63,16 @@ public class WxFloatingLayerController extends BaseController { } @ApiOperation("根据id更新接口") - @PostMapping("/update") + @PostMapping("/updateStatus") @SystemControllerLog(description = "id更新") - public ResultData update(@RequestBody WxFloatingLayer wxFloatingLayer) { - logger.debug("[" + getIpAddr() + "] WxFloatingLayerController::update"); + public ResultData updateStatus(@RequestBody WxFloatingLayer wxFloatingLayer) { + logger.debug("[" + getIpAddr() + "] WxFloatingLayerController::updateStatus"); + if (wxFloatingLayer.getId() == null) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "id不能为空"); + } try { wxFloatingLayer.setStatus(EnumFloatingLayerStatus.STATUS_TAKE_OFFF.getCode()); - return wxFloatingLayerService.saveOrUpdate(wxFloatingLayer); + return wxFloatingLayerService.updateStatus(wxFloatingLayer); } catch (MallinkException e) { logger.error(e.getMessage()); return new ResultData(e.getErrorCode(), e.getMessage()); diff --git a/mallinkService/src/main/java/com/iformall/service/WxFloatingLayerService.java b/mallinkService/src/main/java/com/iformall/service/WxFloatingLayerService.java index 59232c9fd..dbaa8aaa5 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxFloatingLayerService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxFloatingLayerService.java @@ -36,4 +36,6 @@ public interface WxFloatingLayerService { ResultData saveOrUpdate(WxFloatingLayer record); + ResultData updateStatus(WxFloatingLayer wxFloatingLayer); + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCuserFloatingLayerServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCuserFloatingLayerServiceImpl.java index dd9ffbf7d..f34658896 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCuserFloatingLayerServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCuserFloatingLayerServiceImpl.java @@ -40,8 +40,9 @@ public class WxCuserFloatingLayerServiceImpl implements WxCuserFloatingLayerServ WxCUser user = new WxCUser(); user.setOpenId(openId); WxCUser byOpenId = wxCUserMapper.findByOpenId(user); + String tenantId = byOpenId.getTenantId(); if (byOpenId == null) { - return getWxFloatingLayer(); + return getWxFloatingLayer(tenantId); } //2 用户存在 查看是否已有弹出记录 没有 保存记录后返回浮层信息 WxCuserFloatingLayer wxCuserFloatingLayerQuery = new WxCuserFloatingLayer(); @@ -49,7 +50,7 @@ public class WxCuserFloatingLayerServiceImpl implements WxCuserFloatingLayerServ WxCuserFloatingLayer wxCuserFloatingLayer = wxCuserFloatingLayerMapper.selectOne(new QueryWrapper<>(wxCuserFloatingLayerQuery)); if (wxCuserFloatingLayer == null) { saveCuserFloatingLayer(byOpenId); - return getWxFloatingLayer(); + return getWxFloatingLayer(tenantId); } return null; } @@ -65,8 +66,9 @@ public class WxCuserFloatingLayerServiceImpl implements WxCuserFloatingLayerServ wxCuserFloatingLayerMapper.insert(wxCuserFloatingLayer); } - public WxFloatingLayer getWxFloatingLayer() { + public WxFloatingLayer getWxFloatingLayer(String tenantId) { WxFloatingLayer wxFloatingLayer = new WxFloatingLayer(); + wxFloatingLayer.setTenantId(tenantId); wxFloatingLayer.setStatus(EnumFloatingLayerStatus.STATUS_THROW_IN.getCode()); return wxFloatingLayerMapper.selectOne(new QueryWrapper<>(wxFloatingLayer)); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxFloatingLayerServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxFloatingLayerServiceImpl.java index 5ac85241d..bcd1eef51 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxFloatingLayerServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxFloatingLayerServiceImpl.java @@ -71,4 +71,12 @@ public class WxFloatingLayerServiceImpl implements WxFloatingLayerService { return new ResultData(Result.SUCCESS, "操作成功"); } + @Override + public ResultData updateStatus(WxFloatingLayer wxFloatingLayer) { + wxFloatingLayer.setUpdateTime(new Date()); + wxFloatingLayerMapper.updateById(wxFloatingLayer); + return new ResultData(Result.SUCCESS, "操作成功"); + + } + } From 35e01a58e9464447c3469d1333a02cd2be020691 Mon Sep 17 00:00:00 2001 From: gongbiao Date: Mon, 30 Sep 2019 11:38:14 +0800 Subject: [PATCH 3/6] =?UTF-8?q?[=E6=B5=AE=E5=B1=82=E5=B9=BF=E5=91=8A][?= =?UTF-8?q?=E4=BF=AE=E6=94=B9][C=E7=AB=AF=E8=AE=BF=E9=97=AE]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WxCuserFloatingLayerController.java | 9 ++++++--- .../iformall/service/WxCuserFloatingLayerService.java | 2 +- .../service/impl/WxCuserFloatingLayerServiceImpl.java | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxCuserFloatingLayerController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxCuserFloatingLayerController.java index 9df67b6c2..88b4c7c03 100755 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxCuserFloatingLayerController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxCuserFloatingLayerController.java @@ -7,6 +7,7 @@ import com.iformall.domain.po.WxFloatingLayer; import com.iformall.service.WxCuserFloatingLayerService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -30,9 +31,11 @@ public class WxCuserFloatingLayerController extends BaseController { @AuthIgnore @ApiOperation("获取浮层") @GetMapping("/getFloatingLayer") - @ApiImplicitParam(name = "openId", value = "openId", dataType = "String", paramType = "query", required = true) - public ResultData getAppIcon(String openId) { - WxFloatingLayer wxFloatingLayer = wxCuserFloatingLayerService.getFloatingLayer(openId); + @ApiImplicitParams({ + @ApiImplicitParam(name = "openId", value = "openId", dataType = "String", paramType = "query", required = true), + @ApiImplicitParam(name = "appId", value = "appId", dataType = "String", paramType = "query", required = true)}) + public ResultData getAppIcon(String openId, String appId) { + WxFloatingLayer wxFloatingLayer = wxCuserFloatingLayerService.getFloatingLayer(openId, appId); return new ResultData(Result.SUCCESS, "查询成功", wxFloatingLayer); } diff --git a/mallinkService/src/main/java/com/iformall/service/WxCuserFloatingLayerService.java b/mallinkService/src/main/java/com/iformall/service/WxCuserFloatingLayerService.java index 6e175d55f..1b16f1abd 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCuserFloatingLayerService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCuserFloatingLayerService.java @@ -7,6 +7,6 @@ import com.iformall.domain.po.WxFloatingLayer; */ public interface WxCuserFloatingLayerService { - WxFloatingLayer getFloatingLayer(String openId); + WxFloatingLayer getFloatingLayer(String openId, String appId); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCuserFloatingLayerServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCuserFloatingLayerServiceImpl.java index f34658896..2961c80c0 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCuserFloatingLayerServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCuserFloatingLayerServiceImpl.java @@ -35,10 +35,11 @@ public class WxCuserFloatingLayerServiceImpl implements WxCuserFloatingLayerServ @Override - public WxFloatingLayer getFloatingLayer(String openId) { + public WxFloatingLayer getFloatingLayer(String openId, String appId) { //1 查看是否存在用户,用户不存在 直接返回浮层信息 WxCUser user = new WxCUser(); user.setOpenId(openId); + user.setAppId(appId); WxCUser byOpenId = wxCUserMapper.findByOpenId(user); String tenantId = byOpenId.getTenantId(); if (byOpenId == null) { From 223aa36381f5304bfdf23c2295a3ce9138434e5f Mon Sep 17 00:00:00 2001 From: gongbiao Date: Mon, 30 Sep 2019 11:51:34 +0800 Subject: [PATCH 4/6] =?UTF-8?q?[=E6=B5=AE=E5=B1=82=E5=B9=BF=E5=91=8A][?= =?UTF-8?q?=E4=BF=AE=E6=94=B9][=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/mapper/WxFloatingLayerMapper.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mallinkService/src/main/resources/mapper/WxFloatingLayerMapper.xml b/mallinkService/src/main/resources/mapper/WxFloatingLayerMapper.xml index 6178e37c1..d3a71ad0c 100644 --- a/mallinkService/src/main/resources/mapper/WxFloatingLayerMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxFloatingLayerMapper.xml @@ -5,9 +5,9 @@ - + - + @@ -58,16 +58,16 @@ - + - + - + where 1=1 and fl.`id` = #{id} From b5c21b14d25930fb8101043b64009a2a19aa2e18 Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Tue, 1 Oct 2019 17:41:32 +0800 Subject: [PATCH 5/6] =?UTF-8?q?[qrcode][=E4=BF=AE=E6=94=B9]:=E4=BA=8C?= =?UTF-8?q?=E7=BB=B4=E7=A0=81=E7=94=9F=E6=88=90=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/iformall/service/impl/WxCampaignServiceImpl.java | 2 +- .../com/iformall/service/impl/WxCouponChannelServiceImpl.java | 2 +- .../main/java/com/iformall/service/impl/WxGameServiceImpl.java | 2 +- .../main/java/com/iformall/service/impl/WxTopicServiceImpl.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCampaignServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCampaignServiceImpl.java index 432ea2ae8..e338dc18e 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCampaignServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCampaignServiceImpl.java @@ -269,7 +269,7 @@ public class WxCampaignServiceImpl implements WxCampaignService { couponChannel.setId(wxCouponChannel.getId()); couponChannel.setType(wxCouponChannel.getType()); String param = couponChannel.getWeappScene(); - ResultData resultDataQ = qrCodeService.exportQrcode(null,null,couponChannel.getTenantId(),1,pageUrl,param,0,"","","卷",true); + ResultData resultDataQ = qrCodeService.exportQrcode(null,null,wxCoupon.getTenantId(),1,pageUrl,param,0,"","","卷",true); Map map = (Map)resultDataQ.data; if(map!=null && map.get("url") !=null) { String url = map.get("url"); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java index 6726472ba..bdbd17441 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java @@ -265,7 +265,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { couponChannel.setId(vo.getId()); couponChannel.setType(vo.getType()); String param = couponChannel.getWeappScene(); - ResultData resultDataQ = qrCodeService.exportQrcode(null,null,couponChannel.getTenantId(),1,pageUrl,param,0,"","","卷",true); + ResultData resultDataQ = qrCodeService.exportQrcode(null,null,wxCoupon.getTenantId(),1,pageUrl,param,0,"","","卷",true); Map map = (Map)resultDataQ.data; if(map!=null && map.get("url") !=null) { String url = map.get("url"); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java index c2f3d6724..e378e3fb7 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java @@ -317,7 +317,7 @@ public class WxGameServiceImpl implements WxGameService { couponChannel.setId(wxCouponChannel.getId()); couponChannel.setType(wxCouponChannel.getType()); String param = couponChannel.getWeappScene(); - ResultData resultDataQ = qrCodeService.exportQrcode(null,null,couponChannel.getTenantId(),1,pageUrl,param,0,"","","卷",true); + ResultData resultDataQ = qrCodeService.exportQrcode(null,null,wxCoupon.getTenantId(),1,pageUrl,param,0,"","","卷",true); Map map = (Map)resultDataQ.data; if(map!=null && map.get("url") !=null) { String url = map.get("url"); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxTopicServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxTopicServiceImpl.java index eda05196b..b8fe5673a 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxTopicServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxTopicServiceImpl.java @@ -140,7 +140,7 @@ public class WxTopicServiceImpl implements WxTopicService { couponChannel.setId(wxCouponChannel.getId()); couponChannel.setType(wxCouponChannel.getType()); String param = couponChannel.getWeappScene(); - ResultData resultDataQ = qrCodeService.exportQrcode(null,null,couponChannel.getTenantId(),1,pageUrl,param,0,"","","卷",true); + ResultData resultDataQ = qrCodeService.exportQrcode(null,null,wxCoupon.getTenantId(),1,pageUrl,param,0,"","","卷",true); Map map = (Map)resultDataQ.data; if(map!=null && map.get("url") !=null) { String url = map.get("url"); From 4ae7c822fd076b824e1ef596a39619ad4628be94 Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Tue, 1 Oct 2019 23:22:27 +0800 Subject: [PATCH 6/6] =?UTF-8?q?[qrcode][=E4=BF=AE=E6=94=B9]:=E4=BA=8C?= =?UTF-8?q?=E7=BB=B4=E7=A0=81=E7=94=9F=E6=88=90=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/app/WxAppinfoController.java | 6 +- .../basic/WxMerchantController.java | 2 +- .../market/WxCouponChannelController.java | 2 +- .../com/iformall/service/QrCodeService.java | 5 +- .../service/impl/QrCodeServiceImpl.java | 144 ++++++++++++------ .../service/impl/WxCampaignServiceImpl.java | 2 +- .../impl/WxCouponChannelServiceImpl.java | 2 +- .../service/impl/WxGameServiceImpl.java | 2 +- .../service/impl/WxTopicServiceImpl.java | 2 +- 9 files changed, 110 insertions(+), 57 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/app/WxAppinfoController.java b/mallinkAdmin/src/main/java/com/iformall/controller/app/WxAppinfoController.java index 237ccc0b2..158c3af1f 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/app/WxAppinfoController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/app/WxAppinfoController.java @@ -55,7 +55,7 @@ public class WxAppinfoController extends BaseController { @Override public void run() { String param = merchant.getWeappScene(); - ResultData resultData = qrCodeService.exportQrcode(null, null, merchant.getTenantId(), 1, pageUrl, param, 0, "", "", "店铺详情", true); + ResultData resultData = qrCodeService.uploadQrcode(merchant.getTenantId(), 1, pageUrl, param, 0, "", "", "店铺详情"); Map map = (Map) resultData.data; if(map!=null && map.get("url") !=null) { String url = map.get("url"); @@ -81,7 +81,7 @@ public class WxAppinfoController extends BaseController { @Override public void run() { String param = couponChannel.getWeappScene(); - ResultData resultData = qrCodeService.exportQrcode(null,null,couponChannel.getTenantId(),1,pageUrl,param,0,"","","卷",true); + ResultData resultData = qrCodeService.uploadQrcode(couponChannel.getTenantId(),1,pageUrl,param,0,"","","卷"); Map map = (Map)resultData.data; if(map!=null && map.get("url") !=null) { String url = map.get("url"); @@ -124,7 +124,7 @@ public class WxAppinfoController extends BaseController { qrCodeService.exportQrcode(request, response, getTenantId(), type, pageUrl, sceneParam, withText, text1, text2, - name,false); + name); } catch (Exception e) { logger.error(e.getMessage()); throw new MallinkException(Result.ERROR, "下载异常"); diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java b/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java index 2e2d4e1db..eecb8c549 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java @@ -138,7 +138,7 @@ public class WxMerchantController extends BaseController { //加载二维码图片 String pageUrl = "pages/index/index"; String param = "t:md:"+resultData.data; - ResultData resultQrCode = qrCodeService.exportQrcode(null,null,wxMerchant.getTenantId(),1,pageUrl,param,0,"","","店铺详情",true); + ResultData resultQrCode = qrCodeService.uploadQrcode(wxMerchant.getTenantId(),1,pageUrl,param,0,"","","店铺详情"); Map map = (Map)resultQrCode.data; if(map!=null && map.get("url") !=null) { String url = map.get("url"); diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java index 5af188862..95b18af9a 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponChannelController.java @@ -86,7 +86,7 @@ public class WxCouponChannelController extends BaseController { if(couponChannel!=null){ String pageUrl = "pages/index/index"; String param = couponChannel.getWeappScene(); - ResultData resultDataQ = qrCodeService.exportQrcode(null,null,couponChannel.getTenantId(),1,pageUrl,param,0,"","","卷",true); + ResultData resultDataQ = qrCodeService.uploadQrcode(couponChannel.getTenantId(),1,pageUrl,param,0,"","","卷"); Map map = (Map)resultDataQ.data; if(map!=null && map.get("url") !=null) { String url = map.get("url"); diff --git a/mallinkService/src/main/java/com/iformall/service/QrCodeService.java b/mallinkService/src/main/java/com/iformall/service/QrCodeService.java index 570bbe313..e8a089bad 100644 --- a/mallinkService/src/main/java/com/iformall/service/QrCodeService.java +++ b/mallinkService/src/main/java/com/iformall/service/QrCodeService.java @@ -18,6 +18,9 @@ public interface QrCodeService { ResultData exportQrcode(HttpServletRequest request, HttpServletResponse response, String tenantId, int type, String pageUrl, String sceneParam, int withText, String text1, String text2, - String name, boolean upload); + String name); + ResultData uploadQrcode(String tenantId, int type, String pageUrl, String sceneParam, + int withText, String text1, String text2, + String name); ResultData awsUpload(InputStream inputStream, ObjectMetadata metadata, String fileName, String tenantId); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/QrCodeServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/QrCodeServiceImpl.java index e8e7e318f..83f486365 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/QrCodeServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/QrCodeServiceImpl.java @@ -151,7 +151,7 @@ public class QrCodeServiceImpl implements QrCodeService { exportQrcode(request, response, tenantId, type, pageUrl, sceneParam, withText, text1, text2, - name,false); + name); } catch (Exception e) { logger.error(e.getMessage()); throw new MallinkException(Result.ERROR, "下载异常"); @@ -162,7 +162,7 @@ public class QrCodeServiceImpl implements QrCodeService { public ResultData exportQrcode(HttpServletRequest request, HttpServletResponse response, String tenantId, int type, String pageUrl, String sceneParam, int withText, String text1, String text2, - String name, boolean upload) { + String name) { // type 0 有限二维码, 1 无限制二维码 // withText 0 不带字 1. 带下面的字,2 带下面的两行字 WxAppinfo appinfo = wxAppinfoService.getCAppInfo(tenantId); @@ -198,35 +198,73 @@ public class QrCodeServiceImpl implements QrCodeService { try { if(type == 0) { final File codeFile = wxMaService.getQrcodeService().createQrcode(pathStr, QRCodeUtils.QR_WIDTH); - if (withText == 1) { - File dest1 = new File(destPath1); - org.apache.commons.io.FileUtils.copyFile(codeFile, dest1); - QRCodeUtils.graphicsGeneration(dest1, dest, text1); - org.apache.commons.io.FileUtils.forceDelete(dest1); - } else if (withText == 2) { - File dest1 = new File(destPath1); - org.apache.commons.io.FileUtils.copyFile(codeFile, dest1); - QRCodeUtils.graphicsGeneration2(dest1, dest, text1, text2); - org.apache.commons.io.FileUtils.forceDelete(dest1); - } else { - org.apache.commons.io.FileUtils.copyFile(codeFile, dest); - } + copyFileToDest(withText, text1, text2, destPath1, dest, codeFile); org.apache.commons.io.FileUtils.forceDelete(codeFile); } else { final File codeFile = wxMaService.getQrcodeService().createWxaCodeUnlimit(sceneParam, pageUrl, QRCodeUtils.QR_WIDTH, autoColor, color, isHyaline); - if (withText == 1) { - File dest1 = new File(destPath1); - org.apache.commons.io.FileUtils.copyFile(codeFile, dest1); - QRCodeUtils.graphicsGeneration(dest1, dest, text1); - org.apache.commons.io.FileUtils.forceDelete(dest1); - } else if (withText == 2) { - File dest1 = new File(destPath1); - org.apache.commons.io.FileUtils.copyFile(codeFile, dest1); - QRCodeUtils.graphicsGeneration2(dest1, dest, text1, text2); - org.apache.commons.io.FileUtils.forceDelete(dest1); - } else { - org.apache.commons.io.FileUtils.copyFile(codeFile, dest); - } + copyFileToDest(withText, text1, text2, destPath1, dest, codeFile); + org.apache.commons.io.FileUtils.forceDelete(codeFile); + } + + } catch (WxErrorException e) { + logger.error(e.getMessage()); + } catch (Exception e) { + logger.error(e.getMessage()); + } + + try { + downFile(destPath, fileName, response, request); + org.apache.commons.io.FileUtils.forceDelete(dest); + } catch (Exception e) { + logger.error(e.getMessage()); + } + return new ResultData(); + } + + @Override + public ResultData uploadQrcode(String tenantId, int type, String pageUrl, String sceneParam, + int withText, String text1, String text2, + String name) { + // type 0 有限二维码, 1 无限制二维码 + // withText 0 不带字 1. 带下面的字,2 带下面的两行字 + WxAppinfo appinfo = wxAppinfoService.getCAppInfo(tenantId); + boolean autoColor = false; + boolean isHyaline = true; + WxMaCodeLineColor color = new WxMaCodeLineColor("0", "0", "0"); + + WxMaService wxMaService; + if(isFmOpen) { + wxMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appinfo.getAppId()); + } else { + wxMaService = MaUtil.getWeappService(appinfo); + } + + String pathStr = ""; + if (StringUtils.isNotBlank(sceneParam)) { + pathStr = pageUrl + "?scene="+sceneParam; + } else { + pathStr = pageUrl; + } + + + String filepath = fmUploadDir; + String fileName = name + ".png"; + String destPath1 = filepath + "1_" + fileName; + String destPath = filepath + fileName; + + File dest = new File(destPath); + File pDest = dest.getParentFile(); + if (!pDest.exists()) { + pDest.mkdirs(); + } + try { + if(type == 0) { + final File codeFile = wxMaService.getQrcodeService().createQrcode(pathStr, QRCodeUtils.QR_WIDTH); + copyFileToDest(withText, text1, text2, destPath1, dest, codeFile); + org.apache.commons.io.FileUtils.forceDelete(codeFile); + } else { + final File codeFile = wxMaService.getQrcodeService().createWxaCodeUnlimit(sceneParam, pageUrl, QRCodeUtils.QR_WIDTH, autoColor, color, isHyaline); + copyFileToDest(withText, text1, text2, destPath1, dest, codeFile); org.apache.commons.io.FileUtils.forceDelete(codeFile); } @@ -238,34 +276,46 @@ public class QrCodeServiceImpl implements QrCodeService { try { //上传 - if (upload){ - ObjectMetadata metadata = new ObjectMetadata(); - metadata.setContentType("image/jpeg"); - metadata.setContentLength(dest.length()); - - FileOutputStream fos = null; - BufferedInputStream fs = null; - - String fn = UUID.randomUUID().toString(); - int dot = fileName.lastIndexOf('.'); - if (dot >= 0) { - fn = tenantId + "/" + fn + dest.getName().substring(dot, dest.getName().length()); - } else { - fn = tenantId + "/" + fn; - } - - ResultData data = awsUpload(new FileInputStream(dest), metadata, fn, tenantId); - return data; + ObjectMetadata metadata = new ObjectMetadata(); + metadata.setContentType("image/jpeg"); + metadata.setContentLength(dest.length()); + + FileOutputStream fos = null; + BufferedInputStream fs = null; + + String fn = UUID.randomUUID().toString(); + int dot = fileName.lastIndexOf('.'); + if (dot >= 0) { + fn = tenantId + "/" + fn + dest.getName().substring(dot, dest.getName().length()); + } else { + fn = tenantId + "/" + fn; } - downFile(destPath, fileName, response, request); + ResultData data = awsUpload(new FileInputStream(dest), metadata, fn, tenantId); org.apache.commons.io.FileUtils.forceDelete(dest); + return data; } catch (Exception e) { logger.error(e.getMessage()); } return new ResultData(); } + private void copyFileToDest(int withText, String text1, String text2, String destPath1, File dest, File codeFile) throws IOException { + if (withText == 1) { + File dest1 = new File(destPath1); + org.apache.commons.io.FileUtils.copyFile(codeFile, dest1); + QRCodeUtils.graphicsGeneration(dest1, dest, text1); + org.apache.commons.io.FileUtils.forceDelete(dest1); + } else if (withText == 2) { + File dest1 = new File(destPath1); + org.apache.commons.io.FileUtils.copyFile(codeFile, dest1); + QRCodeUtils.graphicsGeneration2(dest1, dest, text1, text2); + org.apache.commons.io.FileUtils.forceDelete(dest1); + } else { + org.apache.commons.io.FileUtils.copyFile(codeFile, dest); + } + } + private void downFile(String filePath, String filename, HttpServletResponse response, HttpServletRequest req) throws IOException { try { response.reset(); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCampaignServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCampaignServiceImpl.java index e338dc18e..8ebc7e025 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCampaignServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCampaignServiceImpl.java @@ -269,7 +269,7 @@ public class WxCampaignServiceImpl implements WxCampaignService { couponChannel.setId(wxCouponChannel.getId()); couponChannel.setType(wxCouponChannel.getType()); String param = couponChannel.getWeappScene(); - ResultData resultDataQ = qrCodeService.exportQrcode(null,null,wxCoupon.getTenantId(),1,pageUrl,param,0,"","","卷",true); + ResultData resultDataQ = qrCodeService.uploadQrcode(wxCoupon.getTenantId(),1,pageUrl,param,0,"","","卷"); Map map = (Map)resultDataQ.data; if(map!=null && map.get("url") !=null) { String url = map.get("url"); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java index bdbd17441..df5104906 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java @@ -265,7 +265,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { couponChannel.setId(vo.getId()); couponChannel.setType(vo.getType()); String param = couponChannel.getWeappScene(); - ResultData resultDataQ = qrCodeService.exportQrcode(null,null,wxCoupon.getTenantId(),1,pageUrl,param,0,"","","卷",true); + ResultData resultDataQ = qrCodeService.uploadQrcode(wxCoupon.getTenantId(),1,pageUrl,param,0,"","","卷"); Map map = (Map)resultDataQ.data; if(map!=null && map.get("url") !=null) { String url = map.get("url"); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java index e378e3fb7..ab911d527 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java @@ -317,7 +317,7 @@ public class WxGameServiceImpl implements WxGameService { couponChannel.setId(wxCouponChannel.getId()); couponChannel.setType(wxCouponChannel.getType()); String param = couponChannel.getWeappScene(); - ResultData resultDataQ = qrCodeService.exportQrcode(null,null,wxCoupon.getTenantId(),1,pageUrl,param,0,"","","卷",true); + ResultData resultDataQ = qrCodeService.uploadQrcode(wxCoupon.getTenantId(),1,pageUrl,param,0,"","","卷"); Map map = (Map)resultDataQ.data; if(map!=null && map.get("url") !=null) { String url = map.get("url"); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxTopicServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxTopicServiceImpl.java index b8fe5673a..aa52b828c 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxTopicServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxTopicServiceImpl.java @@ -140,7 +140,7 @@ public class WxTopicServiceImpl implements WxTopicService { couponChannel.setId(wxCouponChannel.getId()); couponChannel.setType(wxCouponChannel.getType()); String param = couponChannel.getWeappScene(); - ResultData resultDataQ = qrCodeService.exportQrcode(null,null,wxCoupon.getTenantId(),1,pageUrl,param,0,"","","卷",true); + ResultData resultDataQ = qrCodeService.uploadQrcode(wxCoupon.getTenantId(),1,pageUrl,param,0,"","","卷"); Map map = (Map)resultDataQ.data; if(map!=null && map.get("url") !=null) { String url = map.get("url");