|
@@ -7,13 +7,18 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
+import zs.payment.dto.AfterSalesDTO;
|
|
|
|
|
+import zs.payment.dto.OrderItemDTO;
|
|
|
import zs.payment.entity.mongodb.supply.Orders;
|
|
import zs.payment.entity.mongodb.supply.Orders;
|
|
|
|
|
+import zs.payment.exception.ApiException;
|
|
|
import zs.payment.messages.KafkaProducer;
|
|
import zs.payment.messages.KafkaProducer;
|
|
|
import zs.payment.req.*;
|
|
import zs.payment.req.*;
|
|
|
import zs.payment.req.aftersales.AfterSalesOrderReq;
|
|
import zs.payment.req.aftersales.AfterSalesOrderReq;
|
|
|
import zs.payment.req.aftersales.AfterSalesOrderTypeReq;
|
|
import zs.payment.req.aftersales.AfterSalesOrderTypeReq;
|
|
|
import zs.payment.resp.Result;
|
|
import zs.payment.resp.Result;
|
|
|
|
|
|
|
|
|
|
+import zs.payment.service.order.OrdersService;
|
|
|
|
|
+import zs.payment.service.supply.order.OrderSupplyService;
|
|
|
import zs.payment.service.supply.paysupply.PaySupplyService;
|
|
import zs.payment.service.supply.paysupply.PaySupplyService;
|
|
|
import zs.payment.service.supply.token.SupplyTokenService;
|
|
import zs.payment.service.supply.token.SupplyTokenService;
|
|
|
import zs.payment.utils.HttpUtil;
|
|
import zs.payment.utils.HttpUtil;
|
|
@@ -21,6 +26,7 @@ import zs.payment.utils.HttpUtil;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -33,6 +39,13 @@ public class PaySupplyServiceImpl implements PaySupplyService {
|
|
|
private SupplyTokenService supplyTokenService;
|
|
private SupplyTokenService supplyTokenService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 芸信供应的中台订单
|
|
|
|
|
+ */
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private OrdersService ordersService;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public Result orderPayOnly(OrderPayReq req) {
|
|
public Result orderPayOnly(OrderPayReq req) {
|
|
|
Map<String, String> headers = supplyTokenService.buildAuthHeaders();
|
|
Map<String, String> headers = supplyTokenService.buildAuthHeaders();
|
|
@@ -86,38 +99,48 @@ public class PaySupplyServiceImpl implements PaySupplyService {
|
|
|
return Result.fail("获取token失败");
|
|
return Result.fail("获取token失败");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
|
|
- params.put("third_order_sn", req.getThirdOrderSn());
|
|
|
|
|
- params.put("is_received",req.getIsReceived());
|
|
|
|
|
- params.put("order_item_id",req.getOrderItemId());
|
|
|
|
|
- if (!ObjectUtils.isEmpty(req.getAmount())){
|
|
|
|
|
- //退款总额不为空
|
|
|
|
|
- params.put("amount",req.getAmount());
|
|
|
|
|
- }
|
|
|
|
|
- if (!ObjectUtils.isEmpty(req.getRefundType())){
|
|
|
|
|
- // 退款方式: "0": "退款", "1": "退货退款"
|
|
|
|
|
- params.put("refund_type",req.getRefundType());
|
|
|
|
|
- }
|
|
|
|
|
- if (!ObjectUtils.isEmpty(req.getTechnicalServicesFee())){
|
|
|
|
|
- //技术服务费
|
|
|
|
|
- params.put("technical_services_fee",req.getTechnicalServicesFee());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (!ObjectUtils.isEmpty(req.getFreight())){
|
|
|
|
|
- //运费
|
|
|
|
|
- params.put("freight",req.getFreight());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- String resp = HttpUtil.restTemplatePost(prefixUrl + "/supplyapi/app/afterSales/create", params, headers);
|
|
|
|
|
- JSONObject respJson = JSONObject.parseObject(resp);
|
|
|
|
|
- if (respJson.getIntValue("code") != 0) {
|
|
|
|
|
- return Result.fail(respJson.getString("msg"));
|
|
|
|
|
|
|
+ Orders orders = ordersService.getOrderBySn(req.getOrderSn());
|
|
|
|
|
+ if (Optional.ofNullable(orders).isPresent()) {
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < orders.getOrderItems().size(); i++) {
|
|
|
|
|
+ OrderItemDTO item = orders.getOrderItems().get(i);
|
|
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
|
|
+ params.put("third_order_sn", req.getOrderSn());
|
|
|
|
|
+ params.put("is_received",req.getIsReceived());
|
|
|
|
|
+ params.put("order_item_id",item.getId());
|
|
|
|
|
+ //退款总额不为空
|
|
|
|
|
+ params.put("amount",item.getAmount());
|
|
|
|
|
+ //技术服务费
|
|
|
|
|
+ params.put("technical_services_fee",orders.getTechnicalServicesFee());
|
|
|
|
|
+ //运费
|
|
|
|
|
+ params.put("freight",orders.getFreight());
|
|
|
|
|
+ if (!ObjectUtils.isEmpty(req.getRefundType())){
|
|
|
|
|
+ // 退款方式: "0": "退款", "1": "退货退款"
|
|
|
|
|
+ params.put("refund_type",req.getRefundType());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String resp = HttpUtil.restTemplatePost(prefixUrl + "/supplyapi/app/afterSales/create", params, headers);
|
|
|
|
|
+ JSONObject respJson = JSONObject.parseObject(resp);
|
|
|
|
|
+ if (respJson.getIntValue("code") != 0) {
|
|
|
|
|
+ log.error("--第三方订单编号{}申请售后失败,错误原因---",req.getOrderSn(),respJson.getString("msg"));
|
|
|
|
|
+ throw new ApiException(req.getOrderSn()+"申请售后失败");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //todo 将申请售后id存储到Orders表中,方便后续通过第三方订单编号取消申请售后
|
|
|
|
|
+ log.info("----申请售后成功,返回了{}------",respJson.get("data"));
|
|
|
|
|
+ AfterSalesDTO afterSalesDTO=new AfterSalesDTO();
|
|
|
|
|
+ afterSalesDTO.setId(respJson.getInteger("data"));
|
|
|
|
|
+ item.setAfter_sales(afterSalesDTO);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ //保存order
|
|
|
|
|
+ ordersService.saveOrders(orders);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ return Result.fail("订单不存在");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //todo 需要把data进行存储,方便之后的取消售后操作
|
|
|
|
|
|
|
+ return Result.success();
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- return Result.success(respJson.getJSONObject("data"));
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|