|
|
@@ -6,12 +6,13 @@ import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
-import cn.hutool.json.JSONObject;
|
|
|
import com.alipay.api.AlipayApiException;
|
|
|
import com.alipay.api.AlipayClient;
|
|
|
import com.alipay.api.AlipayRequest;
|
|
|
-import com.alipay.api.AlipayResponse;
|
|
|
-import com.alipay.api.domain.*;
|
|
|
+import com.alipay.api.domain.AlipayFundTransCommonQueryModel;
|
|
|
+import com.alipay.api.domain.AlipayTradePagePayModel;
|
|
|
+import com.alipay.api.domain.AlipayTradeRefundModel;
|
|
|
+import com.alipay.api.domain.AlipayTradeWapPayModel;
|
|
|
import com.alipay.api.internal.util.AlipaySignature;
|
|
|
import com.alipay.api.request.*;
|
|
|
import com.alipay.api.response.AlipayFundTransCommonQueryResponse;
|
|
|
@@ -48,14 +49,12 @@ import com.cyksj.mapper.manage.distribute.*;
|
|
|
import com.cyksj.mapper.market.task.TaskTypeMapper;
|
|
|
import com.cyksj.mapper.market.task.UserBindDetailMapper;
|
|
|
import com.cyksj.model.dto.*;
|
|
|
-import com.cyksj.model.entity.Address;
|
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.manage.views.GroupsRelationView;
|
|
|
import com.cyksj.model.manage.views.OrderDonView;
|
|
|
import com.cyksj.model.request.OrderAttach;
|
|
|
import com.cyksj.model.request.OrderPayRequest;
|
|
|
import com.cyksj.model.request.TelegramBotMsgReq;
|
|
|
-import com.cyksj.model.request.TransferAccountsReq;
|
|
|
import com.cyksj.model.views.CouponNewUserView;
|
|
|
import com.cyksj.model.views.CouponUserView;
|
|
|
import com.cyksj.model.views.GoodsDonSkuView;
|
|
|
@@ -1087,35 +1086,6 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
saveTransportByAddress(address, orderId);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public AlipayResponse transferAccounts(TransferAccountsReq transferAccountsReq) throws Exception {
|
|
|
- Long userId = transferAccountsReq.getUserId();
|
|
|
- String account = transferAccountsReq.getAccount();
|
|
|
- String name = transferAccountsReq.getName();
|
|
|
- BigDecimal money = transferAccountsReq.getMoney();
|
|
|
- String type = transferAccountsReq.getType();
|
|
|
- BigDecimal points = transferAccountsReq.getPoints();
|
|
|
- /* 生成商户转账订单号 */
|
|
|
- String donNo = SEQUENCE.nextId().toString();
|
|
|
- if (StrUtil.isEmpty(type)) {
|
|
|
- type = TransferConstant.ALIPAY;
|
|
|
- }
|
|
|
- Integer scope = transferAccountsReq.getScope();
|
|
|
- AlipayClient alipayClient = AliPayClientFactory.getAlipayClient(ShopConfig.DISTRIBUTE_ZFB_DEFAULT_APP_ID);
|
|
|
-
|
|
|
- AlipayRequest alipayRequest = aliPayTransferAccountsRequest(donNo, account, name, money);
|
|
|
-
|
|
|
- AlipayResponse response = alipayClient.certificateExecute(alipayRequest);
|
|
|
- if (response.isSuccess()) {
|
|
|
- log.info("支付宝转账金额:{}至用户:{}成功", money.divide(BigDecimal.valueOf(100)), userId);
|
|
|
- saveTransferRecord(userId, donNo, account, name, money, points, type, scope, response.getBody(), null);
|
|
|
- return response;
|
|
|
- }
|
|
|
- log.info("支付宝转账金额:{}至用户:{}失败", money.divide(BigDecimal.valueOf(100)), userId);
|
|
|
- saveTransferRecord(userId, donNo, account, name, money, points, type, scope, response.getBody(), response.getSubMsg());
|
|
|
- return response;
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public AlipayFundTransCommonQueryResponse getTransFerStatusByTid(String translationId) throws Exception {
|
|
|
AlipayClient alipayClient = AliPayClientFactory.getAlipayClient(ShopConfig.ZFB_DEFAULT_APP_ID);
|
|
|
@@ -1129,31 +1099,6 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
- private AlipayRequest aliPayTransferAccountsRequest(String donNo, String account, String name, BigDecimal money) {
|
|
|
- //支付宝转账
|
|
|
- AlipayFundTransUniTransferRequest transUniTransferRequest = new AlipayFundTransUniTransferRequest();
|
|
|
- //转账参数
|
|
|
- AlipayFundTransUniTransferModel model = new AlipayFundTransUniTransferModel();
|
|
|
- model.setOutBizNo(donNo);
|
|
|
- //单位元
|
|
|
- model.setTransAmount(money.divide(BigDecimal.valueOf(100)).toString());
|
|
|
- model.setProductCode(ZfbProductCode.STD_RED_PACKET.getProductCode());
|
|
|
- model.setBizScene(TransferConstant.DIRECT_TRANSFER);
|
|
|
- model.setOrderTitle("分销提现");
|
|
|
- //红包业务必传,取值REDPACKET
|
|
|
- JSONObject businessParams = new JSONObject();
|
|
|
- businessParams.putOpt(TransferConstant.SUB_BIZ_SCENE, TransferConstant.RED_PACKET);
|
|
|
- model.setBusinessParams(businessParams.toString());
|
|
|
- Participant payeeInfo = new Participant();
|
|
|
- payeeInfo.setIdentity(account);
|
|
|
- payeeInfo.setIdentityType(TransferConstant.ALIPAY_LOGON_ID);
|
|
|
- payeeInfo.setName(name);
|
|
|
- model.setPayeeInfo(payeeInfo);
|
|
|
- model.setRemark("分销提现转账");
|
|
|
- transUniTransferRequest.setBizModel(model);
|
|
|
- return transUniTransferRequest;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 查询支付宝订单详情
|
|
|
*/
|
|
|
@@ -1771,32 +1716,6 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 保存转账记录
|
|
|
- */
|
|
|
- public void saveTransferRecord(Long userId, String donNo, String account, String name, BigDecimal money, BigDecimal points, String type, Integer scope, String body, String error) throws Exception {
|
|
|
- TransferAccountsRecord record = new TransferAccountsRecord();
|
|
|
- JSONObject re = Jsons.parseObject(body, JSONObject.class);
|
|
|
- JSONObject response = Jsons.parseObject(re.get("alipay_fund_trans_uni_transfer_response"), JSONObject.class);
|
|
|
- String transactionId = response.getStr("order_id");
|
|
|
- String transDate = response.getStr("trans_date");
|
|
|
- record.setUserId(userId);
|
|
|
- record.setAccount(account);
|
|
|
- record.setName(name);
|
|
|
- record.setMoney(money);
|
|
|
- record.setType(type);
|
|
|
- record.setScope(scope);
|
|
|
- Optional.ofNullable(error).ifPresent(msg -> {
|
|
|
- record.setErrorMsg(msg);
|
|
|
- record.setStatus(0);
|
|
|
- });
|
|
|
- record.setPoints(points);
|
|
|
- record.setTransferOutNo(donNo);
|
|
|
- record.setTransactionId(transactionId);
|
|
|
- Optional.ofNullable(transDate).ifPresent(transferTime -> record.setTransferTime(DateTime.of(transferTime, "yyyy-MM-dd HH:mm:ss")));
|
|
|
- transferAccountsRecordMapper.insert(record);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* @param orderDon 续费订单
|
|
|
* @param afterSku 续费之后的规格
|