| @@ -8,6 +8,7 @@ import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxCouponChannel; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxPayAccount; | |||
| import com.iformall.enums.EnumAppPlat; | |||
| import com.iformall.enums.EnumPayVersion; | |||
| import com.iformall.enums.EnumPayWay; | |||
| @@ -17,6 +18,7 @@ import com.iformall.mapper.WxCouponMapper; | |||
| import com.iformall.mapper.WxMerchantMapper; | |||
| import com.iformall.service.QrCodeService; | |||
| import com.iformall.service.WxAppinfoService; | |||
| import com.iformall.service.WxPayAccountService; | |||
| import com.iformall.utils.Constant; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| @@ -41,6 +43,9 @@ public class WxAppinfoController extends BaseController { | |||
| @Autowired | |||
| private WxAppinfoService wxAppinfoService; | |||
| @Autowired | |||
| private WxPayAccountService wxPayAccountService; | |||
| @Autowired | |||
| private WxMerchantMapper wxMerchantMapper; | |||
| @@ -68,14 +73,14 @@ public class WxAppinfoController extends BaseController { | |||
| public void run() { | |||
| String param = merchant.getWeappScene(); | |||
| if(StringUtils.isBlank(merchant.getQrCode())){ | |||
| ResultData wxQrCode = qrCodeService.uploadQrcode(merchant, 1, pageUrl, param, 0, "", "", "WX店铺"+merchant.getId().toString(),EnumAppPlat.WX,EnumPayVersion.WX_PAY_V2); | |||
| ResultData wxQrCode = qrCodeService.uploadQrcode(merchant, 1, pageUrl, param, 0, "", "", "WX店铺"+merchant.getId().toString(),EnumAppPlat.WX); | |||
| Map<String, String> wxMap = (Map) wxQrCode.data; | |||
| if(wxMap != null && wxMap.get("url") != null) { | |||
| merchant.setQrCode(wxMap.get("url")); | |||
| } | |||
| } | |||
| if(StringUtils.isBlank(merchant.getTtQrCode())){ | |||
| ResultData ttQrCode = qrCodeService.uploadQrcode(merchant, 1, pageUrl, param, 0, "", "", "TT店铺"+merchant.getId().toString(),EnumAppPlat.TOUTIAO,EnumPayVersion.DY_PAY_V2); | |||
| ResultData ttQrCode = qrCodeService.uploadQrcode(merchant, 1, pageUrl, param, 0, "", "", "TT店铺"+merchant.getId().toString(),EnumAppPlat.TOUTIAO); | |||
| Map<String, String> ttMap = (Map) ttQrCode.data; | |||
| if(ttMap != null && ttMap.get("url") != null) { | |||
| merchant.setTtQrCode(ttMap.get("url")); | |||
| @@ -107,14 +112,14 @@ public class WxAppinfoController extends BaseController { | |||
| String param = couponChannel.getWeappScene(); | |||
| if(StringUtils.isBlank(couponChannel.getQrCode())){ | |||
| ResultData wxQrCode = qrCodeService.uploadQrcode(couponChannel, 1, pageUrl, param, 0, "", "", "WX券"+couponChannel.getId().toString(),EnumAppPlat.WX,EnumPayVersion.WX_PAY_V2); | |||
| ResultData wxQrCode = qrCodeService.uploadQrcode(couponChannel, 1, pageUrl, param, 0, "", "", "WX券"+couponChannel.getId().toString(),EnumAppPlat.WX); | |||
| Map<String, String> wxMap = (Map) wxQrCode.data; | |||
| if(wxMap != null && wxMap.get("url") != null) { | |||
| couponChannel.setQrCode(wxMap.get("url")); | |||
| } | |||
| } | |||
| if(StringUtils.isBlank(couponChannel.getTtQrCode())){ | |||
| ResultData ttQrCode = qrCodeService.uploadQrcode(couponChannel, 1, pageUrl, param, 0, "", "", "TT券"+couponChannel.getId().toString(),EnumAppPlat.TOUTIAO,EnumPayVersion.DY_PAY_V2); | |||
| ResultData ttQrCode = qrCodeService.uploadQrcode(couponChannel, 1, pageUrl, param, 0, "", "", "TT券"+couponChannel.getId().toString(),EnumAppPlat.TOUTIAO); | |||
| Map<String, String> ttMap = (Map) ttQrCode.data; | |||
| if(ttMap != null && ttMap.get("url") != null) { | |||
| couponChannel.setTtQrCode(ttMap.get("url")); | |||
| @@ -136,7 +141,7 @@ public class WxAppinfoController extends BaseController { | |||
| String pageUrl = (String) params.get("pageUrl"); | |||
| String sceneParam = (String) params.get("sceneParam"); | |||
| Integer platCode = (Integer) params.get("plat"); | |||
| Integer payVersion = (Integer) params.get("payVersion"); | |||
| // Integer payVersion = (Integer) params.get("payVersion"); | |||
| if(platCode == null){ | |||
| platCode = EnumAppPlat.WX.getCode(); | |||
| @@ -146,11 +151,6 @@ public class WxAppinfoController extends BaseController { | |||
| plat = EnumAppPlat.WX; | |||
| } | |||
| EnumPayVersion ePayVersion = EnumPayVersion.WX_PAY_V2; | |||
| if(payVersion != null){ | |||
| ePayVersion = EnumPayVersion.getEnum(payVersion); | |||
| } | |||
| int type = 1; | |||
| try { | |||
| type = (int) params.get("type"); | |||
| @@ -173,7 +173,7 @@ public class WxAppinfoController extends BaseController { | |||
| qrCodeService.exportQrcode(request, response, | |||
| getTenantInfo(), type, pageUrl, sceneParam, | |||
| withText, text1, text2, | |||
| name,plat,ePayVersion); | |||
| name,plat); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| throw new MallinkException(Result.ERROR, "下载异常"); | |||
| @@ -100,46 +100,47 @@ public class WxCashOutController extends BaseController { | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("查询当前提现信息") | |||
| @GetMapping("getCurrentCashOutData") | |||
| public ResultData getCurrentCashOutData() { | |||
| WxMerchantBUser buser = getLoginBUser(); | |||
| WxMerchant merchant = wxMerchantService.getById(buser.getMerchantId()); | |||
| WxMall mall = wxMallService.getByTenantId(buser.getTenantId()); | |||
| Map<String,Object> resultMap = new HashMap<String,Object>(); | |||
| resultMap.put("cashOutCount", merchant.getCashOutCount()); | |||
| resultMap.put("cashOutNumber", merchant.getCashOutNumber()); | |||
| WxAppinfo appInfo = getCurrentApp(); | |||
| if (null == appInfo.getPayId()) { | |||
| resultMap.put("cashOutSupport", 0); | |||
| } | |||
| WxPayAccount payAccount= wxPayAccountService.getById(appInfo.getPayId()); | |||
| if (payAccount.getShare().intValue() == EnumPayShare.YES.getCode().intValue()) { | |||
| resultMap.put("cashOutSupport", 0); | |||
| }else { | |||
| CUser user = getCUser(); | |||
| if (!currentWxBUserIsAdmin(user,merchant)) { | |||
| resultMap.put("cashOutSupport", 0); | |||
| }else { | |||
| //此处注销是为了满足一个联系手机存在于多个商户的情况。只用微信做验证 | |||
| //if (!currentMerchantBUserIsAdmin(buser,merchant)) { | |||
| // resultMap.put("cashOutSupport", 0); | |||
| //}else { | |||
| resultMap.put("cashOutSupport", mall.getCashOutSupport()); | |||
| if (1 == mall.getCashOutSupport().intValue()) { | |||
| WxCUser mUser = getCurrentCUser(merchant); | |||
| if (mUser == null) { | |||
| return new ResultData(Result.ERROR,"请用绑定["+merchant.getLinkPhone()+"]的微信在C端完成授权手机号操作。"); | |||
| } | |||
| resultMap.put("cashOutOpenNickName", mUser.getNickName()); | |||
| resultMap.put("cashOutOpenHeadImg", mUser.getAvatarUrl()); | |||
| } | |||
| //} | |||
| } | |||
| } | |||
| resultMap.put("cashOutLimit", mall.getCashOutLimit()); | |||
| return new ResultData(resultMap); | |||
| } | |||
| // @ApiOperation("查询当前提现信息") | |||
| // @GetMapping("getCurrentCashOutData") | |||
| // public ResultData getCurrentCashOutData() { | |||
| // WxMerchantBUser buser = getLoginBUser(); | |||
| // WxMerchant merchant = wxMerchantService.getById(buser.getMerchantId()); | |||
| // WxMall mall = wxMallService.getByTenantId(buser.getTenantId()); | |||
| // Map<String,Object> resultMap = new HashMap<String,Object>(); | |||
| // resultMap.put("cashOutCount", merchant.getCashOutCount()); | |||
| // resultMap.put("cashOutNumber", merchant.getCashOutNumber()); | |||
| // WxAppinfo appInfo = getCurrentApp(); | |||
| // if (null == appInfo.getPayId()) { | |||
| // resultMap.put("cashOutSupport", 0); | |||
| // } | |||
| // WxPayAccount payAccount= wxPayAccountService.getById(appInfo.getPayId()); | |||
| // if (payAccount.getShare().intValue() == EnumPayShare.YES.getCode().intValue()) { | |||
| // resultMap.put("cashOutSupport", 0); | |||
| // }else { | |||
| // CUser user = getCUser(); | |||
| // if (!currentWxBUserIsAdmin(user,merchant)) { | |||
| // resultMap.put("cashOutSupport", 0); | |||
| // }else { | |||
| // //此处注销是为了满足一个联系手机存在于多个商户的情况。只用微信做验证 | |||
| // //if (!currentMerchantBUserIsAdmin(buser,merchant)) { | |||
| // // resultMap.put("cashOutSupport", 0); | |||
| // //}else { | |||
| // resultMap.put("cashOutSupport", mall.getCashOutSupport()); | |||
| // if (1 == mall.getCashOutSupport().intValue()) { | |||
| // WxCUser mUser = getCurrentCUser(merchant); | |||
| // if (mUser == null) { | |||
| // return new ResultData(Result.ERROR,"请用绑定["+merchant.getLinkPhone()+"]的微信在C端完成授权手机号操作。"); | |||
| // } | |||
| // resultMap.put("cashOutOpenNickName", mUser.getNickName()); | |||
| // resultMap.put("cashOutOpenHeadImg", mUser.getAvatarUrl()); | |||
| // } | |||
| // //} | |||
| // } | |||
| // } | |||
| // resultMap.put("cashOutLimit", mall.getCashOutLimit()); | |||
| // return new ResultData(resultMap); | |||
| // } | |||
| private WxCUser getCurrentCUser(WxMerchant merchant) { | |||
| //当前管理员的账户必须在c端授权了 | |||
| @@ -15,14 +15,14 @@ import java.util.Map; | |||
| @Service | |||
| public interface QrCodeService { | |||
| void downQrCode(TenantEntity tenantEntity, HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, Object> params,EnumAppPlat plat,EnumPayVersion payVersion) throws MallinkException; | |||
| void downQrCode(TenantEntity tenantEntity, HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, Object> params,EnumAppPlat plat) throws MallinkException; | |||
| ResultData exportQrcode(HttpServletRequest request, HttpServletResponse response, | |||
| TenantEntity tenantEntity, int type, String pageUrl, String sceneParam, | |||
| int withText, String text1, String text2, | |||
| String name, EnumAppPlat plat,EnumPayVersion payVersion); | |||
| String name, EnumAppPlat plat); | |||
| ResultData uploadQrcode(TenantEntity tenantEntity, int type, String pageUrl, String sceneParam, | |||
| int withText, String text1, String text2, | |||
| String name,EnumAppPlat plat,EnumPayVersion payVersion); | |||
| String name,EnumAppPlat plat); | |||
| } | |||
| @@ -348,7 +348,7 @@ public class TtCUserServiceAdapter extends BasicCUserService implements CUserSer | |||
| String pageUrl = Constant.mainPageUrl; | |||
| String param = userL.getWeappScene(); | |||
| ResultData resultData = qrCodeService.uploadQrcode(user, 1, pageUrl, param, 0, "", "", "TT用户"+userL.getUserId().toString(),EnumAppPlat.TOUTIAO,EnumPayVersion.DY_PAY_V2); | |||
| ResultData resultData = qrCodeService.uploadQrcode(user, 1, pageUrl, param, 0, "", "", "TT用户"+userL.getUserId().toString(),EnumAppPlat.TOUTIAO); | |||
| Map<String, String> map = (Map) resultData.data; | |||
| if(map!=null && map.get("url") !=null) { | |||
| String url = map.get("url"); | |||
| @@ -357,7 +357,7 @@ public class WxCUserServiceAdapter extends BasicCUserService implements CUserSer | |||
| String pageUrl = Constant.mainPageUrl; | |||
| String param = userL.getWeappScene(); | |||
| ResultData resultData = qrCodeService.uploadQrcode(user, 1, pageUrl, param, 0, "", "", "WX用户"+userL.getUserId().toString(),EnumAppPlat.WX,EnumPayVersion.WX_PAY_V2); | |||
| ResultData resultData = qrCodeService.uploadQrcode(user, 1, pageUrl, param, 0, "", "", "WX用户"+userL.getUserId().toString(),EnumAppPlat.WX); | |||
| Map<String, String> map = (Map) resultData.data; | |||
| if(map!=null && map.get("url") !=null) { | |||
| String url = map.get("url"); | |||
| @@ -3,6 +3,7 @@ package com.iformall.service.impl; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxPayAccount; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.EnumAppPlat; | |||
| import com.iformall.enums.EnumPayVersion; | |||
| @@ -12,6 +13,7 @@ import com.iformall.exception.MallinkException; | |||
| import com.iformall.file.aliyun.AliyunOSS; | |||
| import com.iformall.service.QrCodeService; | |||
| import com.iformall.service.WxAppinfoService; | |||
| import com.iformall.service.WxPayAccountService; | |||
| import com.iformall.service.pay.PayServiceFactory; | |||
| import com.iformall.utils.QRCodeUtils; | |||
| import me.chanjar.weixin.common.error.WxErrorException; | |||
| @@ -34,6 +36,8 @@ public class QrCodeServiceImpl implements QrCodeService { | |||
| @Autowired | |||
| private WxAppinfoService wxAppinfoService; | |||
| @Autowired | |||
| private WxPayAccountService wxPayAccountService; | |||
| @Autowired | |||
| private boolean isFmOpen; | |||
| @Autowired | |||
| private String fmUploadDir; | |||
| @@ -44,7 +48,7 @@ public class QrCodeServiceImpl implements QrCodeService { | |||
| @Override | |||
| public void downQrCode(TenantEntity tenantEntity, HttpServletRequest request, HttpServletResponse response, Map<String, Object> params,EnumAppPlat plat,EnumPayVersion payVersion) throws MallinkException { | |||
| public void downQrCode(TenantEntity tenantEntity, HttpServletRequest request, HttpServletResponse response, Map<String, Object> params,EnumAppPlat plat) throws MallinkException { | |||
| String name = (String) params.get("name"); | |||
| String pageUrl = (String) params.get("pageUrl"); | |||
| String sceneParam = (String) params.get("sceneParam"); | |||
| @@ -70,7 +74,7 @@ public class QrCodeServiceImpl implements QrCodeService { | |||
| exportQrcode(request, response, | |||
| tenantEntity, type, pageUrl, sceneParam, | |||
| withText, text1, text2, | |||
| name,plat,payVersion); | |||
| name,plat); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| throw new MallinkException(Result.ERROR, "下载异常"); | |||
| @@ -81,7 +85,7 @@ public class QrCodeServiceImpl implements QrCodeService { | |||
| public ResultData exportQrcode(HttpServletRequest request, HttpServletResponse response, | |||
| TenantEntity tenantEntity, int type, String pageUrl, String sceneParam, | |||
| int withText, String text1, String text2, | |||
| String name, EnumAppPlat plat,EnumPayVersion payVersion) { | |||
| String name, EnumAppPlat plat) { | |||
| // type 0 有限二维码, 1 无限制二维码 | |||
| // withText 0 不带字 1. 带下面的字,2 带下面的两行字 | |||
| WxAppinfo appinfo = wxAppinfoService.getCAppInfo(tenantEntity,plat); | |||
| @@ -89,6 +93,15 @@ public class QrCodeServiceImpl implements QrCodeService { | |||
| logger.error("生成二维码{}未找到对应的小程序"); | |||
| return new ResultData(); | |||
| } | |||
| if(appinfo.getPayId() == null){ | |||
| logger.error("生成二维码{}未找到对应的支付配置"); | |||
| return new ResultData(); | |||
| } | |||
| WxPayAccount payAccount = wxPayAccountService.getById(appinfo.getPayId()); | |||
| if(payAccount == null){ | |||
| logger.error("生成二维码{}未找到对应的支付配置"); | |||
| return new ResultData(); | |||
| } | |||
| String filepath = fmUploadDir; | |||
| String fileName = name + ".png"; | |||
| @@ -101,7 +114,7 @@ public class QrCodeServiceImpl implements QrCodeService { | |||
| pDest.mkdirs(); | |||
| } | |||
| try { | |||
| File codeFile = payServiceFactory.getQrcodeService(appinfo.getPlat(),payVersion.getCode()).getQrcode(appinfo, pageUrl, type, sceneParam); | |||
| File codeFile = payServiceFactory.getQrcodeService(appinfo.getPlat(),payAccount.getPayVersion()).getQrcode(appinfo, pageUrl, type, sceneParam); | |||
| copyFileToDest(withText, text1, text2, destPath1, dest, codeFile); | |||
| org.apache.commons.io.FileUtils.forceDelete(codeFile); | |||
| } catch (WxErrorException e) { | |||
| @@ -122,7 +135,7 @@ public class QrCodeServiceImpl implements QrCodeService { | |||
| @Override | |||
| public ResultData uploadQrcode(TenantEntity tenantEntity, int type, String pageUrl, String sceneParam, | |||
| int withText, String text1, String text2, | |||
| String name,EnumAppPlat plat,EnumPayVersion payVersion) { | |||
| String name,EnumAppPlat plat) { | |||
| // type 0 有限二维码, 1 无限制二维码 | |||
| // withText 0 不带字 1. 带下面的字,2 带下面的两行字 | |||
| WxAppinfo appinfo = wxAppinfoService.getCAppInfo(tenantEntity,plat); | |||
| @@ -130,6 +143,15 @@ public class QrCodeServiceImpl implements QrCodeService { | |||
| logger.error("生成二维码{}未找到对应的小程序"); | |||
| return new ResultData(); | |||
| } | |||
| if(appinfo.getPayId() == null){ | |||
| logger.error("生成二维码{}未找到对应的支付配置"); | |||
| return new ResultData(); | |||
| } | |||
| WxPayAccount payAccount = wxPayAccountService.getById(appinfo.getPayId()); | |||
| if(payAccount == null){ | |||
| logger.error("生成二维码{}未找到对应的支付配置"); | |||
| return new ResultData(); | |||
| } | |||
| String filepath = fmUploadDir; | |||
| String fileName = name + ".png"; | |||
| @@ -142,7 +164,7 @@ public class QrCodeServiceImpl implements QrCodeService { | |||
| pDest.mkdirs(); | |||
| } | |||
| try { | |||
| File codeFile = payServiceFactory.getQrcodeService(appinfo.getPlat(),payVersion.getCode()).getQrcode(appinfo, pageUrl, type, sceneParam); | |||
| File codeFile = payServiceFactory.getQrcodeService(appinfo.getPlat(),payAccount.getPayVersion()).getQrcode(appinfo, pageUrl, type, sceneParam); | |||
| copyFileToDest(withText, text1, text2, destPath1, dest, codeFile); | |||
| org.apache.commons.io.FileUtils.forceDelete(codeFile); | |||
| } catch (WxErrorException e) { | |||
| @@ -208,13 +208,13 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||
| String pageUrl = Constant.mainPageUrl; | |||
| String param = couponChannel.getWeappScene(); | |||
| ResultData wxQrCode = qrCodeService.uploadQrcode(tenantEntity, 1, pageUrl, param, 0, "", "", "WX券"+couponChannelId.toString(),EnumAppPlat.WX,EnumPayVersion.WX_PAY_V2); | |||
| ResultData wxQrCode = qrCodeService.uploadQrcode(tenantEntity, 1, pageUrl, param, 0, "", "", "WX券"+couponChannelId.toString(),EnumAppPlat.WX); | |||
| Map<String, String> wxMap = (Map) wxQrCode.data; | |||
| if(wxMap != null && wxMap.get("url") != null) { | |||
| String url = wxMap.get("url"); | |||
| couponChannel.setQrCode(url); | |||
| } | |||
| ResultData ttQrCode = qrCodeService.uploadQrcode(tenantEntity, 1, pageUrl, param, 0, "", "", "TT券"+couponChannelId.toString(),EnumAppPlat.TOUTIAO,EnumPayVersion.DY_PAY_V2); | |||
| ResultData ttQrCode = qrCodeService.uploadQrcode(tenantEntity, 1, pageUrl, param, 0, "", "", "TT券"+couponChannelId.toString(),EnumAppPlat.TOUTIAO); | |||
| Map<String, String> ttmap = (Map) ttQrCode.data; | |||
| if(ttmap != null && ttmap.get("url") != null) { | |||
| String url = ttmap.get("url"); | |||
| @@ -614,14 +614,14 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| String param = merchant.getWeappScene(); | |||
| //微信二维码,后续有别的二维码,再加字段 | |||
| ResultData wxQrCode = qrCodeService.uploadQrcode(tenantEntity,1,pageUrl,param,0,"","","WX店铺"+merchantId.toString(), EnumAppPlat.WX,EnumPayVersion.WX_PAY_V2); | |||
| ResultData wxQrCode = qrCodeService.uploadQrcode(tenantEntity,1,pageUrl,param,0,"","","WX店铺"+merchantId.toString(), EnumAppPlat.WX); | |||
| Map<String,String> wxMap = (Map)wxQrCode.data; | |||
| if(wxMap != null && wxMap.get("url") != null) { | |||
| String url = wxMap.get("url"); | |||
| merchant.setQrCode(url); | |||
| } | |||
| //抖音二维码,后续有别的二维码,再加字段 | |||
| ResultData ttQrCode = qrCodeService.uploadQrcode(tenantEntity,1,pageUrl,param,0,"","","TT店铺"+merchantId.toString(), EnumAppPlat.TOUTIAO,EnumPayVersion.DY_PAY_V2); | |||
| ResultData ttQrCode = qrCodeService.uploadQrcode(tenantEntity,1,pageUrl,param,0,"","","TT店铺"+merchantId.toString(), EnumAppPlat.TOUTIAO); | |||
| Map<String,String> ttmap = (Map)ttQrCode.data; | |||
| if(ttmap != null && ttmap.get("url") != null) { | |||
| String url = ttmap.get("url"); | |||