From 668788bd40fb1e4b63cc92ce6629537e99101822 Mon Sep 17 00:00:00 2001 From: hupeng Date: Thu, 9 Apr 2020 13:07:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B8=E9=94=80=E5=A2=9E=E5=8A=A0=E5=88=86?= =?UTF-8?q?=E9=94=80=E4=B8=8E=E7=A7=AF=E5=88=86=E5=A5=96=E5=8A=B1=EF=BC=8C?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E6=A0=B8=E9=94=80=E6=96=B0=E5=A2=9Erest?= =?UTF-8?q?=E8=B0=83=E7=94=A8api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/service/YxStoreOrderService.java | 2 ++ .../service/impl/YxStoreOrderServiceImpl.java | 24 +++++++++++++ .../web/controller/StoreOrderController.java | 35 +++++++++++++++++-- .../shop/rest/StoreOrderController.java | 24 +++++++++++-- .../src/main/resources/config/application.yml | 3 +- 5 files changed, 83 insertions(+), 5 deletions(-) diff --git a/yshop-api/src/main/java/co/yixiang/modules/order/service/YxStoreOrderService.java b/yshop-api/src/main/java/co/yixiang/modules/order/service/YxStoreOrderService.java index 83e48900..91ea66f5 100644 --- a/yshop-api/src/main/java/co/yixiang/modules/order/service/YxStoreOrderService.java +++ b/yshop-api/src/main/java/co/yixiang/modules/order/service/YxStoreOrderService.java @@ -75,6 +75,8 @@ public interface YxStoreOrderService extends BaseService { void takeOrder(String orderId,int uid); + void verificOrder(String orderId); + List orderList(int uid,int type,int page,int limit); //@WebMethod diff --git a/yshop-api/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java b/yshop-api/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java index 62f87c7f..7765d90d 100644 --- a/yshop-api/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java +++ b/yshop-api/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java @@ -592,6 +592,30 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl orderAminVerify(@PathVariable String code){ + YxStoreOrder storeOrder = new YxStoreOrder(); + storeOrder.setVerifyCode(code); + storeOrder.setIsDel(OrderInfoEnum.CANCEL_STATUS_0.getValue()); + storeOrder.setPaid(OrderInfoEnum.PAY_STATUS_1.getValue()); + storeOrder.setRefundStatus(OrderInfoEnum.REFUND_STATUS_0.getValue()); + + YxStoreOrder order = storeOrderService.getOne(Wrappers.query(storeOrder)); + if(order == null) return ApiResult.fail("核销的订单不存在或未支付或已退款"); + + + if(order.getStatus() > 0) return ApiResult.fail("订单已经核销"); + + if(order.getCombinationId() > 0 && order.getPinkId() > 0){ + YxStorePinkQueryVo storePink = storePinkService.getYxStorePinkById(order.getPinkId()); + if(!OrderInfoEnum.PINK_STATUS_2.getValue().equals(storePink.getStatus())){ + return ApiResult.fail("拼团订单暂未成功无法核销"); + } + } + + storeOrderService.verificOrder(order.getOrderId()); return ApiResult.ok("核销成功"); } + } diff --git a/yshop-shop/src/main/java/co/yixiang/modules/shop/rest/StoreOrderController.java b/yshop-shop/src/main/java/co/yixiang/modules/shop/rest/StoreOrderController.java index 2e84eb44..12891525 100644 --- a/yshop-shop/src/main/java/co/yixiang/modules/shop/rest/StoreOrderController.java +++ b/yshop-shop/src/main/java/co/yixiang/modules/shop/rest/StoreOrderController.java @@ -22,9 +22,12 @@ import co.yixiang.mp.service.WxMpTemplateMessageService; import co.yixiang.mp.service.YxTemplateService; import co.yixiang.mp.service.YxWechatTemplateService; import co.yixiang.utils.OrderUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; import org.springframework.data.domain.Pageable; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.http.HttpStatus; @@ -32,7 +35,9 @@ import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import org.springframework.web.client.RestTemplate; +import java.text.MessageFormat; import java.util.concurrent.TimeUnit; /** @@ -45,6 +50,9 @@ import java.util.concurrent.TimeUnit; @Slf4j public class StoreOrderController { + @Value("${yshop.apiUrl}") + private String apiUrl; + private final YxStoreOrderService yxStoreOrderService; private final YxStoreOrderStatusService yxStoreOrderStatusService; @@ -243,6 +251,8 @@ public class StoreOrderController { if(OrderInfoEnum.PAY_STATUS_0.getValue().equals(storeOrderDTO.getPaid())){ throw new BadRequestException("订单未支付"); } + + /** if(storeOrderDTO.getStatus() > 0) throw new BadRequestException("订单已核销"); if(storeOrderDTO.getCombinationId() > 0 && storeOrderDTO.getPinkId() > 0){ @@ -251,9 +261,19 @@ public class StoreOrderController { throw new BadRequestException("拼团订单暂未成功无法核销"); } } + **/ - resources.setStatus(OrderInfoEnum.STATUS_2.getValue()); - yxStoreOrderService.update(resources); + //远程调用API + RestTemplate rest = new RestTemplate(); + String url = StrUtil.format(apiUrl+"/order/admin/order_verific/{}", resources.getVerifyCode()); + String text = rest.getForObject(url, String.class); + + JSONObject jsonObject = JSON.parseObject(text); + + Integer status = jsonObject.getInteger("status"); + String msg = jsonObject.getString("msg"); + + if(status != 200) throw new BadRequestException(msg); return new ResponseEntity(HttpStatus.NO_CONTENT); diff --git a/yshop-system/src/main/resources/config/application.yml b/yshop-system/src/main/resources/config/application.yml index 2a8e39c1..51d0b688 100644 --- a/yshop-system/src/main/resources/config/application.yml +++ b/yshop-system/src/main/resources/config/application.yml @@ -57,4 +57,5 @@ yshop: express: enable: true appId: 1607734 - appKey: 81f43a2e-f504-45c4-9b54-2637d59f8190 \ No newline at end of file + appKey: 81f43a2e-f504-45c4-9b54-2637d59f8190 + apiUrl: http://127.0.0.1:8009/api \ No newline at end of file