Authored by mali

库存管理区分到期不到期

@@ -22,7 +22,9 @@ import org.springframework.web.bind.annotation.RestController; @@ -22,7 +22,9 @@ import org.springframework.web.bind.annotation.RestController;
22 22
23 import java.lang.reflect.Method; 23 import java.lang.reflect.Method;
24 import java.util.Collection; 24 import java.util.Collection;
  25 +import java.util.HashMap;
25 import java.util.List; 26 import java.util.List;
  27 +import java.util.Map;
26 28
27 @RestController 29 @RestController
28 public class DepositController { 30 public class DepositController {
@@ -149,4 +151,55 @@ public class DepositController { @@ -149,4 +151,55 @@ public class DepositController {
149 depositService.clearCacheByDepositCode(uid, depositCode); 151 depositService.clearCacheByDepositCode(uid, depositCode);
150 return new ApiResponse(200, "缓存清除成功!", Boolean.TRUE); 152 return new ApiResponse(200, "缓存清除成功!", Boolean.TRUE);
151 } 153 }
  154 +
  155 + /**
  156 + * 仓库管理详情,几个尺码 几个库存接口
  157 + * @param uid
  158 + * @param productId
  159 + * @return
  160 + */
  161 + @RequestMapping(params = "method=ufo.deposit.queryUserDopositProduct")
  162 + @Cachable(expire = 180, pageArgs = {2,3})
  163 + public ApiResponse queryUserDopositingEx(@RequestParam("uid") Integer uid , @RequestParam("productId") Integer productId) {
  164 + LOG.info("method queryUserDopositingEx in, uid is {}, productId is {}", uid, productId);
  165 + DepositProductBo countBo = depositService.queryUserDepositProductCountInfo(uid, productId);
  166 + Map<String, Object> result = new HashMap<>();
  167 + result.put("product", countBo);
  168 + LOG.info("end queryUserDopositingEx uid is {}, productId is {} result: {}", uid, productId, result);
  169 + return new ApiResponse.ApiResponseBuilder().code(200).data(result).build();
  170 + }
  171 +
  172 + /**
  173 + * 查询 到期和不到期的 库存
  174 + * @param uid
  175 + * @param productId
  176 + * @param page
  177 + * @param limit
  178 + * @param sort
  179 + * @return
  180 + */
  181 + @RequestMapping(params = "method=ufo.deposit.queryUserDopositingSort")
  182 + @Cachable(expire = 180, pageArgs = {2,3})
  183 + public ApiResponse queryUserDopositingSort(@RequestParam("uid") Integer uid
  184 + , @RequestParam("productId") Integer productId
  185 + , @RequestParam(value = "page", required = false, defaultValue = "1") Integer page
  186 + , @RequestParam(value = "limit", required = false, defaultValue = "10") Integer limit,
  187 + @RequestParam(value = "sort") Integer sort ) {
  188 + if (uid == null || uid < 1) {
  189 + LOG.warn("queryUserDopositing failed, invalid uid: {}", uid);
  190 + return new ApiResponse.ApiResponseBuilder().code(500).message("查询失败").build();
  191 + }
  192 + if (productId == null || productId < 1) {
  193 + LOG.warn("queryUserDopositing failed, invalid productId: {}", productId);
  194 + return new ApiResponse.ApiResponseBuilder().code(500).message("查询失败").build();
  195 + }
  196 +
  197 + PageResp<List<DepositDetailBo>> depositDetailBoList = depositService.queryUserProductDopositingDetail(uid, productId, page, limit);
  198 + DepositProductBo countBo = depositService.queryUserDepositProductCountInfo(uid, productId);
  199 + JSONObject result = new JSONObject();
  200 + result.put("product", countBo);
  201 + result.put("items", depositDetailBoList);
  202 + LOG.info("queryUserDopositing result: {}", result);
  203 + return new ApiResponse.ApiResponseBuilder().code(200).data(result).build();
  204 + }
152 } 205 }
1 package com.yohoufo.order.service.impl; 1 package com.yohoufo.order.service.impl;
2 2
3 import com.yoho.core.dal.datasource.annotation.Database; 3 import com.yoho.core.dal.datasource.annotation.Database;
  4 +import com.yoho.error.exception.ServiceException;
4 import com.yohobuy.ufo.model.order.bo.ButtonShowBo; 5 import com.yohobuy.ufo.model.order.bo.ButtonShowBo;
5 import com.yohobuy.ufo.model.order.bo.DepositDetailBo; 6 import com.yohobuy.ufo.model.order.bo.DepositDetailBo;
6 import com.yohobuy.ufo.model.order.bo.DepositProductBo; 7 import com.yohobuy.ufo.model.order.bo.DepositProductBo;
@@ -218,6 +219,9 @@ public class DepositServiceImpl implements DepositService { @@ -218,6 +219,9 @@ public class DepositServiceImpl implements DepositService {
218 } 219 }
219 220
220 public DepositProductBo queryUserDepositProductCountInfo(Integer uid, Integer productId) { 221 public DepositProductBo queryUserDepositProductCountInfo(Integer uid, Integer productId) {
  222 + checkUid(uid, "queryUserDepositProductCountInfo failed, invalid uid: {}");
  223 + checkProductId(productId, "queryUserDepositProductCountInfo failed, invalid productId: {}");
  224 +
221 List<StorageDepositCount> countInfoList = storageDepositMapper.queryUserDepositProduct(uid, Arrays.asList(productId)); 225 List<StorageDepositCount> countInfoList = storageDepositMapper.queryUserDepositProduct(uid, Arrays.asList(productId));
222 if (countInfoList.isEmpty()) { 226 if (countInfoList.isEmpty()) {
223 return null; 227 return null;
@@ -236,6 +240,20 @@ public class DepositServiceImpl implements DepositService { @@ -236,6 +240,20 @@ public class DepositServiceImpl implements DepositService {
236 return bo; 240 return bo;
237 } 241 }
238 242
  243 + private void checkProductId(Integer productId, String format) {
  244 + if (productId == null || productId < 1) {
  245 + LOGGER.warn(format, productId);
  246 + throw new UfoServiceException(500, "参数非法");
  247 + }
  248 + }
  249 +
  250 + private void checkUid(Integer uid, String format) {
  251 + if (uid == null || uid < 1) {
  252 + LOGGER.warn(format, uid);
  253 + throw new UfoServiceException(500, "参数非法");
  254 + }
  255 + }
  256 +
239 257
240 // 上架 258 // 上架
241 @Override 259 @Override