leon hace 4 años
padre
commit
aa6949470f

+ 18 - 0
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxCashMobileController.java

@@ -1,11 +1,15 @@
 package com.mokamrp.privates.controller.pangu;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.mokamrp.privates.constant.Constants;
 import com.mokamrp.privates.constant.HttpStatus;
 import com.mokamrp.privates.entity.PostBasePageHandle;
+import com.mokamrp.privates.entity.SetGroupHandle;
 import com.mokamrp.privates.entity.SetIdsHandle;
 import com.mokamrp.privates.help.AjaxResult;
 import com.mokamrp.privates.entity.ResHandle;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashOasBox;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -62,5 +66,19 @@ public class FosterwxCashMobileController extends BaseController<FosterwxCashMob
         fosterwxCashMobileService.update(save,new QueryWrapper<FosterwxCashMobile>().in("id",setIdsHandle.getIds()));
         return AjaxResult.success();
     }
+
+    @ApiOperation(value = "批量设置分组")
+    @PostMapping("/setGroup")
+    public Object setGroup(@Valid @RequestBody SetGroupHandle handle, BindingResult bindingResult) {
+        if (bindingResult.hasErrors()) {
+            return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
+        }
+        FosterwxCashMobile save = new FosterwxCashMobile();
+        save.setGroupId(handle.getGroupId());
+        save.setUpdateAt(LocalDateTime.now());
+        service.update(save, new QueryWrapper<FosterwxCashMobile>().in("id", handle.getIds()));
+//        this.sync();
+        return AjaxResult.success(Constants.SUCCESS, true);
+    }
 }
 

+ 2 - 2
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxMobileController.java

