|
@@ -12,11 +12,13 @@ import com.zhongshu.payment.client.service.v2.OrderService2;
|
|
|
import com.zhongshu.payment.client.type.JobFlowMap;
|
|
|
import com.zhongshu.payment.client.type.TransferOwner;
|
|
|
import com.zhongshu.payment.client.type.TransferType;
|
|
|
+import com.zswl.cloud.shop.client.service.ShopService;
|
|
|
+import com.zswl.cloud.shop.client.vo.life.AccountDetailVo;
|
|
|
+import com.zswl.cloud.shop.client.vo.life.SharePlatformVo;
|
|
|
import com.zswl.cloud.springBatch.client.model.dfy.Hotel.request.*;
|
|
|
import com.zswl.cloud.springBatch.client.model.dfy.Hotel.response.*;
|
|
|
import com.zswl.cloud.springBatch.client.service.DfyHotelService;
|
|
|
import com.zswl.cloud.springBtach.server.core.api.dfy.DomesticHotelApi;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -39,6 +41,9 @@ public class DfyHotelServiceImpl implements DfyHotelService {
|
|
|
@Autowired
|
|
|
private AuthHelper authHelper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ShopService shopService;
|
|
|
+
|
|
|
|
|
|
public ResultContent<QueryNewResponse> queryNew(QueryNewRequest queryNewRequest) {
|
|
|
return ResultContent.buildContent(domesticHotelApi.queryNew(queryNewRequest));
|
|
@@ -61,6 +66,14 @@ public class DfyHotelServiceImpl implements DfyHotelService {
|
|
|
}
|
|
|
|
|
|
public ResultContent<CreatOrderResultModel> addOrder(AddOrderRequest addOrderRequest) {
|
|
|
+
|
|
|
+ com.zswl.cloud.shop.client.ret.ResultContent<AccountDetailVo> shopSetting = shopService.shopSetting("酒店");
|
|
|
+ if (!shopSetting.getState().equals(com.zswl.cloud.shop.client.ret.ResultState.Success)) {
|
|
|
+ return ResultContent.build(ResultState.Fail, "酒店商户信息未配置");
|
|
|
+ }
|
|
|
+ AccountDetailVo accountDetailVo = shopSetting.getContent();
|
|
|
+
|
|
|
+
|
|
|
String orderNo = snowflake.nextIdStr();
|
|
|
addOrderRequest.setSourceOrderId(orderNo);
|
|
|
HotelDetailRequest hotelDetailRequest = new HotelDetailRequest();
|
|
@@ -77,17 +90,23 @@ public class DfyHotelServiceImpl implements DfyHotelService {
|
|
|
ratePlanRequest.setChildAges(addOrderRequest.getChildAges());
|
|
|
|
|
|
RatePlanResponse ratePlanResponse = domesticHotelApi.ratePlan(ratePlanRequest);
|
|
|
+ if (!ratePlanResponse.getSuccess()) {
|
|
|
+ return ResultContent.build(ResultState.Fail, ratePlanResponse.getMsg());
|
|
|
+ }
|
|
|
BigDecimal totalPrice = ratePlanResponse.getData().getTotalPrice();
|
|
|
addOrderRequest.setTotalPrice(totalPrice.intValue());
|
|
|
|
|
|
|
|
|
AddOrderResponse addOrderResponse = domesticHotelApi.addOrder(addOrderRequest);
|
|
|
if (!addOrderResponse.getSuccess()) {
|
|
|
- return ResultContent.build(ResultState.Fail, addOrderResponse.getData());
|
|
|
+ return ResultContent.build(ResultState.Fail, addOrderResponse.getMsg());
|
|
|
}
|
|
|
// 平台订单
|
|
|
|
|
|
- String shopId="6645c05f32e63427d1a45b34";
|
|
|
+
|
|
|
+ String shopId = accountDetailVo.getAccountId();
|
|
|
+ String authAccount = accountDetailVo.getAuthAccount();
|
|
|
+ SharePlatformVo sharePlatformVo = accountDetailVo.getSharePlatformVo();
|
|
|
|
|
|
// 平台订单
|
|
|
CreateOrder2Model createOrder2Model = new CreateOrder2Model();
|
|
@@ -95,12 +114,12 @@ public class DfyHotelServiceImpl implements DfyHotelService {
|
|
|
createOrder2Model.setUserId(authHelper.getCurrentUser().getUserId());
|
|
|
createOrder2Model.setShopId(shopId);
|
|
|
JSONObject shopInfo = JSONUtil.parseObj(hotelDetailResponse);
|
|
|
- shopInfo.set("hotelIdPic",addOrderRequest.getHotelIdPic());
|
|
|
+ shopInfo.set("hotelIdPic", addOrderRequest.getHotelIdPic());
|
|
|
createOrder2Model.setShopInfo(shopInfo);
|
|
|
createOrder2Model.setTotalAmount(totalPrice);
|
|
|
createOrder2Model.setDiscountAmount(BigDecimal.ZERO);
|
|
|
createOrder2Model.setPayAmount(totalPrice);
|
|
|
- createOrder2Model.setAccesserUserId("648b55efff875512b518c28c");
|
|
|
+ createOrder2Model.setAccesserUserId(authAccount);
|
|
|
createOrder2Model.setChannel(addOrderRequest.getChannel());
|
|
|
JSONObject goodsInfo = JSONUtil.parseObj(addOrderRequest);
|
|
|
goodsInfo.set("HotlOrderId", addOrderResponse.getData().getOrderId());
|
|
@@ -113,21 +132,26 @@ public class DfyHotelServiceImpl implements DfyHotelService {
|
|
|
goods.setGoodsInfo(goodsInfo);
|
|
|
goods.setPayAmount(totalPrice);
|
|
|
goods.setValidDay(90);
|
|
|
- goods.setTransferType(TransferType.RATIO);
|
|
|
+ goods.setTransferType(sharePlatformVo.getShareType().equals(1) ? TransferType.RATIO : TransferType.FIXED);
|
|
|
|
|
|
List<CreateOrder2Model.Owner> ownerList = new ArrayList<>();
|
|
|
|
|
|
CreateOrder2Model.Owner platfor = new CreateOrder2Model.Owner();
|
|
|
platfor.setOwner(TransferOwner.PLATFORM);
|
|
|
- platfor.setValue(BigDecimal.ZERO);
|
|
|
+ platfor.setValue(sharePlatformVo.getPlatformRate());
|
|
|
|
|
|
CreateOrder2Model.Owner buy = new CreateOrder2Model.Owner();
|
|
|
buy.setOwner(TransferOwner.BUY_SHOP);
|
|
|
- buy.setValue(BigDecimal.valueOf(100));
|
|
|
+ buy.setValue(sharePlatformVo.getBuyShopRate());
|
|
|
buy.setShopId(shopId);
|
|
|
|
|
|
+ CreateOrder2Model.Owner use = new CreateOrder2Model.Owner();
|
|
|
+ use.setOwner(TransferOwner.USE_SHOP);
|
|
|
+ use.setValue(sharePlatformVo.getCheckShopRate());
|
|
|
+
|
|
|
ownerList.add(platfor);
|
|
|
ownerList.add(buy);
|
|
|
+ ownerList.add(use);
|
|
|
goods.setTransferRrule(ownerList);
|
|
|
goods.setExtend(JSONUtil.toJsonStr(addOrderResponse.getData()));
|
|
|
createOrder2Model.setGoodsList(List.of(goods));
|