| @@ -142,13 +142,11 @@ public class AliPayController extends BaseController { | |||||
| return; | return; | ||||
| }else { | }else { | ||||
| UserAuthData authData = alipayUtil.queryUserAuthData(wxMall.getAlipayAppAuthToken(), authCode); | UserAuthData authData = alipayUtil.queryUserAuthData(wxMall.getAlipayAppAuthToken(), authCode); | ||||
| logger.info(">>>> UserAuthData >>>>"+JSON.toJSONString(authData)); | |||||
| if (null == authData ) { | if (null == authData ) { | ||||
| writeResponse(response,"Auth Failed!queryUserAuthData return null."); | writeResponse(response,"Auth Failed!queryUserAuthData return null."); | ||||
| return; | return; | ||||
| }else { | }else { | ||||
| Map<EnumMemberCardConfig,Object> map = alipayUtil.queryUserFormData(wxMall.getAlipayAppAuthToken(), authData.getAccessToken(), templateId, requestId); | Map<EnumMemberCardConfig,Object> map = alipayUtil.queryUserFormData(wxMall.getAlipayAppAuthToken(), authData.getAccessToken(), templateId, requestId); | ||||
| logger.info(">>>> queryUserFormData >>>>"+JSON.toJSONString(map)); | |||||
| if (null == map) { | if (null == map) { | ||||
| writeResponse(response,"Auth Failed!queryUserFormData return null."); | writeResponse(response,"Auth Failed!queryUserFormData return null."); | ||||
| return; | return; | ||||
| @@ -160,13 +158,14 @@ public class AliPayController extends BaseController { | |||||
| }else { | }else { | ||||
| //查询该userId是否已经开卡,已经开卡不再开卡 | //查询该userId是否已经开卡,已经开卡不再开卡 | ||||
| AliPayCUser query = new AliPayCUser(); | AliPayCUser query = new AliPayCUser(); | ||||
| query.setAlipayUserId(authData.getUserId()); | |||||
| //query.setAlipayUserId(authData.getUserId()); | |||||
| query.setAlipayUserId(authData.getOpenId()); | |||||
| query.updateTenantInfo(wxMall); | query.updateTenantInfo(wxMall); | ||||
| AliPayCUser alicuser = aliPayCUserService.getByAliPayUserId(query); | AliPayCUser alicuser = aliPayCUserService.getByAliPayUserId(query); | ||||
| if (null == alicuser) { | if (null == alicuser) { | ||||
| //添加用户信息 | //添加用户信息 | ||||
| alicuser = new AliPayCUser(); | alicuser = new AliPayCUser(); | ||||
| alicuser.setAlipayUserId(authData.getUserId()); | |||||
| alicuser.setAlipayUserId(authData.getOpenId()); | |||||
| alicuser.setPhone(phone); | alicuser.setPhone(phone); | ||||
| alicuser.updateTenantInfo(wxMall); | alicuser.updateTenantInfo(wxMall); | ||||
| aliPayCUserService.saveOrUpdate(alicuser); | aliPayCUserService.saveOrUpdate(alicuser); | ||||
| @@ -207,7 +207,7 @@ public class AliPayUtil { | |||||
| return null; | return null; | ||||
| } | } | ||||
| //商圈智能积分授权(算法授权)URL | |||||
| //商圈智能积分授权(算法授权)URL https://opendocs.alipay.com/open/01lsmc?scene=SC00001296&sourceCode=SC00001296&projectCode=2191000403&sceneVersion=382 | |||||
| public String getH5SmartDistrictMallVipPointsUrl(String param) { | public String getH5SmartDistrictMallVipPointsUrl(String param) { | ||||
| try { | try { | ||||
| return "https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id="+getConfig().appId+"&scope=mall_vip_points&redirect_uri="+URLEncoder.encode(getCallBack(),"utf-8")+"&state="+param; | return "https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id="+getConfig().appId+"&scope=mall_vip_points&redirect_uri="+URLEncoder.encode(getCallBack(),"utf-8")+"&state="+param; | ||||
| @@ -224,10 +224,12 @@ public class AliPayUtil { | |||||
| //JSONObject result = getGenericResponse(response.getHttpBody(),"alipay_system_oauth_token_response"); | //JSONObject result = getGenericResponse(response.getHttpBody(),"alipay_system_oauth_token_response"); | ||||
| JSONObject responseResult = JSON.parseObject(response.getHttpBody()); | JSONObject responseResult = JSON.parseObject(response.getHttpBody()); | ||||
| if (null != responseResult) { | if (null != responseResult) { | ||||
| log.info("queryUserAuthData:"+JSON.toJSONString(responseResult)); | |||||
| JSONObject result = responseResult.getJSONObject("alipay_system_oauth_token_response"); | JSONObject result = responseResult.getJSONObject("alipay_system_oauth_token_response"); | ||||
| if (null != result) { | if (null != result) { | ||||
| UserAuthData authData = new UserAuthData(); | UserAuthData authData = new UserAuthData(); | ||||
| authData.setUserId(result.getString("user_id")); | |||||
| //authData.setUserId(result.getString("user_id")); | |||||
| authData.setOpenId(result.getString("open_id")); | |||||
| authData.setAccessToken(result.getString("access_token")); | authData.setAccessToken(result.getString("access_token")); | ||||
| return authData; | return authData; | ||||
| }else { | }else { | ||||
| @@ -254,7 +254,7 @@ public class AliPayApi { | |||||
| } | } | ||||
| /** | /** | ||||
| * https://opendocs.alipay.com/apis/api_9/alipay.system.oauth.token | |||||
| * https://opendocs.alipay.com/open/84bc7352_alipay.system.oauth.token?scene=common&pathHash=fe1502d5 | |||||
| * 会员授权,换取授权访问令牌 | * 会员授权,换取授权访问令牌 | ||||
| * @return | * @return | ||||
| * @throws Exception | * @throws Exception | ||||
| @@ -5,6 +5,7 @@ import lombok.Data; | |||||
| @Data | @Data | ||||
| public class UserAuthData { | public class UserAuthData { | ||||
| private String userId; | |||||
| //private String userId; | |||||
| private String openId; | |||||
| private String accessToken; | private String accessToken; | ||||
| } | } | ||||