Jelajahi Sumber

账号修改密码国际用户短信通知;临时mid车票申请候补

zoujiajian 2 tahun lalu
induk
melakukan
e8f1d05269

+ 18 - 7
netflix-common/src/main/java/com/cyksj/common/util/SmsUtil.java

@@ -45,6 +45,9 @@ public class SmsUtil {
     //国际腾讯云短信
     private static final String TENCENT_SMS_INTERNATIONAL_TEMPLATE_ID = "1705927";
 
+    //账号修改密码国际短信通知
+    private static final String TENCENT_SMS_ACCOUNT_INTERNATIONAL_TEMPLATE_ID = "2040574";
+
     private static final Logger log = LoggerFactory.getLogger(SmsUtil.class);
 
     public static void main(String[] args) {
@@ -94,6 +97,19 @@ public class SmsUtil {
     }
 
     public static Boolean sendTencent(Integer cid, String mobile, String msg) {
+        String templateId = TENCENT_SMS_TEMPLATE_ID;
+        if (cid != 86) {
+            templateId = TENCENT_SMS_INTERNATIONAL_TEMPLATE_ID;
+        }
+        return commonSendTencentSmsMsg(templateId, cid, mobile, msg);
+    }
+
+    public static Boolean sendAccountInternalSmsMsg(Integer cid, String mobile, String msg) {
+        String templateId = TENCENT_SMS_ACCOUNT_INTERNATIONAL_TEMPLATE_ID;
+        return commonSendTencentSmsMsg(templateId, cid, mobile, msg);
+    }
+
+    public static Boolean commonSendTencentSmsMsg(String templateId, Integer cid, String mobile, String msg) {
         try {
             /* 必要步骤:
              * 实例化一个认证对象,入参需要传入腾讯云账户密钥对secretId,secretKey。
@@ -108,8 +124,8 @@ public class SmsUtil {
              * 如有需要请在代码中查阅以获取最新的默认值 */
             httpProfile.setConnTimeout(60);
             /* 指定接入地域域名,默认就近地域接入域名为 sms.tencentcloudapi.com ,也支持指定地域域名访问,例如广州地域的域名为 sms.ap-guangzhou.tencentcloudapi.com
-            * 南京地域
-            * */
+             * 南京地域
+             * */
             httpProfile.setEndpoint("sms.ap-nanjing.tencentcloudapi.com");
 
             /* 非必要步骤:
@@ -138,10 +154,6 @@ public class SmsUtil {
             req.setSignName(TENCENT_SMS_SIGN_NAME);
 
             /* 模板 ID: 必须填写已审核通过的模板 ID */
-            String templateId = TENCENT_SMS_TEMPLATE_ID;
-            if (cid != 86) {
-                templateId = TENCENT_SMS_INTERNATIONAL_TEMPLATE_ID;
-            }
             req.setTemplateId(templateId);
 
             /* 模板参数: 模板参数的个数需要与 TemplateId 对应模板的变量个数保持一致,若无模板参数,则设置为空 */
@@ -164,7 +176,6 @@ public class SmsUtil {
             if ("Ok".equalsIgnoreCase(sendStatus.getCode())) {
                 return true;
             }
-            return false;
 
             // 也可以取出单个值,你可以通过官网接口文档或跳转到response对象的定义处查看返回字段的定义
             // System.out.println(res.getRequestId());

+ 3 - 0
netflix-dao/src/main/java/com/cyksj/mapper/GroupsRelationMapper.java

@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateTime;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.cyksj.model.entity.GroupsRelation;
+import com.cyksj.model.entity.PhoneCode;
 import com.cyksj.model.manage.views.GroupsRelationBackView;
 import com.cyksj.model.manage.views.GroupsRelationView;
 import com.cyksj.model.views.GroupsRelationUserView;
@@ -64,4 +65,6 @@ public interface GroupsRelationMapper extends BaseMapper<GroupsRelation> {
 	Integer selectLimitAvailableNum(@Param("skuId") Long skuId, @Param("maxNum") Integer maxNum);
 
 	GroupsRelationBackView getGroupRelationAccountView(Long relationId);
+
+	PhoneCode getAreaPhoneByUserId(Long userId);
 }

+ 12 - 0
netflix-dao/src/main/resources/mapper/GroupRelationMapper.xml

@@ -309,4 +309,16 @@
                  inner join groups_trips gt on gt.id = s.groups_id
                  left join account a on a.id = gt.account_id
     </select>
+
+    <select id="getAreaPhoneByUserId" resultType="com.cyksj.model.entity.PhoneCode">
+        select s.phone, pc.cid
+        from (select if(login_phone != '', login_phone,
+                        (select phone
+                         from user_bind_detail
+                         where user_id = u.id
+                            or email_user_id = u.id limit 1)) as phone
+              from user u
+              where id = #{userId} limit 1) s
+                 left join phone_code pc on pc.phone = s.phone
+    </select>
 </mapper>

+ 2 - 4
netflix-service/src/main/java/com/cyksj/service/mange/group/CmsGroupServiceImpl.java

@@ -191,7 +191,6 @@ public class CmsGroupServiceImpl extends ServiceImpl<GroupsMapper,GroupsTrips> i
         if (trips != null && StrUtil.isNotBlank(trips.getTitle())) {
             title = trips.getTitle();
         }
-        String msg = String.format(Constant.CHANGE_GROUPS_TRIPS_ACCOUNT, title);
         //配置midJourney安全码
         String verifyCodes = groupsTrips.getVerifyCodes();
         List<String> verifyCodeList = null;
@@ -241,7 +240,7 @@ public class CmsGroupServiceImpl extends ServiceImpl<GroupsMapper,GroupsTrips> i
             }
             if (relation.getUserId() != 0 && isPrdEnv && relation.getYhsId() == 0) {
                 //发送短信
-                smsService.sendSmsToRelationUser(relation.getUserId(), msg);
+                smsService.sendSmsToRelationUser(relation.getUserId(), Constant.CHANGE_GROUPS_TRIPS_ACCOUNT, title);
             }
             if (verifyCodeList != null && verifyCodeList.size() > 0 && i < verifyCodeList.size()) {
                 relation.setVerifyCode(verifyCodeList.get(i));
@@ -438,9 +437,8 @@ public class CmsGroupServiceImpl extends ServiceImpl<GroupsMapper,GroupsTrips> i
                 return;
             }
             if (relation.getUserId() != 0 && isPrd && relation.getYhsId() == 0) {
-                String msg = String.format(Constant.CHANGE_GROUPS_TRIPS_ACCOUNT, title);
                 try {
-                    smsService.sendSmsToRelationUser(relation.getUserId(), msg);
+                    smsService.sendSmsToRelationUser(relation.getUserId(), Constant.CHANGE_GROUPS_TRIPS_ACCOUNT, title);
                 } catch (Exception e) {
                 }
             }

+ 1 - 1
netflix-service/src/main/java/com/cyksj/service/sms/SmsService.java

@@ -11,5 +11,5 @@ public interface SmsService {
 	/**
 	 * 发送车队短信通知 车位用户
 	 */
-	void sendSmsToRelationUser(Long userId, String msg) throws Exception;
+	void sendSmsToRelationUser(Long userId, String template, String... title) throws Exception;
 }

+ 16 - 4
netflix-service/src/main/java/com/cyksj/service/sms/impl/SmsServiceImpl.java

@@ -1,8 +1,10 @@
 package com.cyksj.service.sms.impl;
 
 import cn.hutool.core.util.StrUtil;
+import com.cyksj.common.constant.Constant;
 import com.cyksj.common.util.SmsUtil;
 import com.cyksj.mapper.GroupsRelationMapper;
+import com.cyksj.model.entity.PhoneCode;
 import com.cyksj.service.sms.SmsService;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -21,10 +23,20 @@ public class SmsServiceImpl implements SmsService {
 	private final GroupsRelationMapper groupsRelationMapper;
 
 	@Override
-	public void sendSmsToRelationUser(Long userId, String msg) throws Exception {
-		String phone = groupsRelationMapper.getBindPhoneByUserId(userId);
-		if (StrUtil.isNotBlank(phone)) {
-			SmsUtil.sendLuoKey2Msg(phone, msg);
+	public void sendSmsToRelationUser(Long userId, String template, String... objs) throws Exception {
+		PhoneCode areaPhone = groupsRelationMapper.getAreaPhoneByUserId(userId);
+		if (areaPhone != null && StrUtil.isNotBlank(areaPhone.getPhone())) {
+			String phone = areaPhone.getPhone();
+			//国际短信通知
+			if (areaPhone.getCid() != null && areaPhone.getCid() != 86) {
+				if (StrUtil.equals(template, Constant.CHANGE_GROUPS_TRIPS_ACCOUNT)) {
+					log.info("发送手机号:{}国际化短信通知车票账号密码修改", phone);
+					SmsUtil.sendAccountInternalSmsMsg(areaPhone.getCid(), phone, objs[0]);
+				}
+			} else {
+				String msg = String.format(template, objs);
+				SmsUtil.sendLuoKey2Msg(phone, msg);
+			}
 		}
 	}
 }

+ 1 - 2
netflix-service/src/main/java/com/cyksj/service/template/impl/TemplateCommonServiceImpl.java

@@ -232,8 +232,7 @@ public class TemplateCommonServiceImpl implements TemplateCommonService {
 					return;
 				}
 				if (relation.getUserId() != 0 && isPrdEnv && relation.getYhsId() == 0) {
-					String msg = String.format(Constant.CHANGE_GROUPS_TRIPS_ACCOUNT, title);
-					smsService.sendSmsToRelationUser(relation.getUserId(), msg);
+					smsService.sendSmsToRelationUser(relation.getUserId(), Constant.CHANGE_GROUPS_TRIPS_ACCOUNT, title);
 				}
 			}
 		}

+ 1 - 2
netflix-service/src/main/java/com/cyksj/service/user/impl/UserBenefitsServiceImpl.java

@@ -87,8 +87,7 @@ public class UserBenefitsServiceImpl implements UserBenefitsService {
 					if (source != UserBalanceSourceRecord.Source.close && source != UserBalanceSourceRecord.Source.balance && yhsId == 0) {
 						try {
 							//短信到账提醒
-							String msg = String.format(Constant.BALANCE_NOTIFY_MSG, addBalance.divide(BigDecimal.valueOf(100)));
-							smsService.sendSmsToRelationUser(userId, msg);
+							smsService.sendSmsToRelationUser(userId, Constant.BALANCE_NOTIFY_MSG, String.valueOf(addBalance.divide(BigDecimal.valueOf(100))));
 						} catch (Exception e) {
 						}
 					}

+ 4 - 6
netflix-web/src/main/java/com/cyksj/web/controller/group/GroupRelationController.java

@@ -582,17 +582,15 @@ public class GroupRelationController {
     }
 
     /**
-     * 是否有gpt车票可候补
+     * 是否有mid车票可候补
      */
     @GetMapping("/get/standby")
     public Result<GptStandbyResp> getGptStandby() {
         long userId = StpUserUtil.getLoginIdAsLong();
         List<Long> relationUserIdList = userBindRelationService.getRelationUserIdList(userId, null);
-        String condition = " a.created_time < '2023-10-18' and a.account not like '%@rambler.ru%'";
         Number number = beanSearcher.searchCount(RenewalView.class, MapUtils.builder()
                 .field(RenewalView::getUserId, relationUserIdList).op(Operator.InList)
-                .field(RenewalView::getYhsId, 0)
-                .put("condition", condition)
+                .field(RenewalView::getGoodsId, 26)
                 .field(RenewalView::getExpiryTime).op(Operator.NotNull)
                 .build());
         GptStandbyResp gptStandbyResp = new GptStandbyResp();
@@ -619,12 +617,12 @@ public class GroupRelationController {
                 .field(RenewalView::getExpiryTime).op(Operator.NotNull)
                 .build());
         if (number.intValue() == 0) {
-            throw BusinessRuntimeException.getInstance("你未有GPT plus账号");
+            throw BusinessRuntimeException.getInstance("你未有车票账号");
         }
         Integer count = gptTicketStandbyMapper.selectCount(Wrappers.lambdaQuery(GptTicketStandby.class)
                 .in(GptTicketStandby::getUserId, relationUserIdList));
         if (count > 0) {
-            throw BusinessRuntimeException.getInstance("你已申请GPT plus账号候补");
+            throw BusinessRuntimeException.getInstance("你已申请车票账号候补");
         }
         GptTicketStandby gptTicketStandby = new GptTicketStandby();
         gptTicketStandby.setUserId(userId);

+ 41 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/account/CmsAccountController.java

@@ -18,6 +18,8 @@ import com.cyksj.common.annotation.NoSubmit;
 import com.cyksj.common.constant.Constant;
 import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.common.task.GlobalThreadPoolTaskExecutor;
+import com.cyksj.common.util.J11HttpC;
+import com.cyksj.common.util.Jsons;
 import com.cyksj.dto.RedisKey;
 import com.cyksj.dto.Result;
 import com.cyksj.enums.BusinessType;
@@ -58,6 +60,7 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.net.http.HttpResponse;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -353,6 +356,44 @@ public class CmsAccountController {
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
 
+	@GetMapping("/test")
+	public Result<String> stest(MultipartFile file) throws IOException {
+		List<Object> objects = EasyExcel.read(file.getInputStream()).sheet().headRowNumber(0).doReadSync();
+
+		String url = "https://plus1.caifree.com/api?email=%s";
+		objects.forEach(e->{
+			Map<String, Object> map = Jsons.toMap(e);
+			String account = String.valueOf(map.get("0"));
+			if (StrUtil.isNotEmpty(account)) {
+				String formatUrl = String.format(url, account);
+				try {
+					HttpResponse<String> send = J11HttpC.custom()
+							.ofGet()
+							.url(formatUrl)
+							.send(HttpResponse.BodyHandlers.ofString());
+					System.out.println(send.body());
+				} catch (Exception exception) {
+
+				}
+			}
+
+		});
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
+
+	public static void main(String[] args) {
+		String url = "https://plus1.caifree.com/api?email=sentzb99@gmail.com";
+		try {
+			HttpResponse<String> send = J11HttpC.custom()
+					.ofGet()
+					.url(url)
+					.send(HttpResponse.BodyHandlers.ofString());
+			System.out.println(send.body());
+		} catch (Exception exception) {
+
+		}
+	}
+
     @PostMapping("/post")
     @NoSubmit
     @Transactional(rollbackFor = Throwable.class)