developrelease_toaliyun_real
| @@ -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); | ||||
| @@ -5,27 +5,21 @@ import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| 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.domain.po.WxMerchant; | |||||
| import com.iformall.domain.po.WxMerchantBUser; | |||||
| import com.iformall.domain.po.WxMerchantTradeDaily; | import com.iformall.domain.po.WxMerchantTradeDaily; | ||||
| import com.iformall.domain.vo.WxMerchantTradeDailyVo; | import com.iformall.domain.vo.WxMerchantTradeDailyVo; | ||||
| import com.iformall.service.WxMerchantBUserService; | |||||
| import com.iformall.service.WxMerchantService; | |||||
| import com.iformall.service.WxMerchantTradeDailyService; | import com.iformall.service.WxMerchantTradeDailyService; | ||||
| import com.iformall.utils.DateUtils; | |||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import org.apache.commons.collections.CollectionUtils; | |||||
| import org.apache.commons.collections.map.LinkedMap; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | 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.HttpServletResponse; | |||||
| import java.text.SimpleDateFormat; | import java.text.SimpleDateFormat; | ||||
| import java.util.*; | |||||
| import java.util.Date; | |||||
| @RestController | @RestController | ||||
| @RequestMapping("wxMerchantTradeDaily") | @RequestMapping("wxMerchantTradeDaily") | ||||
| @@ -109,4 +103,16 @@ public class WxMerchantTradeDailyController extends BaseController { | |||||
| return wxMerchantTradeDailyService.queryTradeDaily(wxMerchantTradeDaily); | return wxMerchantTradeDailyService.queryTradeDaily(wxMerchantTradeDaily); | ||||
| } | } | ||||
| @GetMapping("exportData") | |||||
| @SystemControllerLog(description = "商户解单数据-导出数据") | |||||
| public void exportData(@ModelAttribute WxMerchantTradeDailyVo wxMerchantTradeDaily, HttpServletRequest request, HttpServletResponse response) { | |||||
| logger.debug("[" + getIpAddr() + "] WxMerchantTradeDailyController::exportData"); | |||||
| if (null == wxMerchantTradeDaily) { | |||||
| wxMerchantTradeDaily = new WxMerchantTradeDailyVo(); | |||||
| } | |||||
| wxMerchantTradeDaily.setTenantId(getTenantId()); | |||||
| wxMerchantTradeDaily.setSortColumns(WxMerchantTradeDailyVo.Field.MerchantId_DESC); | |||||
| wxMerchantTradeDailyService.exportData(wxMerchantTradeDaily, request, response); | |||||
| } | |||||
| } | } | ||||
| @@ -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); | ||||
| @@ -129,6 +129,7 @@ public class HomeController extends BaseController { | |||||
| UsernamePasswordToken token = new UsernamePasswordToken(user.getUsername(), user.getPassword()); | UsernamePasswordToken token = new UsernamePasswordToken(user.getUsername(), user.getPassword()); | ||||
| subject.login(token); | subject.login(token); | ||||
| isLogin = true; | isLogin = true; | ||||
| logger.info("ADMIN USER:"+user.getUsername() + ", password:" + user.getPassword()); | |||||
| } catch (UnknownAccountException e) { | } catch (UnknownAccountException e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| return new ResultData(ErrorCode.USER_IS_EMPTY); | return new ResultData(ErrorCode.USER_IS_EMPTY); | ||||
| @@ -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; | ||||
| } | } | ||||
| @@ -1,6 +1,5 @@ | |||||
| package com.iformall.common; | package com.iformall.common; | ||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.utils.IPUtil; | import com.iformall.utils.IPUtil; | ||||
| import java.lang.management.ManagementFactory; | import java.lang.management.ManagementFactory; | ||||
| @@ -8,13 +7,21 @@ import java.net.UnknownHostException; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.List; | import java.util.List; | ||||
| /** | |||||
| * 产生唯一ID的snow flake | |||||
| * 41(timestamp)+16(ip)+18(pid)+8(seq) | |||||
| * | |||||
| * @author changstone | |||||
| * | |||||
| */ | |||||
| public class IdWorker { | public class IdWorker { | ||||
| // ==============================Fields=========================================== | // ==============================Fields=========================================== | ||||
| /** 开始时间截 (2015-01-01) */ | /** 开始时间截 (2015-01-01) */ | ||||
| private final long twepoch = 1489111610226L; | private final long twepoch = 1489111610226L; | ||||
| /** 机器id所占的位数 */ | /** 机器id所占的位数 */ | ||||
| private final long workerIdBits = 5L; | |||||
| private final long workerIdBits = 9L; | |||||
| /** 数据标识id所占的位数 */ | /** 数据标识id所占的位数 */ | ||||
| private final long dataCenterIdBits = 5L; | private final long dataCenterIdBits = 5L; | ||||
| @@ -70,8 +77,9 @@ public class IdWorker { | |||||
| e.printStackTrace(); | e.printStackTrace(); | ||||
| } | } | ||||
| String[] ipArray = ipAddr.split("\\."); | String[] ipArray = ipAddr.split("\\."); | ||||
| Long ip = Long.valueOf(ipArray[2]) << 8 | Long.valueOf(ipArray[3]) & maxWorkerId; | |||||
| Long processId = Long.valueOf(ManagementFactory.getRuntimeMXBean().getName().split("@")[0]) & maxDataCenterId; | |||||
| Long workerId = Long.valueOf(ipArray[3]) & maxWorkerId; /// Long.valueOf(ipArray[2]) << 8 | | |||||
| String pName = ManagementFactory.getRuntimeMXBean().getName(); | |||||
| Long dataCenterId = Long.valueOf(pName.split("@")[0]) & maxDataCenterId; | |||||
| if (workerId > maxWorkerId || workerId < 0) { | if (workerId > maxWorkerId || workerId < 0) { | ||||
| throw new IllegalArgumentException(String.format("workerId can't be greater than %d or less than 0", maxWorkerId)); | throw new IllegalArgumentException(String.format("workerId can't be greater than %d or less than 0", maxWorkerId)); | ||||
| @@ -166,7 +174,7 @@ public class IdWorker { | |||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| List<Thread> list = new ArrayList<>(); | List<Thread> list = new ArrayList<>(); | ||||
| for(int j=0;j< 10;j++) { | |||||
| for(int j=0;j< 40;j++) { | |||||
| list.add(new Thread(() -> { | list.add(new Thread(() -> { | ||||
| long startTime = System.nanoTime(); | long startTime = System.nanoTime(); | ||||
| for (int i = 0; i < 50000; i++) { | for (int i = 0; i < 50000; i++) { | ||||
| @@ -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; | |||||
| } | |||||
| } | |||||
| @@ -1,5 +1,6 @@ | |||||
| package com.iformall.domain.vo; | package com.iformall.domain.vo; | ||||
| import cn.afterturn.easypoi.excel.annotation.Excel; | |||||
| import com.iformall.domain.po.BaseEntity; | import com.iformall.domain.po.BaseEntity; | ||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
| @@ -33,25 +34,42 @@ public class WxMerchantTradeDailyVo extends BaseEntity { | |||||
| private Long merchantId; | private Long merchantId; | ||||
| @io.swagger.annotations.ApiModelProperty(value = "b用户id", name = "bUserId") | @io.swagger.annotations.ApiModelProperty(value = "b用户id", name = "bUserId") | ||||
| private Long bUserId; | private Long bUserId; | ||||
| @Excel(name = "解单金额(元)", width = 20, orderNum = "3") | |||||
| @io.swagger.annotations.ApiModelProperty(value = "交易额", name = "tradeAmt") | @io.swagger.annotations.ApiModelProperty(value = "交易额", name = "tradeAmt") | ||||
| private Integer tradeAmt; | private Integer tradeAmt; | ||||
| @io.swagger.annotations.ApiModelProperty(value = "解单提交日期", name = "createDate") | @io.swagger.annotations.ApiModelProperty(value = "解单提交日期", name = "createDate") | ||||
| private Date createDate; | private Date createDate; | ||||
| @Excel(name = "上报时间", width = 20, orderNum = "5", format = "yyyy-MM-dd HH:mm:ss") | |||||
| @io.swagger.annotations.ApiModelProperty(value = "解单更新日期", name = "updateDate") | @io.swagger.annotations.ApiModelProperty(value = "解单更新日期", name = "updateDate") | ||||
| private Date updateDate; | private Date updateDate; | ||||
| @Excel(name = "解单日期", width = 20, orderNum = "1", format = "yyyy-MM-dd") | |||||
| @io.swagger.annotations.ApiModelProperty(value = "解单日期", name = "reportDate") | @io.swagger.annotations.ApiModelProperty(value = "解单日期", name = "reportDate") | ||||
| private String reportDate; | private String reportDate; | ||||
| @Excel(name = "商户名称", width = 20, orderNum = "2") | |||||
| @io.swagger.annotations.ApiModelProperty(value="商户名",name="merchantName") | @io.swagger.annotations.ApiModelProperty(value="商户名",name="merchantName") | ||||
| private String merchantName; | private String merchantName; | ||||
| public String getbUserName() { | |||||
| return bUserName; | |||||
| } | |||||
| public void setbUserName(String bUserName) { | |||||
| this.bUserName = bUserName; | |||||
| } | |||||
| @Excel(name = "操作人", width = 20, orderNum = "6") | |||||
| @io.swagger.annotations.ApiModelProperty(value = "b端用户姓名", name = "bUserName") | @io.swagger.annotations.ApiModelProperty(value = "b端用户姓名", name = "bUserName") | ||||
| private String bUserName; | private String bUserName; | ||||
| @Excel(name = "联系电话", width = 20, orderNum = "7") | |||||
| @io.swagger.annotations.ApiModelProperty(value = "B端用户手机号", name = "bUserPhone") | @io.swagger.annotations.ApiModelProperty(value = "B端用户手机号", name = "bUserPhone") | ||||
| private String bUserPhone; | private String bUserPhone; | ||||
| @Excel(name = "交易笔数", width = 20, orderNum = "4") | |||||
| @io.swagger.annotations.ApiModelProperty(value = "交易笔数", name = "tradeCount") | @io.swagger.annotations.ApiModelProperty(value = "交易笔数", name = "tradeCount") | ||||
| private Integer tradeCount; | private Integer tradeCount; | ||||
| @io.swagger.annotations.ApiModelProperty(value = "凭证", name = "proof") | @io.swagger.annotations.ApiModelProperty(value = "凭证", name = "proof") | ||||
| @@ -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); | |||||
| } | |||||
| @@ -5,6 +5,9 @@ import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxMerchantTradeDaily; | import com.iformall.domain.po.WxMerchantTradeDaily; | ||||
| import com.iformall.domain.vo.WxMerchantTradeDailyVo; | import com.iformall.domain.vo.WxMerchantTradeDailyVo; | ||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| public interface WxMerchantTradeDailyService { | public interface WxMerchantTradeDailyService { | ||||
| /** | /** | ||||
| @@ -84,4 +87,5 @@ public interface WxMerchantTradeDailyService { | |||||
| ResultData queryTradeDaily(WxMerchantTradeDailyVo wxMerchantTradeDaily); | ResultData queryTradeDaily(WxMerchantTradeDailyVo wxMerchantTradeDaily); | ||||
| void exportData(WxMerchantTradeDailyVo wxMerchantTradeDaily, HttpServletRequest request, HttpServletResponse response); | |||||
| } | } | ||||
| @@ -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); | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,12 +1,9 @@ | |||||
| package com.iformall.service.impl; | package com.iformall.service.impl; | ||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.*; | |||||
| import java.util.stream.Collectors; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxMall; | import com.iformall.domain.po.WxMall; | ||||
| @@ -15,17 +12,17 @@ import com.iformall.domain.po.WxMerchantBUser; | |||||
| import com.iformall.domain.po.WxMerchantTradeDaily; | import com.iformall.domain.po.WxMerchantTradeDaily; | ||||
| import com.iformall.domain.vo.WxMerchantTradeDailyVo; | import com.iformall.domain.vo.WxMerchantTradeDailyVo; | ||||
| import com.iformall.mapper.WxMerchantTradeDailyMapper; | import com.iformall.mapper.WxMerchantTradeDailyMapper; | ||||
| import com.iformall.service.WxMerchantTradeDailyService; | |||||
| import com.iformall.service.WxMallService; | |||||
| import com.iformall.service.WxMerchantBUserService; | |||||
| import com.iformall.service.WxMerchantService; | |||||
| import com.iformall.utils.DateUtils; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import com.iformall.service.*; | |||||
| import org.slf4j.Logger; | 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.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import com.iformall.common.IdWorker; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.*; | |||||
| import java.util.stream.Collectors; | |||||
| @Service | @Service | ||||
| public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyService { | public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyService { | ||||
| @@ -43,6 +40,9 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ | |||||
| @Autowired | @Autowired | ||||
| WxMallService wxMallService; | WxMallService wxMallService; | ||||
| @Autowired | |||||
| ExcelService excelService; | |||||
| @Override | @Override | ||||
| public PageInfo<WxMerchantTradeDaily> listAsPage(WxMerchantTradeDaily record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxMerchantTradeDaily> listAsPage(WxMerchantTradeDaily record, Integer pageIndex, Integer pageSize) { | ||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMerchantTradeDailyMapper.findList(record)); | return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMerchantTradeDailyMapper.findList(record)); | ||||
| @@ -172,6 +172,28 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ | |||||
| return new ResultData(wxMerchantTradeDaily); | return new ResultData(wxMerchantTradeDaily); | ||||
| } | } | ||||
| @Override | |||||
| public void exportData(WxMerchantTradeDailyVo wxMerchantTradeDailyVo, HttpServletRequest request, HttpServletResponse response) { | |||||
| //没有商户ID导出全部数据 | |||||
| String name = "解单数据"; | |||||
| if (wxMerchantTradeDailyVo.getMerchantId() == null) { | |||||
| String title = wxMerchantTradeDailyVo.getReportDate() + "商户解单数据"; | |||||
| List<WxMerchantTradeDailyVo> list = wxMerchantTradeDailyMapper.findListVo(wxMerchantTradeDailyVo); | |||||
| excelService.exportExcel(list, title, name, WxMerchantTradeDailyVo.class, name + ".xlsx", response, false); | |||||
| } else { | |||||
| WxMerchantTradeDaily wxMerchantTradeDaily = new WxMerchantTradeDaily(); | |||||
| wxMerchantTradeDaily.setTenantId(wxMerchantTradeDailyVo.getTenantId()); | |||||
| wxMerchantTradeDaily.setMerchantId(wxMerchantTradeDailyVo.getMerchantId()); | |||||
| List<WxMerchantTradeDailyVo> list = wxMerchantTradeDailyMapper.findListVoOfMonth(wxMerchantTradeDaily); | |||||
| String title = "近30天解单数据"; | |||||
| if (!list.isEmpty()) { | |||||
| String merchantName = list.get(0).getMerchantName(); | |||||
| title = merchantName + title; | |||||
| } | |||||
| excelService.exportExcel(list, title, name, WxMerchantTradeDailyVo.class, name + ".xlsx", response, false); | |||||
| } | |||||
| } | |||||
| @Override | @Override | ||||
| public ResultData getVolumeOfMonth(Long merchantId) { | public ResultData getVolumeOfMonth(Long merchantId) { | ||||
| @@ -188,9 +210,9 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ | |||||
| Calendar cal = Calendar.getInstance(); | Calendar cal = Calendar.getInstance(); | ||||
| SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); | SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); | ||||
| SimpleDateFormat fmtv = new SimpleDateFormat("MM/dd"); | SimpleDateFormat fmtv = new SimpleDateFormat("MM/dd"); | ||||
| cal.setTime(new Date()); | |||||
| for (int i = 0; i < 30; i++) { | for (int i = 0; i < 30; i++) { | ||||
| cal.add(Calendar.DAY_OF_YEAR, -1); | |||||
| cal.setTime(new Date()); | |||||
| cal.add(Calendar.DAY_OF_YEAR, -i); | |||||
| WxMerchantTradeDailyVo trade = recordMap.get(fmt.format(cal.getTime())); | WxMerchantTradeDailyVo trade = recordMap.get(fmt.format(cal.getTime())); | ||||
| if (trade != null){ | if (trade != null){ | ||||
| trade.setReportDate(fmtv.format(cal.getTime())); | trade.setReportDate(fmtv.format(cal.getTime())); | ||||
| @@ -204,6 +226,7 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ | |||||
| trade.setReportDate(fmtv.format(cal.getTime())); | trade.setReportDate(fmtv.format(cal.getTime())); | ||||
| tradeList.add(trade); | tradeList.add(trade); | ||||
| } | } | ||||
| cal.clear(); | |||||
| } | } | ||||
| Collections.reverse(tradeList); | Collections.reverse(tradeList); | ||||
| return new ResultData(tradeList); | return new ResultData(tradeList); | ||||
| @@ -223,9 +246,10 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ | |||||
| Calendar cal = Calendar.getInstance(); | Calendar cal = Calendar.getInstance(); | ||||
| SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); | SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); | ||||
| SimpleDateFormat fmtv = new SimpleDateFormat("MM/dd"); | SimpleDateFormat fmtv = new SimpleDateFormat("MM/dd"); | ||||
| cal.setTime(new Date()); | |||||
| for (int i = 0; i < 30; i++) { | for (int i = 0; i < 30; i++) { | ||||
| cal.add(Calendar.DAY_OF_YEAR, -1); | |||||
| cal.setTime(new Date()); | |||||
| cal.add(Calendar.DAY_OF_MONTH, -i); | |||||
| System.out.println(fmt.format(cal.getTime())); | |||||
| WxMerchantTradeDaily trade = recordMap.get(fmt.format(cal.getTime())); | WxMerchantTradeDaily trade = recordMap.get(fmt.format(cal.getTime())); | ||||
| if (trade != null){ | if (trade != null){ | ||||
| trade.setReportDate(fmtv.format(cal.getTime())); | trade.setReportDate(fmtv.format(cal.getTime())); | ||||
| @@ -236,6 +260,7 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ | |||||
| trade.setReportDate(fmtv.format(cal.getTime())); | trade.setReportDate(fmtv.format(cal.getTime())); | ||||
| tradeList.add(trade); | tradeList.add(trade); | ||||
| } | } | ||||
| cal.clear(); | |||||
| } | } | ||||
| Collections.reverse(tradeList); | Collections.reverse(tradeList); | ||||
| @@ -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); | |||||
| } | } | ||||
| } | } | ||||
| @@ -12,10 +12,11 @@ | |||||
| <result column="details" jdbcType="VARCHAR" property="details"/> | <result column="details" jdbcType="VARCHAR" property="details"/> | ||||
| <result column="createtime" jdbcType="TIMESTAMP" property="createtime"/> | <result column="createtime" jdbcType="TIMESTAMP" property="createtime"/> | ||||
| <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime"/> | <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime"/> | ||||
| <result column="pay_date" jdbcType="TIMESTAMP" property="payDate"/> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`bill_id`,`user_id`,`user_name`,`phone`,`action`,`details`,`createtime`,`updatetime` | |||||
| `id`,`tenant_id`,`bill_id`,`user_id`,`user_name`,`phone`,`action`,`details`,`createtime`,`updatetime`,`pay_date` | |||||
| </sql> | </sql> | ||||
| @@ -244,6 +244,7 @@ | |||||
| </foreach> | </foreach> | ||||
| </if> | </if> | ||||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | <if test=" null != sortColumns">order by ${sortColumns}</if> | ||||
| </sql> | </sql> | ||||
| @@ -414,6 +415,13 @@ | |||||
| #{typesItem} | #{typesItem} | ||||
| </foreach> | </foreach> | ||||
| </if> | </if> | ||||
| <!-- | |||||
| <if test="0 == status "> | |||||
| and c.id not in | |||||
| (select coupon_id from wx_coupon_channel where tenant_id=#{tenantId} and status = 0) | |||||
| </if>--> | |||||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | <if test=" null != sortColumns">order by ${sortColumns}</if> | ||||
| </sql> | </sql> | ||||
| @@ -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> | ||||