|
@@ -4,8 +4,11 @@ import cn.hutool.json.JSONUtil;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.bosshand.virgo.api.workark.config.WxPayConfig;
|
|
import com.bosshand.virgo.api.workark.config.WxPayConfig;
|
|
-import com.bosshand.virgo.api.workark.dao.ProceDao;
|
|
|
|
|
|
+import com.bosshand.virgo.api.workark.dao.AccountBalanceDao;
|
|
import com.bosshand.virgo.api.workark.dao.TransferInfoDao;
|
|
import com.bosshand.virgo.api.workark.dao.TransferInfoDao;
|
|
|
|
+import com.bosshand.virgo.api.workark.enums.wxpay.WxNotifyType;
|
|
|
|
+import com.bosshand.virgo.api.workark.enums.wxpay.WxTransferState;
|
|
|
|
+import com.bosshand.virgo.api.workark.model.AccountBalance;
|
|
import com.bosshand.virgo.api.workark.model.TransferInfo;
|
|
import com.bosshand.virgo.api.workark.model.TransferInfo;
|
|
import com.bosshand.virgo.api.workark.util.OrderNoUtils;
|
|
import com.bosshand.virgo.api.workark.util.OrderNoUtils;
|
|
import com.bosshand.virgo.core.utils.ContextUtils;
|
|
import com.bosshand.virgo.core.utils.ContextUtils;
|
|
@@ -15,6 +18,7 @@ import com.wechat.pay.java.core.http.*;
|
|
import okhttp3.OkHttpClient;
|
|
import okhttp3.OkHttpClient;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
@@ -27,7 +31,7 @@ public class WxTransferService {
|
|
private WxPayConfig wxPayConfig;
|
|
private WxPayConfig wxPayConfig;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- ProceDao proceDao;
|
|
|
|
|
|
+ AccountBalanceDao accountBalanceDao;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
TransferInfoDao transferInfoDao;
|
|
TransferInfoDao transferInfoDao;
|
|
@@ -75,7 +79,7 @@ public class WxTransferService {
|
|
// 转账备注
|
|
// 转账备注
|
|
map.put("transfer_remark", "佣金提现: " + orderNo);
|
|
map.put("transfer_remark", "佣金提现: " + orderNo);
|
|
//回调地址: 商家转账回调地址
|
|
//回调地址: 商家转账回调地址
|
|
- map.put("notify_url", "");
|
|
|
|
|
|
+ map.put("notify_url", wxPayConfig.getNotifyDomain().concat(WxNotifyType.TRANSFER_NOTIFY.getType()));
|
|
// 用户收款感知
|
|
// 用户收款感知
|
|
map.put("user_recv_perception", "佣金奖励");
|
|
map.put("user_recv_perception", "佣金奖励");
|
|
// 转账场景报备信息
|
|
// 转账场景报备信息
|
|
@@ -102,6 +106,7 @@ public class WxTransferService {
|
|
|
|
|
|
transferInfo.setTransferBillNo(transferBillNo);
|
|
transferInfo.setTransferBillNo(transferBillNo);
|
|
transferInfo.setPackageInfo(packageInfo);
|
|
transferInfo.setPackageInfo(packageInfo);
|
|
|
|
+ transferInfo.setState(WxTransferState.ACCEPTED.getType());
|
|
transferInfoDao.save(transferInfo);
|
|
transferInfoDao.save(transferInfo);
|
|
|
|
|
|
return packageInfo;
|
|
return packageInfo;
|
|
@@ -122,6 +127,7 @@ public class WxTransferService {
|
|
.build();
|
|
.build();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Transactional
|
|
public String transferOutBillNo(String outBillNo) {
|
|
public String transferOutBillNo(String outBillNo) {
|
|
OkHttpClient okHttpClient = new OkHttpClient();
|
|
OkHttpClient okHttpClient = new OkHttpClient();
|
|
HttpClient httpClient = new DefaultHttpClientBuilder()
|
|
HttpClient httpClient = new DefaultHttpClientBuilder()
|
|
@@ -141,13 +147,12 @@ public class WxTransferService {
|
|
try {
|
|
try {
|
|
HttpResponse<JSONObject> execute = httpClient.execute(executeSendGetHttpRequest, JSONObject.class);
|
|
HttpResponse<JSONObject> execute = httpClient.execute(executeSendGetHttpRequest, JSONObject.class);
|
|
JSONObject responseBody = execute.getServiceResponse();
|
|
JSONObject responseBody = execute.getServiceResponse();
|
|
-
|
|
|
|
String state = responseBody.getString("state");
|
|
String state = responseBody.getString("state");
|
|
-
|
|
|
|
- if("SUCCESS".equals(state)){
|
|
|
|
- TransferInfo outBillNo1 = transferInfoDao.getOutBillNo(outBillNo);
|
|
|
|
- outBillNo1.setState(state);
|
|
|
|
- transferInfoDao.update(outBillNo1);
|
|
|
|
|
|
+ TransferInfo outBillNo1 = transferInfoDao.getOutBillNo(outBillNo);
|
|
|
|
+ outBillNo1.setState(state);
|
|
|
|
+ transferInfoDao.update(outBillNo1);
|
|
|
|
+ if(WxTransferState.SUCCESS.equals(state)){
|
|
|
|
+ updateAccountBalance(outBillNo1);
|
|
}
|
|
}
|
|
return state;
|
|
return state;
|
|
} catch (ServiceException e) {
|
|
} catch (ServiceException e) {
|
|
@@ -162,4 +167,13 @@ public class WxTransferService {
|
|
transferInfoDao.update(transferInfo);
|
|
transferInfoDao.update(transferInfo);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void updateAccountBalance(TransferInfo outBillNo){
|
|
|
|
+ AccountBalance accountBalance = accountBalanceDao.getUserId(outBillNo.getUserId());
|
|
|
|
+ BigDecimal totalFee = accountBalance.getTotalFee();
|
|
|
|
+ BigDecimal result = totalFee.subtract(outBillNo.getMoney());
|
|
|
|
+ accountBalance.setTotalFee(result);
|
|
|
|
+ accountBalanceDao.updateTotalFee(accountBalance);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|