|
@@ -89,6 +89,12 @@ public class WxOrderServiceImpl extends ServiceImpl<WxOrderMapper, WxOrder> impl
|
|
|
@Value("${xcx.appId}")
|
|
|
private String xcxAppid;
|
|
|
|
|
|
+ @Value("${gzh.appId}")
|
|
|
+ private String gzhAppid;
|
|
|
+
|
|
|
+ @Value("${app.appId}")
|
|
|
+ private String appid;
|
|
|
+
|
|
|
@Value("${xcx.mchId}")
|
|
|
private String mchId;
|
|
|
|
|
@@ -97,26 +103,31 @@ public class WxOrderServiceImpl extends ServiceImpl<WxOrderMapper, WxOrder> impl
|
|
|
@Transactional
|
|
|
public boolean wxAddFenZhang(OrderInfo orderInfo) throws Exception {
|
|
|
//查询上级
|
|
|
- Map<String, Object> accountMap = getAccount(orderInfo);
|
|
|
String url = "https://api.mch.weixin.qq.com/pay/profitsharingaddreceiver";
|
|
|
|
|
|
String nonceStr = RandomStringUtils.randomAlphanumeric(32);
|
|
|
//用于签名
|
|
|
Map<String, String> sortMap = new TreeMap<String, String>();
|
|
|
sortMap.put("mch_id", mchId);
|
|
|
- sortMap.put("appid", xcxAppid);
|
|
|
+
|
|
|
+ int foreType = orderInfo.getForeType(); //前端类型 1:app 2:小程序 3:公众号
|
|
|
+ if (foreType == 1) {
|
|
|
+ sortMap.put("appid", appid);
|
|
|
+ } else if (foreType == 2) {
|
|
|
+ sortMap.put("appid", xcxAppid);
|
|
|
+ } else if (foreType == 3) {
|
|
|
+ sortMap.put("appid", gzhAppid);
|
|
|
+ }
|
|
|
sortMap.put("nonce_str", nonceStr);
|
|
|
sortMap.put("sign_type", "HMAC-SHA256");
|
|
|
Map<String, String> receiverMap = new TreeMap<String, String>();
|
|
|
receiverMap.put("type", "PERSONAL_OPENID");
|
|
|
|
|
|
- if (accountMap != null) {
|
|
|
- String account = (String) accountMap.get("account");
|
|
|
- if (StringUtils.isNotEmpty(account)) { //如果存在上级,分给上给
|
|
|
- receiverMap.put("account", account);
|
|
|
- } else { //如果不存在上级,分给固定的
|
|
|
- receiverMap.put("account", "o7N3j5XxUrgOKE4ulP-HseFpBCiM");
|
|
|
- }
|
|
|
+ String account = getAccount(orderInfo);
|
|
|
+ if (StringUtils.isNotEmpty(account)) { //如果存在上级,分给上给
|
|
|
+ receiverMap.put("account", account);
|
|
|
+ } else { //如果不存在上级,分给固定的
|
|
|
+ receiverMap.put("account", "o7N3j5XxUrgOKE4ulP-HseFpBCiM");
|
|
|
}
|
|
|
|
|
|
receiverMap.put("relation_type", "SERVICE_PROVIDER"); //合作合伙
|
|
@@ -156,7 +167,14 @@ public class WxOrderServiceImpl extends ServiceImpl<WxOrderMapper, WxOrder> impl
|
|
|
//用于签名
|
|
|
Map<String, String> sortMap = new TreeMap<String, String>();
|
|
|
sortMap.put("mch_id", mchId);
|
|
|
- sortMap.put("appid", xcxAppid);
|
|
|
+ int foreType = orderInfo.getForeType(); //前端类型 1:app 2:小程序 3:公众号
|
|
|
+ if (foreType == 1) {
|
|
|
+ sortMap.put("appid", appid);
|
|
|
+ } else if (foreType == 2) {
|
|
|
+ sortMap.put("appid", xcxAppid);
|
|
|
+ } else if (foreType == 3) {
|
|
|
+ sortMap.put("appid", gzhAppid);
|
|
|
+ }
|
|
|
sortMap.put("nonce_str", nonceStr);
|
|
|
sortMap.put("sign_type", "HMAC-SHA256");
|
|
|
sortMap.put("transaction_id", orderInfo.getTransactionId());
|
|
@@ -171,13 +189,7 @@ public class WxOrderServiceImpl extends ServiceImpl<WxOrderMapper, WxOrder> impl
|
|
|
receiverMap.put("type", "PERSONAL_OPENID");
|
|
|
|
|
|
//获取上级
|
|
|
- Map<String, Object> accountMap = getAccount(orderInfo);
|
|
|
- String account = null;
|
|
|
- Integer openIdType = null;
|
|
|
- if (accountMap != null) {
|
|
|
- account = (String) accountMap.get("account");
|
|
|
- openIdType = (Integer) accountMap.get("openIdType");
|
|
|
- }
|
|
|
+ String account = getAccount(orderInfo);
|
|
|
if (StringUtils.isNotEmpty(account)) { //如果存在上级,分给上给
|
|
|
receiverMap.put("account", account);
|
|
|
} else { //如果不存在上级,分给固定的
|
|
@@ -214,8 +226,8 @@ public class WxOrderServiceImpl extends ServiceImpl<WxOrderMapper, WxOrder> impl
|
|
|
orderSplit.setOutTradeNo(orderInfo.getOutTradeNo());
|
|
|
orderSplit.setAmount(amount);
|
|
|
orderSplit.setOpenId(account);
|
|
|
- if (openIdType!=null) {
|
|
|
- orderSplit.setOpenIdType(openIdType);
|
|
|
+ if(account!=null) {
|
|
|
+ orderSplit.setOpenIdType(orderInfo.getForeType());
|
|
|
} else {
|
|
|
orderSplit.setOpenIdType(2);
|
|
|
}
|
|
@@ -346,8 +358,8 @@ public class WxOrderServiceImpl extends ServiceImpl<WxOrderMapper, WxOrder> impl
|
|
|
* @param orderInfo
|
|
|
* @return
|
|
|
*/
|
|
|
- private Map<String, Object> getAccount(OrderInfo orderInfo) {
|
|
|
- Map<String, Object> resultMap = new HashMap<String, Object>();
|
|
|
+ private String getAccount(OrderInfo orderInfo) {
|
|
|
+ int foreType = orderInfo.getForeType(); //前端类型 1:app 2:小程序 3:公众号
|
|
|
|
|
|
String account = null;
|
|
|
UserInfo userInfo = sysUserService.getStudentByUnionId(orderInfo.getUnionId());
|
|
@@ -356,23 +368,21 @@ public class WxOrderServiceImpl extends ServiceImpl<WxOrderMapper, WxOrder> impl
|
|
|
pUserInfo = sysUserService.getStudentByUnionId(userInfo.getPUnionId());
|
|
|
}
|
|
|
if (pUserInfo != null) {
|
|
|
- if (StringUtils.isNotEmpty(pUserInfo.getXcxOpenid())) {
|
|
|
+
|
|
|
+ if (foreType == 2 && StringUtils.isNotEmpty(pUserInfo.getXcxOpenid())) {
|
|
|
account = pUserInfo.getXcxOpenid();
|
|
|
- resultMap.put("account", account);
|
|
|
- resultMap.put("openIdType", 2);
|
|
|
- } else if (StringUtils.isNotEmpty(pUserInfo.getGzhOpenid())) {
|
|
|
+ return account;
|
|
|
+ } else if (foreType == 3 && StringUtils.isNotEmpty(pUserInfo.getGzhOpenid())) {
|
|
|
account = pUserInfo.getGzhOpenid();
|
|
|
- resultMap.put("account", account);
|
|
|
- resultMap.put("openIdType", 3);
|
|
|
- } else if (StringUtils.isNotEmpty(pUserInfo.getAppOpenid())) {
|
|
|
+ return account;
|
|
|
+ } else if (foreType == 1 && StringUtils.isNotEmpty(pUserInfo.getAppOpenid())) {
|
|
|
account = pUserInfo.getAppOpenid();
|
|
|
- resultMap.put("account", account);
|
|
|
- resultMap.put("openIdType", 1);
|
|
|
+ return account;
|
|
|
} else {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
- return resultMap;
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
|