|
@@ -2,13 +2,16 @@
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
|
|
+using System.Linq.Expressions;
|
|
using System.Text;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
using ZhonTai.Admin.Core.Attributes;
|
|
using ZhonTai.Admin.Core.Attributes;
|
|
using ZhonTai.Admin.Core.Consts;
|
|
using ZhonTai.Admin.Core.Consts;
|
|
using ZhonTai.Admin.Core.Dto;
|
|
using ZhonTai.Admin.Core.Dto;
|
|
|
|
+using ZhonTai.Admin.Domain.User;
|
|
using ZhonTai.Admin.Repositories.ProjectLink;
|
|
using ZhonTai.Admin.Repositories.ProjectLink;
|
|
using ZhonTai.Admin.Services.DiTuiAPI.Dto;
|
|
using ZhonTai.Admin.Services.DiTuiAPI.Dto;
|
|
|
|
+using ZhonTai.Admin.Services.Notice.Dto;
|
|
using ZhonTai.Admin.Services.ProjectLink.Dto;
|
|
using ZhonTai.Admin.Services.ProjectLink.Dto;
|
|
using ZhonTai.DynamicApi;
|
|
using ZhonTai.DynamicApi;
|
|
using ZhonTai.DynamicApi.Attributes;
|
|
using ZhonTai.DynamicApi.Attributes;
|
|
@@ -226,6 +229,73 @@ namespace ZhonTai.Admin.Services.DiTuiAPI
|
|
return data;
|
|
return data;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 开码
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="id"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpPost]
|
|
|
|
+ [NoOprationLog]
|
|
|
|
+ public async Task<string> BindQrcodeAsync(BindQrcodeInput input)
|
|
|
|
+ {
|
|
|
|
+ // 判断用户是否已经 开码 同租户 同项目 手机号唯一
|
|
|
|
+ var doubleUser = await _ProjectLinkRepository.Select.Where(a => a.SalesmanPhone == input.SalesmanPhone && a.ProjectId == input.ProjectId)
|
|
|
|
+ .FirstAsync(a => new { a.Salesman, a.SalesmanPhone, a.Id });
|
|
|
|
+ if(doubleUser != null)
|
|
|
|
+ {
|
|
|
|
+ throw ResultOutput.Exception($"手机号已开码");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 查询未使用的链接的第一条数据
|
|
|
|
+ var existsLink = await _ProjectLinkRepository.Select.Where(a => a.IsUse == 0 && a.ProjectId == input.ProjectId)
|
|
|
|
+ .FirstAsync(a => new { a.Id, a.ModifiedTime});
|
|
|
|
+ if (existsLink == null)
|
|
|
|
+ {
|
|
|
|
+ throw ResultOutput.Exception($"当前项目已无可用链接");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var qrcode = await _ProjectLinkRepository.GetAsync(existsLink.Id);
|
|
|
|
+ if (!(qrcode?.Id > 0))
|
|
|
|
+ {
|
|
|
|
+ throw ResultOutput.Exception("链接不存在");
|
|
|
|
+ }
|
|
|
|
+ if(qrcode?.IsUse > 0)
|
|
|
|
+ {
|
|
|
|
+ throw ResultOutput.Exception("链接已使用,请重新开码");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Mapper.Map(input, qrcode);
|
|
|
|
+ qrcode.IsUse = 1;
|
|
|
|
+
|
|
|
|
+ await _ProjectLinkRepository.UpdateAsync(qrcode);
|
|
|
|
+
|
|
|
|
+ // 返回 链接ID
|
|
|
|
+ return qrcode.Id.ToString();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 获取开码信息
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="id">二维码ID(链接ID)</param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpGet]
|
|
|
|
+ [NoOprationLog]
|
|
|
|
+ public async Task<BindQrcodeOutput> GetBindQrcodeAsync(long id = 0)
|
|
|
|
+ {
|
|
|
|
+ if (id == 0)
|
|
|
|
+ {
|
|
|
|
+ throw ResultOutput.Exception($"无效参数");
|
|
|
|
+ }
|
|
|
|
+ var result = await _ProjectLinkRepository.GetAsync<BindQrcodeOutput>(id);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 判断字符串是否是手机号
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="str_handset"></param>
|
|
|
|
+ /// <returns></returns>
|
|
private static bool IsPhoneNumber(string str_handset)
|
|
private static bool IsPhoneNumber(string str_handset)
|
|
{
|
|
{
|
|
return System.Text.RegularExpressions.Regex.IsMatch(str_handset, @"^1[3456789]\d{9}$");
|
|
return System.Text.RegularExpressions.Regex.IsMatch(str_handset, @"^1[3456789]\d{9}$");
|