|
@@ -1,22 +1,26 @@
|
|
|
package com.cyksj.web.controller.manage.group;
|
|
package com.cyksj.web.controller.manage.group;
|
|
|
|
|
|
|
|
-import com.cyksj.web.util.StpAbroadUtil;
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
|
+import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.thread.ThreadUtil;
|
|
import cn.hutool.core.thread.ThreadUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONObject;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Assert;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.annotation.Log;
|
|
import com.cyksj.common.annotation.Log;
|
|
|
import com.cyksj.common.annotation.NoSubmit;
|
|
import com.cyksj.common.annotation.NoSubmit;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.util.GoogleGenerator;
|
|
import com.cyksj.common.util.GoogleGenerator;
|
|
|
|
|
+import com.cyksj.common.util.Jsons;
|
|
|
import com.cyksj.dto.Result;
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.BusinessType;
|
|
import com.cyksj.enums.BusinessType;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
|
|
+import com.cyksj.mapper.GroupsRelationAlertMapper;
|
|
|
import com.cyksj.mapper.GroupsRelationMapper;
|
|
import com.cyksj.mapper.GroupsRelationMapper;
|
|
|
import com.cyksj.mapper.UserMapper;
|
|
import com.cyksj.mapper.UserMapper;
|
|
|
import com.cyksj.model.entity.Account;
|
|
import com.cyksj.model.entity.Account;
|
|
|
|
|
+import com.cyksj.model.entity.GroupsRelationAlert;
|
|
|
import com.cyksj.model.entity.GroupsTrips;
|
|
import com.cyksj.model.entity.GroupsTrips;
|
|
|
import com.cyksj.model.entity.GroupsTripsAccountReplaceRecord;
|
|
import com.cyksj.model.entity.GroupsTripsAccountReplaceRecord;
|
|
|
import com.cyksj.model.request.AccountGroupsReq;
|
|
import com.cyksj.model.request.AccountGroupsReq;
|
|
@@ -26,6 +30,7 @@ import com.cyksj.model.views.GoodsDonSkuView;
|
|
|
import com.cyksj.model.views.GroupsTripsWaitingView;
|
|
import com.cyksj.model.views.GroupsTripsWaitingView;
|
|
|
import com.cyksj.service.mange.CmsAccountService;
|
|
import com.cyksj.service.mange.CmsAccountService;
|
|
|
import com.cyksj.service.mange.CmsGroupService;
|
|
import com.cyksj.service.mange.CmsGroupService;
|
|
|
|
|
+import com.cyksj.web.util.StpAbroadUtil;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
import com.ejlchina.searcher.SearchResult;
|
|
import com.ejlchina.searcher.SearchResult;
|
|
|
import com.ejlchina.searcher.param.Operator;
|
|
import com.ejlchina.searcher.param.Operator;
|
|
@@ -34,6 +39,7 @@ import com.ejlchina.searcher.util.MapUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
+import org.springframework.dao.DuplicateKeyException;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
@@ -63,6 +69,8 @@ public class CmsGroupController {
|
|
|
|
|
|
|
|
private final UserMapper userMapper;
|
|
private final UserMapper userMapper;
|
|
|
|
|
|
|
|
|
|
+ private final GroupsRelationAlertMapper alertMapper;
|
|
|
|
|
+
|
|
|
@GetMapping("/get")
|
|
@GetMapping("/get")
|
|
|
public Result<SearchResult<GroupsTrips>> get(String account, Long userId, String showId, String nickName, String submitAccount, Boolean isEmpty) {
|
|
public Result<SearchResult<GroupsTrips>> get(String account, Long userId, String showId, String nickName, String submitAccount, Boolean isEmpty) {
|
|
|
MapBuilder mapBuilder = MapUtils.flatBuilder(request.getParameterMap());
|
|
MapBuilder mapBuilder = MapUtils.flatBuilder(request.getParameterMap());
|
|
@@ -296,4 +304,55 @@ public class CmsGroupController {
|
|
|
re.putOpt("time", time);
|
|
re.putOpt("time", time);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(re.toString());
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(re.toString());
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取该规格下可用车位数
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/get/available/relation")
|
|
|
|
|
+ public Result<Integer> getAvailableRelation(Long goodsId, Long skuId) {
|
|
|
|
|
+ Integer available = groupService.getAvailableRelation(goodsId, skuId);
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(available);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 设置库存预警通知
|
|
|
|
|
+ */
|
|
|
|
|
+ @PutMapping("/set/relation/alert")
|
|
|
|
|
+ public Result<String> setGroupsRelationAlert(@RequestBody @Validated GroupsRelationAlert groupsRelationAlert) throws Exception {
|
|
|
|
|
+ if (groupsRelationAlert.getId() == null) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ alertMapper.insert(groupsRelationAlert);
|
|
|
|
|
+ } catch (DuplicateKeyException e) {
|
|
|
|
|
+ }
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
|
|
+ }
|
|
|
|
|
+ Long id = groupsRelationAlert.getId();
|
|
|
|
|
+ Assert.notNull(id, "预警id不存在");
|
|
|
|
|
+ GroupsRelationAlert dbAlert = alertMapper.selectById(id);
|
|
|
|
|
+ Assert.notNull(dbAlert, "预警不存在");
|
|
|
|
|
+ String phoneStr = groupsRelationAlert.getPhoneStr();
|
|
|
|
|
+ List<String> phoneList = Jsons.parseList(phoneStr, String.class);
|
|
|
|
|
+ phoneList.forEach(phone -> {
|
|
|
|
|
+ if (!Validator.isMobile(phone)) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("请输入正确的手机格式");
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ Integer dbNum = dbAlert.getNum();
|
|
|
|
|
+ Integer num = groupsRelationAlert.getNum();
|
|
|
|
|
+ if (dbNum != num) {
|
|
|
|
|
+ groupsRelationAlert.setIsReset(true);
|
|
|
|
|
+ }
|
|
|
|
|
+ alertMapper.updateById(groupsRelationAlert);
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 库存预警通知
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/get/relation/alert")
|
|
|
|
|
+ public Result<GroupsRelationAlert> getGroupsRelationAlert(@RequestParam(required = true) Long skuId) {
|
|
|
|
|
+ GroupsRelationAlert groupsRelationAlert = alertMapper.selectOne(Wrappers.lambdaQuery(GroupsRelationAlert.class)
|
|
|
|
|
+ .eq(GroupsRelationAlert::getSkuId, skuId).last("limit 1"));
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(groupsRelationAlert);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|