@@ -327,11 +327,11 @@ public class FosterwxMobileController extends BaseController<FosterwxMobile> {
      * @return
      */
     @PostMapping("/addCashMobileList")
-    public Object addCashMobileList(@Valid @RequestBody SetIdsHandle setIdsHandle, BindingResult bindingResult) {
+    public Object addCashMobileList(@Valid @RequestBody SetIdsHandle handle, BindingResult bindingResult) {
         if (bindingResult.hasErrors()) {
             return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
         }
-        fosterwxMobileService.addCashMobileList(setIdsHandle.getIds());
+        fosterwxMobileService.addCashMobileList(handle);
         return AjaxResult.success();
     }
 

+ 2 - 0
src/main/java/com/mokamrp/privates/entity/PostBasePageHandle.java

@@ -8,6 +8,8 @@ public class PostBasePageHandle {
     private Integer pagesize;
     private Integer id;
     private Integer groupId;
+    private Integer stationId;
+    private Integer mobileId;
     private String name;
     public Integer getPage() {
         return page;

+ 3 - 1
src/main/java/com/mokamrp/privates/mapper/pangu/FosterwxCashMobileMapper.xml

@@ -28,7 +28,9 @@
         left join pan_fosterwx_station as C on A.station_id = C.id
         left join pan_fosterwx_domain as D on A.domain_id = D.id and D.status = 1
         <where>
-            <if test="params.groupId != null">and group_id = #{params.groupId}</if>
+            <if test="params.groupId != null">and A.group_id = #{params.groupId}</if>
+            <if test="params.stationId != null">and A.station_id = #{params.stationId}</if>
+            <if test="params.mobileId != null">and A.mobile_id = #{params.mobileId}</if>
         </where>
         order by A.id desc
     </select>

+ 2 - 1
src/main/java/com/mokamrp/privates/service/pangu/FosterwxMobileService.java

@@ -1,6 +1,7 @@
 package com.mokamrp.privates.service.pangu;
 
 import com.mokamrp.privates.entity.ResHandle;
+import com.mokamrp.privates.entity.SetIdsHandle;
 import com.mokamrp.privates.entity.VoltaHandle;
 import com.mokamrp.privates.entity.pangu.GetForsterwxMobileHandle;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
@@ -29,6 +30,6 @@ public interface FosterwxMobileService extends IService<FosterwxMobile> {
 
     public List<FosterwxMobileVo> setWxFriend(List<FosterwxMobileVo> list);
     //.@leon 批量加入变现账号
-    public Boolean addCashMobileList(List<Integer> mobileIds);
+    public Boolean addCashMobileList(SetIdsHandle setIdsHandle);
 
 }

+ 12 - 2
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxCashOasBoxServiceImpl.java

@@ -3,6 +3,8 @@ package com.mokamrp.privates.service.pangu.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashOasBox;
 import com.mokamrp.privates.mapper.pangu.FosterwxCashOasBoxMapper;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashOasBoxMobileGroup;
+import com.mokamrp.privates.service.pangu.FosterwxCashOasBoxMobileGroupService;
 import com.mokamrp.privates.service.pangu.FosterwxCashOasBoxService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.mokamrp.privates.utils.StringUtils;
@@ -16,6 +18,7 @@ import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -31,6 +34,9 @@ public class FosterwxCashOasBoxServiceImpl extends ServiceImpl<FosterwxCashOasBo
     @Autowired
     public FosterwxCashOasBoxMapper fosterwxCashOasBoxMapper;
 
+    @Autowired
+    public FosterwxCashOasBoxMobileGroupService fosterwxCashOasBoxMobileGroupService;
+
     /**
      * 获取数据列表 支持分页
      *
@@ -68,9 +74,11 @@ public class FosterwxCashOasBoxServiceImpl extends ServiceImpl<FosterwxCashOasBo
      * @return
      */
     public FosterwxCashOasBox getRandBox(Integer groupId) {
+        List<FosterwxCashOasBoxMobileGroup> mobileGroupList = fosterwxCashOasBoxMobileGroupService.list(new QueryWrapper<FosterwxCashOasBoxMobileGroup>().eq("cash_mobile_group_id",groupId));
+        List<Integer> boxOasIds = mobileGroupList.stream().map(FosterwxCashOasBoxMobileGroup::getOasBoxId).collect(Collectors.toList());
         List<FosterwxCashOasBox> list = this.list(new QueryWrapper<FosterwxCashOasBox>()
                 .eq("type", 1)
-                .eq("group_id", groupId)
+                .in("id", boxOasIds)
                 .lt("send_text_cnt", 90)
                 .eq("fobidden_status", 1));
         if (list == null || list.size() <= 0) {
@@ -89,9 +97,11 @@ public class FosterwxCashOasBoxServiceImpl extends ServiceImpl<FosterwxCashOasBo
      * @return
      */
     public FosterwxCashOasBox getRandOas(Integer groupId) {
+        List<FosterwxCashOasBoxMobileGroup> mobileGroupList = fosterwxCashOasBoxMobileGroupService.list(new QueryWrapper<FosterwxCashOasBoxMobileGroup>().eq("cash_mobile_group_id",groupId));
+        List<Integer> boxOasIds = mobileGroupList.stream().map(FosterwxCashOasBoxMobileGroup::getOasBoxId).collect(Collectors.toList());
         List<FosterwxCashOasBox> list = this.list(new QueryWrapper<FosterwxCashOasBox>()
                 .eq("type", 2)
-                .eq("group_id", groupId)
+                .in("id", boxOasIds)
                 .lt("send_text_cnt", 90)
                 .eq("fobidden_status", 1));
         if (list == null || list.size() <= 0) {

+ 11 - 3
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxMobileServiceImpl.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.mokamrp.privates.entity.ResHandle;
+import com.mokamrp.privates.entity.SetIdsHandle;
 import com.mokamrp.privates.entity.VoltaHandle;
 import com.mokamrp.privates.entity.pangu.GetForsterwxMobileHandle;
 import com.mokamrp.privates.mapper.pangu.FosterwxMobileMapper;
@@ -49,6 +50,9 @@ public class FosterwxMobileServiceImpl extends ServiceImpl<FosterwxMobileMapper,
     public FosterwxMobileService fosterwxMobileService;
 
     @Autowired
+    public FosterwxDomainService fosterwxDomainService;
+
+    @Autowired
     public CorpService corpService;
 
     @Autowired
@@ -255,18 +259,22 @@ public class FosterwxMobileServiceImpl extends ServiceImpl<FosterwxMobileMapper,
 
     /**
      * 批量加入变现账号
-     * @param mobileIds
+     * @param setIdsHandle
      * @return
      */
-    public Boolean addCashMobileList(List<Integer> mobileIds) {
+    public Boolean addCashMobileList(SetIdsHandle setIdsHandle) {
         LocalDateTime now = LocalDateTime.now();
-        for (Integer id : mobileIds) {
+        for (Integer id : setIdsHandle.getIds()) {
             FosterwxMobile fosterwxMobile = this.getOne(new QueryWrapper<FosterwxMobile>().eq("id", id));
             FosterwxCashMobile fosterwxCashMobile = fosterwxCashMobileService.getOne(new QueryWrapper<FosterwxCashMobile>().eq("mobile_id",id));
             if (fosterwxCashMobile != null){
                 continue;
             }
+            List<FosterwxDomain> domainList = fosterwxDomainService.list(new QueryWrapper<FosterwxDomain>().eq("station_id",fosterwxMobile.getStationId()));
+            Integer rand = (int)(0+Math.random()*((domainList.size()-1)-0+1));
             FosterwxCashMobile add = new FosterwxCashMobile();
+            add.setDomainId(domainList.get(rand).getId());
+            add.setGroupId(setIdsHandle.getId());
             add.setMobileId(fosterwxMobile.getId());
             add.setStationId(fosterwxMobile.getStationId());
             add.setCreateAt(now);