DuGuYang 1 year ago
parent
commit
9e1baf587f
1 changed files with 9 additions and 14 deletions
  1. 9 14
      Areas/Api/Controllers/v1/MainServer/ConsumerOrdersController.cs

+ 9 - 14
Areas/Api/Controllers/v1/MainServer/ConsumerOrdersController.cs

@@ -243,10 +243,10 @@ namespace MySystem.Areas.Api.Controllers.v1
             JsonData data = JsonMapper.ToObject(value);
             string SnNo = data["Sn"].ToString(); //码牌SN
             // string Machine = data["Machine"].ToString();
-            if(SnNo.Length > 20)
+            if (SnNo.Length > 20)
             {
                 SnNo = System.Web.HttpUtility.UrlDecode(SnNo);
-                if(!SnNo.EndsWith("="))
+                if (!SnNo.EndsWith("="))
                 {
                     SnNo += "=";
                 }
@@ -274,14 +274,14 @@ namespace MySystem.Areas.Api.Controllers.v1
             PosMachinesTwo pos = PosMachinesTwoDbconn.Instance.Get(SnNo) ?? new PosMachinesTwo();
             // PosMachines machine = PosMachinesDbconn.Instance.Get(qrcode.SnId) ?? new PosMachines();
             // if (machine.BindMerchantId == 0) machine.BindMerchantId = 1; // TODO: 需要绑定二维码
-            if(pos.OpId == 1)
+            if (pos.OpId == 1)
             {
                 MerchantInfo merchant = MerchantInfoDbconn.Instance.Get(qrcode.MerchantId) ?? new MerchantInfo();
                 MerchantAddInfo merchantAdd = MerchantAddInfoDbconn.Instance.Get(qrcode.MerchantId) ?? new MerchantAddInfo();
                 MerchantParamSet merchantset = MerchantParamSetDbconn.Instance.Get(qrcode.MerchantId) ?? new MerchantParamSet();
                 string openid = "";
                 if (PayMode == 1)
-                { 
+                {
                     openid = new AlipayFunction(_accessor.HttpContext).GetAlipayUserId(Code);
                     if (openid.Contains("|"))
                     {
@@ -296,7 +296,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();
@@ -308,20 +308,15 @@ 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);
                 bool ActFlag = merchantset.IsAll == 1 ? false : true;
-                if(PayMoney < merchantset.MinPayMoney) //支付金额小于活动最小金额,则不分账
+                if (PayMoney < merchantset.MinPayMoney) //支付金额小于活动最小金额,则不分账
                 {
                     ActFlag = false;
                 }
@@ -350,7 +345,7 @@ namespace MySystem.Areas.Api.Controllers.v1
                 });
                 maindb.SaveChanges();
                 if (PayMode == 1)
-                { 
+                {
                     string backString = new AlipayFunction(_accessor.HttpContext).CreateTrade(OrderNo, merchant.Name, PayMoney, openid, merchantAdd.AlipayAuthToken, SpHost + "/api/alipay/notice");
                     JsonData obj = JsonMapper.ToObject(backString);
                     if (obj["alipay_trade_create_response"]["code"].ToString() == "10000")
@@ -360,7 +355,7 @@ namespace MySystem.Areas.Api.Controllers.v1
                         Obj.Add("tradeNo", tradeNo);
                     }
                     else
-                    { 
+                    {
                         Obj.Add("respCode", obj["alipay_trade_create_response"]["code"].ToString());
                         Obj.Add("tradeNo", "");
                         return new AppResultJson() { Status = "-1", Info = obj["alipay_trade_create_response"]["sub_msg"].ToString(), Data = Obj };