develop
old易 2024-10-08 11:55:21 +08:00
commit 162b7b28f9
2 changed files with 23 additions and 37 deletions

View File

@ -22,7 +22,7 @@ namespace New_College.Api.Controllers.Front
{
[Route("api/front/[controller]/[action]")]
[ApiController]
[Authorize(Roles = "users")]
[Authorize]
public class CustomerController : ControllerBase
{
private readonly IV_CustomerInfoServices _services;
@ -194,6 +194,11 @@ namespace New_College.Api.Controllers.Front
response.OpenId = result.openid;
response.Id = save;
}
//同步合并公众号与微信小程序数据
Task.Run(async () =>
{
await updatesync(result.unionid);
});
TokenModelJwt tokenModel = new TokenModelJwt { Uid = response.Id, Role = "users" };
response.Token = JwtHelper.IssueJwt(tokenModel);
response.session_key = result.session_key;
@ -249,7 +254,7 @@ namespace New_College.Api.Controllers.Front
{
await DistrFanc(request.SaleId, customerinfo.Id);
});
newId = await updatesync(customerinfo.Phone);
// newId = await updatesync(customerinfo.Phone);
}
catch (Exception ex)
@ -304,18 +309,17 @@ namespace New_College.Api.Controllers.Front
/// <summary>
/// 同步合并数据
/// </summary>
/// <param name="phone"></param>
/// <param name="uuid"></param>
/// <returns></returns>
private async Task<int> updatesync(string phone)
private async Task<int> updatesync(string uuid)
{
int newId = 0;
var customer = await _services.Query(c => c.Phone == phone);
var customer = await _services.Query(c => c.UUID == uuid);
if (customer.Count() > 1)
{
var exists = customer.Exists(e => !string.IsNullOrWhiteSpace(e.UUID));
if (exists)
var firstinfo = customer.FirstOrDefault(e => !string.IsNullOrWhiteSpace(e.UUID) && e.IsDelete == false && string.IsNullOrWhiteSpace(e.GZOpenId));
if (firstinfo != null)
{
var firstinfo = customer.FirstOrDefault(e => !string.IsNullOrWhiteSpace(e.UUID));
newId = firstinfo.Id;
var endinfo = customer.FirstOrDefault(e => e.Id != firstinfo.Id);
firstinfo.IsVIP = endinfo.IsVIP ? true : firstinfo.IsVIP;
@ -323,21 +327,12 @@ namespace New_College.Api.Controllers.Front
firstinfo.subjectgroupName = endinfo.subjectgroupName;
firstinfo.Subjectgroup = endinfo.Subjectgroup;
firstinfo.OpenId = endinfo.OpenId;
//firstinfo.UserPwd = endinfo.UserPwd;
//firstinfo.Salt= endinfo.Salt;
firstinfo.NickName = !string.IsNullOrWhiteSpace(endinfo.NickName) ? endinfo.NickName : firstinfo.NickName;
var casdoorinfo = await _casdoorUserServices.QueryById((string)firstinfo.UUID);
if (casdoorinfo != null)
{
casdoorinfo.id_card = firstinfo.OpenId;
await _casdoorUserServices.Update(casdoorinfo);
firstinfo.GZOpenId = endinfo.GZOpenId;
await _services.Update(firstinfo);
await _services.Delete(endinfo);
}
}
}
return newId;
}

View File

@ -43,15 +43,6 @@ namespace New_College.Controllers
var response = new CasDoorToken();
string jwtStr = string.Empty;
bool suc = false;
if (String.IsNullOrWhiteSpace(code))
{
return new MessageModel<CasDoorToken>()
{
success = false,
msg = "参数错误",
response = response
};
}
var userinfo = CasdoorHttpHelper.Http_Post<JWTSSOResult<MinProWxOutPut>>("api/syswechat/user_info", null,
new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(
new CasdoorRequest()