diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/ViewHandoverController.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/ViewHandoverController.java index c8d5c4d3..fb73d613 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/ViewHandoverController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/rest/ViewHandoverController.java @@ -1,9 +1,15 @@ package cn.ysk.cashier.cons.rest; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpResponse; +import cn.hutool.http.HttpUtil; import cn.ysk.cashier.annotation.Log; import cn.ysk.cashier.cons.domain.ViewHandover; import cn.ysk.cashier.cons.service.ViewHandoverService; import cn.ysk.cashier.cons.service.dto.ViewHandoverQueryCriteria; +import cn.ysk.cashier.exception.BadRequestException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; import org.springframework.data.domain.Pageable; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; @@ -12,20 +18,43 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import io.swagger.annotations.*; import java.io.IOException; +import java.util.Objects; import javax.servlet.http.HttpServletResponse; /** * @author admin * @date 2024-08-05 **/ +@Slf4j @RestController @RequiredArgsConstructor -@Api(tags = "交班查询管理") +@Api(tags = "交班管理") @RequestMapping("/api/tbHandover") public class ViewHandoverController { private final ViewHandoverService viewHandoverService; + @Value("${cashier.server.wx}") + private String wxServiceHostname; + + @PostMapping("handoverData") + @Log("提交交班") + @ApiOperation("提交交班") + public ResponseEntity handoverData(@RequestBody ViewHandover resources){ + if(Objects.isNull(resources.getShopId())) throw new BadRequestException("店铺信息不可为空"); + HttpResponse response = HttpUtil.createGet(StrUtil.format(wxServiceHostname,"/cashierService/common/handoverData?shopId={}", resources.getShopId())).execute(); + if (response.getStatus() >= 200 && response.getStatus() < 300) { + String body = response.body(); + return new ResponseEntity<>(HttpStatus.OK); + } else { + // 请求失败,获取状态码和错误信息 + int statusCode = response.getStatus(); + String errorMessage = response.body(); // 可以获取错误信息 + log.error("交班提交失败:{}",errorMessage); + throw new BadRequestException("请求失败,状态码:"+statusCode); + } + } + @Log("导出数据") @ApiOperation("导出数据") @GetMapping(value = "/download") diff --git a/eladmin-system/src/main/resources/config/application-dev.yml b/eladmin-system/src/main/resources/config/application-dev.yml index 440d114b..ffd0536f 100644 --- a/eladmin-system/src/main/resources/config/application-dev.yml +++ b/eladmin-system/src/main/resources/config/application-dev.yml @@ -143,4 +143,7 @@ decorator: logging: file log-file: spy.log log-format: executeTime:%(executionTime) ms | sql:%(sqlSingleLine) - multiline: false \ No newline at end of file + multiline: false +cashier: + server: + wx: https://wxcashiertest.sxczgkj.cn/ \ No newline at end of file diff --git a/eladmin-system/src/main/resources/config/application-pre.yml b/eladmin-system/src/main/resources/config/application-pre.yml index 510008d1..be11be7a 100644 --- a/eladmin-system/src/main/resources/config/application-pre.yml +++ b/eladmin-system/src/main/resources/config/application-pre.yml @@ -135,3 +135,6 @@ file: # 文件大小 /M maxSize: 100 avatarMaxSize: 5 +cashier: + server: + wx: https://pre-cashier.sxczgkj.cn/ diff --git a/eladmin-system/src/main/resources/config/application-prod.yml b/eladmin-system/src/main/resources/config/application-prod.yml index e28172da..9ebb64ba 100644 --- a/eladmin-system/src/main/resources/config/application-prod.yml +++ b/eladmin-system/src/main/resources/config/application-prod.yml @@ -140,3 +140,6 @@ file: # 文件大小 /M maxSize: 100 avatarMaxSize: 5 +cashier: + server: + wx: https://cashier.sxczgkj.cn/