|
@@ -67,32 +67,32 @@ namespace MySystem.Areas.Api.Controllers.v1
|
|
|
return new AppResultJson() { Status = "-1", Info = "授权失败,请重试", Data = Obj };
|
|
|
}
|
|
|
int ConsumerId = 0;
|
|
|
- ConsumerOpenIds check = ConsumerOpenIdsDbconn.Instance.Get(openid);
|
|
|
+ Consumers check = maindb.Consumers.FirstOrDefault(m => m.WechatOpenId == openid);
|
|
|
if (check == null)
|
|
|
{
|
|
|
- // ConsumerId = PublicFunction.MakeConsumerId();
|
|
|
- Consumers consumer = new Consumers()
|
|
|
+ check = maindb.Consumers.Add(new Consumers()
|
|
|
{
|
|
|
- Id = ConsumerId,
|
|
|
CreateDate = DateTime.Now,
|
|
|
NickName = filterEmoji(nickName),
|
|
|
HeadPhoto = avatarUrl,
|
|
|
Mobile = mobile,
|
|
|
WechatOpenId = openid,
|
|
|
- };
|
|
|
- check = new ConsumerOpenIds()
|
|
|
+ }).Entity;
|
|
|
+ maindb.SaveChanges();
|
|
|
+ maindb.ConsumerOpenIds.Add(new ConsumerOpenIds()
|
|
|
{
|
|
|
OpenId = openid,
|
|
|
ConsumerId = ConsumerId,
|
|
|
- };
|
|
|
+ });
|
|
|
+ maindb.SaveChanges();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- Consumers consumer = ConsumersDbconn.Instance.Get(check.ConsumerId);
|
|
|
- consumer.NickName = filterEmoji(nickName);
|
|
|
- consumer.HeadPhoto = avatarUrl;
|
|
|
- consumer.Mobile = mobile;
|
|
|
- ConsumerId = check.ConsumerId;
|
|
|
+ check.NickName = filterEmoji(nickName);
|
|
|
+ check.HeadPhoto = avatarUrl;
|
|
|
+ check.Mobile = mobile;
|
|
|
+ ConsumerId = check.Id;
|
|
|
+ maindb.SaveChanges();
|
|
|
}
|
|
|
Obj.Add("ConsumerId", ConsumerId); //消费者Id
|
|
|
return new AppResultJson() { Status = "1", Info = "", Data = Obj };
|