|
|
@@ -1,11 +1,14 @@
|
|
|
package com.mokamrp.privates.controller.pangu;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.mokamrp.privates.constant.HttpStatus;
|
|
|
import com.mokamrp.privates.controller.BaseController;
|
|
|
-import com.mokamrp.privates.entity.PostBasePageHandle;
|
|
|
+import com.mokamrp.privates.entity.pangu.FosterwxFlowListHandle;
|
|
|
import com.mokamrp.privates.help.AjaxResult;
|
|
|
import com.mokamrp.privates.mapper.pangu.pojo.FosterwxFlowList;
|
|
|
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobilePool;
|
|
|
import com.mokamrp.privates.service.pangu.FosterwxFlowListService;
|
|
|
+import com.mokamrp.privates.service.pangu.FosterwxMobilePoolService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
@@ -14,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
@@ -32,6 +36,9 @@ public class FosterwxFlowListController extends BaseController<FosterwxFlowList>
|
|
|
@Autowired
|
|
|
public FosterwxFlowListService fosterwxFlowListService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ public FosterwxMobilePoolService fosterwxMobilePoolService;
|
|
|
+
|
|
|
/*
|
|
|
* @fast
|
|
|
* 默认生成的控制器所继承的父类中有index/add/edit/del四个基础方法,均为post json请求
|
|
|
@@ -39,14 +46,72 @@ public class FosterwxFlowListController extends BaseController<FosterwxFlowList>
|
|
|
*/
|
|
|
|
|
|
@PostMapping("/list")
|
|
|
- public Object list(@Valid @RequestBody PostBasePageHandle postBasePageHandle, BindingResult bindingResult) {
|
|
|
+ public Object list(@Valid @RequestBody FosterwxFlowListHandle fosterwxFlowListHandle, BindingResult bindingResult) {
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
|
|
|
}
|
|
|
- Map<String, Object> res = fosterwxFlowListService.getList(postBasePageHandle);
|
|
|
+ Map<String, Object> res = fosterwxFlowListService.getList(fosterwxFlowListHandle);
|
|
|
return AjaxResult.success(res);
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/changeStatus")
|
|
|
+ public Object changeStatus(FosterwxFlowList fosterwxFlowList) {
|
|
|
+ // 先从个微池中获取进粉阈值
|
|
|
+ FosterwxMobilePool fosterwxMobilePool = fosterwxMobilePoolService.getOne(new QueryWrapper<FosterwxMobilePool>().eq("pool_index", fosterwxFlowList.getPoolId()).last("Limit 1"));
|
|
|
+
|
|
|
+ // 最大进粉阈值
|
|
|
+ Integer maxFans = Integer.valueOf(fosterwxMobilePool.getMaxFans());
|
|
|
+
|
|
|
+ // 查看是否超过百分之五十
|
|
|
+ if (fosterwxFlowList.getBusFans() > maxFans / 2.0) {
|
|
|
+ // 超过
|
|
|
+ // 更新个微池状态为停用
|
|
|
+ fosterwxMobilePool.setStatus(0);
|
|
|
+ fosterwxMobilePool.setUpdateUid(fosterwxFlowList.getUpdateUid());
|
|
|
+ fosterwxMobilePool.setUpdateAt(LocalDateTime.now());
|
|
|
+ fosterwxMobilePoolService.updateById(fosterwxMobilePool);
|
|
|
+
|
|
|
+ // 更新
|
|
|
+ FosterwxFlowList lastPosition = fosterwxFlowListService.getOne(new QueryWrapper<FosterwxFlowList>().eq("pool_id", fosterwxFlowList.getPoolId()));
|
|
|
+ String position = "";
|
|
|
+ if (null == lastPosition) {
|
|
|
+ // 新开账号 需要激活个微池状态
|
|
|
+ position = "1001";
|
|
|
+ } else {
|
|
|
+ position = String.valueOf(Integer.parseInt(lastPosition.getFlowPosition()) + 1);
|
|
|
+ }
|
|
|
+ // 设置流量位置
|
|
|
+ fosterwxFlowList.setFlowPosition(position);
|
|
|
+ // 设置状态
|
|
|
+ fosterwxFlowList.setStatus(0);
|
|
|
+ fosterwxFlowListService.save(fosterwxFlowList);
|
|
|
+ // 更新全部位置为超限
|
|
|
+ fosterwxFlowListService.update(new FosterwxFlowList(1), new QueryWrapper<FosterwxFlowList>().eq("pool_id", fosterwxFlowList.getPoolId()));
|
|
|
+ } else {
|
|
|
+ // 未超过
|
|
|
+ // 查找上一个流量位置
|
|
|
+ FosterwxFlowList lastPosition = fosterwxFlowListService.getOne(new QueryWrapper<FosterwxFlowList>().eq("pool_id", fosterwxFlowList.getPoolId()));
|
|
|
+ String position = "";
|
|
|
+ if (null == lastPosition) {
|
|
|
+ // 新开账号 需要激活个微池状态
|
|
|
+ position = "1001";
|
|
|
+ fosterwxMobilePool.setStatus(2);
|
|
|
+ fosterwxMobilePool.setUpdateUid(fosterwxFlowList.getUpdateUid());
|
|
|
+ fosterwxMobilePool.setUpdateAt(LocalDateTime.now());
|
|
|
+ fosterwxMobilePoolService.updateById(fosterwxMobilePool);
|
|
|
|
|
|
+ } else {
|
|
|
+ position = String.valueOf(Integer.parseInt(lastPosition.getFlowPosition()) + 1);
|
|
|
+ }
|
|
|
+ // 设置流量位置
|
|
|
+ fosterwxFlowList.setFlowPosition(position);
|
|
|
+ // 设置状态
|
|
|
+ fosterwxFlowList.setStatus(1);
|
|
|
+ fosterwxFlowListService.save(fosterwxFlowList);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return AjaxResult.success("操作成功!");
|
|
|
+ }
|
|
|
}
|
|
|
|