|
|
@@ -14,13 +14,17 @@ import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
import com.cyksj.mapper.GroupsMapper;
|
|
|
import com.cyksj.mapper.HomeGroupMapper;
|
|
|
+import com.cyksj.mapper.UserMapper;
|
|
|
import com.cyksj.model.entity.Account;
|
|
|
import com.cyksj.model.entity.GroupsTrips;
|
|
|
import com.cyksj.model.entity.HomeGroup;
|
|
|
+import com.cyksj.model.entity.User;
|
|
|
import com.cyksj.model.excel.ExcelAccountTemplateData;
|
|
|
import com.cyksj.model.excel.ExcelManageAccountData;
|
|
|
import com.cyksj.model.manage.request.ReqAccountIncrExpiryTime;
|
|
|
import com.cyksj.model.manage.views.AccountView;
|
|
|
+import com.cyksj.model.response.ExpiredAccountRep;
|
|
|
+import com.cyksj.model.response.OrderDonAccountRep;
|
|
|
import com.cyksj.service.mange.CmsAccountService;
|
|
|
import com.cyksj.service.template.TemplateCommonService;
|
|
|
import com.cyksj.web.util.EasyExcelUtils;
|
|
|
@@ -62,6 +66,8 @@ public class CmsAccountController {
|
|
|
|
|
|
private final TemplateCommonService templateCommonService;
|
|
|
|
|
|
+ private final UserMapper userMapper;
|
|
|
+
|
|
|
@GetMapping("/get")
|
|
|
public Result<SearchResult<AccountView>> get(Long userId ,String nickName ,String submitAccount ,String expiryStartTime, String expiryEndTime) {
|
|
|
MapBuilder mapBuilder = MapUtils.flatBuilder(request.getParameterMap());
|
|
|
@@ -143,8 +149,9 @@ public class CmsAccountController {
|
|
|
account.setExpiryTime(data.getExpiryTime());
|
|
|
flag = true;
|
|
|
}
|
|
|
- if (StrUtil.isNotBlank(data.getPassword()) && !data.getPassword().equals(account.getPassword())) {
|
|
|
- account.setPassword(data.getPassword());
|
|
|
+ String new_pass = data.getPassword();
|
|
|
+ if (StrUtil.isNotBlank(new_pass) && !new_pass.trim().equals(account.getPassword())) {
|
|
|
+ account.setPassword(new_pass.trim());
|
|
|
flag = true;
|
|
|
//发放模板消息
|
|
|
templateCommonService.sendAccountTemplateMsg(account);
|
|
|
@@ -214,4 +221,74 @@ public class CmsAccountController {
|
|
|
});
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 拉取最近购买订单的列表
|
|
|
+ */
|
|
|
+ @GetMapping("/get/latest/orders")
|
|
|
+ public Result<List<OrderDonAccountRep>> getLatestOrders() {
|
|
|
+ //最近五分钟
|
|
|
+ DateTime offFive = DateUtil.offsetMinute(DateTime.now(), -5);
|
|
|
+ List<OrderDonAccountRep> list = beanSearcher.searchAll(OrderDonAccountRep.class, MapUtils.builder()
|
|
|
+ .put("time", String.format("od.created_time >= '%s'", offFive))
|
|
|
+ .orderBy(ExpiredAccountRep::getAccountId)
|
|
|
+ .orderBy(ExpiredAccountRep::getNum)
|
|
|
+ .build());
|
|
|
+ list.forEach(data->{
|
|
|
+ User user = userMapper.selectById(data.getUserId());
|
|
|
+ data.setNickname(user != null ? user.getNickname() : "");
|
|
|
+ });
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 15天要到期的账号列表
|
|
|
+ */
|
|
|
+ @GetMapping("/get/expired/accounts")
|
|
|
+ public Result<List<ExpiredAccountRep>> getExpiredAccountsList() {
|
|
|
+ //十五天后
|
|
|
+ DateTime afterFif = DateUtil.offsetDay(DateTime.now(), 15);
|
|
|
+ List<ExpiredAccountRep> list = beanSearcher.searchAll(ExpiredAccountRep.class, MapUtils.builder()
|
|
|
+ .field(ExpiredAccountRep::getExpiredTime, afterFif).op(Operator.LessEqual)
|
|
|
+ .orderBy(ExpiredAccountRep::getAccountId)
|
|
|
+ .orderBy(ExpiredAccountRep::getNum)
|
|
|
+ .build());
|
|
|
+ list.forEach(data->{
|
|
|
+ User user = userMapper.selectById(data.getUserId());
|
|
|
+ data.setNickname(user != null ? user.getNickname() : "");
|
|
|
+ });
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改账号密码 并发放模板消息
|
|
|
+ */
|
|
|
+ @PutMapping("/put")
|
|
|
+ public Result<String> updateAccountPwd(@RequestBody Account accountReq) throws Exception {
|
|
|
+ if (accountReq.getId() == null || StrUtil.isEmpty(accountReq.getPassword())) {
|
|
|
+ return GatewayResponse.FAIL.newBuilder().toResult("缺少必填入参");
|
|
|
+ }
|
|
|
+ Account account = accountService.getById(accountReq.getId());
|
|
|
+ if (account == null) {
|
|
|
+ return GatewayResponse.FAIL.newBuilder().toResult("账号不存在");
|
|
|
+ }
|
|
|
+ Boolean flag = false;
|
|
|
+ if (account != null) {
|
|
|
+ if (accountReq.getExpiryTime() != null) {
|
|
|
+ account.setExpiryTime(accountReq.getExpiryTime());
|
|
|
+ flag = true;
|
|
|
+ }
|
|
|
+ String new_pass = accountReq.getPassword();
|
|
|
+ if (StrUtil.isNotBlank(new_pass) && !new_pass.trim().equals(account.getPassword())) {
|
|
|
+ account.setPassword(new_pass.trim());
|
|
|
+ flag = true;
|
|
|
+ //发放模板消息
|
|
|
+ templateCommonService.sendAccountTemplateMsg(account);
|
|
|
+ }
|
|
|
+ if (flag) {
|
|
|
+ accountService.updateById(account);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
}
|