765 lines
30 KiB
C#
765 lines
30 KiB
C#
|
|
using New_College.IServices;
|
|
using New_College.Model.Models;
|
|
using New_College.Services.BASE;
|
|
using New_College.IRepository.Base;
|
|
using New_College.Model.ViewModels;
|
|
using System.Threading.Tasks;
|
|
using New_College.Common;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using New_College.Common.Helper;
|
|
using New_College.Model;
|
|
using LinqKit;
|
|
using New_College.Model.Request;
|
|
using New_College.IRepository;
|
|
using Newtonsoft.Json;
|
|
using New_College.Common.HttpRestSharp;
|
|
using StackExchange.Profiling.Internal;
|
|
using New_College.Repository;
|
|
using System.Xml.Linq;
|
|
using NPOI.HPSF;
|
|
using System.IO;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
namespace New_College.Services
|
|
{
|
|
public class V_CustomerInfoServices : BaseServices<V_CustomerInfo>, IV_CustomerInfoServices
|
|
{
|
|
private readonly IBaseRepository<V_CustomerInfo> _dal;
|
|
private readonly IT_BatchlineRepository t_BatchlineRepository;
|
|
private readonly ICasdoorUserRepository _casdoorUserRepository;
|
|
private readonly ID_UserSettingBaseServices _userSetting;
|
|
private readonly ID_XiaoEtongUserRepository _XiaoEtongUserRepository;
|
|
private readonly IWebHostEnvironment environment;
|
|
public V_CustomerInfoServices(IBaseRepository<V_CustomerInfo> dal, IT_BatchlineRepository t_Batchline, ICasdoorUserRepository casdoorUserRepository, ID_UserSettingBaseServices userSetting, ID_XiaoEtongUserRepository d_XiaoEtongUserRepository, IWebHostEnvironment webHostEnvironment)
|
|
{
|
|
this._dal = dal;
|
|
base.BaseDal = dal;
|
|
t_BatchlineRepository = t_Batchline;
|
|
_casdoorUserRepository = casdoorUserRepository;
|
|
_userSetting = userSetting;
|
|
_XiaoEtongUserRepository = d_XiaoEtongUserRepository;
|
|
environment = webHostEnvironment;
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// vip任务订阅
|
|
/// </summary>
|
|
/// <param name="openid"></param>
|
|
private void MinProVipSubscribe(string openid)
|
|
{
|
|
try
|
|
{
|
|
var data = new Dictionary<string, object>();
|
|
data.Add("thing6.DATA", "邀请注册");
|
|
data.Add("thing11.DATA", "恭喜!您分享的好友已注册成功!获取填报卡一张");
|
|
var access_token = WeixinHelper.GetAccessToken<Access_Token>(WeixinConfig.Appid, WeixinConfig.Secret);
|
|
var subscribe = WeixinHelper.SendSubscribeMessageAsync(access_token.access_token, openid, data);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据要求更新vip状态
|
|
/// </summary>
|
|
/// <param name="saleId"></param>
|
|
public async Task<bool> UpdateIsVip(int saleId)
|
|
{
|
|
var single = await this._dal.QueryById(saleId);
|
|
if (single == null)
|
|
{
|
|
MinProVipSubscribe(single.OpenId);
|
|
}
|
|
|
|
return await this._dal.Update(string.Format("update V_CustomerInfo set IsVIP=1 where Id={0}", saleId));
|
|
}
|
|
/// <summary>
|
|
/// 同步修改密码
|
|
/// </summary>
|
|
/// <param name="query"></param>
|
|
private async void UpdateCasdoorPwd(CasDoorUpdatePwdDto query)
|
|
{
|
|
try
|
|
{
|
|
// DingHookHelper.DingTalkHookMessage("UpdateCasdoorPwd", JsonConvert.SerializeObject(query));
|
|
var list = await _casdoorUserRepository.Query(e => e.id_card == query.openId);
|
|
if (list != null && list.Count() > 0)
|
|
{
|
|
var updatemodels = list.FirstOrDefault();
|
|
updatemodels.password = query.newPassword;
|
|
var up = await _casdoorUserRepository.Update(updatemodels);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
DingHookHelper.DingTalkHookMessage("UpdateCasdoorPwd", ex.Message);
|
|
}
|
|
//获取access_token
|
|
}
|
|
/// <summary>
|
|
/// 修改用户信息
|
|
/// </summary>
|
|
/// <param name="query"></param>
|
|
/// <returns></returns>
|
|
public async Task<CustomerInfoResult> UpdateCustomerInfo(UpdateCustomerQuery query)
|
|
{
|
|
DingHookHelper.DingTalkHookMessage("UpdateCustomerInfo", JsonConvert.SerializeObject(query));
|
|
var info = await _dal.QueryById(query.Id);
|
|
if (info == null)
|
|
return new CustomerInfoResult() { Status = 3 };
|
|
info.NickName = query.NickName;
|
|
//info.Phone = query.Phone;
|
|
info.Gender = query.Gender;
|
|
info.AvatarUrl = query.AvatarUrl;
|
|
if (!string.IsNullOrWhiteSpace(query.UserPwd))
|
|
{
|
|
UpdateCasdoorPwd(new CasDoorUpdatePwdDto()
|
|
{
|
|
newPassword = query.UserPwd,
|
|
openId = info.OpenId,
|
|
service_token = query.service_token
|
|
});
|
|
var salt = RadomHelper.RandCode(6);
|
|
info.UserPwd = MD5Helper.MD5Encrypt16(query.UserPwd + salt);
|
|
}
|
|
var result = await _dal.Update(info);
|
|
|
|
return new CustomerInfoResult()
|
|
{
|
|
Status = 1,
|
|
AvatarUrl = info.AvatarUrl,
|
|
Gender = info.Gender,
|
|
Id = info.Id,
|
|
OpenId = info.OpenId,
|
|
NickName = info.NickName,
|
|
AreaId = info.AreaId,
|
|
AreaName = info.AreaName,
|
|
Datainit = info.Datainit,
|
|
Expectedscore = info.Expectedscore,
|
|
IsVIP = info.IsVIP,
|
|
Subject = info.Subject,
|
|
Subjectgroup = info.Subjectgroup,
|
|
subjectgroupName = info.subjectgroupName,
|
|
VipCode = info.VipCode,
|
|
IsUpdateScore = info.IsUpdateScore,
|
|
Year = info.Year
|
|
};
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 更改分数和学科
|
|
/// </summary>
|
|
/// <param name="query"></param>
|
|
/// <returns></returns>
|
|
public async Task<CustomerInfoResult> UpdateScore(UpdateScoreQuery query)
|
|
{
|
|
var info = await _dal.QueryById(query.StudentId);
|
|
if (info == null)
|
|
return new CustomerInfoResult() { Status = 3 };
|
|
info.IsUpdateScore += 1;
|
|
info.Expectedscore = query.Score;
|
|
info.Subject = query.Subject;
|
|
info.Subjectgroup = query.Subjectgroup;
|
|
info.subjectgroupName = query.subjectgroupName;
|
|
var result = await _dal.Update(info);
|
|
if (result)
|
|
{
|
|
return new CustomerInfoResult()
|
|
{
|
|
Status = 1,
|
|
AvatarUrl = info.AvatarUrl,
|
|
Gender = info.Gender,
|
|
Id = info.Id,
|
|
OpenId = info.OpenId,
|
|
NickName = info.NickName,
|
|
AreaId = info.AreaId,
|
|
AreaName = info.AreaName,
|
|
Datainit = info.Datainit,
|
|
Expectedscore = info.Expectedscore,
|
|
IsVIP = info.IsVIP,
|
|
Subject = info.Subject,
|
|
Subjectgroup = info.Subjectgroup,
|
|
subjectgroupName = info.subjectgroupName,
|
|
VipCode = info.VipCode,
|
|
IsUpdateScore = info.IsUpdateScore,
|
|
Year = info.Year
|
|
};
|
|
}
|
|
else
|
|
{
|
|
return new CustomerInfoResult() { Status = 3 };
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 更新生涯平台数据
|
|
/// </summary>
|
|
/// <param name="sync"></param>
|
|
/// <returns></returns>
|
|
private void UpdateSYCustomer(SyncUpdateCustomerDto sync)
|
|
{
|
|
var postres = HttpHelper.PostApi<dynamic>(ThridConfig.Url, JsonConvert.SerializeObject(sync));
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 完善用户信息
|
|
/// </summary>
|
|
/// <param name="query"></param>
|
|
/// <returns></returns>
|
|
public async Task<CustomerInfoResult> UpdateCustomer(CustomerUpdateQuery query)
|
|
{
|
|
var info = await _dal.QueryById(query.StudentId);
|
|
if (info == null)
|
|
return new CustomerInfoResult() { Status = 3 };
|
|
if (query.AreaId > 0)
|
|
{
|
|
info.AreaId = query.AreaId;
|
|
}
|
|
if (query.Gender.HasValue && query.Gender > 0)
|
|
{
|
|
info.Gender = query.Gender.Value;
|
|
}
|
|
if (!string.IsNullOrEmpty(query.AreaName))
|
|
{
|
|
info.AreaName = query.AreaName;
|
|
}
|
|
if (query.Subject >= 0)
|
|
{
|
|
info.Subject = query.Subject;
|
|
}
|
|
if (!string.IsNullOrEmpty(query.NickName))
|
|
{
|
|
info.NickName = query.NickName;
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(query.Subjectgroup))
|
|
{
|
|
info.Subjectgroup = query.Subjectgroup;
|
|
}
|
|
if (!string.IsNullOrEmpty(query.subjectgroupName))
|
|
{
|
|
info.subjectgroupName = query.subjectgroupName;
|
|
}
|
|
if (query.Expectedscore > 0)
|
|
{
|
|
if (query.Expectedscore != info.Expectedscore)
|
|
{
|
|
// await _userSetting.UpdateSingleCustomerSetting(new UserBaseSettingUpdateDTO() { UType = 0, CustomerId = query.StudentId });//修改参数次数
|
|
info.Expectedscore = query.Expectedscore;
|
|
}
|
|
}
|
|
if (query.Year > 0)
|
|
{
|
|
info.Datainit = true;
|
|
info.Year = query.Year;
|
|
}
|
|
if (!string.IsNullOrEmpty(query.SchoolName))
|
|
{
|
|
info.SchoolName = query.SchoolName;
|
|
}
|
|
if (!string.IsNullOrEmpty(query.ClassName))
|
|
{
|
|
info.ClassName = query.ClassName;
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(query.Phone))
|
|
{
|
|
info.Phone = query.Phone;
|
|
}
|
|
if (!string.IsNullOrEmpty(query.AvatarUrl))
|
|
{
|
|
info.AvatarUrl = query.AvatarUrl;
|
|
}
|
|
var result = await _dal.Update(info);
|
|
if (result)
|
|
{
|
|
//
|
|
//Task.Factory.StartNew(() =>
|
|
//{
|
|
// UpdateSYCustomer(new SyncUpdateCustomerDto()
|
|
// {
|
|
// syncUpdateStudentInfoDto = new SyncUpdateStudentInfoDto()
|
|
// {
|
|
// AreaId = info.AreaId,
|
|
// AreaName = info.AreaName,
|
|
// ClassName = info.ClassName,
|
|
// Datainit = true,
|
|
// Gender = info.Gender,
|
|
// IsVIP = info.IsVIP,
|
|
// NickName = info.NickName,
|
|
// OpenId = info.OpenId,
|
|
// Phone = info.Phone,
|
|
// Salt = info.Salt,
|
|
// SchoolName = info.SchoolName,
|
|
// Status = info.Status,
|
|
// UserCode = info.UserCode,
|
|
// UserPwd = info.UserPwd,
|
|
// Year = info.Year
|
|
// },
|
|
// key = ThridConfig.secretKey
|
|
// });
|
|
//});
|
|
return new CustomerInfoResult()
|
|
{
|
|
Status = 1,
|
|
AvatarUrl = info.AvatarUrl,
|
|
Gender = info.Gender,
|
|
Id = info.Id,
|
|
OpenId = info.OpenId,
|
|
NickName = info.NickName,
|
|
AreaId = info.AreaId,
|
|
AreaName = info.AreaName,
|
|
Datainit = info.Datainit,
|
|
Expectedscore = info.Expectedscore,
|
|
IsVIP = info.IsVIP,
|
|
Subject = info.Subject,
|
|
Subjectgroup = info.Subjectgroup,
|
|
subjectgroupName = info.subjectgroupName,
|
|
VipCode = info.VipCode,
|
|
IsUpdateScore = info.IsUpdateScore,
|
|
CustomerType = info.CustomerType,
|
|
Phone = info.Phone,
|
|
SchoolName = info.SchoolName,
|
|
ClassName = info.ClassName,
|
|
Year = info.Year
|
|
};
|
|
}
|
|
else
|
|
{
|
|
return new CustomerInfoResult() { Status = 3 };
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根绝Id获取用户信息
|
|
/// </summary>
|
|
/// <param name="query"></param>
|
|
/// <returns></returns>
|
|
public async Task<MessageModel<CustomerInfoResult>> GetCustomerInfoById(IdQuery query)
|
|
{
|
|
try
|
|
{
|
|
var info = await _dal.QueryById(query.Id);
|
|
if (info == null || info.IsDelete)
|
|
return new MessageModel<CustomerInfoResult>() { success = false, msg = "获取失败,用户信息为空" };
|
|
var years = info.Year;
|
|
|
|
string typename = "综合";
|
|
if (info.subjectgroupName != null)
|
|
{
|
|
typename = info.subjectgroupName.Length > 2 ? "综合" : info.subjectgroupName;
|
|
|
|
}
|
|
var batchlist = await t_BatchlineRepository.Query(c => c.Year == years && c.AreaName == info.AreaName && c.Type_name == typename);
|
|
string BatchName = string.Empty;
|
|
if (info.AreaName == "河南省")
|
|
{
|
|
BatchName = batchlist.Where(c => c.Average <= info.Expectedscore && c.Batch_name == "本科一批").Any() ? "本科一批" : batchlist.Where(c => c.Average <= info.Expectedscore && c.Batch_name == "本科二批").Any() ? "本科二批" : "专科批";
|
|
}
|
|
else if (info.AreaName == "上海市")
|
|
{
|
|
BatchName = batchlist.Where(c => c.Average <= info.Expectedscore && c.Batch_name == "本科").Any() ? "本科" : "专科";
|
|
}
|
|
else
|
|
{
|
|
|
|
BatchName = batchlist.Where(c => c.Average <= info.Expectedscore && c.Batch_name == "普通类一段").Any() ? "普通类一段" : "普通类二段";
|
|
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(info.Phone) && !info.IsVIP)
|
|
{
|
|
//Task.Run(async () =>
|
|
//{
|
|
// SyncXET(info);
|
|
//});
|
|
}
|
|
|
|
return new MessageModel<CustomerInfoResult>()
|
|
{
|
|
success = true,
|
|
msg = "获取成功",
|
|
response = new CustomerInfoResult()
|
|
{
|
|
AvatarUrl = info.AvatarUrl,
|
|
UserCode = info.UserCode,
|
|
Gender = info.Gender,
|
|
Id = info.Id,
|
|
OpenId = info.OpenId,
|
|
NickName = info.NickName,
|
|
AreaId = info.AreaId,
|
|
AreaName = info.AreaName,
|
|
Datainit = info.Datainit,
|
|
Expectedscore = info.Expectedscore,
|
|
Phone = info.Phone,
|
|
Rank = info.Rank,
|
|
IsVIP = info.IsVIP,
|
|
Subject = info.Subject,
|
|
Subjectgroup = info.Subjectgroup,
|
|
subjectgroupName = info.subjectgroupName,
|
|
VipCode = info.VipCode,
|
|
IsUpdateScore = info.IsUpdateScore,
|
|
Year = info.Year,
|
|
SchoolName = info.SchoolName,
|
|
ClassName = info.ClassName,
|
|
BatchName = BatchName
|
|
}
|
|
};
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new MessageModel<CustomerInfoResult>()
|
|
{
|
|
msg = ex.Message,
|
|
success = false
|
|
|
|
};
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 同步小鹅通
|
|
/// </summary>
|
|
/// <param name="info"></param>
|
|
/// <returns></returns>
|
|
private async Task<V_CustomerInfo> SyncXET(V_CustomerInfo info)
|
|
{
|
|
try
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(info.Phone))
|
|
{
|
|
var xet = XiaoEtongApp.GetUsersList(new UserRequest()
|
|
{
|
|
phone = info.Phone,
|
|
page = 1,
|
|
page_size = 1,
|
|
});
|
|
if (xet != null && xet.data.list != null && xet.data.list.Count() > 0)
|
|
{
|
|
var xiaoetong = (await _XiaoEtongUserRepository.Query(e => e.collect_phone == info.Phone));
|
|
if (!xiaoetong.Any())
|
|
{
|
|
await _XiaoEtongUserRepository.Add(new D_XiaoEtongUser()
|
|
{
|
|
avatar = xet.data.list.First().avatar,
|
|
bind_phone = xet.data.list.First().bind_phone,
|
|
collect_phone = xet.data.list.First().collect_phone,
|
|
CreateBy = "system",
|
|
CreateTime = DateTime.Now,
|
|
from = xet.data.list.First().from,
|
|
IsDelete = false,
|
|
ModifyBy = "system",
|
|
ModifyTime = DateTime.Now,
|
|
OrderSort = 0,
|
|
pay_sum = xet.data.list.First().pay_sum,
|
|
punch_count = xet.data.list.First().punch_count,
|
|
user_created_at = xet.data.list.First().user_created_at,
|
|
user_nickname = xet.data.list.First().user_nickname,
|
|
wx_app_open_id = xet.data.list.First().wx_app_open_id,
|
|
wx_open_id = xet.data.list.First().wx_open_id,
|
|
wx_union_id = xet.data.list.First().wx_union_id,
|
|
user_id = xet.data.list.First().user_id
|
|
});
|
|
var orders = XiaoEtongApp.GetOrdersList(new XETOrdersRequest()
|
|
{
|
|
page = 1,
|
|
page_size = 30,
|
|
user_id = xet.data.list.First().user_id
|
|
});
|
|
if (orders.data.list.Any() && orders.data.list.Count() > 0 && !info.IsVIP)
|
|
{
|
|
// var isvip = orders.data.list.Select(c => c.order_info).Where(e => e.activity_type_bitmap.Contains(11));
|
|
// info.IsVIP = isvip.Count() > 0 ? true : false;
|
|
info.IsVIP = true;
|
|
info.ModifyTime = DateTime.Now;
|
|
await _dal.Update(info);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
catch (Exception exx)
|
|
{
|
|
|
|
}
|
|
return info;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询CustomerInfo表信息
|
|
/// </summary>
|
|
/// <param name="query"></param>
|
|
/// <returns></returns>
|
|
public async Task<MessageModel<PageModel<CustomerInfoListResult>>> GetCustomerInfoListByPage(CustomerSeachQuery query)
|
|
{
|
|
var wheres = PredicateBuilder.New<V_CustomerInfo>();
|
|
wheres = wheres.And(x => x.IsDelete == false);
|
|
if (!string.IsNullOrWhiteSpace(query.Phone))
|
|
wheres = wheres.And(x => x.Phone.Contains(query.Phone));
|
|
if (query.Subject != 2)
|
|
wheres = wheres.And(x => (int)x.Subject == query.Subject);
|
|
if (!string.IsNullOrWhiteSpace(query.VipCode))
|
|
wheres = wheres.And(x => x.VipCode.Contains(query.VipCode));
|
|
var info = await _dal.QueryPage(wheres, query.PageIndex, query.PageSize);
|
|
if (info.data.Count <= 0)
|
|
return new MessageModel<PageModel<CustomerInfoListResult>>()
|
|
{
|
|
success = false,
|
|
msg = "获取失败"
|
|
};
|
|
//var regioninfo = await sysRegionRepository.Query(x => x.ParentCode == "100000");
|
|
PageModel<CustomerInfoListResult> pageModel = new PageModel<CustomerInfoListResult>() { };
|
|
List<CustomerInfoListResult> list = new List<CustomerInfoListResult>() { };
|
|
foreach (var item in info.data)
|
|
{
|
|
list.Add(new CustomerInfoListResult()
|
|
{
|
|
Id = item.Id,
|
|
Phone = item.Phone,
|
|
Subject = item.Subject,
|
|
Subjectgroup = item.Subjectgroup,
|
|
AreaName = item.AreaName,
|
|
Expectedscore = item.Expectedscore,
|
|
VipCode = item.VipCode,
|
|
NickName = item.NickName
|
|
});
|
|
}
|
|
pageModel.data = list;
|
|
pageModel.dataCount = info.dataCount;
|
|
pageModel.page = info.page;
|
|
pageModel.pageCount = info.pageCount;
|
|
pageModel.PageSize = info.PageSize;
|
|
return new MessageModel<PageModel<CustomerInfoListResult>>()
|
|
{
|
|
success = true,
|
|
msg = "获取成功",
|
|
response = pageModel
|
|
};
|
|
}
|
|
|
|
public Weixinauthinfo AuthCode2Session(string Code)
|
|
{
|
|
var result = WeixinHelper.AuthCode2Session<Weixinauthinfo>(WeixinConfig.Appid, WeixinConfig.Secret, Code);
|
|
return result;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取accesstoken
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public Access_Token access_Token()
|
|
{
|
|
return WeixinHelper.GetAccessToken<Access_Token>(WeixinConfig.Appid, WeixinConfig.Secret);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
public WxaBusinessGetUserPhoneNumberResponse WxaBusinessGetUserPhoneNumber(WxaBusinessGetUserPhoneNumberRequest request)
|
|
{
|
|
return WeixinHelper.WxaBusinessGetUserPhoneNumber<WxaBusinessGetUserPhoneNumberResponse>(request.access_Token, request.code);
|
|
}
|
|
public string GetWeixinPhone(GetPhoneInfo phoneInfo)
|
|
{
|
|
string phone = string.Empty;
|
|
try
|
|
{
|
|
phone = WeixinHelper.getPhoneNumber(phoneInfo.encryptedData, phoneInfo.iv, phoneInfo.session_key);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
}
|
|
return phone;
|
|
}
|
|
|
|
public async Task<Tuple<bool, CustomerInfoResult>> Logined(LoginQuery query)
|
|
{
|
|
|
|
var userinfo = (await _dal.Query(w => w.OpenId == query.openId && w.IsDelete == false)).ToList().FirstOrDefault();
|
|
if (userinfo != null)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(userinfo.UUID))
|
|
{
|
|
userinfo.UUID = query.unionId;
|
|
await _dal.Update(userinfo);
|
|
}
|
|
|
|
//if (!userinfo.IsVIP)
|
|
//{
|
|
// await SyncXET(userinfo);
|
|
//}
|
|
return new Tuple<bool, CustomerInfoResult>(true, new CustomerInfoResult()
|
|
{
|
|
AreaId = userinfo.AreaId,
|
|
AreaName = userinfo.AreaName,
|
|
AvatarUrl = userinfo.AvatarUrl,
|
|
CustomerType = userinfo.CustomerType,
|
|
NickName = userinfo.NickName,
|
|
OpenId = userinfo.OpenId,
|
|
Phone = userinfo.Phone,
|
|
Gender = userinfo.Gender,
|
|
Datainit = userinfo.Datainit,
|
|
Expectedscore = userinfo.Expectedscore,
|
|
IsVIP = userinfo.IsVIP,
|
|
Subject = userinfo.Subject,
|
|
Subjectgroup = userinfo.Subjectgroup,
|
|
subjectgroupName = userinfo.subjectgroupName,
|
|
ClassName = userinfo.ClassName,
|
|
SchoolName = userinfo.SchoolName,
|
|
Year = userinfo.Year,
|
|
Id = userinfo.Id
|
|
});
|
|
}
|
|
else
|
|
{
|
|
return new Tuple<bool, CustomerInfoResult>(false, null);
|
|
}
|
|
}
|
|
|
|
public async Task<Tuple<bool, CustomerInfoResult>> GetUserInfo(LoginQuery query)
|
|
{
|
|
var userinfo = (await _dal.Query(w => w.OpenId == query.openId && w.IsDelete == false)).ToList().First();
|
|
if (userinfo != null)
|
|
{
|
|
return new Tuple<bool, CustomerInfoResult>(true, new CustomerInfoResult()
|
|
{
|
|
|
|
AreaId = userinfo.AreaId,
|
|
AreaName = userinfo.AreaName,
|
|
AvatarUrl = userinfo.AvatarUrl,
|
|
CustomerType = userinfo.CustomerType,
|
|
NickName = userinfo.NickName,
|
|
OpenId = userinfo.OpenId,
|
|
Phone = userinfo.Phone,
|
|
Gender = userinfo.Gender,
|
|
Datainit = userinfo.Datainit,
|
|
Expectedscore = userinfo.Expectedscore,
|
|
IsVIP = userinfo.IsVIP,
|
|
Subject = userinfo.Subject,
|
|
Subjectgroup = userinfo.Subjectgroup,
|
|
subjectgroupName = userinfo.subjectgroupName,
|
|
Year = userinfo.Year,
|
|
Id = userinfo.Id,
|
|
});
|
|
}
|
|
else
|
|
{
|
|
return new Tuple<bool, CustomerInfoResult>(false, null);
|
|
}
|
|
}
|
|
|
|
public async Task<long> GetCustomerId(string OpenId)
|
|
{
|
|
var customerinfo = await _dal.Query(x => x.IsDelete == false && x.OpenId == OpenId);
|
|
if (customerinfo.Count == 0)
|
|
return -1;
|
|
return customerinfo.FirstOrDefault().Id;
|
|
}
|
|
|
|
public async Task<string> GetOpenId(int CustomerId)
|
|
{
|
|
var customerinfo = await _dal.QueryById(CustomerId);
|
|
if (customerinfo == null)
|
|
return "";
|
|
return customerinfo.OpenId;
|
|
}
|
|
|
|
public async Task<int> CustomerSave(DecryptUserInfoRequest register)
|
|
{
|
|
var i = await _dal.Add(new V_CustomerInfo()
|
|
{
|
|
OpenId = register.openid,
|
|
CustomerType = CustomerTypeEnum.General,
|
|
UUID = register.UnionId
|
|
});
|
|
return i;
|
|
}
|
|
|
|
public Task<CustomerInfoResult> Login(CustomerInfoQuery query)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task<bool> SendLogin(PhoneQuery query)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task<int> ResetPwd(ResetPwdQuery query)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task<bool> SendReset(PhoneQuery query)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 定期抓取数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public async Task CustomeBillExport()
|
|
{
|
|
var customer = await _dal.Query(c => c.IsDelete == false && c.CreateTime >= DateTime.Now.AddDays(-7));
|
|
|
|
if (customer.Any())
|
|
{
|
|
var clist = new List<CustomeExportModel>();
|
|
customer.ForEach(c =>
|
|
{
|
|
clist.Add(new CustomeExportModel()
|
|
{
|
|
AreaName = c.AreaName,
|
|
Datainit = c.Datainit.Value ? "是" : "否",
|
|
Expectedscore = c.Expectedscore,
|
|
Gender = c.Gender == 1 ? "男" : c.Gender == 2 ? "女" : "未填写",
|
|
IsVIP = c.IsVIP ? "是" : "否",
|
|
Phone = c.Phone,
|
|
SchoolName = c.SchoolName,
|
|
subjectgroupName = c.subjectgroupName,
|
|
Year = c.Year,
|
|
CreateTime = c.CreateTime.Value.ToString()
|
|
});
|
|
});
|
|
|
|
var outputPath = string.Format("last_week_registeruser_{0}.xlsx", DateTime.Now.ToString("yyyyMMdd")); // 或指定完整的文件路径
|
|
var path = environment.WebRootPath;
|
|
string urlPath = $"/Content/Upload/";
|
|
var newpath = path + urlPath + outputPath;
|
|
string DirectoryName = Path.GetDirectoryName(path + urlPath);
|
|
if (!Directory.Exists(DirectoryName))
|
|
Directory.CreateDirectory(DirectoryName);
|
|
ListExportExcelUtil.ExportToExcel(clist, newpath);
|
|
|
|
string outputres = "Excel/" + outputPath;
|
|
string outputurl = AliYunOssHelper.UploadFile(outputres, newpath);
|
|
System.Threading.Thread.Sleep(1500);
|
|
await MailKitManagement.SendMessageAsync(new List<string>() { SHanDongTel.Mail, "156663459@qq.com" }, new List<string>() { }, "六纬志愿技术团队", string.Format("文件下载地址:<a href='{0}'>上周用户数据</a></p>", outputurl), null, true);
|
|
System.IO.File.Delete(newpath);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
} |