|
@@ -13,6 +13,8 @@ import com.emato.biz.service.mall.InventoryService;
|
|
|
import com.emato.biz.service.merchant.IThirdMerchantBizService;
|
|
|
import com.emato.common.core.Result;
|
|
|
import com.emato.common.exception.CustomException;
|
|
|
+import com.emato.common.exception.ServiceException;
|
|
|
+import com.emato.common.utils.oms.response.ResultCodeEnum;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -20,6 +22,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -40,9 +43,6 @@ public class InventoryServiceImpl implements InventoryService {
|
|
|
@Autowired
|
|
|
private SignService signService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private IThirdMerchantBizService thirdMerService;
|
|
|
-
|
|
|
@Resource
|
|
|
private InventoryDataMapper inventoryDataMapper;
|
|
|
|
|
@@ -58,7 +58,7 @@ public class InventoryServiceImpl implements InventoryService {
|
|
|
log.info("---------- 查询库存数据开始 ----------");
|
|
|
log.info("========== 电商请求 eccs 报文 =========> {}", outRequest);
|
|
|
// 验签
|
|
|
- Assert.notTrue(!signService.verifySign(outRequest), "验签失败!");
|
|
|
+ Assert.notTrue(!signService.verifySign(outRequest), ResultCodeEnum.SIGN_ERROR);
|
|
|
// 转为请求类
|
|
|
InventoryReqVO reqVO = JSON.parseObject(outRequest.getData(), InventoryReqVO.class);
|
|
|
log.debug("========== 解析后的请求数据 ==========> {}", reqVO);
|
|
@@ -68,10 +68,10 @@ public class InventoryServiceImpl implements InventoryService {
|
|
|
String pageSizeStr = reqVO.getPageSize();
|
|
|
|
|
|
// 参数校验
|
|
|
- Assert.notNull(pageIndexStr, "分页页码不能为空!");
|
|
|
- Assert.notNull(pageSizeStr, "分页大小不能为空!");
|
|
|
- Assert.notTrue(!isPositiveInteger(pageIndexStr), "分页页码请填入正整数!");
|
|
|
- Assert.notTrue(!isPositiveInteger(pageSizeStr), "分页大小请填入正整数!");
|
|
|
+ Assert.notNull(pageIndexStr, ResultCodeEnum.PARAM_ERROR_PAGE_INDEX_NOT_NULL);
|
|
|
+ Assert.notNull(pageSizeStr, ResultCodeEnum.PARAM_ERROR_PAGE_SIZE_NOT_NULL);
|
|
|
+ Assert.notTrue(!isPositiveInteger(pageIndexStr), ResultCodeEnum.PARAM_ERROR_PAGE_INDEX_NOT_POS_INT);
|
|
|
+ Assert.notTrue(!isPositiveInteger(pageSizeStr), ResultCodeEnum.PARAM_ERROR_PAGE_SIZE_NOT_POS_INT);
|
|
|
|
|
|
// 分页大小
|
|
|
int pageSize = Integer.parseInt(pageSizeStr);
|
|
@@ -83,19 +83,24 @@ public class InventoryServiceImpl implements InventoryService {
|
|
|
pageIndex = Math.max(pageIndex, 1);
|
|
|
pageIndex = (pageIndex - 1) * pageSize;
|
|
|
|
|
|
- // 查询参数
|
|
|
- List<InventoryDataPushVo> inventoryData = inventoryDataMapper.getInventoryData(pageIndex, pageSize);
|
|
|
+ // 查询库存数据
|
|
|
+ List<InventoryDataPushVo> inventoryData = inventoryDataMapper.selectInventoryData(pageIndex, pageSize);
|
|
|
+ // 查询库存记录总数
|
|
|
+ int inventoryTotal = inventoryDataMapper.selectInventoryTotal();
|
|
|
|
|
|
// 组装返回数据
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
- resultMap.put("row", inventoryData);
|
|
|
- resultMap.put("invTime", LocalDateTime.now().toString());
|
|
|
+ resultMap.put("rows", inventoryData);
|
|
|
+ resultMap.put("total", inventoryTotal);
|
|
|
+
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ resultMap.put("invTime", LocalDateTime.now().format(formatter));
|
|
|
|
|
|
log.info("---------- 查询库存数据结束 ----------");
|
|
|
return Result.success(resultMap);
|
|
|
- }catch (CustomException ce){
|
|
|
+ }catch (ServiceException se){
|
|
|
// 交给统一异常处理
|
|
|
- throw ce;
|
|
|
+ throw se;
|
|
|
} catch (Exception e) {
|
|
|
log.error("查询库存数据异常 => ", e);
|
|
|
throw new CustomException("查询库存数据异常,请稍后再试!");
|