调整数据同步问题
parent
052f19a6fd
commit
be73ebb3bc
|
|
@ -22,7 +22,7 @@ namespace New_College.Api.Controllers.Front
|
||||||
{
|
{
|
||||||
[Route("api/front/[controller]/[action]")]
|
[Route("api/front/[controller]/[action]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Authorize(Roles = "users")]
|
[Authorize]
|
||||||
public class CustomerController : ControllerBase
|
public class CustomerController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly IV_CustomerInfoServices _services;
|
private readonly IV_CustomerInfoServices _services;
|
||||||
|
|
@ -194,6 +194,11 @@ namespace New_College.Api.Controllers.Front
|
||||||
response.OpenId = result.openid;
|
response.OpenId = result.openid;
|
||||||
response.Id = save;
|
response.Id = save;
|
||||||
}
|
}
|
||||||
|
//同步合并公众号与微信小程序数据
|
||||||
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
await updatesync(result.unionid);
|
||||||
|
});
|
||||||
TokenModelJwt tokenModel = new TokenModelJwt { Uid = response.Id, Role = "users" };
|
TokenModelJwt tokenModel = new TokenModelJwt { Uid = response.Id, Role = "users" };
|
||||||
response.Token = JwtHelper.IssueJwt(tokenModel);
|
response.Token = JwtHelper.IssueJwt(tokenModel);
|
||||||
response.session_key = result.session_key;
|
response.session_key = result.session_key;
|
||||||
|
|
@ -249,7 +254,7 @@ namespace New_College.Api.Controllers.Front
|
||||||
{
|
{
|
||||||
await DistrFanc(request.SaleId, customerinfo.Id);
|
await DistrFanc(request.SaleId, customerinfo.Id);
|
||||||
});
|
});
|
||||||
newId = await updatesync(customerinfo.Phone);
|
// newId = await updatesync(customerinfo.Phone);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
@ -304,18 +309,17 @@ namespace New_College.Api.Controllers.Front
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 同步合并数据
|
/// 同步合并数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="phone"></param>
|
/// <param name="uuid"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private async Task<int> updatesync(string phone)
|
private async Task<int> updatesync(string uuid)
|
||||||
{
|
{
|
||||||
int newId = 0;
|
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)
|
if (customer.Count() > 1)
|
||||||
{
|
{
|
||||||
var exists = customer.Exists(e => !string.IsNullOrWhiteSpace(e.UUID));
|
var firstinfo = customer.FirstOrDefault(e => !string.IsNullOrWhiteSpace(e.UUID) && e.IsDelete == false && string.IsNullOrWhiteSpace(e.GZOpenId));
|
||||||
if (exists)
|
if (firstinfo != null)
|
||||||
{
|
{
|
||||||
var firstinfo = customer.FirstOrDefault(e => !string.IsNullOrWhiteSpace(e.UUID));
|
|
||||||
newId = firstinfo.Id;
|
newId = firstinfo.Id;
|
||||||
var endinfo = customer.FirstOrDefault(e => e.Id != firstinfo.Id);
|
var endinfo = customer.FirstOrDefault(e => e.Id != firstinfo.Id);
|
||||||
firstinfo.IsVIP = endinfo.IsVIP ? true : firstinfo.IsVIP;
|
firstinfo.IsVIP = endinfo.IsVIP ? true : firstinfo.IsVIP;
|
||||||
|
|
@ -323,19 +327,10 @@ namespace New_College.Api.Controllers.Front
|
||||||
firstinfo.subjectgroupName = endinfo.subjectgroupName;
|
firstinfo.subjectgroupName = endinfo.subjectgroupName;
|
||||||
firstinfo.Subjectgroup = endinfo.Subjectgroup;
|
firstinfo.Subjectgroup = endinfo.Subjectgroup;
|
||||||
firstinfo.OpenId = endinfo.OpenId;
|
firstinfo.OpenId = endinfo.OpenId;
|
||||||
//firstinfo.UserPwd = endinfo.UserPwd;
|
|
||||||
//firstinfo.Salt= endinfo.Salt;
|
|
||||||
firstinfo.NickName = !string.IsNullOrWhiteSpace(endinfo.NickName) ? endinfo.NickName : firstinfo.NickName;
|
firstinfo.NickName = !string.IsNullOrWhiteSpace(endinfo.NickName) ? endinfo.NickName : firstinfo.NickName;
|
||||||
var casdoorinfo = await _casdoorUserServices.QueryById((string)firstinfo.UUID);
|
firstinfo.GZOpenId = endinfo.GZOpenId;
|
||||||
if (casdoorinfo != null)
|
await _services.Update(firstinfo);
|
||||||
{
|
await _services.Delete(endinfo);
|
||||||
|
|
||||||
casdoorinfo.id_card = firstinfo.OpenId;
|
|
||||||
await _casdoorUserServices.Update(casdoorinfo);
|
|
||||||
await _services.Update(firstinfo);
|
|
||||||
|
|
||||||
await _services.Delete(endinfo);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newId;
|
return newId;
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ namespace New_College.Controllers
|
||||||
var response = new CasDoorToken();
|
var response = new CasDoorToken();
|
||||||
string jwtStr = string.Empty;
|
string jwtStr = string.Empty;
|
||||||
bool suc = false;
|
bool suc = false;
|
||||||
var userinfo = CasdoorHttpHelper.Http_Post<JWTSSOResult<MinProWxOutPut>>("/api/syswechat/user_info", null,
|
var userinfo = CasdoorHttpHelper.Http_Post<JWTSSOResult<MinProWxOutPut>>("api/syswechat/user_info", null,
|
||||||
new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(
|
new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(
|
||||||
new CasdoorRequest()
|
new CasdoorRequest()
|
||||||
{
|
{
|
||||||
|
|
@ -55,7 +55,7 @@ namespace New_College.Controllers
|
||||||
if (userinfo != null && userinfo.code == 200 && userinfo.type == "success")
|
if (userinfo != null && userinfo.code == 200 && userinfo.type == "success")
|
||||||
{
|
{
|
||||||
var user = (await _CustomerInfoServices.Query(q => q.UUID == userinfo.result.UnionId)).FirstOrDefault();
|
var user = (await _CustomerInfoServices.Query(q => q.UUID == userinfo.result.UnionId)).FirstOrDefault();
|
||||||
if (user != null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
//没有用户则注册一个新用户
|
//没有用户则注册一个新用户
|
||||||
user = new Model.Models.V_CustomerInfo()
|
user = new Model.Models.V_CustomerInfo()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue