Pārlūkot izejas kodu

fix 脚本修改账号密码提供接口

zoujiajian 3 gadi atpakaļ
vecāks
revīzija
63b0b32521

+ 66 - 0
netflix-dao/src/main/java/com/cyksj/model/response/ExpiredAccountRep.java

@@ -0,0 +1,66 @@
+package com.cyksj.model.response;
+
+import com.ejlchina.searcher.bean.DbField;
+import com.ejlchina.searcher.bean.DbIgnore;
+import com.ejlchina.searcher.bean.SearchBean;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Date;
+
+/*
+ *项目名: netflix
+ *文件名: ExpiredAccountRep
+ *创建者: JavaZou
+ *创建时间:2023/2/16 15:14
+ */
+@Getter
+@Setter
+@SearchBean(tables = "groups_relation gr left join groups_trips gt on gt.id = gr.groups_id" +
+		" left join account a on a.id = gt.account_id",
+		where = "gr.status = 'validity'")
+public class ExpiredAccountRep {
+	/**
+	 * 账号id
+	 */
+	@DbField("a.id")
+	private Long accountId;
+
+	/**
+	 * 账号
+	 */
+	@DbField("a.account")
+	private String account;
+
+	/**
+	 * 密码
+	 */
+	@DbField("a.password")
+	private String password;
+
+	/**
+	 * 用户id
+	 */
+	@DbField("gr.user_id")
+	@JsonIgnore
+	private Long userId;
+
+	/**
+	 * 用户昵称
+	 */
+	@DbIgnore
+	private String nickname;
+
+	/**
+	 * 座位位置
+	 */
+	@DbField("gr.num")
+	private Integer num;
+
+	/**
+	 * 过期时间
+	 */
+	@DbField("gr.expiry_time")
+	private Date expiredTime;
+}

+ 68 - 0
netflix-dao/src/main/java/com/cyksj/model/response/OrderDonAccountRep.java

@@ -0,0 +1,68 @@
+package com.cyksj.model.response;
+
+import com.ejlchina.searcher.bean.DbField;
+import com.ejlchina.searcher.bean.DbIgnore;
+import com.ejlchina.searcher.bean.SearchBean;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Date;
+
+/*
+ *项目名: netflix
+ *文件名: OrderDonRep
+ *创建者: JavaZou
+ *创建时间:2023/2/16 14:57
+ */
+@Getter
+@Setter
+@SearchBean(tables = "order_don od left join groups_relation gr on gr.id = od.relation_id" +
+		" left join groups_trips gt on gt.id = gr.groups_id" +
+		" left join account a on a.id = gt.account_id",
+		where = ":time: and od.status not in ('close','noPayment','refund')" +
+				" and gr.status = 'validity' and gr.expiry_time is not null")
+public class OrderDonAccountRep {
+	/**
+	 * 账号id
+	 */
+	@DbField("a.id")
+	private Long accountId;
+
+	/**
+	 * 账号
+	 */
+	@DbField("a.account")
+	private String account;
+
+	/**
+	 * 密码
+	 */
+	@DbField("a.password")
+	private String password;
+
+	/**
+	 * 用户id
+	 */
+	@DbField("gr.user_id")
+	@JsonIgnore
+	private Long userId;
+
+	/**
+	 * 用户昵称
+	 */
+	@DbIgnore
+	private String nickname;
+
+	/**
+	 * 座位位置
+	 */
+	@DbField("gr.num")
+	private Integer num;
+
+	/**
+	 * 过期时间
+	 */
+	@DbField("gr.expiry_time")
+	private Date expiredTime;
+}

+ 4 - 1
netflix-web/src/main/java/com/cyksj/config/SaTokenConfigure.java

@@ -27,7 +27,10 @@ public class SaTokenConfigure implements WebMvcConfigurer {
 						"/manage/coupon",
 						"/manage/register/wx/refund/notify",
 						"/manage/register/unLimit",
-						"/manage/gzh/msg/notify"));
+						"/manage/gzh/msg/notify",
+						"/manage/account/get/latest/orders",
+						"/manage/account/get/expired/accounts",
+						"/manage/account/put/account"));
 	}
 }
 

+ 79 - 2
netflix-web/src/main/java/com/cyksj/web/controller/manage/account/CmsAccountController.java

@@ -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();
+	}
 }