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