|
@@ -0,0 +1,155 @@
|
|
|
+package com.zswl.cloud.springBtach.server.core.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
+import com.github.microservice.auth.client.content.ResultContent;
|
|
|
+import com.github.microservice.auth.client.content.ResultState;
|
|
|
+import com.github.microservice.auth.security.helper.AuthHelper;
|
|
|
+import com.zhongshu.payment.client.model.order.v2.CreatOrderResultModel;
|
|
|
+import com.zhongshu.payment.client.model.order.v2.CreateOrder2Model;
|
|
|
+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.ypp.kfc.request.CreateOrdereRquest;
|
|
|
+import com.zswl.cloud.springBatch.client.model.ypp.kfc.response.CityListResponse;
|
|
|
+import com.zswl.cloud.springBatch.client.model.ypp.kfc.response.CreateOrdereResponse;
|
|
|
+import com.zswl.cloud.springBatch.client.model.ypp.kfc.response.ShopResponse;
|
|
|
+import com.zswl.cloud.springBatch.client.model.ypp.kfc.response.ShopsResponse;
|
|
|
+import com.zswl.cloud.springBatch.client.model.ypp.movie.response.CreateOrder2Response;
|
|
|
+import com.zswl.cloud.springBatch.client.model.ypp.movie.response.OrderDetailResponse;
|
|
|
+import com.zswl.cloud.springBtach.server.core.api.ypp.KfcApi;
|
|
|
+import com.zswl.cloud.springBtach.server.core.api.ypp.request.KfcGoodsDetailRequest;
|
|
|
+import com.zswl.cloud.springBtach.server.core.api.ypp.request.KfcShopDetailRequest;
|
|
|
+import com.zswl.cloud.springBtach.server.core.api.ypp.request.KfcShopsRequest;
|
|
|
+import lombok.extern.log4j.Log4j2;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Service
|
|
|
+@Log4j2
|
|
|
+public class KfcServiceImpl {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ OrderService2 orderService2;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ShopService shopService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ AuthHelper authHelper;
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private KfcApi kfcApi;
|
|
|
+
|
|
|
+
|
|
|
+ public ResultContent<CityListResponse> cityList() {
|
|
|
+
|
|
|
+ CityListResponse cityListResponse = kfcApi.cityList();
|
|
|
+ return ResultContent.buildContent(cityListResponse);
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultContent<ShopsResponse> shops(KfcShopsRequest kfcShopsRequest) {
|
|
|
+
|
|
|
+ ShopsResponse shops = kfcApi.shops(kfcShopsRequest);
|
|
|
+ return ResultContent.buildContent(shops);
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultContent<ShopResponse> shop(KfcShopDetailRequest kfcShopDetailRequest) {
|
|
|
+
|
|
|
+ ShopResponse shop = kfcApi.shop(kfcShopDetailRequest);
|
|
|
+ return ResultContent.buildContent(shop);
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultContent<JSONObject> menus(String shopId) {
|
|
|
+
|
|
|
+ JSONObject menus = kfcApi.menus(shopId);
|
|
|
+ return ResultContent.buildContent(menus);
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultContent<JSONObject> goodsDetail(KfcGoodsDetailRequest kfcGoodsDetailRequest) {
|
|
|
+
|
|
|
+ JSONObject menus = kfcApi.goods_detail(kfcGoodsDetailRequest);
|
|
|
+ return ResultContent.buildContent(menus);
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultContent<CreatOrderResultModel> createOrder(CreateOrdereRquest kfcGoodsDetailRequest) {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ 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 shopId = accountDetailVo.getAccountId();
|
|
|
+ String authAccount = accountDetailVo.getAuthAccount();
|
|
|
+ SharePlatformVo sharePlatformVo = accountDetailVo.getSharePlatformVo();
|
|
|
+
|
|
|
+ kfcGoodsDetailRequest.setPhone(authHelper.getCurrentUser().getPhone());
|
|
|
+ CreateOrdereResponse createOrdereResponse = kfcApi.create_order(kfcGoodsDetailRequest);
|
|
|
+ BigDecimal bigDecimal = BigDecimal.valueOf(createOrdereResponse.getData().getPayAmount());
|
|
|
+
|
|
|
+
|
|
|
+ CreateOrder2Model createOrder2Model = new CreateOrder2Model();
|
|
|
+ createOrder2Model.setUserId(authHelper.getCurrentUser().getUserId());
|
|
|
+ createOrder2Model.setShopId(shopId);
|
|
|
+ JSONObject shopInfo = new JSONObject();
|
|
|
+ shopInfo.set("shopName", kfcGoodsDetailRequest.getShopName());
|
|
|
+ createOrder2Model.setShopInfo(shopInfo);
|
|
|
+ createOrder2Model.setTotalAmount(bigDecimal);
|
|
|
+ createOrder2Model.setDiscountAmount(BigDecimal.ZERO);
|
|
|
+ createOrder2Model.setPayAmount(bigDecimal);
|
|
|
+ createOrder2Model.setAccesserUserId(authAccount);
|
|
|
+ createOrder2Model.setChannel(kfcGoodsDetailRequest.getChannel());
|
|
|
+
|
|
|
+
|
|
|
+ JSONObject goodsInfo = JSONUtil.parseObj(kfcGoodsDetailRequest);
|
|
|
+ goodsInfo.set("goodsName", kfcGoodsDetailRequest.getGoodsName());
|
|
|
+ goodsInfo.set("goodsPath", kfcGoodsDetailRequest.getImageCnUrl());
|
|
|
+ goodsInfo.set("channelOrderId", createOrdereResponse.getData().getOrderId());
|
|
|
+
|
|
|
+
|
|
|
+ CreateOrder2Model.Goods goods = new CreateOrder2Model.Goods();
|
|
|
+ goods.setGoodsId(kfcGoodsDetailRequest.getProducts().get(0).getProductId());
|
|
|
+ goods.setJobFlowMap(JobFlowMap.YPP);
|
|
|
+ goods.setGoodsInfo(goodsInfo);
|
|
|
+ goods.setPayAmount(bigDecimal);
|
|
|
+ goods.setValidDay(90);
|
|
|
+ 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(sharePlatformVo.getPlatformRate());
|
|
|
+
|
|
|
+ CreateOrder2Model.Owner buy = new CreateOrder2Model.Owner();
|
|
|
+ buy.setOwner(TransferOwner.BUY_SHOP);
|
|
|
+ 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.parseObj(createOrdereResponse));
|
|
|
+ createOrder2Model.setGoodsList(List.of(goods));
|
|
|
+
|
|
|
+ return orderService2.creat(createOrder2Model);
|
|
|
+// return ResultContent.buildContent(order);
|
|
|
+ }
|
|
|
+}
|