Browse Source

Merge branch 'feature-dgy-调整消费者信息添加条件' into DuGuYang

DuGuYang 1 year ago
parent
commit
af9677ecb8

+ 2 - 7
Areas/Api/Controllers/v1/MainServer/ConsumerOrdersController.cs

@@ -301,7 +301,7 @@ namespace MySystem.Areas.Api.Controllers.v1
                     openid = jsonObj["openid"].ToString();
                 }
                 int ConsumerId = 0;
-                ConsumerOpenIds check = maindb.ConsumerOpenIds.FirstOrDefault(m => m.OpenId == openid);
+                Consumers check = maindb.Consumers.FirstOrDefault(m => m.WechatOpenId == openid);
                 if (check == null)
                 {
                     // ConsumerId = PublicFunction.MakeConsumerId();
@@ -313,15 +313,10 @@ namespace MySystem.Areas.Api.Controllers.v1
                     }).Entity;
                     maindb.SaveChanges();
                     ConsumerId = consumer.Id;
-                    check = maindb.ConsumerOpenIds.Add(new ConsumerOpenIds()
-                    {
-                        OpenId = openid,
-                        ConsumerId = ConsumerId,
-                    }).Entity;
                 }
                 else
                 {
-                    ConsumerId = check.ConsumerId;
+                    ConsumerId = check.Id;
                 }
                 maindb.SaveChanges();
                 string OrderNo = DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);

+ 22 - 22
Areas/Api/Controllers/v1/MainServer/ConsumersController.cs

@@ -78,12 +78,12 @@ namespace MySystem.Areas.Api.Controllers.v1
                 }).Entity;
                 maindb.SaveChanges();
                 ConsumerId = check.Id;
-                maindb.ConsumerOpenIds.Add(new ConsumerOpenIds()
-                {
-                    OpenId = openid,
-                    ConsumerId = ConsumerId,
-                });
-                maindb.SaveChanges();
+                // maindb.ConsumerOpenIds.Add(new ConsumerOpenIds()
+                // {
+                //     OpenId = openid,
+                //     ConsumerId = ConsumerId,
+                // });
+                // maindb.SaveChanges();
             }
             else
             {
@@ -175,8 +175,8 @@ namespace MySystem.Areas.Api.Controllers.v1
         {
             JsonData data = JsonMapper.ToObject(value);
             string code = data["code"].ToString(); //微信小程序获取的code
-            // string nickName = data["nickName"].ToString(); //昵称
-            // string avatarUrl = data["avatarUrl"].ToString(); //头像地址
+            string nickName = data["nickName"].ToString(); //昵称
+            string avatarUrl = data["avatarUrl"].ToString(); //头像地址
             string encryptedData = data["encryptedData"].ToString(); //微信小程序获取手机号的数据包
             // string iv = data["iv"].ToString(); //微信小程序获取手机号的IV
             Dictionary<string, object> Obj = new Dictionary<string, object>();
@@ -188,31 +188,31 @@ namespace MySystem.Areas.Api.Controllers.v1
                 mobile = mobile.Split('|')[1];
             }
             int ConsumerId = 0;
-            Consumers check = maindb.Consumers.FirstOrDefault(m => m.AlipayUserId == openid);
+            Consumers check = maindb.Consumers.FirstOrDefault(m => m.WechatOpenId == openid);
             if (check == null)
             {
                 check = maindb.Consumers.Add(new Consumers()
                 {
                     CreateDate = DateTime.Now,
-                    // NickName = filterEmoji(nickName),
-                    // HeadPhoto = avatarUrl,
-                    // Mobile = mobile,
-                    AlipayUserId = openid,
+                    NickName = filterEmoji(nickName),
+                    HeadPhoto = avatarUrl,
+                    Mobile = mobile,
+                    WechatOpenId = openid,
                 }).Entity;
                 maindb.SaveChanges();
                 ConsumerId = check.Id;
-                maindb.ConsumerOpenIds.Add(new ConsumerOpenIds()
-                {
-                    OpenId = openid,
-                    ConsumerId = ConsumerId,
-                });
-                maindb.SaveChanges();
+                // maindb.ConsumerOpenIds.Add(new ConsumerOpenIds()
+                // {
+                //     OpenId = openid,
+                //     ConsumerId = ConsumerId,
+                // });
+                // maindb.SaveChanges();
             }
             else
             {
-                // check.NickName = filterEmoji(nickName);
-                // check.HeadPhoto = avatarUrl;
-                // check.Mobile = mobile;
+                check.NickName = filterEmoji(nickName);
+                check.HeadPhoto = avatarUrl;
+                check.Mobile = mobile;
                 ConsumerId = check.Id;
                 maindb.SaveChanges();
             }