|
@@ -0,0 +1,221 @@
|
|
|
|
|
+package com.mokamrp.privates.controller.pangu;
|
|
|
|
|
+
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.mokamrp.privates.entity.pangu.FosterwxCashBoxClientInfo;
|
|
|
|
|
+import com.mokamrp.privates.entity.pangu.FosterwxWorkServeHandle;
|
|
|
|
|
+import com.mokamrp.privates.help.AjaxResult;
|
|
|
|
|
+import com.mokamrp.privates.mapper.pangu.pojo.*;
|
|
|
|
|
+import com.mokamrp.privates.mapper.pojo.Corp;
|
|
|
|
|
+import com.mokamrp.privates.service.CorpService;
|
|
|
|
|
+import com.mokamrp.privates.service.pangu.*;
|
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.http.MediaType;
|
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
+
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
|
+import java.time.LocalTime;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * @Classname FosterwxCashWorkClientController
|
|
|
|
|
+ * @Description TODO
|
|
|
|
|
+ * @Date 2021/10/26 9:41 上午
|
|
|
|
|
+ * @Created by luqiucheng
|
|
|
|
|
+ */
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/pangu/server")
|
|
|
|
|
+@Api(tags = "供客户端调用接口")
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+public class FosterwxCashWorkClientController {
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FosterwxCashScheduleTaskListService fosterwxCashScheduleTaskListService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private CorpService corpService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FosterwxMobileService fosterwxMobileService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FosterwxCashMobileService fosterwxCashMobileService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FosterwxCashWorkBoxClientInfoService fosterwxCashWorkBoxClientInfoService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FosterwxCashWorkwxTaskListService fosterwxCashWorkwxTaskListService;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping(value = "/getTaskInfo", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
|
|
|
|
|
+ @ApiOperation(value = "返回凌晨到当前时间的未发送的数据,主体 昵称/团队id 昵称 两两一组必须有数据")
|
|
|
|
|
+ public Object getTaskInfo(FosterwxWorkServeHandle handle) {
|
|
|
|
|
+ log.info("客户端请求的信息:{}", handle);
|
|
|
|
|
+
|
|
|
|
|
+ String errInfo = checkParam(handle);
|
|
|
|
|
+
|
|
|
|
|
+ // 报错的的情况返回报错信息
|
|
|
|
|
+ if (null != errInfo && !errInfo.isEmpty()) return AjaxResult.error(errInfo);
|
|
|
|
|
+
|
|
|
|
|
+ // 根据参数获取账号信息
|
|
|
|
|
+ FosterwxMobile fosterwxMobile = getAccountInfo(handle);
|
|
|
|
|
+
|
|
|
|
|
+ if (null == fosterwxMobile) return AjaxResult.error("根据参数无法获取所属账号");
|
|
|
|
|
+
|
|
|
|
|
+ // 根据手机id 获取分组id
|
|
|
|
|
+ FosterwxCashMobile fosterwxCashMobile = fosterwxCashMobileService.getOne(new LambdaQueryWrapper<FosterwxCashMobile>().eq(FosterwxCashMobile::getMobileId, fosterwxMobile.getId()).last("LIMIT 1"));
|
|
|
|
|
+
|
|
|
|
|
+ if (null == fosterwxCashMobile) return AjaxResult.error("该账号未划入变现分组");
|
|
|
|
|
+
|
|
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
|
|
+ LocalDateTime firstDateTime = LocalDateTime.of(now, LocalTime.MIN);
|
|
|
|
|
+ LocalDateTime lastDateTime = LocalDateTime.now();
|
|
|
|
|
+
|
|
|
|
|
+ LambdaQueryWrapper<FosterwxCashScheduleTaskList> fosterwxCashScheduleTaskListLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ // 企微任务
|
|
|
|
|
+ fosterwxCashScheduleTaskListLambdaQueryWrapper.eq(FosterwxCashScheduleTaskList::getType, 2);
|
|
|
|
|
+ // 分组id
|
|
|
|
|
+ fosterwxCashScheduleTaskListLambdaQueryWrapper.eq(FosterwxCashScheduleTaskList::getGroupId, fosterwxCashMobile.getGroupId());
|
|
|
|
|
+ // 已生成的任务 待发送的任务
|
|
|
|
|
+ fosterwxCashScheduleTaskListLambdaQueryWrapper.in(FosterwxCashScheduleTaskList::getStatus, 2, 4);
|
|
|
|
|
+
|
|
|
|
|
+ fosterwxCashScheduleTaskListLambdaQueryWrapper.between(FosterwxCashScheduleTaskList::getSendTime, firstDateTime, lastDateTime);
|
|
|
|
|
+
|
|
|
|
|
+ List<FosterwxCashScheduleTaskList> fosterwxCashScheduleTaskListList = fosterwxCashScheduleTaskListService.list(fosterwxCashScheduleTaskListLambdaQueryWrapper);
|
|
|
|
|
+
|
|
|
|
|
+ List<FosterwxCashBoxClientInfo> fosterwxCashBoxClientInfoList = new ArrayList<>();
|
|
|
|
|
+ fosterwxCashScheduleTaskListList.forEach(fosterwxCashScheduleTaskList -> {
|
|
|
|
|
+ fosterwxCashScheduleTaskListService.updateById(new FosterwxCashScheduleTaskList() {{
|
|
|
|
|
+ setId(fosterwxCashScheduleTaskList.getId());
|
|
|
|
|
+ setStatus(5);
|
|
|
|
|
+ setUpdateAt(LocalDateTime.now());
|
|
|
|
|
+ }});
|
|
|
|
|
+
|
|
|
|
|
+ // 获取任务详情
|
|
|
|
|
+ FosterwxCashWorkwxTaskList fosterwxCashWorkwxTaskList = fosterwxCashWorkwxTaskListService.getOne(new LambdaQueryWrapper<FosterwxCashWorkwxTaskList>().
|
|
|
|
|
+ eq(FosterwxCashWorkwxTaskList::getTemplateId, fosterwxCashScheduleTaskList.getTemplateId()).
|
|
|
|
|
+ eq(FosterwxCashWorkwxTaskList::getCatalogId, fosterwxCashScheduleTaskList.getTaskId()).
|
|
|
|
|
+ eq(FosterwxCashWorkwxTaskList::getId, fosterwxCashScheduleTaskList.getChildTaskId()).
|
|
|
|
|
+ last("LIMIT 1"));
|
|
|
|
|
+ FosterwxCashBoxClientInfo fosterwxCashBoxClientInfo = new FosterwxCashBoxClientInfo();
|
|
|
|
|
+ if (1 == fosterwxCashScheduleTaskList.getTaskType() || 3 == fosterwxCashScheduleTaskList.getTaskType()) {
|
|
|
|
|
+ FosterwxCashWorkBoxClientInfo fosterwxCashWorkBoxClientInfo = fosterwxCashWorkBoxClientInfoService.getOne(new LambdaQueryWrapper<FosterwxCashWorkBoxClientInfo>().like(FosterwxCashWorkBoxClientInfo::getGhid, fosterwxCashScheduleTaskList.getBoxGhid()));
|
|
|
|
|
+ FosterwxCashBoxClientInfo.BoxInfo boxInfo = fosterwxCashBoxClientInfo.new BoxInfo();
|
|
|
|
|
+ boxInfo.setGhid(fosterwxCashWorkBoxClientInfo.getGhid());
|
|
|
|
|
+ boxInfo.setWxid(fosterwxCashWorkBoxClientInfo.getWxid());
|
|
|
|
|
+ boxInfo.setName(fosterwxCashWorkBoxClientInfo.getName());
|
|
|
|
|
+ boxInfo.setTitle(fosterwxCashWorkwxTaskList.getTitle());
|
|
|
|
|
+ boxInfo.setEnterpoint(fosterwxCashScheduleTaskList.getBoxUrl());
|
|
|
|
|
+ boxInfo.setHeadimg(fosterwxCashWorkBoxClientInfo.getHeadimg());
|
|
|
|
|
+ boxInfo.setImage_key1(fosterwxCashWorkBoxClientInfo.getImageKey1());
|
|
|
|
|
+ boxInfo.setImage_key2(fosterwxCashWorkBoxClientInfo.getImageKey2());
|
|
|
|
|
+ boxInfo.setImage_key3(fosterwxCashWorkBoxClientInfo.getImageKey3());
|
|
|
|
|
+ boxInfo.setImageSize(fosterwxCashWorkBoxClientInfo.getImageSize());
|
|
|
|
|
+ boxInfo.setAppType(fosterwxCashWorkBoxClientInfo.getAppType());
|
|
|
|
|
+ boxInfo.setDesc(fosterwxCashWorkBoxClientInfo.getDesc());
|
|
|
|
|
+
|
|
|
|
|
+ fosterwxCashBoxClientInfo.setBoxInfo(boxInfo);
|
|
|
|
|
+ } else if (2 == fosterwxCashScheduleTaskList.getTaskType()) {
|
|
|
|
|
+ FosterwxCashBoxClientInfo.UrlInfo urlInfo = fosterwxCashBoxClientInfo.new UrlInfo();
|
|
|
|
|
+ urlInfo.setTitle(fosterwxCashWorkwxTaskList.getUrlTitle());
|
|
|
|
|
+ urlInfo.setDesc(fosterwxCashWorkwxTaskList.getUrlDesc());
|
|
|
|
|
+ urlInfo.setUrl(fosterwxCashScheduleTaskList.getSendUrl());
|
|
|
|
|
+ urlInfo.setImage_url(fosterwxCashWorkwxTaskList.getUrlImage());
|
|
|
|
|
+
|
|
|
|
|
+ fosterwxCashBoxClientInfo.setUrlInfo(urlInfo);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ fosterwxCashBoxClientInfoList.add(fosterwxCashBoxClientInfo);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ return AjaxResult.success(fosterwxCashScheduleTaskListList);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据参数获取账号信息
|
|
|
|
|
+ * @since: 1.18.1
|
|
|
|
|
+ * @param: [handle]
|
|
|
|
|
+ * @return: com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile
|
|
|
|
|
+ * @author: lqc
|
|
|
|
|
+ * @date: 2021/10/26
|
|
|
|
|
+ */
|
|
|
|
|
+ private FosterwxMobile getAccountInfo(FosterwxWorkServeHandle handle) {
|
|
|
|
|
+ FosterwxMobile fosterwxMobile = new FosterwxMobile();
|
|
|
|
|
+
|
|
|
|
|
+ // 主体 手机号 组
|
|
|
|
|
+ if (null != handle.getCorpName() && !handle.getCorpName().isEmpty()) {
|
|
|
|
|
+ // 获取主题信息
|
|
|
|
|
+ Corp corp = corpService.getOne(new LambdaQueryWrapper<Corp>().eq(Corp::getName, handle.getCorpName()).last("LIMIT 1"));
|
|
|
|
|
+ if (null != handle.getMobileNo() && !handle.getMobileNo().isEmpty()) {
|
|
|
|
|
+ if (null == corp) return null;
|
|
|
|
|
+
|
|
|
|
|
+ fosterwxMobile = fosterwxMobileService.getOne(new LambdaQueryWrapper<FosterwxMobile>().eq(FosterwxMobile::getMobileNo, handle.getMobileNo()).eq(FosterwxMobile::getWorkWxCorpId, corp.getId()).last("LIMIT 1"));
|
|
|
|
|
+
|
|
|
|
|
+ return fosterwxMobile;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 主体 昵称 组
|
|
|
|
|
+ if (null != handle.getNickName() && !handle.getNickName().isEmpty()) {
|
|
|
|
|
+ if (null == corp) return null;
|
|
|
|
|
+
|
|
|
|
|
+ fosterwxMobile = fosterwxMobileService.getOne(new LambdaQueryWrapper<FosterwxMobile>().eq(FosterwxMobile::getCustserviceName, handle.getNickName()).eq(FosterwxMobile::getWorkWxCorpId, corp.getId()).last("LIMIT 1"));
|
|
|
|
|
+
|
|
|
|
|
+ return fosterwxMobile;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 团队id 昵称 组
|
|
|
|
|
+ if (null != handle.getNickName() && !handle.getNickName().isEmpty() && null != handle.getTeamId() && !handle.getTeamId().isEmpty()) {
|
|
|
|
|
+ fosterwxMobile = fosterwxMobileService.getOne(new LambdaQueryWrapper<FosterwxMobile>().eq(FosterwxMobile::getTeamId, handle.getTeamId()).eq(FosterwxMobile::getCustserviceName, handle.getNickName()).last("LIMIT 1"));
|
|
|
|
|
+
|
|
|
|
|
+ return fosterwxMobile;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 检查入参
|
|
|
|
|
+ * @since: 1.18.1
|
|
|
|
|
+ * @param: [handle]
|
|
|
|
|
+ * @return: java.lang.String
|
|
|
|
|
+ * @author: lqc
|
|
|
|
|
+ * @date: 2021/10/26
|
|
|
|
|
+ */
|
|
|
|
|
+ private String checkParam(FosterwxWorkServeHandle handle) {
|
|
|
|
|
+ // 判断主体 手机号 组
|
|
|
|
|
+ if (null != handle.getMobileNo() && !handle.getMobileNo().isEmpty() && null != handle.getCorpName() && !handle.getCorpName().isEmpty()) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 判断主体 昵称 组
|
|
|
|
|
+ if (null != handle.getNickName() && !handle.getNickName().isEmpty() && null != handle.getCorpName() && !handle.getCorpName().isEmpty()) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 判断团队id 昵称 组
|
|
|
|
|
+ if (null != handle.getNickName() && !handle.getNickName().isEmpty() && null != handle.getTeamId() && !handle.getTeamId().isEmpty()) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return "参数没有设置全,无法根据现有信息获取任务";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping(value = "/saveBoxInfo", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
|
|
|
|
|
+ @ApiOperation(value = "保存小程序信息,已经保存过的小程序更新处理")
|
|
|
|
|
+ public Object saveBoxInfo(FosterwxCashWorkBoxClientInfo fosterwxCashWorkBoxClientInfo) {
|
|
|
|
|
+ if (fosterwxCashWorkBoxClientInfoService.count(new LambdaQueryWrapper<FosterwxCashWorkBoxClientInfo>().eq(FosterwxCashWorkBoxClientInfo::getGhid, fosterwxCashWorkBoxClientInfo.getGhid())) == 0) {
|
|
|
|
|
+ fosterwxCashWorkBoxClientInfoService.save(fosterwxCashWorkBoxClientInfo);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ fosterwxCashWorkBoxClientInfoService.update(fosterwxCashWorkBoxClientInfo, new LambdaQueryWrapper<FosterwxCashWorkBoxClientInfo>().eq(FosterwxCashWorkBoxClientInfo::getGhid, fosterwxCashWorkBoxClientInfo.getGhid()));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return "新增修改成功!";
|
|
|
|
|
+ }
|
|
|
|
|
+}
|