| @@ -1,26 +1,17 @@ | |||||
| package com.iformall.controller.app; | package com.iformall.controller.app; | ||||
| import cn.binarywang.wx.miniapp.api.WxMaService; | |||||
| import cn.binarywang.wx.miniapp.bean.WxMaCodeLineColor; | |||||
| import com.amazonaws.services.s3.model.ObjectMetadata; | |||||
| import com.iformall.annotation.SystemControllerLog; | import com.iformall.annotation.SystemControllerLog; | ||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.controller.sys.UploadController; | |||||
| import com.iformall.domain.po.WxAppinfo; | |||||
| import com.iformall.domain.po.WxCouponChannel; | import com.iformall.domain.po.WxCouponChannel; | ||||
| import com.iformall.domain.po.WxMerchant; | import com.iformall.domain.po.WxMerchant; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.mapper.WxCouponChannelMapper; | import com.iformall.mapper.WxCouponChannelMapper; | ||||
| import com.iformall.mapper.WxMerchantMapper; | import com.iformall.mapper.WxMerchantMapper; | ||||
| import com.iformall.service.WxAppinfoService; | |||||
| import com.iformall.service.wechat.FmOpenService; | |||||
| import com.iformall.utils.MaUtil; | |||||
| import com.iformall.utils.QRCodeUtils; | |||||
| import com.iformall.service.QrCodeService; | |||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import me.chanjar.weixin.common.error.WxErrorException; | |||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| @@ -32,7 +23,6 @@ import javax.servlet.http.HttpServletResponse; | |||||
| import java.io.*; | import java.io.*; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| import java.util.UUID; | |||||
| import java.util.concurrent.ExecutorService; | import java.util.concurrent.ExecutorService; | ||||
| import java.util.concurrent.Executors; | import java.util.concurrent.Executors; | ||||
| @@ -41,23 +31,11 @@ import java.util.concurrent.Executors; | |||||
| public class WxAppinfoController extends BaseController { | public class WxAppinfoController extends BaseController { | ||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | |||||
| private boolean isFmOpen; | |||||
| @Autowired | |||||
| private String fmUploadDir; | |||||
| @Autowired | |||||
| private WxAppinfoService wxAppinfoService; | |||||
| @Autowired | |||||
| private FmOpenService openService; | |||||
| @Autowired | @Autowired | ||||
| private WxMerchantMapper wxMerchantMapper; | private WxMerchantMapper wxMerchantMapper; | ||||
| @Autowired | @Autowired | ||||
| private UploadController uploadController; | |||||
| private QrCodeService qrCodeService; | |||||
| @Autowired | @Autowired | ||||
| private WxCouponChannelMapper wxCouponChannelMapper; | private WxCouponChannelMapper wxCouponChannelMapper; | ||||
| @@ -77,7 +55,7 @@ public class WxAppinfoController extends BaseController { | |||||
| @Override | @Override | ||||
| public void run() { | public void run() { | ||||
| String param = merchant.getWeappScene(); | String param = merchant.getWeappScene(); | ||||
| ResultData resultData = exportQrcode(null, null, merchant.getTenantId(), 1, pageUrl, param, 0, "", "", "店铺详情", true); | |||||
| ResultData resultData = qrCodeService.exportQrcode(null, null, merchant.getTenantId(), 1, pageUrl, param, 0, "", "", "店铺详情", true); | |||||
| Map<String, String> map = (Map) resultData.data; | Map<String, String> map = (Map) resultData.data; | ||||
| String url = map.get("url"); | String url = map.get("url"); | ||||
| merchant.setQrCode(url); | merchant.setQrCode(url); | ||||
| @@ -101,7 +79,7 @@ public class WxAppinfoController extends BaseController { | |||||
| @Override | @Override | ||||
| public void run() { | public void run() { | ||||
| String param = couponChannel.getWeappScene(); | String param = couponChannel.getWeappScene(); | ||||
| ResultData resultData = exportQrcode(null,null,couponChannel.getTenantId(),1,pageUrl,param,0,"","","卷",true); | |||||
| ResultData resultData = qrCodeService.exportQrcode(null,null,couponChannel.getTenantId(),1,pageUrl,param,0,"","","卷",true); | |||||
| Map<String,String> map = (Map)resultData.data; | Map<String,String> map = (Map)resultData.data; | ||||
| String url = map.get("url"); | String url = map.get("url"); | ||||
| couponChannel.setQrCode(url); | couponChannel.setQrCode(url); | ||||
| @@ -139,7 +117,7 @@ public class WxAppinfoController extends BaseController { | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "pageUrl不能为空"); | throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "pageUrl不能为空"); | ||||
| } | } | ||||
| try { | try { | ||||
| exportQrcode(request, response, | |||||
| qrCodeService.exportQrcode(request, response, | |||||
| getTenantId(), type, pageUrl, sceneParam, | getTenantId(), type, pageUrl, sceneParam, | ||||
| withText, text1, text2, | withText, text1, text2, | ||||
| name,false); | name,false); | ||||
| @@ -149,138 +127,7 @@ public class WxAppinfoController extends BaseController { | |||||
| } | } | ||||
| } | } | ||||
| 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) { | |||||
| // 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); | |||||
| 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); | |||||
| } | |||||
| 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); | |||||
| } | |||||
| org.apache.commons.io.FileUtils.forceDelete(codeFile); | |||||
| } | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| 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 = uploadController.awsUpload(new FileInputStream(dest), metadata, fn, getTenantId()); | |||||
| return data; | |||||
| } | |||||
| downFile(destPath, fileName, response, request); | |||||
| org.apache.commons.io.FileUtils.forceDelete(dest); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| private void downFile(String filePath, String filename, HttpServletResponse response, HttpServletRequest req) throws IOException { | |||||
| try { | |||||
| response.reset(); | |||||
| response.setContentType("application/octet-stream"); | |||||
| String agent = req.getHeader("user-agent"); | |||||
| if (agent.contains("Firefox")) { | |||||
| response.setHeader("Content-disposition", | |||||
| "attachment; filename=" | |||||
| + new String(filename.getBytes("GB2312"),"ISO-8859-1")); | |||||
| } else { | |||||
| response.setHeader("Content-disposition", | |||||
| "attachment; filename=" | |||||
| + java.net.URLEncoder.encode(filename,"UTF-8")); | |||||
| } | |||||
| // 循环取出流中的数据 | |||||
| byte[] b = new byte[1024]; | |||||
| int len; | |||||
| InputStream inStream = new FileInputStream(filePath); | |||||
| while ((len = inStream.read(b)) > 0) | |||||
| response.getOutputStream().write(b, 0, len); | |||||
| inStream.close(); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -4,11 +4,11 @@ import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | import com.iformall.annotation.SystemControllerLog; | ||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.controller.app.WxAppinfoController; | |||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.domain.po.WxMerchant; | import com.iformall.domain.po.WxMerchant; | ||||
| import com.iformall.domain.po.WxProfitSharingReceiver; | import com.iformall.domain.po.WxProfitSharingReceiver; | ||||
| import com.iformall.domain.vo.WxMerchantVo; | import com.iformall.domain.vo.WxMerchantVo; | ||||
| import com.iformall.service.QrCodeService; | |||||
| import com.iformall.service.WxMerchantService; | import com.iformall.service.WxMerchantService; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| @@ -17,7 +17,6 @@ import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| import java.util.List; | import java.util.List; | ||||
| @@ -34,7 +33,7 @@ public class WxMerchantController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private WxMerchantService wxMerchantService; | private WxMerchantService wxMerchantService; | ||||
| @Autowired | @Autowired | ||||
| private WxAppinfoController wxAppinfoController; | |||||
| private QrCodeService qrCodeService; | |||||
| @ApiOperation("分页列表接口") | @ApiOperation("分页列表接口") | ||||
| @GetMapping("list") | @GetMapping("list") | ||||
| @@ -107,7 +106,7 @@ public class WxMerchantController extends BaseController { | |||||
| //加载二维码图片 | //加载二维码图片 | ||||
| String pageUrl = "pages/index/index"; | String pageUrl = "pages/index/index"; | ||||
| String param = "t:md:"+resultData.data; | String param = "t:md:"+resultData.data; | ||||
| ResultData resultQrCode = wxAppinfoController.exportQrcode(null,null,wxMerchant.getTenantId(),1,pageUrl,param,0,"","","店铺详情",true); | |||||
| ResultData resultQrCode = qrCodeService.exportQrcode(null,null,wxMerchant.getTenantId(),1,pageUrl,param,0,"","","店铺详情",true); | |||||
| Map<String,String> map = (Map)resultQrCode.data; | Map<String,String> map = (Map)resultQrCode.data; | ||||
| String url = map.get("url"); | String url = map.get("url"); | ||||
| wxMerchant.setQrCode(url); | wxMerchant.setQrCode(url); | ||||
| @@ -13,6 +13,7 @@ import com.iformall.domain.po.WxCouponChannel; | |||||
| import com.iformall.domain.vo.WxCouponChannelAddVo; | import com.iformall.domain.vo.WxCouponChannelAddVo; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | import com.iformall.domain.vo.WxCouponChannelVo; | ||||
| import com.iformall.mapper.WxCouponChannelMapper; | import com.iformall.mapper.WxCouponChannelMapper; | ||||
| import com.iformall.service.QrCodeService; | |||||
| import com.iformall.service.WxCouponChannelService; | import com.iformall.service.WxCouponChannelService; | ||||
| import com.iformall.service.WxCouponService; | import com.iformall.service.WxCouponService; | ||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| @@ -38,11 +39,12 @@ public class WxCouponChannelController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private WxCouponChannelService wxCouponChannelService; | private WxCouponChannelService wxCouponChannelService; | ||||
| @Autowired | @Autowired | ||||
| private WxAppinfoController wxAppinfoController; | private WxAppinfoController wxAppinfoController; | ||||
| @Autowired | @Autowired | ||||
| private WxCouponChannelMapper wxCouponChannelMapper; | private WxCouponChannelMapper wxCouponChannelMapper; | ||||
| @Autowired | |||||
| private QrCodeService qrCodeService; | |||||
| @ApiOperation("分页列表接口") | @ApiOperation("分页列表接口") | ||||
| @GetMapping("list") | @GetMapping("list") | ||||
| @@ -76,7 +78,7 @@ public class WxCouponChannelController extends BaseController { | |||||
| if(couponChannel!=null){ | if(couponChannel!=null){ | ||||
| String pageUrl = "pages/index/index"; | String pageUrl = "pages/index/index"; | ||||
| String param = couponChannel.getWeappScene(); | String param = couponChannel.getWeappScene(); | ||||
| ResultData resultDataQ = wxAppinfoController.exportQrcode(null,null,couponChannel.getTenantId(),1,pageUrl,param,0,"","","卷",true); | |||||
| ResultData resultDataQ = qrCodeService.exportQrcode(null,null,couponChannel.getTenantId(),1,pageUrl,param,0,"","","卷",true); | |||||
| Map<String,String> map = (Map)resultDataQ.data; | Map<String,String> map = (Map)resultDataQ.data; | ||||
| String url = map.get("url"); | String url = map.get("url"); | ||||
| couponChannel.setQrCode(url); | couponChannel.setQrCode(url); | ||||
| @@ -124,7 +126,7 @@ public class WxCouponChannelController extends BaseController { | |||||
| couponChannel.setType(vo.getType()); | couponChannel.setType(vo.getType()); | ||||
| String param = couponChannel.getWeappScene(); | String param = couponChannel.getWeappScene(); | ||||
| ResultData resultDataQ = wxAppinfoController.exportQrcode(null,null,couponChannel.getTenantId(),1,pageUrl,param,0,"","","卷",true); | |||||
| ResultData resultDataQ = qrCodeService.exportQrcode(null,null,couponChannel.getTenantId(),1,pageUrl,param,0,"","","卷",true); | |||||
| Map<String,String> map = (Map)resultDataQ.data; | Map<String,String> map = (Map)resultDataQ.data; | ||||
| String url = map.get("url"); | String url = map.get("url"); | ||||
| couponChannel.setQrCode(url); | couponChannel.setQrCode(url); | ||||
| @@ -1,21 +1,10 @@ | |||||
| package com.iformall.controller.sys; | package com.iformall.controller.sys; | ||||
| import com.amazonaws.AmazonClientException; | |||||
| import com.amazonaws.AmazonServiceException; | |||||
| import com.amazonaws.auth.AWSCredentials; | |||||
| import com.amazonaws.auth.AWSCredentialsProvider; | |||||
| import com.amazonaws.auth.BasicAWSCredentials; | |||||
| import com.amazonaws.services.s3.AmazonS3; | |||||
| import com.amazonaws.services.s3.AmazonS3ClientBuilder; | |||||
| import com.amazonaws.services.s3.model.*; | import com.amazonaws.services.s3.model.*; | ||||
| import com.iformall.annotation.SystemControllerLog; | import com.iformall.annotation.SystemControllerLog; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.config.AwsProperty; | |||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.domain.po.MallResource; | |||||
| import com.iformall.service.MallResourceService; | |||||
| import com.iformall.utils.Constant; | |||||
| import com.iformall.service.QrCodeService; | |||||
| import com.iformall.utils.ImgUtil; | import com.iformall.utils.ImgUtil; | ||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| @@ -28,9 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.RequestParam; | import org.springframework.web.bind.annotation.RequestParam; | ||||
| import org.springframework.web.bind.annotation.RestController; | import org.springframework.web.bind.annotation.RestController; | ||||
| import org.springframework.web.multipart.MultipartFile; | import org.springframework.web.multipart.MultipartFile; | ||||
| import java.io.*; | import java.io.*; | ||||
| import java.net.URL; | |||||
| import java.util.*; | import java.util.*; | ||||
| import java.util.List; | import java.util.List; | ||||
| @@ -41,81 +28,11 @@ public class UploadController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | |||||
| private AwsProperty awsProperty; | |||||
| @Autowired | |||||
| private MallResourceService mallResourceService; | |||||
| @Autowired | @Autowired | ||||
| private String fmUploadDir; | private String fmUploadDir; | ||||
| private AmazonS3 s3 = null; | |||||
| public ResultData awsUpload(InputStream inputStream, ObjectMetadata metadata, String fileName, String tenantId) { | |||||
| ResultData data = new ResultData(); | |||||
| try { | |||||
| if(s3 == null) { | |||||
| s3 = AmazonS3ClientBuilder.standard() | |||||
| .withRegion(awsProperty.getClientRegion()) | |||||
| .withCredentials(new AWSCredentialsProvider() { | |||||
| @Override | |||||
| public AWSCredentials getCredentials() { | |||||
| return new BasicAWSCredentials(awsProperty.getAccess(), awsProperty.getSecret()); | |||||
| } | |||||
| @Override | |||||
| public void refresh() { | |||||
| } | |||||
| }) | |||||
| .build(); | |||||
| } | |||||
| s3.putObject( | |||||
| new PutObjectRequest(awsProperty.getBucketName(), fileName, inputStream, metadata) | |||||
| .withCannedAcl(CannedAccessControlList.PublicRead)); | |||||
| URL url = s3.getUrl(awsProperty.getBucketName(), fileName); | |||||
| logger.info(url.toString()); | |||||
| MallResource mr = new MallResource(); | |||||
| mr.setTenantId(tenantId); | |||||
| mr.setBucket(awsProperty.getBucketName()); | |||||
| mr.setS3Key(fileName); | |||||
| mr.setUrl(url.toString()); | |||||
| mallResourceService.saveOrUpdate(mr); | |||||
| data.code = ResultData.SUCCESS; | |||||
| Map<String, String> map = new HashMap<>(); | |||||
| map.put("url", url.toString()); | |||||
| data.data = map; | |||||
| } catch (AmazonServiceException ase) { | |||||
| data.code = ResultData.ERROR; | |||||
| logger.warn("Caught an AmazonServiceException, which " + | |||||
| "means your request made it " + | |||||
| "to Amazon S3, but was rejected with an error response" + | |||||
| " for some reason."); | |||||
| logger.warn(ase.getMessage()); | |||||
| data.code = ResultData.ERROR; | |||||
| data.message = "上传失败"; | |||||
| } catch (AmazonClientException ace) { | |||||
| data.code = ResultData.ERROR; | |||||
| logger.warn("Caught an AmazonClientException, which " + | |||||
| "means the client encountered " + | |||||
| "an internal error while trying to " + | |||||
| "communicate with S3, " + | |||||
| "such as not being able to access the network."); | |||||
| logger.warn("Error Message: " + ace.getMessage()); | |||||
| data.code = ResultData.ERROR; | |||||
| data.message = "上传失败"; | |||||
| } catch (Exception ioe) { | |||||
| data.code = ResultData.ERROR; | |||||
| logger.warn("Caught an IOException: " + ioe.getMessage()); | |||||
| data.code = ResultData.ERROR; | |||||
| data.message = "上传失败"; | |||||
| } | |||||
| return data; | |||||
| } | |||||
| @Autowired | |||||
| private QrCodeService qrCodeService; | |||||
| /** | /** | ||||
| * 上传文件 | * 上传文件 | ||||
| @@ -134,9 +51,6 @@ public class UploadController extends BaseController { | |||||
| metadata.setContentType(multiReq.getContentType()); | metadata.setContentType(multiReq.getContentType()); | ||||
| metadata.setContentLength(multiReq.getSize()); | metadata.setContentLength(multiReq.getSize()); | ||||
| FileOutputStream fos = null; | |||||
| BufferedInputStream fs = null; | |||||
| String fileName = UUID.randomUUID().toString(); | String fileName = UUID.randomUUID().toString(); | ||||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | ||||
| if (dot >= 0) { | if (dot >= 0) { | ||||
| @@ -146,7 +60,7 @@ public class UploadController extends BaseController { | |||||
| } | } | ||||
| System.out.println(fileName); | System.out.println(fileName); | ||||
| ResultData data = awsUpload(multiReq.getInputStream(), metadata, fileName, getTenantId()); | |||||
| ResultData data = qrCodeService.awsUpload(multiReq.getInputStream(), metadata, fileName, getTenantId()); | |||||
| return data; | return data; | ||||
| } | } | ||||
| @@ -203,7 +117,7 @@ public class UploadController extends BaseController { | |||||
| ObjectMetadata metadata = new ObjectMetadata(); | ObjectMetadata metadata = new ObjectMetadata(); | ||||
| metadata.setContentType(multiReq.getContentType()); | metadata.setContentType(multiReq.getContentType()); | ||||
| metadata.setContentLength(newFile.length()); | metadata.setContentLength(newFile.length()); | ||||
| ResultData data = awsUpload(new FileInputStream(newFile), metadata, fileName, getTenantId()); | |||||
| ResultData data = qrCodeService.awsUpload(new FileInputStream(newFile), metadata, fileName, getTenantId()); | |||||
| // 删除本地缓存 | // 删除本地缓存 | ||||
| newFile.delete(); | newFile.delete(); | ||||
| return data; | return data; | ||||
| @@ -211,7 +125,7 @@ public class UploadController extends BaseController { | |||||
| ObjectMetadata metadata = new ObjectMetadata(); | ObjectMetadata metadata = new ObjectMetadata(); | ||||
| metadata.setContentType(multiReq.getContentType()); | metadata.setContentType(multiReq.getContentType()); | ||||
| metadata.setContentLength(multiReq.getSize()); | metadata.setContentLength(multiReq.getSize()); | ||||
| ResultData data = awsUpload(multiReq.getInputStream(), metadata, fileName, getTenantId()); | |||||
| ResultData data = qrCodeService.awsUpload(multiReq.getInputStream(), metadata, fileName, getTenantId()); | |||||
| return data; | return data; | ||||
| } | } | ||||
| } | } | ||||
| @@ -252,7 +166,7 @@ public class UploadController extends BaseController { | |||||
| fileName = getTenantId() + "/" + fileName; | fileName = getTenantId() + "/" + fileName; | ||||
| } | } | ||||
| ResultData data1 = awsUpload(multipartFile.getInputStream(), metadata, fileName, getTenantId()); | |||||
| ResultData data1 = qrCodeService.awsUpload(multipartFile.getInputStream(), metadata, fileName, getTenantId()); | |||||
| if(data1.code == ResultData.SUCCESS) { | if(data1.code == ResultData.SUCCESS) { | ||||
| Map _data = (Map)data1.data; | Map _data = (Map)data1.data; | ||||
| map.put("url", (String) _data.get("url")); | map.put("url", (String) _data.get("url")); | ||||
| @@ -290,7 +204,7 @@ public class UploadController extends BaseController { | |||||
| String fileName = multiReq.getOriginalFilename(); | String fileName = multiReq.getOriginalFilename(); | ||||
| fileName = "cimg/" + fileName; | fileName = "cimg/" + fileName; | ||||
| ResultData data = awsUpload(multiReq.getInputStream(), metadata, fileName, "cimg"); | |||||
| ResultData data = qrCodeService.awsUpload(multiReq.getInputStream(), metadata, fileName, "cimg"); | |||||
| return data; | return data; | ||||
| } | } | ||||
| @@ -0,0 +1,6 @@ | |||||
| delete from mall_permission where id = 962; | |||||
| INSERT INTO `mall_permission` (`id`, `name`, `parent_id`, `available`, `permission`, `resource_type`, `module_color`, `module_color_num`, `url`, `icon`, `version_type`, `sort`) | |||||
| VALUES (962, '业态分析', 2, 'Y', NULL, 1, NULL, NULL, 'businessList', 'icon-yetaifenxi', 0, 207); | |||||
| update mall_sale_type set menus = '[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 50, 101, 102, 103, 104, 105, 106, 107, 201, 202, 203, 204, 205, 206, 211, 212, 221, 222, 251, 301, 302, 303, 304, 305, 306, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 501, 502, 503, 504, 505, 506, 507, 508, 509, 511, 512, 513, 521, 522, 523, 531, 532, 533, 591, 595, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 621, 622, 623, 624, 625, 626, 627, 641, 642, 643, 644, 645, 651, 661, 662, 663, 671, 672, 673, 674, 681, 682, 683, 684, 685, 691, 692, 693, 694, 701, 702, 711, 712, 713, 901, 902, 903, 931, 932, 951, 961,962]' where id = 1; | |||||
| @@ -0,0 +1,52 @@ | |||||
| package com.iformall.config; | |||||
| import org.springframework.boot.context.properties.ConfigurationProperties; | |||||
| import org.springframework.stereotype.Component; | |||||
| /** | |||||
| * @author Stormeye | |||||
| */ | |||||
| @Component | |||||
| @ConfigurationProperties(prefix = "aws") | |||||
| public class AwsProperty { | |||||
| // AWS ACCESS KEY | |||||
| private String access; | |||||
| private String secret; | |||||
| private String clientRegion; | |||||
| private String bucketName; | |||||
| public String getAccess() { | |||||
| return access; | |||||
| } | |||||
| public void setAccess(String access) { | |||||
| this.access = access; | |||||
| } | |||||
| public String getSecret() { | |||||
| return secret; | |||||
| } | |||||
| public void setSecret(String secret) { | |||||
| this.secret = secret; | |||||
| } | |||||
| public String getClientRegion() { | |||||
| return clientRegion; | |||||
| } | |||||
| public void setClientRegion(String clientRegion) { | |||||
| this.clientRegion = clientRegion; | |||||
| } | |||||
| public String getBucketName() { | |||||
| return bucketName; | |||||
| } | |||||
| public void setBucketName(String bucketName) { | |||||
| this.bucketName = bucketName; | |||||
| } | |||||
| } | |||||
| @@ -14,4 +14,6 @@ public interface WxTopicMapper extends CommonMapper<WxTopic, String> { | |||||
| WxTopic show(WxTopic record); | WxTopic show(WxTopic record); | ||||
| void updateStatus(WxTopic record); | void updateStatus(WxTopic record); | ||||
| void couponDownLine(WxTopic record); | |||||
| } | } | ||||
| @@ -0,0 +1,23 @@ | |||||
| package com.iformall.service; | |||||
| import com.amazonaws.services.s3.model.ObjectMetadata; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import org.springframework.stereotype.Service; | |||||
| import org.springframework.web.bind.annotation.RequestBody; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| import java.io.InputStream; | |||||
| import java.util.Map; | |||||
| @Service | |||||
| public interface QrCodeService { | |||||
| void downQrCode(String tenantId,HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, Object> params) throws MallinkException; | |||||
| ResultData exportQrcode(HttpServletRequest request, HttpServletResponse response, | |||||
| String tenantId, int type, String pageUrl, String sceneParam, | |||||
| int withText, String text1, String text2, | |||||
| String name, boolean upload); | |||||
| ResultData awsUpload(InputStream inputStream, ObjectMetadata metadata, String fileName, String tenantId); | |||||
| } | |||||
| @@ -0,0 +1,294 @@ | |||||
| package com.iformall.service.impl; | |||||
| import cn.binarywang.wx.miniapp.api.WxMaService; | |||||
| import cn.binarywang.wx.miniapp.bean.WxMaCodeLineColor; | |||||
| import com.amazonaws.AmazonClientException; | |||||
| import com.amazonaws.AmazonServiceException; | |||||
| import com.amazonaws.auth.AWSCredentials; | |||||
| import com.amazonaws.auth.AWSCredentialsProvider; | |||||
| import com.amazonaws.auth.BasicAWSCredentials; | |||||
| import com.amazonaws.services.s3.AmazonS3; | |||||
| import com.amazonaws.services.s3.AmazonS3ClientBuilder; | |||||
| import com.amazonaws.services.s3.model.CannedAccessControlList; | |||||
| import com.amazonaws.services.s3.model.ObjectMetadata; | |||||
| import com.amazonaws.services.s3.model.PutObjectRequest; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.config.AwsProperty; | |||||
| import com.iformall.domain.po.MallResource; | |||||
| import com.iformall.domain.po.WxAppinfo; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.service.MallResourceService; | |||||
| import com.iformall.service.QrCodeService; | |||||
| import com.iformall.service.WxAppinfoService; | |||||
| import com.iformall.service.wechat.FmOpenService; | |||||
| import com.iformall.utils.MaUtil; | |||||
| import com.iformall.utils.QRCodeUtils; | |||||
| import me.chanjar.weixin.common.error.WxErrorException; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| import java.io.*; | |||||
| import java.net.URL; | |||||
| import java.util.*; | |||||
| /** | |||||
| * @author luozukai | |||||
| */ | |||||
| @Service | |||||
| public class QrCodeServiceImpl implements QrCodeService { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxAppinfoService wxAppinfoService; | |||||
| @Autowired | |||||
| private FmOpenService openService; | |||||
| @Autowired | |||||
| private boolean isFmOpen; | |||||
| @Autowired | |||||
| private AwsProperty awsProperty; | |||||
| @Autowired | |||||
| private MallResourceService mallResourceService; | |||||
| @Autowired | |||||
| private String fmUploadDir; | |||||
| private AmazonS3 s3 = null; | |||||
| @Override | |||||
| public ResultData awsUpload(InputStream inputStream, ObjectMetadata metadata, String fileName, String tenantId) { | |||||
| ResultData data = new ResultData(); | |||||
| try { | |||||
| if(s3 == null) { | |||||
| s3 = AmazonS3ClientBuilder.standard() | |||||
| .withRegion(awsProperty.getClientRegion()) | |||||
| .withCredentials(new AWSCredentialsProvider() { | |||||
| @Override | |||||
| public AWSCredentials getCredentials() { | |||||
| return new BasicAWSCredentials(awsProperty.getAccess(), awsProperty.getSecret()); | |||||
| } | |||||
| @Override | |||||
| public void refresh() { | |||||
| } | |||||
| }) | |||||
| .build(); | |||||
| } | |||||
| s3.putObject( | |||||
| new PutObjectRequest(awsProperty.getBucketName(), fileName, inputStream, metadata) | |||||
| .withCannedAcl(CannedAccessControlList.PublicRead)); | |||||
| URL url = s3.getUrl(awsProperty.getBucketName(), fileName); | |||||
| logger.info(url.toString()); | |||||
| MallResource mr = new MallResource(); | |||||
| mr.setTenantId(tenantId); | |||||
| mr.setBucket(awsProperty.getBucketName()); | |||||
| mr.setS3Key(fileName); | |||||
| mr.setUrl(url.toString()); | |||||
| mallResourceService.saveOrUpdate(mr); | |||||
| data.code = ResultData.SUCCESS; | |||||
| Map<String, String> map = new HashMap<>(); | |||||
| map.put("url", url.toString()); | |||||
| data.data = map; | |||||
| } catch (AmazonServiceException ase) { | |||||
| data.code = ResultData.ERROR; | |||||
| logger.warn("Caught an AmazonServiceException, which " + | |||||
| "means your request made it " + | |||||
| "to Amazon S3, but was rejected with an error response" + | |||||
| " for some reason."); | |||||
| logger.warn(ase.getMessage()); | |||||
| data.code = ResultData.ERROR; | |||||
| data.message = "上传失败"; | |||||
| } catch (AmazonClientException ace) { | |||||
| data.code = ResultData.ERROR; | |||||
| logger.warn("Caught an AmazonClientException, which " + | |||||
| "means the client encountered " + | |||||
| "an internal error while trying to " + | |||||
| "communicate with S3, " + | |||||
| "such as not being able to access the network."); | |||||
| logger.warn("Error Message: " + ace.getMessage()); | |||||
| data.code = ResultData.ERROR; | |||||
| data.message = "上传失败"; | |||||
| } catch (Exception ioe) { | |||||
| data.code = ResultData.ERROR; | |||||
| logger.warn("Caught an IOException: " + ioe.getMessage()); | |||||
| data.code = ResultData.ERROR; | |||||
| data.message = "上传失败"; | |||||
| } | |||||
| return data; | |||||
| } | |||||
| @Override | |||||
| public void downQrCode(String tenantId,HttpServletRequest request, HttpServletResponse response, Map<String, Object> params) throws MallinkException { | |||||
| String name = (String) params.get("name"); | |||||
| String pageUrl = (String) params.get("pageUrl"); | |||||
| String sceneParam = (String) params.get("sceneParam"); | |||||
| int type = 1; | |||||
| try { | |||||
| type = (int) params.get("type"); | |||||
| } catch (Exception e) { | |||||
| type = 1; | |||||
| } | |||||
| int withText = 0; | |||||
| try { | |||||
| withText = (int) params.get("withText"); | |||||
| } catch (Exception e) { | |||||
| withText = 0; | |||||
| } | |||||
| String text1 = (String) params.get("text1"); | |||||
| String text2 = (String) params.get("text2"); | |||||
| if (StringUtils.isBlank(pageUrl)) { | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "pageUrl不能为空"); | |||||
| } | |||||
| try { | |||||
| exportQrcode(request, response, | |||||
| tenantId, type, pageUrl, sceneParam, | |||||
| withText, text1, text2, | |||||
| name,false); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| throw new MallinkException(Result.ERROR, "下载异常"); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| 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) { | |||||
| // 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); | |||||
| 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); | |||||
| } | |||||
| 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); | |||||
| } | |||||
| org.apache.commons.io.FileUtils.forceDelete(codeFile); | |||||
| } | |||||
| } catch (WxErrorException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| 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; | |||||
| } | |||||
| downFile(destPath, fileName, response, request); | |||||
| org.apache.commons.io.FileUtils.forceDelete(dest); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| private void downFile(String filePath, String filename, HttpServletResponse response, HttpServletRequest req) throws IOException { | |||||
| try { | |||||
| response.reset(); | |||||
| response.setContentType("application/octet-stream"); | |||||
| String agent = req.getHeader("user-agent"); | |||||
| if (agent.contains("Firefox")) { | |||||
| response.setHeader("Content-disposition", | |||||
| "attachment; filename=" | |||||
| + new String(filename.getBytes("GB2312"),"ISO-8859-1")); | |||||
| } else { | |||||
| response.setHeader("Content-disposition", | |||||
| "attachment; filename=" | |||||
| + java.net.URLEncoder.encode(filename,"UTF-8")); | |||||
| } | |||||
| // 循环取出流中的数据 | |||||
| byte[] b = new byte[1024]; | |||||
| int len; | |||||
| InputStream inStream = new FileInputStream(filePath); | |||||
| while ((len = inStream.read(b)) > 0) | |||||
| response.getOutputStream().write(b, 0, len); | |||||
| inStream.close(); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -11,13 +11,16 @@ import com.iformall.domain.po.WxActivity; | |||||
| import com.iformall.domain.po.WxCampaign; | import com.iformall.domain.po.WxCampaign; | ||||
| import com.iformall.domain.po.WxCoupon; | import com.iformall.domain.po.WxCoupon; | ||||
| import com.iformall.domain.po.WxCouponChannel; | import com.iformall.domain.po.WxCouponChannel; | ||||
| import com.iformall.domain.vo.WxCouponChannelAddVo; | |||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.mapper.WxActivityMapper; | import com.iformall.mapper.WxActivityMapper; | ||||
| import com.iformall.mapper.WxCampaignMapper; | import com.iformall.mapper.WxCampaignMapper; | ||||
| import com.iformall.mapper.WxCouponChannelMapper; | import com.iformall.mapper.WxCouponChannelMapper; | ||||
| import com.iformall.service.QrCodeService; | |||||
| import com.iformall.service.WxCampaignService; | import com.iformall.service.WxCampaignService; | ||||
| import com.iformall.service.WxCouponChannelService; | import com.iformall.service.WxCouponChannelService; | ||||
| import com.iformall.service.WxCouponService; | import com.iformall.service.WxCouponService; | ||||
| import org.apache.commons.collections.CollectionUtils; | |||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| @@ -50,7 +53,7 @@ public class WxCampaignServiceImpl implements WxCampaignService { | |||||
| WxCouponService wxCouponService; | WxCouponService wxCouponService; | ||||
| @Autowired | @Autowired | ||||
| WxCouponChannelService wxCouponChannelService; | |||||
| QrCodeService qrCodeService; | |||||
| @Autowired | @Autowired | ||||
| WxActivityMapper wxActivityMapper; | WxActivityMapper wxActivityMapper; | ||||
| @@ -265,6 +268,17 @@ public class WxCampaignServiceImpl implements WxCampaignService { | |||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| wxCouponChannel.setId(idWorker.nextId()); | wxCouponChannel.setId(idWorker.nextId()); | ||||
| wxCouponChannelMapper.insertSelective(wxCouponChannel); | wxCouponChannelMapper.insertSelective(wxCouponChannel); | ||||
| String pageUrl = "pages/index/index"; | |||||
| WxCouponChannel couponChannel = new WxCouponChannel(); | |||||
| 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); | |||||
| Map<String,String> map = (Map)resultDataQ.data; | |||||
| String url = map.get("url"); | |||||
| couponChannel.setQrCode(url); | |||||
| wxCouponChannelMapper.updateByPrimaryKeySelective(couponChannel); | |||||
| } | } | ||||
| } | } | ||||
| @@ -15,16 +15,13 @@ import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.WxCouponChannelMapper; | import com.iformall.mapper.WxCouponChannelMapper; | ||||
| import com.iformall.mapper.WxCouponOrderMapper; | import com.iformall.mapper.WxCouponOrderMapper; | ||||
| import com.iformall.mapper.WxGameActionLogMapper; | import com.iformall.mapper.WxGameActionLogMapper; | ||||
| import com.iformall.service.WxCouponChannelService; | |||||
| import com.iformall.service.WxCouponService; | |||||
| import com.iformall.service.WxGameTemplateService; | |||||
| import com.iformall.service.*; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import java.util.*; | import java.util.*; | ||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.mapper.WxGameMapper; | import com.iformall.mapper.WxGameMapper; | ||||
| import com.iformall.service.WxGameService; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| @@ -56,6 +53,8 @@ public class WxGameServiceImpl implements WxGameService { | |||||
| @Autowired | @Autowired | ||||
| WxGameActionLogMapper wxGameActionLogMapper; | WxGameActionLogMapper wxGameActionLogMapper; | ||||
| @Autowired | |||||
| private QrCodeService qrCodeService; | |||||
| @Override | @Override | ||||
| public PageInfo<WxGame> listAsPage(WxGame record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxGame> listAsPage(WxGame record, Integer pageIndex, Integer pageSize) { | ||||
| @@ -306,6 +305,17 @@ public class WxGameServiceImpl implements WxGameService { | |||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| wxCouponChannel.setId(idWorker.nextId()); | wxCouponChannel.setId(idWorker.nextId()); | ||||
| wxCouponChannelMapper.insertSelective(wxCouponChannel); | wxCouponChannelMapper.insertSelective(wxCouponChannel); | ||||
| String pageUrl = "pages/index/index"; | |||||
| WxCouponChannel couponChannel = new WxCouponChannel(); | |||||
| 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); | |||||
| Map<String,String> map = (Map)resultDataQ.data; | |||||
| String url = map.get("url"); | |||||
| couponChannel.setQrCode(url); | |||||
| wxCouponChannelMapper.updateByPrimaryKeySelective(couponChannel); | |||||
| } | } | ||||
| } | } | ||||
| @@ -14,6 +14,7 @@ import com.iformall.enums.EnumWxTopicStatus; | |||||
| import com.iformall.mapper.WxCouponChannelMapper; | import com.iformall.mapper.WxCouponChannelMapper; | ||||
| import com.iformall.mapper.WxCouponMapper; | import com.iformall.mapper.WxCouponMapper; | ||||
| import com.iformall.mapper.WxTopicMapper; | import com.iformall.mapper.WxTopicMapper; | ||||
| import com.iformall.service.QrCodeService; | |||||
| import com.iformall.service.WxTopicService; | import com.iformall.service.WxTopicService; | ||||
| import com.iformall.utils.DateUtils; | import com.iformall.utils.DateUtils; | ||||
| import org.apache.commons.collections.CollectionUtils; | import org.apache.commons.collections.CollectionUtils; | ||||
| @@ -24,6 +25,7 @@ import org.springframework.stereotype.Service; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | |||||
| /** | /** | ||||
| * @author luozukai ^_^ | * @author luozukai ^_^ | ||||
| @@ -37,10 +39,13 @@ public class WxTopicServiceImpl implements WxTopicService { | |||||
| private WxCouponMapper wxCouponMapper; | private WxCouponMapper wxCouponMapper; | ||||
| @Autowired | @Autowired | ||||
| private WxCouponChannelMapper wxCouponChannelMapper; | private WxCouponChannelMapper wxCouponChannelMapper; | ||||
| @Autowired | |||||
| private QrCodeService qrCodeService; | |||||
| @Override | @Override | ||||
| public PageInfo<WxTopic> listAsPage(WxTopic record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxTopic> listAsPage(WxTopic record, Integer pageIndex, Integer pageSize) { | ||||
| wxTopicMapper.updateStatus(record); | wxTopicMapper.updateStatus(record); | ||||
| wxTopicMapper.couponDownLine(record); | |||||
| if(StringUtils.isNotBlank(record.getStatusStr())){ | if(StringUtils.isNotBlank(record.getStatusStr())){ | ||||
| String[] array = record.getStatusStr().split(","); | String[] array = record.getStatusStr().split(","); | ||||
| List<Integer> integerList = new ArrayList<>(); | List<Integer> integerList = new ArrayList<>(); | ||||
| @@ -104,6 +109,7 @@ public class WxTopicServiceImpl implements WxTopicService { | |||||
| wxCouponChannelMapper.delByTopic(record); | wxCouponChannelMapper.delByTopic(record); | ||||
| addCouponTopic(record); | addCouponTopic(record); | ||||
| } | } | ||||
| wxTopicMapper.couponDownLine(record); | |||||
| return new ResultData(Result.SUCCESS,"更新成功"); | return new ResultData(Result.SUCCESS,"更新成功"); | ||||
| } | } | ||||
| } | } | ||||
| @@ -127,6 +133,17 @@ public class WxTopicServiceImpl implements WxTopicService { | |||||
| wxCouponChannel.setBusiness(wxCoupon.getBusiness()); | wxCouponChannel.setBusiness(wxCoupon.getBusiness()); | ||||
| wxCouponChannel.setSubBusiness(wxCoupon.getSubBusiness()); | wxCouponChannel.setSubBusiness(wxCoupon.getSubBusiness()); | ||||
| wxCouponChannelMapper.insertSelective(wxCouponChannel); | wxCouponChannelMapper.insertSelective(wxCouponChannel); | ||||
| String pageUrl = "pages/index/index"; | |||||
| WxCouponChannel couponChannel = new WxCouponChannel(); | |||||
| 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); | |||||
| Map<String,String> map = (Map)resultDataQ.data; | |||||
| String url = map.get("url"); | |||||
| couponChannel.setQrCode(url); | |||||
| wxCouponChannelMapper.updateByPrimaryKeySelective(couponChannel); | |||||
| } | } | ||||
| } | } | ||||
| @@ -90,4 +90,12 @@ | |||||
| update wx_topic set status = 3 where now() >= end_time and tenant_id = #{tenantId} | update wx_topic set status = 3 where now() >= end_time and tenant_id = #{tenantId} | ||||
| </update> | </update> | ||||
| <update id="couponDownLine" parameterType="com.iformall.domain.po.WxTopic"> | |||||
| update wx_coupon_channel set status = 1 where target_ad = 8 and sub_target_id in( | |||||
| select id from wx_topic where status in(2,3) and tenant_id = #{tenantId} | |||||
| ) | |||||
| </update> | |||||
| </mapper> | </mapper> | ||||