develop
commit
162b7b28f9
|
|
@ -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,19 +327,10 @@ 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);
|
||||
await _services.Update(firstinfo);
|
||||
|
||||
await _services.Delete(endinfo);
|
||||
}
|
||||
firstinfo.GZOpenId = endinfo.GZOpenId;
|
||||
await _services.Update(firstinfo);
|
||||
await _services.Delete(endinfo);
|
||||
}
|
||||
}
|
||||
return newId;
|
||||
|
|
|
|||
|
|
@ -43,24 +43,15 @@ 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()
|
||||
{
|
||||
code = code,
|
||||
client_id = CasdoorConfig.ClientId,
|
||||
client_secret = CasdoorConfig.ClientSecret
|
||||
}),
|
||||
Encoding.UTF8, "application/json"));//
|
||||
new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(
|
||||
new CasdoorRequest()
|
||||
{
|
||||
code = code,
|
||||
client_id = CasdoorConfig.ClientId,
|
||||
client_secret = CasdoorConfig.ClientSecret
|
||||
}),
|
||||
Encoding.UTF8, "application/json"));//
|
||||
if (userinfo != null && userinfo.code == 200 && userinfo.type == "success")
|
||||
{
|
||||
var user = (await _CustomerInfoServices.Query(q => q.UUID == userinfo.result.UnionId)).FirstOrDefault();
|
||||
|
|
|
|||
Loading…
Reference in New Issue