| @@ -367,7 +367,8 @@ public class WxProjectConfigController extends BaseController { | |||||
| if(byId == null){ | if(byId == null){ | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未找到小程序"); | return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未找到小程序"); | ||||
| } | } | ||||
| if(!EnumAppType.B.getCode().equals(byId.getType()) && !EnumAppType.C.getCode().equals(byId.getType())){ | |||||
| if(!EnumAppType.B.getCode().equals(byId.getType()) | |||||
| && !EnumAppType.C.getCode().equals(byId.getType())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"小程序类型不支持"); | return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"小程序类型不支持"); | ||||
| } | } | ||||
| if(wxAppinfo.getEnable() == null || | if(wxAppinfo.getEnable() == null || | ||||
| @@ -799,14 +800,15 @@ public class WxProjectConfigController extends BaseController { | |||||
| @GetMapping("/ttcallback/query/settings") | @GetMapping("/ttcallback/query/settings") | ||||
| @SystemControllerLog(description = "") | @SystemControllerLog(description = "") | ||||
| @TenantIgnore | @TenantIgnore | ||||
| public ResultData ttcallbackQuerySettings(String appid) { | |||||
| public ResultData ttcallbackQuerySettings(String tenantId,String appid) { | |||||
| logger.debug("[" + getIpAddr() + "] WxProjectConfigController::ttcallbackQuerySettings"); | logger.debug("[" + getIpAddr() + "] WxProjectConfigController::ttcallbackQuerySettings"); | ||||
| try { | try { | ||||
| WxAppinfo appinfo = wxAppinfoService.getByAppId(appid); | |||||
| WxAppinfo appinfo = wxAppinfoService.getByAppId(appid,tenantId); | |||||
| if(appinfo == null){ | if(appinfo == null){ | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到对应的小程序"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到对应的小程序"); | ||||
| } | } | ||||
| if(!EnumAppPlat.TOUTIAO.getCode().equals(appinfo.getPlat()) || !EnumAppType.C.getCode().equals(appinfo.getType())){ | |||||
| if(!EnumAppPlat.TOUTIAO.getCode().equals(appinfo.getPlat()) | |||||
| || !EnumAppType.C.getCode().equals(appinfo.getType())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"该小程序不支持"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"该小程序不支持"); | ||||
| } | } | ||||
| WxPayAccount payAccount = wxPayAccountService.getById(appinfo.getPayId()); | WxPayAccount payAccount = wxPayAccountService.getById(appinfo.getPayId()); | ||||
| @@ -829,6 +831,7 @@ public class WxProjectConfigController extends BaseController { | |||||
| public ResultData ttcallbackSettings(@RequestBody Map<String, String> map) { | public ResultData ttcallbackSettings(@RequestBody Map<String, String> map) { | ||||
| logger.debug("[" + getIpAddr() + "] WxProjectConfigController::ttcallbackSettings"); | logger.debug("[" + getIpAddr() + "] WxProjectConfigController::ttcallbackSettings"); | ||||
| String appid = map.get("appid"); | String appid = map.get("appid"); | ||||
| String tenantId = map.get("tenantId"); | |||||
| String create_order_callback = map.get("createOrderCallback"); | String create_order_callback = map.get("createOrderCallback"); | ||||
| String refund_callback = map.get("refundCallback"); | String refund_callback = map.get("refundCallback"); | ||||
| String delivery_qrcode_redirect = map.get("deliveryQrcodeRedirect"); | String delivery_qrcode_redirect = map.get("deliveryQrcodeRedirect"); | ||||
| @@ -837,11 +840,12 @@ public class WxProjectConfigController extends BaseController { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | ||||
| } | } | ||||
| try { | try { | ||||
| WxAppinfo appinfo = wxAppinfoService.getByAppId(appid); | |||||
| WxAppinfo appinfo = wxAppinfoService.getByAppId(appid,tenantId); | |||||
| if(appinfo == null){ | if(appinfo == null){ | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到对应的小程序"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到对应的小程序"); | ||||
| } | } | ||||
| if(!EnumAppPlat.TOUTIAO.getCode().equals(appinfo.getPlat()) || !EnumAppType.C.getCode().equals(appinfo.getType())){ | |||||
| if(!EnumAppPlat.TOUTIAO.getCode().equals(appinfo.getPlat()) | |||||
| || !EnumAppType.C.getCode().equals(appinfo.getType())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"该小程序不支持"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"该小程序不支持"); | ||||
| } | } | ||||
| WxPayAccount payAccount = wxPayAccountService.getById(appinfo.getPayId()); | WxPayAccount payAccount = wxPayAccountService.getById(appinfo.getPayId()); | ||||
| @@ -1,4 +1,11 @@ | |||||
| --历史品牌数据 | --历史品牌数据 | ||||
| UPDATE `mallink`.`wx_brand` SET `tenant_id` = `parent_tenant_id` WHERE `parent_tenant_id` is not null and `parent_tenant_id` != ''; | UPDATE `mallink`.`wx_brand` SET `tenant_id` = `parent_tenant_id` WHERE `parent_tenant_id` is not null and `parent_tenant_id` != ''; | ||||
| UPDATE `mallink`.`wx_brand` SET `parent_tenant_id` = null; | |||||
| UPDATE `mallink`.`wx_brand` SET `parent_tenant_id` = null; | |||||
| --appinfo | |||||
| ALTER TABLE `mallink`.`wx_appinfo` | |||||
| DROP INDEX `appid_index`, | |||||
| ADD INDEX `appid_index`(`app_id`, `tenant_id`) USING BTREE; | |||||
| @@ -168,6 +168,10 @@ public class BaseController { | |||||
| return wxAppinfoService.getByAppId(appId); | return wxAppinfoService.getByAppId(appId); | ||||
| } | } | ||||
| public WxAppinfo getAppInfo(String appId,String tenantId) { | |||||
| return wxAppinfoService.getByAppId(appId,tenantId); | |||||
| } | |||||
| public String getIpAddr() { | public String getIpAddr() { | ||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | ||||
| String ipaddress = IPUtil.getIpAddr(request); | String ipaddress = IPUtil.getIpAddr(request); | ||||
| @@ -446,7 +446,7 @@ public class WxInfoController extends BaseController { | |||||
| CUser user = getCUser(); | CUser user = getCUser(); | ||||
| if (user != null) { | if (user != null) { | ||||
| WxAppinfo wxAppinfo = wxAppinfoService.getByAppId(user.getAppId()); | |||||
| WxAppinfo wxAppinfo = getAppInfo(user.getAppId()); | |||||
| if(wxAppinfo == null){ | if(wxAppinfo == null){ | ||||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | ||||
| } | } | ||||
| @@ -51,7 +51,7 @@ public class WxMallController extends BaseController { | |||||
| @GetMapping("/getAppIcon") | @GetMapping("/getAppIcon") | ||||
| @ApiImplicitParam(name = "appId", value = "appId", dataType = "String", paramType = "query", required = true) | @ApiImplicitParam(name = "appId", value = "appId", dataType = "String", paramType = "query", required = true) | ||||
| public ResultData getAppIcon(String appId) { | public ResultData getAppIcon(String appId) { | ||||
| WxAppinfo appInfo = wxAppinfoService.getByAppId(appId); | |||||
| WxAppinfo appInfo = getAppInfo(appId); | |||||
| if (appInfo == null) { | if (appInfo == null) { | ||||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | ||||
| } | } | ||||
| @@ -149,7 +149,7 @@ public class WxMerchantBUserController extends BaseController { | |||||
| if (StringUtils.isNotBlank(latitude) && StringUtils.isNotBlank(longitude)) { | if (StringUtils.isNotBlank(latitude) && StringUtils.isNotBlank(longitude)) { | ||||
| logger.info("B端用户: " + phone + " 登录 IP" + ipaddress + ", 经纬度(" + longitude + "," + latitude + ")"); | logger.info("B端用户: " + phone + " 登录 IP" + ipaddress + ", 经纬度(" + longitude + "," + latitude + ")"); | ||||
| } | } | ||||
| WxAppinfo wxAppinfo = wxAppinfoService.getByAppId(appId); | |||||
| WxAppinfo wxAppinfo = getAppInfo(appId); | |||||
| if(wxAppinfo == null){ | if(wxAppinfo == null){ | ||||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | ||||
| } | } | ||||
| @@ -306,8 +306,7 @@ public class WxMerchantBUserController extends BaseController { | |||||
| if (StringUtils.isBlank(pwd)) { | if (StringUtils.isBlank(pwd)) { | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "密码不能为空"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "密码不能为空"); | ||||
| } | } | ||||
| return wxMerchantBUserService.updatePwd(appId, phone, code, pwd); | |||||
| return wxMerchantBUserService.updatePwd(getTenantInfo(), phone, code, pwd); | |||||
| } | } | ||||
| } | } | ||||
| @@ -299,7 +299,7 @@ public class WxMicroPayController extends BaseController { | |||||
| } | } | ||||
| WxMerchantBUser bUser = getLoginBUser(); | WxMerchantBUser bUser = getLoginBUser(); | ||||
| WxAppinfo appinfo = getAppInfo(bUser.getAppId()); | |||||
| WxAppinfo appinfo = getAppInfo(bUser.getAppId(),bUser.getTenantId()); | |||||
| try { | try { | ||||
| ResultData rd = wxRefundOrderService.createRefundOrderFromMicroPay(appinfo, orderId, EnumPayType.PAY_B_REFUND, bUser.getId()); | ResultData rd = wxRefundOrderService.createRefundOrderFromMicroPay(appinfo, orderId, EnumPayType.PAY_B_REFUND, bUser.getId()); | ||||
| return rd; | return rd; | ||||
| @@ -40,11 +40,12 @@ public class WxPayAccountController extends BaseController { | |||||
| public ResultData getPayAccount(@RequestBody Map<String, String> paramMap) { | public ResultData getPayAccount(@RequestBody Map<String, String> paramMap) { | ||||
| logger.info("/api/payAccount/getPayAccount" + paramMap.toString()); | logger.info("/api/payAccount/getPayAccount" + paramMap.toString()); | ||||
| String appId = paramMap.get("appId"); | String appId = paramMap.get("appId"); | ||||
| if (StringUtils.isBlank(appId)) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "appId不能为空"); | |||||
| String tenantId = paramMap.get("tenantId"); | |||||
| if (StringUtils.isBlank(appId) || StringUtils.isBlank(tenantId)) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | } | ||||
| WxAppinfo wxAppinfo = getAppInfo(appId); | |||||
| WxAppinfo wxAppinfo = getAppInfo(appId,tenantId); | |||||
| if(wxAppinfo == null){ | if(wxAppinfo == null){ | ||||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | ||||
| } | } | ||||
| @@ -103,7 +103,7 @@ public class WxPayBillController extends BaseController { | |||||
| //openid | //openid | ||||
| String openid = paramMap.get("openId"); | String openid = paramMap.get("openId"); | ||||
| //获取小程序配置信息 | //获取小程序配置信息 | ||||
| WxAppinfo appInfo = getAppInfo(appid); | |||||
| WxAppinfo appInfo = getAppInfo(appid,getTenantInfo().getTenantId()); | |||||
| //支付账单参数 | //支付账单参数 | ||||
| WxPayBill record = new WxPayBill(); | WxPayBill record = new WxPayBill(); | ||||
| record.setBillId(billId); | record.setBillId(billId); | ||||
| @@ -1,6 +1,7 @@ | |||||
| package com.iformall.controller; | package com.iformall.controller; | ||||
| import cn.binarywang.wx.miniapp.api.WxMaService; | import cn.binarywang.wx.miniapp.api.WxMaService; | ||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| @@ -38,6 +39,7 @@ import java.text.ParseException; | |||||
| import java.text.SimpleDateFormat; | import java.text.SimpleDateFormat; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | |||||
| @RestController | @RestController | ||||
| public class BaseController { | public class BaseController { | ||||
| @@ -243,10 +245,6 @@ public class BaseController { | |||||
| RedisCacheUtils.removeCache(objectCommonRedisTemplate, shortKey); | RedisCacheUtils.removeCache(objectCommonRedisTemplate, shortKey); | ||||
| } | } | ||||
| public WxAppinfo getAppInfo(String appId) { | |||||
| return wxAppinfoService.getByAppIdFromRedis(appId); | |||||
| } | |||||
| public WxMaService getWeappService(String appId) { | public WxMaService getWeappService(String appId) { | ||||
| if(isFmOpen) { | if(isFmOpen) { | ||||
| return openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | return openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | ||||
| @@ -275,5 +273,23 @@ public class BaseController { | |||||
| return ipaddress; | return ipaddress; | ||||
| } | } | ||||
| /** | |||||
| * 根据扩展字段获取tenantId | |||||
| */ | |||||
| public String getTenantId(String attach){ | |||||
| if(StringUtils.isNotBlank(attach)){ | |||||
| try{ | |||||
| Map<String,Object> map = JSONObject.parseObject(attach, Map.class); | |||||
| String tenantId = map.get("tenantId").toString(); | |||||
| if(StringUtils.isNotBlank(tenantId)){ | |||||
| return tenantId; | |||||
| } | |||||
| }catch (Exception e){ | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| } | } | ||||
| @@ -30,14 +30,13 @@ public class WxCuserFloatingLayerController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| WxCuserFloatingLayerService wxCuserFloatingLayerService; | WxCuserFloatingLayerService wxCuserFloatingLayerService; | ||||
| @AuthIgnore | |||||
| @ApiOperation("获取浮层") | @ApiOperation("获取浮层") | ||||
| @GetMapping("/getFloatingLayer") | @GetMapping("/getFloatingLayer") | ||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @ApiImplicitParam(name = "openId", value = "openId", dataType = "String", paramType = "query", required = true), | @ApiImplicitParam(name = "openId", value = "openId", dataType = "String", paramType = "query", required = true), | ||||
| @ApiImplicitParam(name = "appId", value = "appId", dataType = "String", paramType = "query", required = true)}) | @ApiImplicitParam(name = "appId", value = "appId", dataType = "String", paramType = "query", required = true)}) | ||||
| public ResultData getAppIcon(String openId, String appId) { | |||||
| WxFloatingLayer wxFloatingLayer = wxCuserFloatingLayerService.getFloatingLayer(openId, appId); | |||||
| public ResultData getAppIcon(String openId) { | |||||
| WxFloatingLayer wxFloatingLayer = wxCuserFloatingLayerService.getFloatingLayer(getTenantInfo(),openId); | |||||
| return new ResultData(Result.SUCCESS, "查询成功", wxFloatingLayer); | return new ResultData(Result.SUCCESS, "查询成功", wxFloatingLayer); | ||||
| } | } | ||||
| @@ -187,6 +187,7 @@ public class WxOrderController extends BaseController { | |||||
| String open_id = msgObject.getString("open_id"); | String open_id = msgObject.getString("open_id"); | ||||
| //透传字段 | //透传字段 | ||||
| Long composeOrderId = null; | Long composeOrderId = null; | ||||
| String tenantId = null; | |||||
| try{ | try{ | ||||
| String cp_extra = msgObject.getString("cp_extra"); | String cp_extra = msgObject.getString("cp_extra"); | ||||
| if(StringUtils.isBlank(cp_extra)){ | if(StringUtils.isBlank(cp_extra)){ | ||||
| @@ -197,16 +198,17 @@ public class WxOrderController extends BaseController { | |||||
| Map<String,String> couponMap = JSONObject.parseObject(cp_extra, Map.class); | Map<String,String> couponMap = JSONObject.parseObject(cp_extra, Map.class); | ||||
| String idstr = couponMap.get("composeOrderId"); | String idstr = couponMap.get("composeOrderId"); | ||||
| composeOrderId = Long.parseLong(idstr); | composeOrderId = Long.parseLong(idstr); | ||||
| tenantId = couponMap.get("tenantId"); | |||||
| }catch(Exception e){ | }catch(Exception e){ | ||||
| } | } | ||||
| if(composeOrderId == null){ | |||||
| if(composeOrderId == null || StringUtils.isBlank(tenantId)){ | |||||
| map.put("err_no",ErrorCode.SYS_PARAMETER_NOT_NULL.getCode()); | map.put("err_no",ErrorCode.SYS_PARAMETER_NOT_NULL.getCode()); | ||||
| map.put("err_tips","透传字段格式不正确"); | map.put("err_tips","透传字段格式不正确"); | ||||
| return map; | return map; | ||||
| } | } | ||||
| //验证app | //验证app | ||||
| WxAppinfo appinfo = wxAppinfoService.getByAppIdFromRedis(app_id); | |||||
| WxAppinfo appinfo = wxAppinfoService.getByAppIdFromRedis(app_id,tenantId); | |||||
| if(appinfo == null || !EnumAppPlat.TOUTIAO.getCode().equals(appinfo.getPlat()) | if(appinfo == null || !EnumAppPlat.TOUTIAO.getCode().equals(appinfo.getPlat()) | ||||
| || !EnumAppType.C.getCode().equals(appinfo.getType())){ | || !EnumAppType.C.getCode().equals(appinfo.getType())){ | ||||
| map.put("err_no",ErrorCode.APP_ID_NOT_FOUND.getCode()); | map.put("err_no",ErrorCode.APP_ID_NOT_FOUND.getCode()); | ||||
| @@ -752,9 +754,10 @@ public class WxOrderController extends BaseController { | |||||
| JSONObject msgObject = JSONObject.parseObject(msg); | JSONObject msgObject = JSONObject.parseObject(msg); | ||||
| String app_id = msgObject.getString("app_id"); | String app_id = msgObject.getString("app_id"); | ||||
| String open_id = msgObject.getString("open_id"); | String open_id = msgObject.getString("open_id"); | ||||
| String cp_extra = msgObject.getString("cp_extra"); | |||||
| //验证app | //验证app | ||||
| WxAppinfo appinfo = wxAppinfoService.getByAppId(app_id); | |||||
| WxAppinfo appinfo = wxAppinfoService.getByAppId(app_id,getTenantId(cp_extra)); | |||||
| if(appinfo == null || !EnumAppPlat.TOUTIAO.getCode().equals(appinfo.getPlat()) | if(appinfo == null || !EnumAppPlat.TOUTIAO.getCode().equals(appinfo.getPlat()) | ||||
| || !EnumAppType.C.getCode().equals(appinfo.getType())){ | || !EnumAppType.C.getCode().equals(appinfo.getType())){ | ||||
| map.put("err_no",ErrorCode.APP_ID_NOT_FOUND.getCode()); | map.put("err_no",ErrorCode.APP_ID_NOT_FOUND.getCode()); | ||||
| @@ -113,7 +113,7 @@ public class WxPayOrderController extends BaseController { | |||||
| if (null != wxCUserBasicInfo && EnumCreditLockedStatus.CLOSE.getCode().equals(wxCUserBasicInfo.getStatus())) { | if (null != wxCUserBasicInfo && EnumCreditLockedStatus.CLOSE.getCode().equals(wxCUserBasicInfo.getStatus())) { | ||||
| return new ResultData(ErrorCode.MEMBER_IS_LOCKED); | return new ResultData(ErrorCode.MEMBER_IS_LOCKED); | ||||
| } | } | ||||
| WxAppinfo appInfo = getAppInfo(appId); | |||||
| WxAppinfo appInfo = wxAppinfoService.getByAppIdFromRedis(appId,getTenantInfo().getTenantId()); | |||||
| if(appInfo == null) { | if(appInfo == null) { | ||||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | ||||
| } | } | ||||
| @@ -1,7 +1,9 @@ | |||||
| package com.iformall.controller.base; | package com.iformall.controller.base; | ||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.utils.IPUtil; | import com.iformall.utils.IPUtil; | ||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.springframework.web.bind.WebDataBinder; | import org.springframework.web.bind.WebDataBinder; | ||||
| import org.springframework.web.bind.annotation.InitBinder; | import org.springframework.web.bind.annotation.InitBinder; | ||||
| import org.springframework.web.bind.annotation.RestController; | import org.springframework.web.bind.annotation.RestController; | ||||
| @@ -13,6 +15,7 @@ import java.beans.PropertyEditorSupport; | |||||
| import java.text.ParseException; | import java.text.ParseException; | ||||
| import java.text.SimpleDateFormat; | import java.text.SimpleDateFormat; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.Map; | |||||
| @RestController | @RestController | ||||
| public class BaseController { | public class BaseController { | ||||
| @@ -44,4 +47,22 @@ public class BaseController { | |||||
| String ipaddress = IPUtil.getIpAddr(request); | String ipaddress = IPUtil.getIpAddr(request); | ||||
| return ipaddress; | return ipaddress; | ||||
| } | } | ||||
| /** | |||||
| * 根据扩展字段获取tenantId | |||||
| */ | |||||
| public String getTenantId(String attach){ | |||||
| if(StringUtils.isNotBlank(attach)){ | |||||
| try{ | |||||
| Map<String,Object> map = JSONObject.parseObject(attach, Map.class); | |||||
| String tenantId = map.get("tenantId").toString(); | |||||
| if(StringUtils.isNotBlank(tenantId)){ | |||||
| return tenantId; | |||||
| } | |||||
| }catch (Exception e){ | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| } | } | ||||
| @@ -100,6 +100,7 @@ public class TtPayController extends BaseController { | |||||
| Map<String, Object> pMap = JSONObject.parseObject(msg, Map.class); | Map<String, Object> pMap = JSONObject.parseObject(msg, Map.class); | ||||
| String appid; | String appid; | ||||
| String tenantId; | |||||
| WxAppinfo appinfo; | WxAppinfo appinfo; | ||||
| WxPayAccount payAccount; | WxPayAccount payAccount; | ||||
| Boolean is2_0 = false; | Boolean is2_0 = false; | ||||
| @@ -111,7 +112,9 @@ public class TtPayController extends BaseController { | |||||
| String nonce = request.getHeader("Byte-Nonce-Str"); | String nonce = request.getHeader("Byte-Nonce-Str"); | ||||
| appid = (String) pMap.get("app_id"); | appid = (String) pMap.get("app_id"); | ||||
| appinfo = appinfoService.getByAppId(appid); | |||||
| String cp_extra = (String) pMap.get("cp_extra"); | |||||
| tenantId = getTenantId(cp_extra); | |||||
| appinfo = appinfoService.getByAppId(appid,tenantId); | |||||
| payAccount = payAccountService.getById(appinfo.getPayId()); | payAccount = payAccountService.getById(appinfo.getPayId()); | ||||
| TtPayService ttPayService = maUtil.getTtPayService(appinfo, payAccount); | TtPayService ttPayService = maUtil.getTtPayService(appinfo, payAccount); | ||||
| @@ -134,7 +137,9 @@ public class TtPayController extends BaseController { | |||||
| String nonce = (String) parameterMap.get("nonce"); | String nonce = (String) parameterMap.get("nonce"); | ||||
| appid = (String) pMap.get("appid"); | appid = (String) pMap.get("appid"); | ||||
| appinfo = appinfoService.getByAppId(appid); | |||||
| String cp_extra = (String) pMap.get("cp_extra"); | |||||
| tenantId = getTenantId(cp_extra); | |||||
| appinfo = appinfoService.getByAppId(appid,tenantId); | |||||
| payAccount = payAccountService.getById(appinfo.getPayId()); | payAccount = payAccountService.getById(appinfo.getPayId()); | ||||
| Map<String,Object> paramMap = new HashMap<>(); | Map<String,Object> paramMap = new HashMap<>(); | ||||
| @@ -207,6 +212,7 @@ public class TtPayController extends BaseController { | |||||
| } | } | ||||
| Map<String,String> map = new HashMap<>(); | Map<String,String> map = new HashMap<>(); | ||||
| map.put("tenantId",tenantId); | |||||
| map.put("appid",appid); | map.put("appid",appid); | ||||
| map.put("cp_refundno",cp_refundno); | map.put("cp_refundno",cp_refundno); | ||||
| map.put("status",status); | map.put("status",status); | ||||
| @@ -216,6 +222,7 @@ public class TtPayController extends BaseController { | |||||
| String jsonMsg = JSON.toJSONString(map); | String jsonMsg = JSON.toJSONString(map); | ||||
| FmInsideNotifyRefundSuccessMsg refundSuccessMsg = new FmInsideNotifyRefundSuccessMsg(); | FmInsideNotifyRefundSuccessMsg refundSuccessMsg = new FmInsideNotifyRefundSuccessMsg(); | ||||
| refundSuccessMsg.setTenantId(tenantId); | |||||
| refundSuccessMsg.setMsgType(EnumMsgRecordType.INSIDE_NOTIFY_REFUND_SUCCESS.getCode()); | refundSuccessMsg.setMsgType(EnumMsgRecordType.INSIDE_NOTIFY_REFUND_SUCCESS.getCode()); | ||||
| refundSuccessMsg.setDelayTimeLevel(3); | refundSuccessMsg.setDelayTimeLevel(3); | ||||
| refundSuccessMsg.setPayWay(EnumPayWay.PAY_WAY_TT.getCode()); | refundSuccessMsg.setPayWay(EnumPayWay.PAY_WAY_TT.getCode()); | ||||
| @@ -109,7 +109,7 @@ public class TtWebController extends BaseController { | |||||
| // String status = (String) content.get("status"); | // String status = (String) content.get("status"); | ||||
| TtCouponChannelPoi couponChannelPoi = new TtCouponChannelPoi(); | TtCouponChannelPoi couponChannelPoi = new TtCouponChannelPoi(); | ||||
| couponChannelPoi.updateTenantInfo(appInfo); | |||||
| // couponChannelPoi.updateTenantInfo(appInfo); | |||||
| couponChannelPoi.setSpuId(product_id); | couponChannelPoi.setSpuId(product_id); | ||||
| if("FAIL".equals(status)){ | if("FAIL".equals(status)){ | ||||
| couponChannelPoi.setLastStatus(EnumSpuSyncStatus.sync_audit_rejection.getCode()); | couponChannelPoi.setLastStatus(EnumSpuSyncStatus.sync_audit_rejection.getCode()); | ||||
| @@ -1,13 +1,16 @@ | |||||
| package com.iformall.controller.callback; | package com.iformall.controller.callback; | ||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.enums.EnumPayVersion; | import com.iformall.enums.EnumPayVersion; | ||||
| import com.iformall.enums.EnumPayWay; | import com.iformall.enums.EnumPayWay; | ||||
| import com.iformall.exception.BizMessageException; | import com.iformall.exception.BizMessageException; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.pay.WxPayment; | import com.iformall.pay.WxPayment; | ||||
| import com.iformall.service.MailService; | |||||
| import com.iformall.service.WxPayBillService; | import com.iformall.service.WxPayBillService; | ||||
| import com.iformall.service.WxRefundOrderService; | import com.iformall.service.WxRefundOrderService; | ||||
| import com.iformall.utils.DateUtils; | |||||
| import com.iformall.utils.XmlUtil; | import com.iformall.utils.XmlUtil; | ||||
| import org.apache.commons.io.IOUtils; | import org.apache.commons.io.IOUtils; | ||||
| import org.jdom2.JDOMException; | import org.jdom2.JDOMException; | ||||
| @@ -24,6 +27,7 @@ import java.io.ByteArrayOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.nio.charset.Charset; | import java.nio.charset.Charset; | ||||
| import java.util.Date; | |||||
| import java.util.Map; | import java.util.Map; | ||||
| import java.util.SortedMap; | import java.util.SortedMap; | ||||
| import java.util.TreeMap; | import java.util.TreeMap; | ||||
| @@ -37,6 +41,12 @@ public class WxPayBillController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | |||||
| private String fmExceptionEmails; | |||||
| @Autowired | |||||
| private MailService mailService; | |||||
| @Autowired | @Autowired | ||||
| private WxPayBillService wxPayBillService; | private WxPayBillService wxPayBillService; | ||||
| @@ -69,7 +79,8 @@ public class WxPayBillController extends BaseController { | |||||
| try { | try { | ||||
| paramMap = WxPayment.xmlToMap(resultxml); | paramMap = WxPayment.xmlToMap(resultxml); | ||||
| logger.info("微信支付回调, notify, param: " + paramMap.toString() ); | logger.info("微信支付回调, notify, param: " + paramMap.toString() ); | ||||
| String response = wxPayBillService.notify(paramMap, EnumPayWay.PAY_WAY_WECHAT); | |||||
| String attach = paramMap.get("attach"); | |||||
| String response = wxPayBillService.notify(getTenantId(attach),paramMap, EnumPayWay.PAY_WAY_WECHAT); | |||||
| logger.info("微信支付回调, notify success, req : " + resultxml + ", resp: " + response.toString()); | logger.info("微信支付回调, notify success, req : " + resultxml + ", resp: " + response.toString()); | ||||
| return response; | return response; | ||||
| } catch (BizMessageException e) { | } catch (BizMessageException e) { | ||||
| @@ -121,6 +132,7 @@ public class WxPayBillController extends BaseController { | |||||
| xml = IOUtils.toString(request.getInputStream(), Charset.forName("UTF-8")); | xml = IOUtils.toString(request.getInputStream(), Charset.forName("UTF-8")); | ||||
| logger.info(xml); | logger.info(xml); | ||||
| paramMap = WxPayment.xmlToMap(xml); | paramMap = WxPayment.xmlToMap(xml); | ||||
| response = wxRefundOrderService.notify(paramMap, EnumPayWay.PAY_WAY_WECHAT,EnumPayVersion.WX_PAY_V2); | response = wxRefundOrderService.notify(paramMap, EnumPayWay.PAY_WAY_WECHAT,EnumPayVersion.WX_PAY_V2); | ||||
| logger.info("refund wxpay, notify success, req : " + xml + ", resp: " + response.toString()); | logger.info("refund wxpay, notify success, req : " + xml + ", resp: " + response.toString()); | ||||
| return response; | return response; | ||||
| @@ -160,7 +172,17 @@ public class WxPayBillController extends BaseController { | |||||
| xml = IOUtils.toString(request.getInputStream(), Charset.forName("UTF-8")); | xml = IOUtils.toString(request.getInputStream(), Charset.forName("UTF-8")); | ||||
| paramMap = WxPayment.xmlToMap(xml); | paramMap = WxPayment.xmlToMap(xml); | ||||
| logger.info("share wxpay, notify, param: " + xml ); | logger.info("share wxpay, notify, param: " + xml ); | ||||
| response = wxPayBillService.notify(paramMap, EnumPayWay.PAY_WAY_WECHAT); | |||||
| //发邮件 | |||||
| String[] receivers = fmExceptionEmails.split(","); | |||||
| StringBuilder sb = new StringBuilder(); | |||||
| sb.append(DateUtils.date2String(new Date())); | |||||
| sb.append("\n"); | |||||
| sb.append("分账回调 :WxPayBillController"); | |||||
| sb.append("\n"); | |||||
| sb.append(JSON.toJSONString(paramMap)); | |||||
| //发送邮件 | |||||
| mailService.sendSimpleMail(receivers, "排查回调位置", sb.toString()); | |||||
| // response = wxPayBillService.notify(paramMap, EnumPayWay.PAY_WAY_WECHAT); | |||||
| logger.info("share wxpay, notify success, req : " + xml + ", resp: " + response.toString()); | logger.info("share wxpay, notify success, req : " + xml + ", resp: " + response.toString()); | ||||
| return response; | return response; | ||||
| } catch (BizMessageException e) { | } catch (BizMessageException e) { | ||||
| @@ -10,9 +10,11 @@ import com.iformall.exception.BizMessageException; | |||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.mq.MqBaseProducer; | import com.iformall.mq.MqBaseProducer; | ||||
| import com.iformall.pay.WxPayment; | import com.iformall.pay.WxPayment; | ||||
| import com.iformall.service.MailService; | |||||
| import com.iformall.service.WxPayOrderService; | import com.iformall.service.WxPayOrderService; | ||||
| import com.iformall.service.WxRefundOrderService; | import com.iformall.service.WxRefundOrderService; | ||||
| import com.iformall.service.WxSubsidyService; | import com.iformall.service.WxSubsidyService; | ||||
| import com.iformall.utils.DateUtils; | |||||
| import com.iformall.utils.XmlUtil; | import com.iformall.utils.XmlUtil; | ||||
| import org.apache.commons.io.IOUtils; | import org.apache.commons.io.IOUtils; | ||||
| import org.jdom2.JDOMException; | import org.jdom2.JDOMException; | ||||
| @@ -32,10 +34,7 @@ import java.io.ByteArrayOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.nio.charset.Charset; | import java.nio.charset.Charset; | ||||
| import java.util.HashMap; | |||||
| import java.util.Map; | |||||
| import java.util.SortedMap; | |||||
| import java.util.TreeMap; | |||||
| import java.util.*; | |||||
| @RestController | @RestController | ||||
| @RequestMapping("/wxPay/notify") | @RequestMapping("/wxPay/notify") | ||||
| @@ -51,14 +50,20 @@ public class WxPayController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private MqBaseProducer mqBaseProducer; | private MqBaseProducer mqBaseProducer; | ||||
| @Autowired | |||||
| private String fmExceptionEmails; | |||||
| @Autowired | |||||
| private MailService mailService; | |||||
| /** | /** | ||||
| * | * | ||||
| * @return 接收微信异步通知 | * @return 接收微信异步通知 | ||||
| * @throws Exception 可能产生的任何异常 | * @throws Exception 可能产生的任何异常 | ||||
| */ | */ | ||||
| @RequestMapping(value = "/pay", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) | |||||
| @RequestMapping(value = "/pay/{tenantId}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) | |||||
| @ResponseBody | @ResponseBody | ||||
| public String _payNotify(HttpServletRequest request) throws IOException, JDOMException { | |||||
| public String _payNotify(@PathVariable String tenantId,HttpServletRequest request) throws IOException, JDOMException { | |||||
| logger.info("[" +getIpAddr() + "]微信支付回调"); | logger.info("[" +getIpAddr() + "]微信支付回调"); | ||||
| SortedMap resultMap = new TreeMap(); | SortedMap resultMap = new TreeMap(); | ||||
| resultMap.put("return_code", "SUCCESS"); | resultMap.put("return_code", "SUCCESS"); | ||||
| @@ -139,8 +144,8 @@ public class WxPayController extends BaseController { | |||||
| * @return 接收微信退款异步通知 | * @return 接收微信退款异步通知 | ||||
| * @throws Exception 可能产生的任何异常 | * @throws Exception 可能产生的任何异常 | ||||
| */ | */ | ||||
| @RequestMapping(value = "/refund") | |||||
| public String __refundNotify(HttpServletRequest request) throws Exception { | |||||
| @RequestMapping(value = "/refund/{tenantId}") | |||||
| public String __refundNotify(@PathVariable String tenantId,HttpServletRequest request) throws Exception { | |||||
| logger.info("[" +getIpAddr() + "]微信退款回调"); | logger.info("[" +getIpAddr() + "]微信退款回调"); | ||||
| Map<String, String> paramMap = null; | Map<String, String> paramMap = null; | ||||
| String response = ""; | String response = ""; | ||||
| @@ -152,6 +157,7 @@ public class WxPayController extends BaseController { | |||||
| String jsonMsg = JSON.toJSONString(paramMap); | String jsonMsg = JSON.toJSONString(paramMap); | ||||
| FmInsideNotifyRefundSuccessMsg refundSuccessMsg = new FmInsideNotifyRefundSuccessMsg(); | FmInsideNotifyRefundSuccessMsg refundSuccessMsg = new FmInsideNotifyRefundSuccessMsg(); | ||||
| refundSuccessMsg.setTenantId(tenantId); | |||||
| refundSuccessMsg.setMsgType(EnumMsgRecordType.INSIDE_NOTIFY_REFUND_SUCCESS.getCode()); | refundSuccessMsg.setMsgType(EnumMsgRecordType.INSIDE_NOTIFY_REFUND_SUCCESS.getCode()); | ||||
| refundSuccessMsg.setDelayTimeLevel(3); | refundSuccessMsg.setDelayTimeLevel(3); | ||||
| refundSuccessMsg.setPayWay(EnumPayWay.PAY_WAY_WECHAT.getCode()); | refundSuccessMsg.setPayWay(EnumPayWay.PAY_WAY_WECHAT.getCode()); | ||||
| @@ -216,6 +222,7 @@ public class WxPayController extends BaseController { | |||||
| String jsonMsg = JSON.toJSONString(paramMap); | String jsonMsg = JSON.toJSONString(paramMap); | ||||
| FmInsideNotifyRefundSuccessMsg refundSuccessMsg = new FmInsideNotifyRefundSuccessMsg(); | FmInsideNotifyRefundSuccessMsg refundSuccessMsg = new FmInsideNotifyRefundSuccessMsg(); | ||||
| refundSuccessMsg.setTenantId(tenantId); | |||||
| refundSuccessMsg.setMsgType(EnumMsgRecordType.INSIDE_NOTIFY_REFUND_SUCCESS.getCode()); | refundSuccessMsg.setMsgType(EnumMsgRecordType.INSIDE_NOTIFY_REFUND_SUCCESS.getCode()); | ||||
| refundSuccessMsg.setDelayTimeLevel(3); | refundSuccessMsg.setDelayTimeLevel(3); | ||||
| refundSuccessMsg.setPayWay(EnumPayWay.PAY_WAY_WECHAT.getCode()); | refundSuccessMsg.setPayWay(EnumPayWay.PAY_WAY_WECHAT.getCode()); | ||||
| @@ -262,8 +269,18 @@ public class WxPayController extends BaseController { | |||||
| try { | try { | ||||
| xml = IOUtils.toString(request.getInputStream(), Charset.forName("UTF-8")); | xml = IOUtils.toString(request.getInputStream(), Charset.forName("UTF-8")); | ||||
| paramMap = WxPayment.xmlToMap(xml); | paramMap = WxPayment.xmlToMap(xml); | ||||
| //发邮件 | |||||
| String[] receivers = fmExceptionEmails.split(","); | |||||
| StringBuilder sb = new StringBuilder(); | |||||
| sb.append(DateUtils.date2String(new Date())); | |||||
| sb.append("\n"); | |||||
| sb.append("分账回调 WxPayController:"); | |||||
| sb.append("\n"); | |||||
| sb.append(JSON.toJSONString(paramMap)); | |||||
| //发送邮件 | |||||
| mailService.sendSimpleMail(receivers, "排查回调位置", sb.toString()); | |||||
| logger.info("share wxpay, notify, param: " + xml ); | logger.info("share wxpay, notify, param: " + xml ); | ||||
| response = wxPayOrderService.shareNotify(paramMap, EnumPayWay.PAY_WAY_WECHAT,EnumPayVersion.WX_PAY_V2); | |||||
| // response = wxPayOrderService.shareNotify(paramMap, EnumPayWay.PAY_WAY_WECHAT,EnumPayVersion.WX_PAY_V2); | |||||
| logger.info("share wxpay, notify success, req : " + xml + ", resp: " + response.toString()); | logger.info("share wxpay, notify success, req : " + xml + ", resp: " + response.toString()); | ||||
| return response; | return response; | ||||
| } catch (BizMessageException e) { | } catch (BizMessageException e) { | ||||
| @@ -56,28 +56,6 @@ public class BaseController { | |||||
| }); | }); | ||||
| } | } | ||||
| public WxAppinfo getAppInfo(String appId) { | |||||
| return wxAppinfoService.getByAppId(appId); | |||||
| } | |||||
| public WxMaService getWeappService(String appId) { | |||||
| if(isFmOpen) { | |||||
| return openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| } else { | |||||
| WxAppinfo appinfo = wxAppinfoService.getByAppId(appId); | |||||
| WxMaService service = maUtil.getWeappService(appinfo); | |||||
| return service; | |||||
| } | |||||
| } | |||||
| public WxMaService getWeappServiceByAppInfo(WxAppinfo appinfo) { | |||||
| if(!isFmOpen) { | |||||
| WxMaService service = maUtil.getWeappService(appinfo); | |||||
| return service; | |||||
| } | |||||
| return null; | |||||
| } | |||||
| public String getIpAddr() { | public String getIpAddr() { | ||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | ||||
| String ipaddress = IPUtil.getIpAddr(request); | String ipaddress = IPUtil.getIpAddr(request); | ||||
| @@ -52,10 +52,11 @@ public class WeChatAccessTokenSchedule { | |||||
| try { | try { | ||||
| String accessToken = wxMaService.getAccessToken(true); | String accessToken = wxMaService.getAccessToken(true); | ||||
| WxAppinfo updateAppInfo = new WxAppinfo(); | WxAppinfo updateAppInfo = new WxAppinfo(); | ||||
| updateAppInfo.setAppId(appinfo.getAppId()); | |||||
| updateAppInfo.setAccessToken(accessToken); | updateAppInfo.setAccessToken(accessToken); | ||||
| updateAppInfo.setLastTokenTime(new Date()); | updateAppInfo.setLastTokenTime(new Date()); | ||||
| updateAppInfo.setExpiresIn(7200); | updateAppInfo.setExpiresIn(7200); | ||||
| wxAppinfoMapper.updateById(updateAppInfo); | |||||
| wxAppinfoMapper.updateAccessToken(updateAppInfo); | |||||
| } catch (WxErrorException e) { | } catch (WxErrorException e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -81,13 +81,13 @@ public class WxPayAccount extends TenantEntity { | |||||
| return notifyUrl + "/pay/v3/"+this.getTenantId(); | return notifyUrl + "/pay/v3/"+this.getTenantId(); | ||||
| } | } | ||||
| public String getPayNotifyUrl() { | public String getPayNotifyUrl() { | ||||
| return notifyUrl + "/pay"; | |||||
| return notifyUrl + "/pay/"+this.getTenantId(); | |||||
| } | } | ||||
| public String getRefundNotifyV3Url() { | public String getRefundNotifyV3Url() { | ||||
| return notifyUrl + "/refund/v3/"+this.getTenantId(); | return notifyUrl + "/refund/v3/"+this.getTenantId(); | ||||
| } | } | ||||
| public String getRefundNotifyUrl() { | public String getRefundNotifyUrl() { | ||||
| return notifyUrl + "/refund"; | |||||
| return notifyUrl + "/refund/"+this.getTenantId(); | |||||
| } | } | ||||
| public String getSubsidyNotifyV3Url() { | public String getSubsidyNotifyV3Url() { | ||||
| return notifyUrl + "/subsidyPay/v3/"+this.getTenantId(); | return notifyUrl + "/subsidyPay/v3/"+this.getTenantId(); | ||||
| @@ -97,7 +97,7 @@ public class TtPayUnifiedOrderV2Request implements Serializable { | |||||
| * 开发者自定义透传字段,不支持二进制,长度 <= 2048 byte | * 开发者自定义透传字段,不支持二进制,长度 <= 2048 byte | ||||
| */ | */ | ||||
| @SerializedName(value = "cp_extra") | @SerializedName(value = "cp_extra") | ||||
| private PageEntry cpExtra; | |||||
| private String cpExtra; | |||||
| /** | /** | ||||
| * 否 | * 否 | ||||
| @@ -7,10 +7,10 @@ import com.iformall.domain.po.WxAppinfo; | |||||
| public interface WxAppinfoMapper extends CommonMapper<WxAppinfo, Long> { | public interface WxAppinfoMapper extends CommonMapper<WxAppinfo, Long> { | ||||
| List<WxAppinfo> findList(WxAppinfo wxAppinfo); | List<WxAppinfo> findList(WxAppinfo wxAppinfo); | ||||
| WxAppinfo findByAppId(String appId); | WxAppinfo findByAppId(String appId); | ||||
| WxAppinfo findByAppId(String appId,String tenantId); | |||||
| int updateAccessToken(WxAppinfo updateApp); | |||||
| } | } | ||||
| @@ -14,6 +14,7 @@ public class WxMicroPayOrderP { | |||||
| private String nonce_str; // 随机字符串 | private String nonce_str; // 随机字符串 | ||||
| private String sign; // 签名 | private String sign; // 签名 | ||||
| private String body; // 商品简单描述 128 | private String body; // 商品简单描述 128 | ||||
| private String attach; // 附加数据 | |||||
| private String out_trade_no; // 商户订单号 | private String out_trade_no; // 商户订单号 | ||||
| private Integer total_fee; // 支付金额 | private Integer total_fee; // 支付金额 | ||||
| private String spbill_create_ip; // 支付IP | private String spbill_create_ip; // 支付IP | ||||
| @@ -17,6 +17,7 @@ public class WxMicroPayOrderSP { | |||||
| private String sign; // 签名 | private String sign; // 签名 | ||||
| private String sign_type; // 签名类型 | private String sign_type; // 签名类型 | ||||
| private String body; // 商品简单描述 128 | private String body; // 商品简单描述 128 | ||||
| private String attach; // 附加数据 | |||||
| private String out_trade_no; // 商户订单号 | private String out_trade_no; // 商户订单号 | ||||
| private Integer total_fee; // 支付金额 | private Integer total_fee; // 支付金额 | ||||
| private String spbill_create_ip; // 支付IP | private String spbill_create_ip; // 支付IP | ||||
| @@ -13,6 +13,7 @@ public class WxPayOrderP { | |||||
| private String nonce_str; // 随机字符串 | private String nonce_str; // 随机字符串 | ||||
| private String sign; // 签名 | private String sign; // 签名 | ||||
| private String body; // 商品简单描述 128 | private String body; // 商品简单描述 128 | ||||
| private String attach; // 附加数据 | |||||
| private String out_trade_no; // 商户订单号 | private String out_trade_no; // 商户订单号 | ||||
| private Integer total_fee; // 支付金额 | private Integer total_fee; // 支付金额 | ||||
| private String spbill_create_ip; // 支付IP | private String spbill_create_ip; // 支付IP | ||||
| @@ -16,6 +16,7 @@ public class WxPayOrderSP { | |||||
| private String sign; // 签名 | private String sign; // 签名 | ||||
| private String sign_type; // 签名类型 | private String sign_type; // 签名类型 | ||||
| private String body; // 商品简单描述 128 | private String body; // 商品简单描述 128 | ||||
| private String attach; // 附加数据 | |||||
| private String out_trade_no; // 商户订单号 | private String out_trade_no; // 商户订单号 | ||||
| private String total_fee; // 支付金额 | private String total_fee; // 支付金额 | ||||
| private String spbill_create_ip; // 支付IP | private String spbill_create_ip; // 支付IP | ||||
| @@ -52,12 +52,13 @@ public interface WxAppinfoService { | |||||
| WxAppinfo getById(Long id); | WxAppinfo getById(Long id); | ||||
| /** | /** | ||||
| * 根据appId获得实体 | |||||
| * 多个存在获取集团的。 | |||||
| * | * | ||||
| * @param appId | * @param appId | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| WxAppinfo getByAppId(String appId); | WxAppinfo getByAppId(String appId); | ||||
| WxAppinfo getByAppId(String appId,String tenantId); | |||||
| /** | /** | ||||
| * 获取c端小程序信息 | * 获取c端小程序信息 | ||||
| @@ -83,7 +84,7 @@ public interface WxAppinfoService { | |||||
| */ | */ | ||||
| void deleteById(Long id); | void deleteById(Long id); | ||||
| WxAppinfo getByAppIdFromRedis(String appId); | |||||
| WxAppinfo getByAppIdFromRedis(String appId,String tenantId); | |||||
| WxAppinfo getByIdFromRedis(Long id); | WxAppinfo getByIdFromRedis(Long id); | ||||
| WxAppinfo getCAppInfoFromRedis(String tenantId, EnumAppPlat appPlat); | WxAppinfo getCAppInfoFromRedis(String tenantId, EnumAppPlat appPlat); | ||||
| @@ -8,6 +8,6 @@ import com.iformall.domain.po.base.TenantEntity; | |||||
| */ | */ | ||||
| public interface WxCuserFloatingLayerService { | public interface WxCuserFloatingLayerService { | ||||
| WxFloatingLayer getFloatingLayer(String openId, String appId); | |||||
| WxFloatingLayer getFloatingLayer(TenantEntity tenantEntity,String openId); | |||||
| } | } | ||||
| @@ -64,6 +64,6 @@ public interface WxMerchantBUserService { | |||||
| boolean hasPhone(TenantEntity tenantEntity, String phone); | boolean hasPhone(TenantEntity tenantEntity, String phone); | ||||
| ResultData updatePwd(String appId, String phone, String code, String pwd); | |||||
| ResultData updatePwd(TenantEntity tenantEntity, String phone, String code, String pwd); | |||||
| } | } | ||||
| @@ -43,7 +43,7 @@ public interface WxPayBillService { | |||||
| * @param payWay 支付方式 | * @param payWay 支付方式 | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| String notify(Map<String, String> paramMap, EnumPayWay payWay); | |||||
| String notify(String tenantId,Map<String, String> paramMap, EnumPayWay payWay); | |||||
| /** | /** | ||||
| * 支付成功处理 | * 支付成功处理 | ||||
| @@ -14,6 +14,7 @@ import com.iformall.domain.vo.UserCountVo; | |||||
| import com.iformall.domain.vo.UserStructureVo; | import com.iformall.domain.vo.UserStructureVo; | ||||
| import com.iformall.enums.EnumAppPlat; | import com.iformall.enums.EnumAppPlat; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.mapper.WxAppinfoMapper; | |||||
| import com.iformall.mapper.WxBuserMapper; | import com.iformall.mapper.WxBuserMapper; | ||||
| import com.iformall.service.WxAppinfoService; | import com.iformall.service.WxAppinfoService; | ||||
| import com.iformall.service.cuser.BasicCUserService; | import com.iformall.service.cuser.BasicCUserService; | ||||
| @@ -40,6 +41,9 @@ public class WxBUserServiceAdapter extends BasicCUserService implements CUserSer | |||||
| @Autowired | @Autowired | ||||
| private WxAppinfoService wxAppinfoService; | private WxAppinfoService wxAppinfoService; | ||||
| @Autowired | |||||
| private WxAppinfoMapper wxAppinfoMapper; | |||||
| @Autowired | @Autowired | ||||
| private FmOpenService openService; | private FmOpenService openService; | ||||
| @@ -300,14 +304,14 @@ public class WxBUserServiceAdapter extends BasicCUserService implements CUserSer | |||||
| try { | try { | ||||
| String accessToken = wxMaService.getAccessToken(true); | String accessToken = wxMaService.getAccessToken(true); | ||||
| WxAppinfo updateApp = new WxAppinfo(); | WxAppinfo updateApp = new WxAppinfo(); | ||||
| updateApp.setId(wxAppinfo.getId()); | |||||
| updateApp.setAppId(wxAppinfo.getAppId()); | |||||
| updateApp.setAccessToken(accessToken); | updateApp.setAccessToken(accessToken); | ||||
| updateApp.setLastTokenTime(new Date()); | updateApp.setLastTokenTime(new Date()); | ||||
| updateApp.setExpiresIn(7200); | updateApp.setExpiresIn(7200); | ||||
| wxAppinfo.setAccessToken(updateApp.getAccessToken()); | wxAppinfo.setAccessToken(updateApp.getAccessToken()); | ||||
| wxAppinfo.setLastTokenTime(updateApp.getLastTokenTime()); | wxAppinfo.setLastTokenTime(updateApp.getLastTokenTime()); | ||||
| wxAppinfo.setExpiresIn(updateApp.getExpiresIn()); | wxAppinfo.setExpiresIn(updateApp.getExpiresIn()); | ||||
| wxAppinfoService.saveOrUpdate(updateApp); | |||||
| wxAppinfoMapper.updateAccessToken(updateApp); | |||||
| } catch (WxErrorException e) { | } catch (WxErrorException e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| @@ -16,6 +16,7 @@ import com.iformall.enums.EnumAppPlat; | |||||
| import com.iformall.enums.EnumAssignTagsTrigger; | import com.iformall.enums.EnumAssignTagsTrigger; | ||||
| import com.iformall.enums.EnumPayVersion; | import com.iformall.enums.EnumPayVersion; | ||||
| import com.iformall.enums.EnumYesOrNo; | import com.iformall.enums.EnumYesOrNo; | ||||
| import com.iformall.mapper.WxAppinfoMapper; | |||||
| import com.iformall.mapper.WxMallMapper; | import com.iformall.mapper.WxMallMapper; | ||||
| import com.iformall.service.WxAppinfoService; | import com.iformall.service.WxAppinfoService; | ||||
| import com.iformall.service.WxCUserBasicInfoService; | import com.iformall.service.WxCUserBasicInfoService; | ||||
| @@ -58,6 +59,9 @@ public class WxCUserServiceAdapter extends BasicCUserService implements CUserSer | |||||
| @Autowired | @Autowired | ||||
| private WxAppinfoService wxAppinfoService; | private WxAppinfoService wxAppinfoService; | ||||
| @Autowired | |||||
| private WxAppinfoMapper wxAppinfoMapper; | |||||
| @Autowired | @Autowired | ||||
| private FmOpenService openService; | private FmOpenService openService; | ||||
| @@ -405,14 +409,14 @@ public class WxCUserServiceAdapter extends BasicCUserService implements CUserSer | |||||
| try { | try { | ||||
| String accessToken = wxMaService.getAccessToken(true); | String accessToken = wxMaService.getAccessToken(true); | ||||
| WxAppinfo updateApp = new WxAppinfo(); | WxAppinfo updateApp = new WxAppinfo(); | ||||
| updateApp.setId(wxAppinfo.getId()); | |||||
| updateApp.setAppId(wxAppinfo.getAppId()); | |||||
| updateApp.setAccessToken(accessToken); | updateApp.setAccessToken(accessToken); | ||||
| updateApp.setLastTokenTime(new Date()); | updateApp.setLastTokenTime(new Date()); | ||||
| updateApp.setExpiresIn(7200); | updateApp.setExpiresIn(7200); | ||||
| wxAppinfo.setAccessToken(updateApp.getAccessToken()); | wxAppinfo.setAccessToken(updateApp.getAccessToken()); | ||||
| wxAppinfo.setLastTokenTime(updateApp.getLastTokenTime()); | wxAppinfo.setLastTokenTime(updateApp.getLastTokenTime()); | ||||
| wxAppinfo.setExpiresIn(updateApp.getExpiresIn()); | wxAppinfo.setExpiresIn(updateApp.getExpiresIn()); | ||||
| wxAppinfoService.saveOrUpdate(updateApp); | |||||
| wxAppinfoMapper.updateAccessToken(updateApp); | |||||
| } catch (WxErrorException e) { | } catch (WxErrorException e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| @@ -605,14 +605,14 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { | |||||
| try { | try { | ||||
| String accessToken = ttWebService.getAccessToken(true); | String accessToken = ttWebService.getAccessToken(true); | ||||
| WxAppinfo updateApp = new WxAppinfo(); | WxAppinfo updateApp = new WxAppinfo(); | ||||
| updateApp.setId(appinfo.getId()); | |||||
| updateApp.setAppId(appinfo.getAppId()); | |||||
| updateApp.setAccessToken(accessToken); | updateApp.setAccessToken(accessToken); | ||||
| updateApp.setLastTokenTime(new Date()); | updateApp.setLastTokenTime(new Date()); | ||||
| updateApp.setExpiresIn(7200); | updateApp.setExpiresIn(7200); | ||||
| appinfo.setAccessToken(updateApp.getAccessToken()); | appinfo.setAccessToken(updateApp.getAccessToken()); | ||||
| appinfo.setLastTokenTime(updateApp.getLastTokenTime()); | appinfo.setLastTokenTime(updateApp.getLastTokenTime()); | ||||
| appinfo.setExpiresIn(updateApp.getExpiresIn()); | appinfo.setExpiresIn(updateApp.getExpiresIn()); | ||||
| wxAppinfoMapper.updateById(updateApp); | |||||
| wxAppinfoMapper.updateAccessToken(updateApp); | |||||
| } catch (WxErrorException e) { | } catch (WxErrorException e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| @@ -14,6 +14,7 @@ import com.iformall.enums.EnumCouponType; | |||||
| import com.iformall.enums.EnumPayWay; | import com.iformall.enums.EnumPayWay; | ||||
| import com.iformall.mapper.WxAppinfoMapper; | import com.iformall.mapper.WxAppinfoMapper; | ||||
| import com.iformall.service.WxAppinfoService; | import com.iformall.service.WxAppinfoService; | ||||
| import com.iformall.service.WxMallService; | |||||
| import com.iformall.utils.Constant; | import com.iformall.utils.Constant; | ||||
| import com.iformall.utils.RedisCacheUtils; | import com.iformall.utils.RedisCacheUtils; | ||||
| @@ -36,6 +37,9 @@ public class WxAppinfoServiceImpl implements WxAppinfoService { | |||||
| @Autowired | @Autowired | ||||
| WxAppinfoMapper wxAppinfoMapper; | WxAppinfoMapper wxAppinfoMapper; | ||||
| @Autowired | |||||
| WxMallService wxMallService; | |||||
| @Autowired | @Autowired | ||||
| @Qualifier("objectCommonRedisTemplate") | @Qualifier("objectCommonRedisTemplate") | ||||
| RedisTemplate<String, Object> wxAppinfoRedisTemplate; | RedisTemplate<String, Object> wxAppinfoRedisTemplate; | ||||
| @@ -95,7 +99,26 @@ public class WxAppinfoServiceImpl implements WxAppinfoService { | |||||
| @Override | @Override | ||||
| public WxAppinfo getByAppId(String appId) { | public WxAppinfo getByAppId(String appId) { | ||||
| return wxAppinfoMapper.findByAppId(appId); | |||||
| WxAppinfo appinfoQ = new WxAppinfo(); | |||||
| appinfoQ.setAppId(appId); | |||||
| List<WxAppinfo> list = wxAppinfoMapper.findList(appinfoQ); | |||||
| if(list.size() == 1){ | |||||
| return list.get(0); | |||||
| }else if(list.size() > 0){ | |||||
| for (WxAppinfo appinfo:list) { | |||||
| TenantEntity tenantEntity = new TenantEntity(); | |||||
| tenantEntity.setTenantId(appinfo.getTenantId()); | |||||
| if(wxMallService.isgroupSupport(tenantEntity)){ | |||||
| return appinfo; | |||||
| } | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| @Override | |||||
| public WxAppinfo getByAppId(String appId, String tenantId) { | |||||
| return wxAppinfoMapper.findByAppId(appId,tenantId); | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -155,9 +178,9 @@ public class WxAppinfoServiceImpl implements WxAppinfoService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public WxAppinfo getByAppIdFromRedis(String appId) { | |||||
| public WxAppinfo getByAppIdFromRedis(String appId,String tenantId) { | |||||
| WxAppinfo record = null; | WxAppinfo record = null; | ||||
| String key = Constant.appinfoPrev + appId; | |||||
| String key = Constant.appinfoPrev + tenantId + ":" + appId; | |||||
| record = RedisCacheUtils.getCacheObject(wxAppinfoRedisTemplate, key, WxAppinfo.class); | record = RedisCacheUtils.getCacheObject(wxAppinfoRedisTemplate, key, WxAppinfo.class); | ||||
| if (null == record) { | if (null == record) { | ||||
| record = this.getByAppId(appId); | record = this.getByAppId(appId); | ||||
| @@ -162,34 +162,23 @@ public class WxAuthorizerInfoServiceImpl implements WxAuthorizerInfoService { | |||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| } | } | ||||
| if (authorizerInfo == null) { | if (authorizerInfo == null) { | ||||
| WxAppinfo appinfo = appinfoMapper.findByAppId(record.getAuthorizerAppid()); | |||||
| if(appinfo != null) { | |||||
| record.setId(appinfo.getId()); | |||||
| // record.updateTenantInfo(appinfo.getTenantInfo()); | |||||
| record.setTenantId(appinfo.getTenantId()); | |||||
| record.setType(appinfo.getType()); | |||||
| } else { | |||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| record.setId(idWorker.nextId()); | |||||
| } | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| record.setId(idWorker.nextId()); | |||||
| record.setCreateTime(curDate); | record.setCreateTime(curDate); | ||||
| record.setUpdateTime(curDate); | record.setUpdateTime(curDate); | ||||
| // 授权表 添加 | // 授权表 添加 | ||||
| authorizerInfoMapper.insert(record); | authorizerInfoMapper.insert(record); | ||||
| if(appinfo.getType() != null) { | |||||
| if (appinfo.getType().equals(EnumAppType.C.getCode()) || | |||||
| appinfo.getType().equals(EnumAppType.B.getCode())) { | |||||
| if(record.getType() != null) { | |||||
| if (record.getType().equals(EnumAppType.C.getCode()) || | |||||
| record.getType().equals(EnumAppType.B.getCode())) { | |||||
| // C/B 扩展配置表添加 | // C/B 扩展配置表添加 | ||||
| WxWeappExtSet weappExtSet = new WxWeappExtSet(); | WxWeappExtSet weappExtSet = new WxWeappExtSet(); | ||||
| weappExtSet.setId(record.getId()); | weappExtSet.setId(record.getId()); | ||||
| weappExtSet.setAppId(record.getAuthorizerAppid()); | weappExtSet.setAppId(record.getAuthorizerAppid()); | ||||
| if (appinfo.getType().equals(EnumAppType.C.getCode())) { | |||||
| if (record.getType().equals(EnumAppType.C.getCode())) { | |||||
| weappExtSet.setCarSupport(EnumCarSupport.NOCAR.getCode()); | weappExtSet.setCarSupport(EnumCarSupport.NOCAR.getCode()); | ||||
| } | } | ||||
| if (appinfo != null) { | |||||
| weappExtSet.setType(appinfo.getType()); | |||||
| } | |||||
| weappExtSet.setType(record.getType()); | |||||
| weappExtSet.setCreateDate(curDate); | weappExtSet.setCreateDate(curDate); | ||||
| weappExtSet.setUpdateDate(curDate); | weappExtSet.setUpdateDate(curDate); | ||||
| weappExtSetMapper.insert(weappExtSet); | weappExtSetMapper.insert(weappExtSet); | ||||
| @@ -2076,6 +2076,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| WxAuthorizerInfo weappInfo = authorizerInfoMapper.findMp(authQ); | WxAuthorizerInfo weappInfo = authorizerInfoMapper.findMp(authQ); | ||||
| if (weappInfo != null) { | if (weappInfo != null) { | ||||
| AppUniformMsg appUniformMsg = new AppUniformMsg(); | AppUniformMsg appUniformMsg = new AppUniformMsg(); | ||||
| appUniformMsg.setTenantId(coupon.getTenantId()); | |||||
| appUniformMsg.setMsgType(EnumMsgRecordType.SMART_APP_UNIFORM.getCode()); | appUniformMsg.setMsgType(EnumMsgRecordType.SMART_APP_UNIFORM.getCode()); | ||||
| appUniformMsg.setAppId(user.getAppId()); | appUniformMsg.setAppId(user.getAppId()); | ||||
| appUniformMsg.setTo(user.getOpenId()); | appUniformMsg.setTo(user.getOpenId()); | ||||
| @@ -43,19 +43,14 @@ public class WxCuserFloatingLayerServiceImpl implements WxCuserFloatingLayerServ | |||||
| @Override | @Override | ||||
| public WxFloatingLayer getFloatingLayer(String openId, String appId) { | |||||
| WxAppinfo appinfo = appinfoMapper.findByAppId(appId); | |||||
| if (StringUtils.isBlank(openId)) { | |||||
| return getWxFloatingLayer(appinfo.getTenantId()); | |||||
| } | |||||
| public WxFloatingLayer getFloatingLayer(TenantEntity tenantEntity,String openId) { | |||||
| //1 查看是否存在用户,用户不存在 直接返回浮层信息 | //1 查看是否存在用户,用户不存在 直接返回浮层信息 | ||||
| WxCUser user = new WxCUser(); | WxCUser user = new WxCUser(); | ||||
| user.setOpenId(openId); | user.setOpenId(openId); | ||||
| user.setAppId(appId); | |||||
| user.setTenantId(appinfo.getTenantId()); | |||||
| user.setTenantId(tenantEntity.getTenantId()); | |||||
| WxCUser byOpenId = wxCUserMapper.findByOpenId(user); | WxCUser byOpenId = wxCUserMapper.findByOpenId(user); | ||||
| if (byOpenId == null) { | if (byOpenId == null) { | ||||
| return getWxFloatingLayer(appinfo.getTenantId()); | |||||
| return getWxFloatingLayer(tenantEntity.getTenantId()); | |||||
| } | } | ||||
| //2 用户存在 查看是否已有弹出记录 没有 保存记录后返回浮层信息 | //2 用户存在 查看是否已有弹出记录 没有 保存记录后返回浮层信息 | ||||
| WxCuserFloatingLayer wxCuserFloatingLayerQuery = new WxCuserFloatingLayer(); | WxCuserFloatingLayer wxCuserFloatingLayerQuery = new WxCuserFloatingLayer(); | ||||
| @@ -19,6 +19,7 @@ import com.iformall.mapper.WxAppinfoMapper; | |||||
| import com.iformall.mapper.WxMerchantBUserMapper; | import com.iformall.mapper.WxMerchantBUserMapper; | ||||
| import com.iformall.mapper.WxMerchantMapper; | import com.iformall.mapper.WxMerchantMapper; | ||||
| import com.iformall.mapper.WxMsgValidationcodeMapper; | import com.iformall.mapper.WxMsgValidationcodeMapper; | ||||
| import com.iformall.service.WxMallService; | |||||
| import com.iformall.service.WxMerchantBUserService; | import com.iformall.service.WxMerchantBUserService; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -36,6 +37,9 @@ import java.util.stream.Collectors; | |||||
| public class WxMerchantBUserServiceImpl implements WxMerchantBUserService { | public class WxMerchantBUserServiceImpl implements WxMerchantBUserService { | ||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | |||||
| WxMallService wxMallService; | |||||
| @Autowired | @Autowired | ||||
| WxAppinfoMapper wxAppinfoMapper; | WxAppinfoMapper wxAppinfoMapper; | ||||
| @@ -144,10 +148,10 @@ public class WxMerchantBUserServiceImpl implements WxMerchantBUserService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public ResultData updatePwd(String appId, String phone, String code, String pwd) { | |||||
| WxAppinfo appinfo = wxAppinfoMapper.findByAppId(appId); | |||||
| public ResultData updatePwd(TenantEntity tenantEntity, String phone, String code, String pwd) { | |||||
| WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode(); | WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode(); | ||||
| wxMsgValidationcode.setTenantId(appinfo.getTenantId()); | |||||
| wxMsgValidationcode.setTenantId(tenantEntity.getTenantId()); | |||||
| wxMsgValidationcode.setPhone(phone); | wxMsgValidationcode.setPhone(phone); | ||||
| wxMsgValidationcode.setCode(code); | wxMsgValidationcode.setCode(code); | ||||
| List<WxMsgValidationcode> msgValidationCodeList = wxMsgValidationcodeMapper.findList(wxMsgValidationcode); | List<WxMsgValidationcode> msgValidationCodeList = wxMsgValidationcodeMapper.findList(wxMsgValidationcode); | ||||
| @@ -157,22 +161,30 @@ public class WxMerchantBUserServiceImpl implements WxMerchantBUserService { | |||||
| if (msgValidationCodeList.size() > 0) { | if (msgValidationCodeList.size() > 0) { | ||||
| //更新 | //更新 | ||||
| WxMerchantBUser bUser = new WxMerchantBUser(); | WxMerchantBUser bUser = new WxMerchantBUser(); | ||||
| bUser.setTenantId(appinfo.getTenantId()); | |||||
| bUser.setTenantId(tenantEntity.getTenantId()); | |||||
| bUser.setPhone(phone); | bUser.setPhone(phone); | ||||
| bUser.setAppId(appId); | |||||
| bUser.setStatus(EnumMerchantBUserStatus.VALID.getCode()); | bUser.setStatus(EnumMerchantBUserStatus.VALID.getCode()); | ||||
| List<WxMerchantBUser> list = wxMerchantBUserMapper.findList(bUser); | List<WxMerchantBUser> list = wxMerchantBUserMapper.findList(bUser); | ||||
| if(wxMallService.isgroupSupport(tenantEntity)){ | |||||
| bUser.setTenantId(null); | |||||
| bUser.setParentTenantId(tenantEntity.getTenantId()); | |||||
| List<WxMerchantBUser> list1 = wxMerchantBUserMapper.findList(bUser); | |||||
| if(list1.size() > 0){ | |||||
| list.addAll(list1); | |||||
| } | |||||
| } | |||||
| if (list.size() > 0) { | if (list.size() > 0) { | ||||
| bUser = list.get(0); | |||||
| bUser.setUserPwd(pwd); | |||||
| try { | |||||
| wxMerchantBUserMapper.updateById(bUser); | |||||
| } catch (Exception e) { | |||||
| logger.error("db failed: 商户-" + bUser.getId() + ", e:" + e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||||
| for (WxMerchantBUser merchantBUser:list) { | |||||
| merchantBUser.setUserPwd(pwd); | |||||
| try { | |||||
| wxMerchantBUserMapper.updateById(bUser); | |||||
| } catch (Exception e) { | |||||
| logger.error("db failed: 商户-" + bUser.getId() + ", e:" + e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||||
| } | |||||
| } | } | ||||
| } else { | } else { | ||||
| logger.error("B端用户不是这个app的用户:" + appId); | |||||
| logger.error("未找到用户:"); | |||||
| throw new MallinkException(ErrorCode.BUSER_NOT_IN_APP); | throw new MallinkException(ErrorCode.BUSER_NOT_IN_APP); | ||||
| } | } | ||||
| } | } | ||||
| @@ -1798,6 +1798,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| WxAuthorizerInfo weappInfo = authorizerInfoMapper.findMp(authQ); | WxAuthorizerInfo weappInfo = authorizerInfoMapper.findMp(authQ); | ||||
| if (weappInfo != null) { | if (weappInfo != null) { | ||||
| AppUniformMsg appUniformMsg = new AppUniformMsg(); | AppUniformMsg appUniformMsg = new AppUniformMsg(); | ||||
| appUniformMsg.setTenantId(coupon.getTenantId()); | |||||
| appUniformMsg.setMsgType(EnumMsgRecordType.SMART_APP_UNIFORM.getCode()); | appUniformMsg.setMsgType(EnumMsgRecordType.SMART_APP_UNIFORM.getCode()); | ||||
| appUniformMsg.setAppId(user.getAppId()); | appUniformMsg.setAppId(user.getAppId()); | ||||
| appUniformMsg.setTo(user.getOpenId()); | appUniformMsg.setTo(user.getOpenId()); | ||||
| @@ -576,7 +576,7 @@ public class WxPayBillServiceImpl implements WxPayBillService { | |||||
| * @return | * @return | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| public String notify(Map<String, String> paramMap, EnumPayWay payWay) { | |||||
| public String notify(String tenantId,Map<String, String> paramMap, EnumPayWay payWay) { | |||||
| // how to get wechatAppId, wechatMchId, partnerKey | // how to get wechatAppId, wechatMchId, partnerKey | ||||
| logger.info("-------------"); | logger.info("-------------"); | ||||
| logger.info("微信回调返回值:" + JSONObject.toJSONString(paramMap)); | logger.info("微信回调返回值:" + JSONObject.toJSONString(paramMap)); | ||||
| @@ -585,18 +585,19 @@ public class WxPayBillServiceImpl implements WxPayBillService { | |||||
| String subAppId = paramMap.get("sub_appid"); | String subAppId = paramMap.get("sub_appid"); | ||||
| String mchId = paramMap.get("mch_id"); | String mchId = paramMap.get("mch_id"); | ||||
| String subMchId = paramMap.get("sub_mch_id"); | String subMchId = paramMap.get("sub_mch_id"); | ||||
| String attach = paramMap.get("attach"); | |||||
| WxAppinfo appinfo; | WxAppinfo appinfo; | ||||
| boolean isNormal = true; | boolean isNormal = true; | ||||
| if (StringUtils.isBlank(subAppId) && StringUtils.isBlank(subMchId)) { | if (StringUtils.isBlank(subAppId) && StringUtils.isBlank(subMchId)) { | ||||
| // 普通商户号 | // 普通商户号 | ||||
| appinfo = wxAppinfoMapper.findByAppId(appId); | |||||
| appinfo = wxAppinfoMapper.findByAppId(appId,tenantId); | |||||
| if (appinfo == null) { | if (appinfo == null) { | ||||
| throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); | throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); | ||||
| } | } | ||||
| isNormal = true; | isNormal = true; | ||||
| } else { | } else { | ||||
| // 服务号 现在用hmac-sha256 | // 服务号 现在用hmac-sha256 | ||||
| appinfo = wxAppinfoMapper.findByAppId(subAppId); | |||||
| appinfo = wxAppinfoMapper.findByAppId(subAppId,tenantId); | |||||
| if (appinfo == null) { | if (appinfo == null) { | ||||
| throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); | throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); | ||||
| } | } | ||||
| @@ -124,8 +124,7 @@ public class WxTemplateMsgServiceImpl implements WxTemplateMsgService { | |||||
| if(isFmOpen) { | if(isFmOpen) { | ||||
| wxMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appinfo.getAppId()); | wxMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appinfo.getAppId()); | ||||
| } else { | } else { | ||||
| WxAppinfo appInfo = wxAppinfoService.getByAppId(appinfo.getAppId()); | |||||
| wxMaService = maUtil.getWeappService(appInfo); | |||||
| wxMaService = maUtil.getWeappService(appinfo); | |||||
| } | } | ||||
| String s = ""; | String s = ""; | ||||
| if(byId.getType() == EnumTemplateType.ACTIVITY_REMIND.getCode()){ | if(byId.getType() == EnumTemplateType.ACTIVITY_REMIND.getCode()){ | ||||
| @@ -76,7 +76,7 @@ public class SendSmartAppMsgServiceImpl implements MsgSendService { | |||||
| return; | return; | ||||
| } | } | ||||
| if(0 == msg.getOnOff().intValue()){ | if(0 == msg.getOnOff().intValue()){ | ||||
| WxAppinfo appInfo = wxAppinfoService.getByAppId(smartAppMsg.getAppId()); | |||||
| WxAppinfo appInfo = wxAppinfoService.getByAppId(smartAppMsg.getAppId(),tenantEntity.getTenantId()); | |||||
| if(EnumTemplateType.TT_SEND_COUPON_REMIND.getCode().equals(msg.getType())){ | if(EnumTemplateType.TT_SEND_COUPON_REMIND.getCode().equals(msg.getType())){ | ||||
| //发抖音 | //发抖音 | ||||
| TtMaService ttappService = maUtil.getTtMaService(appInfo); | TtMaService ttappService = maUtil.getTtMaService(appInfo); | ||||
| @@ -48,10 +48,7 @@ public class SendWeappUniformMsgServiceImpl implements MsgSendService { | |||||
| AppUniformMsg appUniformMsg = (AppUniformMsg)baseMsg; | AppUniformMsg appUniformMsg = (AppUniformMsg)baseMsg; | ||||
| String tenantId = appUniformMsg.getTenantId(); | String tenantId = appUniformMsg.getTenantId(); | ||||
| if (StringUtils.isBlank(tenantId)) { | |||||
| WxAppinfo appinfo = appinfoMapper.findByAppId(appUniformMsg.getAppId()); | |||||
| tenantId = appinfo.getTenantId(); | |||||
| } | |||||
| WxTemplateMsg msg = null; | WxTemplateMsg msg = null; | ||||
| WxMaService wxMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appUniformMsg.getAppId()); | WxMaService wxMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appUniformMsg.getAppId()); | ||||
| @@ -1,5 +1,6 @@ | |||||
| package com.iformall.service.pay.service.pay.douyin.v1; | package com.iformall.service.pay.service.pay.douyin.v1; | ||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.domain.po.WxAppinfo; | import com.iformall.domain.po.WxAppinfo; | ||||
| import com.iformall.domain.po.WxPayAccount; | import com.iformall.domain.po.WxPayAccount; | ||||
| @@ -21,6 +22,8 @@ import org.apache.commons.lang3.StringUtils; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.util.HashMap; | |||||
| import java.util.Map; | |||||
| @Slf4j | @Slf4j | ||||
| public class BaseTtPayAdapterService { | public class BaseTtPayAdapterService { | ||||
| @@ -28,6 +31,17 @@ public class BaseTtPayAdapterService { | |||||
| @Autowired | @Autowired | ||||
| protected MaUtil maUtil; | protected MaUtil maUtil; | ||||
| /** | |||||
| * 做为支付的扩展数据 | |||||
| * @param payOrder | |||||
| * @return | |||||
| */ | |||||
| protected String getCpExtra(WxPayOrder payOrder) { | |||||
| Map<String,String> map = new HashMap<>(); | |||||
| map.put("tenantId",payOrder.getTenantId()); | |||||
| return JSON.toJSONString(map); | |||||
| } | |||||
| protected PayQueryAdapterResult queryPayStatus(WxPayOrder oldRecord, WxAppinfo appInfo, WxPayAccount payAccount) | protected PayQueryAdapterResult queryPayStatus(WxPayOrder oldRecord, WxAppinfo appInfo, WxPayAccount payAccount) | ||||
| throws Exception { | throws Exception { | ||||
| TtPayService ttPayService = maUtil.getTtPayService(appInfo, payAccount); | TtPayService ttPayService = maUtil.getTtPayService(appInfo, payAccount); | ||||
| @@ -138,6 +138,8 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen | |||||
| pageEntry.setParams(JSON.toJSONString(paramMap)); | pageEntry.setParams(JSON.toJSONString(paramMap)); | ||||
| request.setOrderEntrySchema(pageEntry); | request.setOrderEntrySchema(pageEntry); | ||||
| request.setCpExtra(getCpExtra(record)); | |||||
| TtPayUnifiedOrderV2Result orderV2 = ttPayService.createOrderV2(request); | TtPayUnifiedOrderV2Result orderV2 = ttPayService.createOrderV2(request); | ||||
| JSONObject allExtParam = new JSONObject(); | JSONObject allExtParam = new JSONObject(); | ||||
| @@ -452,6 +454,7 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen | |||||
| map.put("outOrderNo",record.getOrderId()); | map.put("outOrderNo",record.getOrderId()); | ||||
| map.put("createPay",record.isCreatPay()); | map.put("createPay",record.isCreatPay()); | ||||
| if(record.isCreatPay()){ | if(record.isCreatPay()){ | ||||
| map.put("callbackData",JSONObject.parseObject(getCpExtra(record),Map.class)); | |||||
| Map<String,Integer> payment = new HashMap(); | Map<String,Integer> payment = new HashMap(); | ||||
| payment.put("totalAmount",composeOrder.getPayment()); | payment.put("totalAmount",composeOrder.getPayment()); | ||||
| map.put("payment",payment); | map.put("payment",payment); | ||||
| @@ -59,6 +59,17 @@ public class BaseWxPayAdapterService { | |||||
| @Autowired | @Autowired | ||||
| MaUtil maUtil; | MaUtil maUtil; | ||||
| /** | |||||
| * 做为支付的扩展数据 | |||||
| * @param payOrder | |||||
| * @return | |||||
| */ | |||||
| protected String getAttach(WxPayOrder payOrder) { | |||||
| Map<String,String> map = new HashMap<>(); | |||||
| map.put("tenantId",payOrder.getTenantId()); | |||||
| return JSON.toJSONString(map); | |||||
| } | |||||
| protected String getMerchantUid(WxPayOrder payOrder,WxOrder order) { | protected String getMerchantUid(WxPayOrder payOrder,WxOrder order) { | ||||
| WxComposeChildOrderShare share = payOrder.getChildOrderShare(order.getId()); | WxComposeChildOrderShare share = payOrder.getChildOrderShare(order.getId()); | ||||
| @@ -9,6 +9,7 @@ public class SFTPayCommonMiniAppReq { | |||||
| private String sp_mchid;//服务商户号 | private String sp_mchid;//服务商户号 | ||||
| private String sub_mchid;//二级商户号 | private String sub_mchid;//二级商户号 | ||||
| private String description;//商品描述 | private String description;//商品描述 | ||||
| private String attach;// 附加数据 | |||||
| private String out_trade_no;//商户订单号 | private String out_trade_no;//商户订单号 | ||||
| private String notify_url;//通知地址,不允许携带查询串 | private String notify_url;//通知地址,不允许携带查询串 | ||||
| private SFTPaySettleReq settle_info;//结算信息 | private SFTPaySettleReq settle_info;//结算信息 | ||||
| @@ -75,6 +75,7 @@ public class WxMiniAppPaySFTAdapterService extends BaseWxPaySFTAdapterService i | |||||
| }catch(Exception e) { | }catch(Exception e) { | ||||
| req.setDescription("weixin miniApp product"); | req.setDescription("weixin miniApp product"); | ||||
| } | } | ||||
| req.setAttach(getAttach(record)); | |||||
| req.setOut_trade_no(String.valueOf(composeOrder.getMainOrderId())); | req.setOut_trade_no(String.valueOf(composeOrder.getMainOrderId())); | ||||
| req.setNotify_url(payAccount.getPayNotifyV3Url()); | req.setNotify_url(payAccount.getPayNotifyV3Url()); | ||||
| @@ -104,6 +105,8 @@ public class WxMiniAppPaySFTAdapterService extends BaseWxPaySFTAdapterService i | |||||
| List<SFTCombineItemOrder> suborders = new ArrayList<SFTCombineItemOrder>(); | List<SFTCombineItemOrder> suborders = new ArrayList<SFTCombineItemOrder>(); | ||||
| for (WxOrder order : childOrders) { | for (WxOrder order : childOrders) { | ||||
| SFTCombineItemOrder so = new SFTCombineItemOrder(); | SFTCombineItemOrder so = new SFTCombineItemOrder(); | ||||
| String subMchId = getMerchantUid(record,order); | String subMchId = getMerchantUid(record,order); | ||||
| so.initByWxOrder(payAccount, order, subMchId, appInfo, productName, String.valueOf(record.getId())); | so.initByWxOrder(payAccount, order, subMchId, appInfo, productName, String.valueOf(record.getId())); | ||||
| suborders.add(so); | suborders.add(so); | ||||
| @@ -68,6 +68,7 @@ public class WxMiniAppPayAdapterService extends BaseWxPayV2AdapterService implem | |||||
| wxPayOrderP.setMch_id(payAccount.getMchId()); | wxPayOrderP.setMch_id(payAccount.getMchId()); | ||||
| wxPayOrderP.setNonce_str(noncestr); | wxPayOrderP.setNonce_str(noncestr); | ||||
| wxPayOrderP.setBody(productName); | wxPayOrderP.setBody(productName); | ||||
| wxPayOrderP.setAttach(getAttach(record)); | |||||
| wxPayOrderP.setOut_trade_no(record.getPayOrderNo()); | wxPayOrderP.setOut_trade_no(record.getPayOrderNo()); | ||||
| wxPayOrderP.setTotal_fee(composeOrder.getPayment()); | wxPayOrderP.setTotal_fee(composeOrder.getPayment()); | ||||
| wxPayOrderP.setSpbill_create_ip(record.getIp()); // 终端IP | wxPayOrderP.setSpbill_create_ip(record.getIp()); // 终端IP | ||||
| @@ -143,6 +144,7 @@ public class WxMiniAppPayAdapterService extends BaseWxPayV2AdapterService implem | |||||
| wxPayOrderSP.setSub_mch_id(payAccount.getSubMchId()); | wxPayOrderSP.setSub_mch_id(payAccount.getSubMchId()); | ||||
| wxPayOrderSP.setNonce_str(noncestr); | wxPayOrderSP.setNonce_str(noncestr); | ||||
| wxPayOrderSP.setBody(productName); | wxPayOrderSP.setBody(productName); | ||||
| wxPayOrderSP.setAttach(getAttach(record)); | |||||
| wxPayOrderSP.setOut_trade_no(record.getPayOrderNo()); | wxPayOrderSP.setOut_trade_no(record.getPayOrderNo()); | ||||
| wxPayOrderSP.setTotal_fee(composeOrder.getPayment().toString()); | wxPayOrderSP.setTotal_fee(composeOrder.getPayment().toString()); | ||||
| wxPayOrderSP.setSpbill_create_ip(record.getIp()); // 终端IP | wxPayOrderSP.setSpbill_create_ip(record.getIp()); // 终端IP | ||||
| @@ -58,6 +58,7 @@ public class WxMiniMaPayAdapterService extends BaseWxPayV2AdapterService impleme | |||||
| wxPayOrderP.setDevice_info(bUserPhone); | wxPayOrderP.setDevice_info(bUserPhone); | ||||
| wxPayOrderP.setNonce_str(noncestr); | wxPayOrderP.setNonce_str(noncestr); | ||||
| wxPayOrderP.setBody(productName); | wxPayOrderP.setBody(productName); | ||||
| wxPayOrderP.setAttach(getAttach(record)); | |||||
| wxPayOrderP.setOut_trade_no(record.getPayOrderNo()); | wxPayOrderP.setOut_trade_no(record.getPayOrderNo()); | ||||
| wxPayOrderP.setTotal_fee(record.getPayAmount()); | wxPayOrderP.setTotal_fee(record.getPayAmount()); | ||||
| wxPayOrderP.setSpbill_create_ip(record.getIp()); // 终端IP | wxPayOrderP.setSpbill_create_ip(record.getIp()); // 终端IP | ||||
| @@ -121,6 +122,7 @@ public class WxMiniMaPayAdapterService extends BaseWxPayV2AdapterService impleme | |||||
| wxPayOrderSP.setDevice_info(bUserPhone); | wxPayOrderSP.setDevice_info(bUserPhone); | ||||
| wxPayOrderSP.setNonce_str(noncestr); | wxPayOrderSP.setNonce_str(noncestr); | ||||
| wxPayOrderSP.setBody(productName); | wxPayOrderSP.setBody(productName); | ||||
| wxPayOrderSP.setAttach(getAttach(record)); | |||||
| wxPayOrderSP.setOut_trade_no(record.getPayOrderNo()); | wxPayOrderSP.setOut_trade_no(record.getPayOrderNo()); | ||||
| wxPayOrderSP.setTotal_fee(record.getPayAmount()); | wxPayOrderSP.setTotal_fee(record.getPayAmount()); | ||||
| wxPayOrderSP.setSpbill_create_ip(record.getIp()); | wxPayOrderSP.setSpbill_create_ip(record.getIp()); | ||||
| @@ -11,6 +11,7 @@ public class V3PayCommonMiniAppReq { | |||||
| private String sub_mchid;//二级商户号 | private String sub_mchid;//二级商户号 | ||||
| private String description;//商品描述 | private String description;//商品描述 | ||||
| private String out_trade_no;//商户订单号 | private String out_trade_no;//商户订单号 | ||||
| private String attach;//附加数据,在查询API和支付通知中原样返回,可作为自定义参数使用,实际情况下只有支付完成状态才会返回该字段。 | |||||
| private String notify_url;//通知地址,不允许携带查询串 | private String notify_url;//通知地址,不允许携带查询串 | ||||
| private V3PaySettleReq settle_info;//结算信息 | private V3PaySettleReq settle_info;//结算信息 | ||||
| private V3PayAmountReq amount;//订单金额 | private V3PayAmountReq amount;//订单金额 | ||||
| @@ -92,6 +92,7 @@ public class WxMiniAppPayV3AdapterService extends BaseWxPayV3AdapterService impl | |||||
| req.setDescription("weixin miniApp product"); | req.setDescription("weixin miniApp product"); | ||||
| } | } | ||||
| req.setOut_trade_no(record.getPayOrderNo()); | req.setOut_trade_no(record.getPayOrderNo()); | ||||
| req.setAttach(getAttach(record)); | |||||
| req.setNotify_url(payAccount.getPayNotifyV3Url()); | req.setNotify_url(payAccount.getPayNotifyV3Url()); | ||||
| V3PaySettleReq settle = new V3PaySettleReq(); | V3PaySettleReq settle = new V3PaySettleReq(); | ||||
| @@ -45,6 +45,17 @@ public class TtRefundAdapterService implements RefundPayAdapterService{ | |||||
| @Autowired | @Autowired | ||||
| WxOrderService wxOrderService; | WxOrderService wxOrderService; | ||||
| /** | |||||
| * 做为分账的扩展数据 | |||||
| * @param | |||||
| * @return | |||||
| */ | |||||
| protected String getCpExtra(WxRefundOrder record) { | |||||
| Map<String,String> map = new HashMap<>(); | |||||
| map.put("tenantId",record.getTenantId()); | |||||
| return JSON.toJSONString(map); | |||||
| } | |||||
| @Override | @Override | ||||
| public RefundAdapterResult refund(WxPayAccount payAccount,WxAppinfo appInfo,WxRefundOrder record,WxPayOrder payOrder,Long orderId,EnumPayType payType) { | public RefundAdapterResult refund(WxPayAccount payAccount,WxAppinfo appInfo,WxRefundOrder record,WxPayOrder payOrder,Long orderId,EnumPayType payType) { | ||||
| @@ -54,6 +65,7 @@ public class TtRefundAdapterService implements RefundPayAdapterService{ | |||||
| TtPayRefundV2Request request = new TtPayRefundV2Request(); | TtPayRefundV2Request request = new TtPayRefundV2Request(); | ||||
| request.setOutOrderNo(payOrder.getPayOrderNo()); | request.setOutOrderNo(payOrder.getPayOrderNo()); | ||||
| request.setOutRefundNo(record.getId().toString()); | request.setOutRefundNo(record.getId().toString()); | ||||
| request.setCpExtra(getCpExtra(record)); | |||||
| TtPayRefundV2Request.PageEntry pageEntry = new TtPayRefundV2Request.PageEntry(); | TtPayRefundV2Request.PageEntry pageEntry = new TtPayRefundV2Request.PageEntry(); | ||||
| pageEntry.setPath(Constant.mainPageUrl); | pageEntry.setPath(Constant.mainPageUrl); | ||||
| Map<String,Object> paramMap = new HashMap<>(); | Map<String,Object> paramMap = new HashMap<>(); | ||||
| @@ -173,9 +185,16 @@ public class TtRefundAdapterService implements RefundPayAdapterService{ | |||||
| @Override | @Override | ||||
| public RefundNotifyAdapterResult notify(Map<String, String> paramMap, EnumPayWay payWay) { | public RefundNotifyAdapterResult notify(Map<String, String> paramMap, EnumPayWay payWay) { | ||||
| log.info("TtRefundAdapterService notify{}"+paramMap); | log.info("TtRefundAdapterService notify{}"+paramMap); | ||||
| String tenantId = paramMap.get("tenantId"); | |||||
| /** | |||||
| * | |||||
| */ | |||||
| String refundno = paramMap.get("cp_refundno"); | |||||
| Long refundOrderId = Long.valueOf(refundno); | |||||
| WxRefundOrder refundOrder = wxRefundOrderMapper.selectById(refundOrderId); | |||||
| String appId = paramMap.get("appid"); | String appId = paramMap.get("appid"); | ||||
| WxAppinfo appinfo = wxAppinfoMapper.findByAppId(appId); | |||||
| WxAppinfo appinfo = wxAppinfoMapper.findByAppId(appId,tenantId); | |||||
| if (appinfo == null) { | if (appinfo == null) { | ||||
| log.error("未找到appid信息:" + appId); | log.error("未找到appid信息:" + appId); | ||||
| throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); | throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); | ||||
| @@ -189,9 +208,7 @@ public class TtRefundAdapterService implements RefundPayAdapterService{ | |||||
| log.error("notify refund, wxpay status not success, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString()); | log.error("notify refund, wxpay status not success, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString()); | ||||
| return notifyErrorResult("订单状态码非SUCCESS"); | return notifyErrorResult("订单状态码非SUCCESS"); | ||||
| } | } | ||||
| String refundno = paramMap.get("cp_refundno"); | |||||
| Long refundOrderId = Long.valueOf(refundno); | |||||
| WxRefundOrder refundOrder = wxRefundOrderMapper.selectById(refundOrderId); | |||||
| // 验证退款金额 | // 验证退款金额 | ||||
| if (!paramMap.get("refund_amount").equals(refundOrder.getRefundFee().toString())) { | if (!paramMap.get("refund_amount").equals(refundOrder.getRefundFee().toString())) { | ||||
| log.error("notify refund, wxpay check refund_fee is invalid, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString()); | log.error("notify refund, wxpay check refund_fee is invalid, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString()); | ||||
| @@ -563,35 +563,38 @@ public class WxRefundAdapterService implements RefundPayAdapterService{ | |||||
| String req_info = CipherUtil.decryptReqInfo(paramMap.get("req_info"), partnerKey); | String req_info = CipherUtil.decryptReqInfo(paramMap.get("req_info"), partnerKey); | ||||
| Map<String, String> reqMap = WxPayment.xmlToMap(req_info); | Map<String, String> reqMap = WxPayment.xmlToMap(req_info); | ||||
| String payOrderNo = reqMap.get("out_trade_no"); | |||||
| Long payOrderId = Long.valueOf(payOrderNo); | |||||
| WxPayOrder payOrder = wxPayOrderMapper.selectById(payOrderId,payAccount.getTenantId()); | |||||
| if (payOrder == null) { | |||||
| log.warn("notify refund, wxpay check pay order not exists, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString()); | |||||
| return notifyErrorResult("支付订单不存在"); | |||||
| } | |||||
| // 验证支付金额 | |||||
| if (!reqMap.get("total_fee").equals(payOrder.getPayAmount().toString())) { | |||||
| log.warn("notify refund, wxpay check total_fee is invalid, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString()); | |||||
| return notifyErrorResult("支付订单总金额不一致"); | |||||
| } | |||||
| String refundIdStr = reqMap.get("out_refund_no"); | String refundIdStr = reqMap.get("out_refund_no"); | ||||
| Long refundOrderId = Long.valueOf(refundIdStr); | Long refundOrderId = Long.valueOf(refundIdStr); | ||||
| WxRefundOrder refundOrder = wxRefundOrderMapper.selectById(refundOrderId); | WxRefundOrder refundOrder = wxRefundOrderMapper.selectById(refundOrderId); | ||||
| if (refundOrder == null) { | if (refundOrder == null) { | ||||
| log.warn("notify refund, wxpay check pay order not exists, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString()); | |||||
| return notifyErrorResult("退款订单不存在"); | |||||
| log.warn("notify refund, wxpay check pay order not exists, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString()); | |||||
| return notifyErrorResult("退款订单不存在"); | |||||
| } | } | ||||
| // 验证支付金额 | // 验证支付金额 | ||||
| if (!reqMap.get("total_fee").equals(refundOrder.getTotalFee().toString())) { | if (!reqMap.get("total_fee").equals(refundOrder.getTotalFee().toString())) { | ||||
| log.warn("notify refund, wxpay check total_fee is invalid, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString()); | |||||
| return notifyErrorResult("订单总金额不一致"); | |||||
| log.warn("notify refund, wxpay check total_fee is invalid, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString()); | |||||
| return notifyErrorResult("订单总金额不一致"); | |||||
| } | } | ||||
| // 验证退款金额 | // 验证退款金额 | ||||
| if (!reqMap.get("refund_fee").equals(refundOrder.getRefundFee().toString())) { | if (!reqMap.get("refund_fee").equals(refundOrder.getRefundFee().toString())) { | ||||
| log.warn("notify refund, wxpay check refund_fee is invalid, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString()); | |||||
| return notifyErrorResult("退款总金额不一致"); | |||||
| log.warn("notify refund, wxpay check refund_fee is invalid, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString()); | |||||
| return notifyErrorResult("退款总金额不一致"); | |||||
| } | |||||
| String payOrderNo = reqMap.get("out_trade_no"); | |||||
| Long payOrderId = Long.valueOf(payOrderNo); | |||||
| WxPayOrder payOrder = wxPayOrderMapper.selectById(payOrderId,refundOrder.getTenantId()); | |||||
| if (payOrder == null) { | |||||
| log.warn("notify refund, wxpay check pay order not exists, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString()); | |||||
| return notifyErrorResult("支付订单不存在"); | |||||
| } | |||||
| // 验证支付金额 | |||||
| if (!reqMap.get("total_fee").equals(payOrder.getPayAmount().toString())) { | |||||
| log.warn("notify refund, wxpay check total_fee is invalid, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString()); | |||||
| return notifyErrorResult("支付订单总金额不一致"); | |||||
| } | } | ||||
| // 处理支付成功 | // 处理支付成功 | ||||
| //handleRefundSuccess(refundOrder, reqMap.get("transaction_id"), reqMap.get("refund_id")); | //handleRefundSuccess(refundOrder, reqMap.get("transaction_id"), reqMap.get("refund_id")); | ||||
| @@ -634,21 +637,6 @@ public class WxRefundAdapterService implements RefundPayAdapterService{ | |||||
| log.info(req_info); | log.info(req_info); | ||||
| Map<String, String> reqMap = WxPayment.xmlToMap(req_info); | Map<String, String> reqMap = WxPayment.xmlToMap(req_info); | ||||
| String payOrderNo = reqMap.get("out_trade_no"); | |||||
| if (payOrderNo == null) { | |||||
| return notifySuccessResult(reqMap.get("transaction_id"), reqMap.get("refund_id"), null); | |||||
| } | |||||
| Long payOrderId = Long.valueOf(payOrderNo); | |||||
| WxPayOrder payOrder = wxPayOrderMapper.selectById(payOrderId,payAccount.getTenantId()); | |||||
| if (payOrder == null) { | |||||
| log.warn("notify refund, wxpay check pay order not exists, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString()); | |||||
| return notifyErrorResult("支付订单不存在"); | |||||
| } | |||||
| // 验证支付金额 | |||||
| if (!reqMap.get("total_fee").equals(payOrder.getPayAmount().toString())) { | |||||
| log.warn("notify refund, wxpay check total_fee is invalid, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString()); | |||||
| return notifyErrorResult("支付订单总金额不一致"); | |||||
| } | |||||
| String refundIdStr = reqMap.get("out_refund_no"); | String refundIdStr = reqMap.get("out_refund_no"); | ||||
| Long refundOrderId = Long.valueOf(refundIdStr); | Long refundOrderId = Long.valueOf(refundIdStr); | ||||
| WxRefundOrder refundOrder = wxRefundOrderMapper.selectById(refundOrderId); | WxRefundOrder refundOrder = wxRefundOrderMapper.selectById(refundOrderId); | ||||
| @@ -667,6 +655,23 @@ public class WxRefundAdapterService implements RefundPayAdapterService{ | |||||
| return notifyErrorResult("退款总金额不一致"); | return notifyErrorResult("退款总金额不一致"); | ||||
| } | } | ||||
| String payOrderNo = reqMap.get("out_trade_no"); | |||||
| if (payOrderNo == null) { | |||||
| return notifySuccessResult(reqMap.get("transaction_id"), reqMap.get("refund_id"), null); | |||||
| } | |||||
| Long payOrderId = Long.valueOf(payOrderNo); | |||||
| WxPayOrder payOrder = wxPayOrderMapper.selectById(payOrderId,refundOrder.getTenantId()); | |||||
| if (payOrder == null) { | |||||
| log.warn("notify refund, wxpay check pay order not exists, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString()); | |||||
| return notifyErrorResult("支付订单不存在"); | |||||
| } | |||||
| // 验证支付金额 | |||||
| if (!reqMap.get("total_fee").equals(payOrder.getPayAmount().toString())) { | |||||
| log.warn("notify refund, wxpay check total_fee is invalid, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString()); | |||||
| return notifyErrorResult("支付订单总金额不一致"); | |||||
| } | |||||
| log.info("notify refund, wxpay checksign success, paramMap:{}, paramMap: " + reqMap.toString() + ", payWay:" + payWay.toString()); | log.info("notify refund, wxpay checksign success, paramMap:{}, paramMap: " + reqMap.toString() + ", payWay:" + payWay.toString()); | ||||
| return notifySuccessResult(reqMap.get("transaction_id"), reqMap.get("refund_id"), refundOrder); | return notifySuccessResult(reqMap.get("transaction_id"), reqMap.get("refund_id"), refundOrder); | ||||
| } | } | ||||
| @@ -1,6 +1,7 @@ | |||||
| package com.iformall.service.pay.service.share; | package com.iformall.service.pay.service.share; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.HashMap; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| @@ -12,6 +13,7 @@ import com.iformall.common.ErrorCode; | |||||
| import com.iformall.domain.dto.WxSharingOrderDto; | import com.iformall.domain.dto.WxSharingOrderDto; | ||||
| import com.iformall.domain.po.WxAppinfo; | import com.iformall.domain.po.WxAppinfo; | ||||
| import com.iformall.domain.po.WxPayAccount; | import com.iformall.domain.po.WxPayAccount; | ||||
| import com.iformall.domain.po.WxProfitSharingOrder; | |||||
| import com.iformall.domain.po.WxProfitSharingReceiver; | import com.iformall.domain.po.WxProfitSharingReceiver; | ||||
| import com.iformall.enums.EnumProfitSharingReceiverStatus; | import com.iformall.enums.EnumProfitSharingReceiverStatus; | ||||
| import com.iformall.enums.EnumProfitSharingReceiverType; | import com.iformall.enums.EnumProfitSharingReceiverType; | ||||
| @@ -77,7 +77,17 @@ public class TtPayShareService extends PayShareBaseAdapterService{ | |||||
| @Lazy | @Lazy | ||||
| @Autowired | @Autowired | ||||
| WxProfitSharingReceiverService wxProfitSharingReceiverService; | WxProfitSharingReceiverService wxProfitSharingReceiverService; | ||||
| /** | |||||
| * 做为分账的扩展数据 | |||||
| * @param payOrder | |||||
| * @return | |||||
| */ | |||||
| protected String getCpExtra(WxProfitSharingOrder record) { | |||||
| Map<String,String> map = new HashMap<>(); | |||||
| map.put("tenantId",record.getTenantId()); | |||||
| return JSON.toJSONString(map); | |||||
| } | |||||
| @Override | @Override | ||||
| public Integer getSubsidyType() { | public Integer getSubsidyType() { | ||||
| @@ -109,6 +119,7 @@ public class TtPayShareService extends PayShareBaseAdapterService{ | |||||
| TtPayService ttPayService = maUtil.getTtPayService(appInfo, payAccount); | TtPayService ttPayService = maUtil.getTtPayService(appInfo, payAccount); | ||||
| ProfitSharingRequest request = new ProfitSharingRequest(); | ProfitSharingRequest request = new ProfitSharingRequest(); | ||||
| request.setOutOrderNo(record.getOrderId().toString()); | request.setOutOrderNo(record.getOrderId().toString()); | ||||
| request.setCpExtra(getCpExtra(record)); | |||||
| if(record.getOutSettleNo() == null){ | if(record.getOutSettleNo() == null){ | ||||
| record.setOutSettleNo(record.getId()); | record.setOutSettleNo(record.getId()); | ||||
| }else{ | }else{ | ||||
| @@ -160,6 +171,7 @@ public class TtPayShareService extends PayShareBaseAdapterService{ | |||||
| TtPayService ttPayService = maUtil.getTtPayService(appInfo, payAccount); | TtPayService ttPayService = maUtil.getTtPayService(appInfo, payAccount); | ||||
| ProfitSharingRequest request = new ProfitSharingRequest(); | ProfitSharingRequest request = new ProfitSharingRequest(); | ||||
| request.setOutOrderNo(record.getOrderId().toString()); | request.setOutOrderNo(record.getOrderId().toString()); | ||||
| request.setCpExtra(getCpExtra(record)); | |||||
| if(record.getOutSettleNo() == null){ | if(record.getOutSettleNo() == null){ | ||||
| record.setOutSettleNo(record.getId()); | record.setOutSettleNo(record.getId()); | ||||
| }else{ | }else{ | ||||
| @@ -23,6 +23,7 @@ import com.iformall.douyin.web.api.TtWebService; | |||||
| import com.iformall.douyin.web.api.impl.TtWebServiceImpl; | import com.iformall.douyin.web.api.impl.TtWebServiceImpl; | ||||
| import com.iformall.douyin.web.config.TtWebDefaultConfigImpl; | import com.iformall.douyin.web.config.TtWebDefaultConfigImpl; | ||||
| import com.iformall.douyin.web.enums.TtWebApiBeginEnum; | import com.iformall.douyin.web.enums.TtWebApiBeginEnum; | ||||
| import com.iformall.mapper.WxAppinfoMapper; | |||||
| import com.iformall.service.WxAppinfoService; | import com.iformall.service.WxAppinfoService; | ||||
| import lombok.extern.flogger.Flogger; | import lombok.extern.flogger.Flogger; | ||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
| @@ -40,6 +41,9 @@ public class MaUtil { | |||||
| @Autowired | @Autowired | ||||
| private WxAppinfoService wxAppinfoService; | private WxAppinfoService wxAppinfoService; | ||||
| @Autowired | |||||
| private WxAppinfoMapper wxAppinfoMapper; | |||||
| private static Map<String,TtMaService> serviceMap = new ConcurrentHashMap<String,TtMaService>(); | private static Map<String,TtMaService> serviceMap = new ConcurrentHashMap<String,TtMaService>(); | ||||
| private static Map<String,String> appServiceKeyMap = new ConcurrentHashMap<String,String>(); | private static Map<String,String> appServiceKeyMap = new ConcurrentHashMap<String,String>(); | ||||
| @@ -230,14 +234,14 @@ public class MaUtil { | |||||
| try { | try { | ||||
| String accessToken = ttMaService.getAccessToken(true); | String accessToken = ttMaService.getAccessToken(true); | ||||
| WxAppinfo updateApp = new WxAppinfo(); | WxAppinfo updateApp = new WxAppinfo(); | ||||
| updateApp.setId(wxAppinfo.getId()); | |||||
| updateApp.setAppId(wxAppinfo.getAppId()); | |||||
| updateApp.setAccessToken(accessToken); | updateApp.setAccessToken(accessToken); | ||||
| updateApp.setLastTokenTime(new Date()); | updateApp.setLastTokenTime(new Date()); | ||||
| updateApp.setExpiresIn(7200); | updateApp.setExpiresIn(7200); | ||||
| wxAppinfo.setAccessToken(updateApp.getAccessToken()); | wxAppinfo.setAccessToken(updateApp.getAccessToken()); | ||||
| wxAppinfo.setLastTokenTime(updateApp.getLastTokenTime()); | wxAppinfo.setLastTokenTime(updateApp.getLastTokenTime()); | ||||
| wxAppinfo.setExpiresIn(updateApp.getExpiresIn()); | wxAppinfo.setExpiresIn(updateApp.getExpiresIn()); | ||||
| wxAppinfoService.saveOrUpdate(updateApp); | |||||
| wxAppinfoMapper.updateAccessToken(updateApp); | |||||
| } catch (WxErrorException e) { | } catch (WxErrorException e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| @@ -112,5 +112,15 @@ | |||||
| SELECT * | SELECT * | ||||
| FROM wx_appinfo | FROM wx_appinfo | ||||
| WHERE `app_id` = #{appId} | WHERE `app_id` = #{appId} | ||||
| <if test=" null != tenantId "> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| limit 1 | |||||
| </select> | </select> | ||||
| <update id="updateAccessToken" parameterType="com.iformall.domain.po.WxAppinfo"> | |||||
| update wx_appinfo set | |||||
| `access_token` = #{accessToken}, `last_token_time` = #{lastTokenTime}, `expires_in` = #{expiresIn} | |||||
| where `app_id` = #{appId} | |||||
| </update> | |||||
| </mapper> | </mapper> | ||||