Browse Source

调整接口

lcl 1 year ago
parent
commit
90ac6a3fec

BIN
.DS_Store


BIN
AppStart/.DS_Store


BIN
AppStart/Redis/.DS_Store


+ 1 - 2
AppStart/Redis/Mysql/PosMachinesTwoDbconn.cs

@@ -25,8 +25,7 @@ namespace MySystem
         public PosMachinesTwo Get(string PosSn)
         {
             WebCMSEntities db = new WebCMSEntities();
-            MachineForSnNo machineFor = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == PosSn) ?? new MachineForSnNo();
-            PosMachinesTwo order = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machineFor.SnId);
+            PosMachinesTwo order = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosSn);
             if (order != null)
             {
             }

BIN
Areas/.DS_Store


BIN
Areas/Api/.DS_Store


BIN
Areas/Api/Controllers/.DS_Store


BIN
Areas/Api/Controllers/v1/.DS_Store


+ 1 - 1
Areas/Api/Controllers/v1/MainServer/BusinessController.cs

@@ -121,7 +121,7 @@ namespace MySystem.Areas.Api.Controllers.v1
             string condition = " and Status>=1";
             if (!string.IsNullOrEmpty(data["OrderId"].ToString()))
             {
-                condition += " and OrderId=" + OrderId;
+                condition += " and Id=" + OrderId;
             }
             if (!string.IsNullOrEmpty(data["MerchantId"].ToString()))
             {

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

@@ -372,109 +372,8 @@ namespace MySystem.Areas.Api.Controllers.v1
             }
             else
             {
-                MainModels2.MerchantInfo merchant = maindb2.MerchantInfo.FirstOrDefault(m => m.Id == qrcode.MerchantId) ?? new MainModels2.MerchantInfo();
-                MainModels2.MerchantAddInfo merchantAdd = maindb2.MerchantAddInfo.FirstOrDefault(m => m.Id == qrcode.MerchantId) ?? new  MainModels2.MerchantAddInfo();
-                MainModels2.MerchantParamSet merchantset = maindb2.MerchantParamSet.FirstOrDefault(m => m.Id == qrcode.MerchantId) ?? new  MainModels2.MerchantParamSet();
-                string openid = "";
-                if (PayMode == 1)
-                { 
-                    openid = new AlipayFunction(_accessor.HttpContext).GetAlipayUserId(Code);
-                    if (openid.Contains("|"))
-                    {
-                        openid = openid.Split('|')[0];
-                    }
-                }
-                else
-                {
-                    string result = function.GetWebRequest("https://api.weixin.qq.com/sns/jscode2session?appid=" + new WeChatFunction().AppId + "&secret=" + new WeChatFunction().AppSecret + "&js_code=" + Code + "&grant_type=authorization_code");
-                    function.WriteLog(DateTime.Now.ToString() + "\n" + result, "微信小程序获取openid");
-                    JsonData jsonObj = JsonMapper.ToObject(result);
-                    openid = jsonObj["openid"].ToString();
-                }
-                int ConsumerId = 0;
-                MainModels2.ConsumerOpenIds check = maindb2.ConsumerOpenIds.FirstOrDefault(m => m.OpenId == openid);
-                if (check == null)
-                {
-                    MainModels2.Consumers consumer = maindb2.Consumers.Add(new MainModels2.Consumers()
-                    {
-                        Id = ConsumerId,
-                        CreateDate = DateTime.Now,
-                        WechatOpenId = openid,
-                    }).Entity;
-                    maindb2.SaveChanges();
-                    ConsumerId = consumer.Id;
-                    check = maindb2.ConsumerOpenIds.Add(new MainModels2.ConsumerOpenIds()
-                    {
-                        OpenId = openid,
-                        ConsumerId = ConsumerId,
-                    }).Entity;
-                }
-                else
-                {
-                    ConsumerId = check.ConsumerId;
-                }
-                maindb2.SaveChanges();
-                string OrderNo = DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
-                bool ActFlag = merchantset.IsAll == 1 ? false : true;
-                if(PayMoney < merchantset.MinPayMoney) //支付金额小于活动最小金额,则不分账
-                {
-                    ActFlag = false;
-                }
-                MainModels2.ConsumerOrders order = maindb2.ConsumerOrders.Add(new MainModels2.ConsumerOrders()
-                {
-                    // Id = PublicFunction.MakeConsumerOrderId(),
-                    CreateDate = DateTime.Now, //创建时间
-                    MerchantId = qrcode.MerchantId, //商户
-                    ConsumerId = ConsumerId, //消费者
-                    UserId = merchant.UserId, //创客
-                    PayMode = PayMode, //支付方式
-                    PayMoney = PayMoney, //支付金额
-                    SnNo = SnNo, //SN号
-                    OrderNo = OrderNo,
-                    MaxDivi = ActFlag ? PayMoney * merchantset.DiviPercent / 100 : 0,
-                    IsAct = ActFlag ? 1u : 0u,
-                    MerchantActualAmount = ActFlag ? PayMoney * merchantset.GetPercent / 100 : PayMoney,
-                    SeoDescription = Newtonsoft.Json.JsonConvert.SerializeObject(merchantset),
-                }).Entity;
-                maindb2.SaveChanges();
-                maindb2.ConsumerOrderForNo.Add(new MainModels2.ConsumerOrderForNo()
-                {
-                    OrderNo = OrderNo,
-                    OrderIds = order.Id,
-                });
-                maindb2.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")
-                    {
-                        string tradeNo = obj["alipay_trade_create_response"]["trade_no"].ToString();
-                        Obj.Add("respCode", obj["alipay_trade_create_response"]["code"].ToString());
-                        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 };
-                    }
-                }
-                else if (PayMode == 2)
-                {
-                    string SubMchId = merchantAdd.SubMchid;
-                    string Description = merchant.Name;
-                    string OpenId = openid;
-                    string Key = AppConfig.WeChatParam.AesGemKey;
-                    string NotifyUrl = SpHost + "/api/wechat/notice";
-                    Dictionary<string, string> dic = new WeChatFunction(_accessor.HttpContext).Pay(SubMchId, PayMoney, OrderNo, Description, OpenId, Key, NotifyUrl, ActFlag);
-                    Obj.Add("appId", dic["appId"]); //微信小程序appid
-                    Obj.Add("timeStamp", dic["timeStamp"]); //时间戳
-                    Obj.Add("nonceStr", dic["nonceStr"]); //随机字符串
-                    Obj.Add("package", dic["package"]); //统一支付接口返回的prepayid参数值
-                    Obj.Add("paySign", dic["paySign"]); //支付签名
-                    Obj.Add("ConsumerId", ConsumerId);
-                }
+                string result = function.PostWebRequest(AppConfig.Base.Host2 + "api/v1/consumerorders/pay", "value=" + value);
+                return Newtonsoft.Json.JsonConvert.DeserializeObject<AppResultJson>(result);
             }
             return new AppResultJson() { Status = "1", Info = "", Data = Obj };
         }

+ 0 - 1
Areas/Api/Controllers/v1/MainServer/MerchantAddInfoController.cs

@@ -36,7 +36,6 @@ namespace MySystem.Areas.Api.Controllers.v1
         }
         public AppResultJson AddDo(string value)
         {
-            // value = "{\"AlipayAccount\": \"13308013195\",\"LicenseCopy\": \"/mptest/v2/2023/5/16/330549a279dc65e1.png\",\"CertMerchantName\": \"测试\",\"LicenseNumber\": \"12341674981561J\",\"BusinessTerm\": \"2023-05-18-2023-05-25\",\"SubjectType\": \"SUBJECT_TYPE_INDIVIDUAL\",\"MerchantShortname\": \"测试\",\"ServicePhone\": \"14781419364\",\"QualificationType\": \"食品生鲜,酒类\",\"SpecialQualification\": \"\",\"MerchantAuthorizationLetter\": \"\",\"BizStoreName\": \"测试门店\",\"BizAddressCode\": \"北京市,东城区\",\"BizStoreAddress\": \"天安门红旗下\",\"IdCardCopy\": \"/mptest/v2/2023/5/16/f1a84d2a06113b5d.png\",\"IdCardNational\": \"/mptest/v2/2023/5/16/f50795237dea60ef.png\",\"CertLegalPerson\": \"张晟源\",\"IdCardNumber\": \"51382219940929723\",\"CardPeriodBegin\": \"2023-05-16\",\"CardPeriodEnd\": \"2023-05-19\",\"MobilePhone\": \"13308013195\",\"ContactEmail\": \"13308013195\",\"AccountName\": \"张晟源\",\"BankAccountType\": \"BANK_ACCOUNT_TYPE_PERSONAL\",\"AccountNumber\": \"6135124587452145\",\"AccountBank\": \"工商银行\",\"BankName\": \"中原银行股份有限公司信阳工商支行\",\"BankAddressCode\": \"北京市,东城区\",\"StoreEntrancePic\": \"/mptest/v2/2023/5/16/ac601bd8da78f4c8.png,/mptest/v2/2023/5/16/61d7dabf9aec0589.png\",\"IndoorPic\": \"/mptest/v2/2023/5/16/d20c693f5c15293b.png,/mptest/v2/2023/5/16/bd365c9d677ee77c.png,/mptest/v2/2023/5/16/706a3b275b7ca186.png\",\"ContactName\": \"张晟源\",\"ContactIdNumber\": \"51382219940929723\",\"IdCardName\": \"张晟源\",\"Qualifications\": \"\",\"Finish\": 1,\"UserId\": \"14\",\"Id\": \"\",\"SettlementId\": \"719_C_C05_5921\"}";
             JsonData data = JsonMapper.ToObject(value);
             string ContactName = data["ContactName"].ToString(); //管理员姓名
             string ContactIdNumber = data["ContactIdNumber"].ToString(); //管理员身份证件号码

+ 3 - 0
Areas/Api/Controllers/v1/MainServer/MerchantInfoController.cs

@@ -680,6 +680,9 @@ namespace MySystem.Areas.Api.Controllers.v1
             Obj.Add("WeChatTotal", WeChatTotal.ToString("f2")); //微信实收
             Obj.Add("AlipayTotal", AlipayTotal.ToString("f2")); //支付宝实收
             Obj.Add("CreateDate", query.CreateDate == null ? "" : query.CreateDate.Value.ToString("yyyy-MM-dd"));
+            string yesterday = DateTime.Now.AddDays(-1).ToString("yyyyMMdd");
+            Obj.Add("YesterDayActual", decimal.Parse(function.CheckNum(UserTradeDbconn.Instance.GetTrade(Id, yesterday, "InFactAmount")["InFactAmount"].ToString())).ToString("f2")); //昨日收入
+            Obj.Add("SettleAmount", ""); //待结算金额
             return Obj;
         }
         #endregion

+ 2 - 1
Areas/Api/Controllers/v1/MainServer/MerchantQrCodeController.cs

@@ -42,7 +42,7 @@ namespace MySystem.Areas.Api.Controllers.v1
             int PageNum = int.Parse(function.CheckInt(data["PageNum"].ToString()));
             List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
             MerchantInfo merchant = MerchantInfoDbconn.Instance.Get(MerchantId) ?? new MerchantInfo();
-            IQueryable<MerchantQrCode> query = maindb.MerchantQrCode.Where(m => m.MerchantId == MerchantId);
+            IQueryable<MerchantQrCode> query = maindb.MerchantQrCode.Where(m => m.MerchantId == MerchantId && m.QueryCount == 1);
             if (PageNum == 1)
             {
                 query = query.Take(PageSize);
@@ -106,6 +106,7 @@ namespace MySystem.Areas.Api.Controllers.v1
             Dictionary<string, object> fields = new Dictionary<string, object>();
             fields.Add("MerchantId", MerchantId);
             fields.Add("SnNo", SnNo);
+            fields.Add("QueryCount", 1);
             new MerchantQrCodeService().Add(fields);
             // query = maindb.MerchantQrCode.Add(new MerchantQrCode()
             // {

+ 10 - 0
Services/MerchantTradeSummaryService.cs

@@ -37,6 +37,16 @@ namespace MySystem
             return diclist;
         }
 
+        public bool CheckTableExist(string date)
+        {
+            DataTable dt = CustomerSqlConn.dtable("show Tables like 'MerchantTradeSummaryList" + date + "'", AppConfig.Base.StatConnRds);
+            if(dt.Rows.Count > 0)
+            {
+                return true;
+            }
+            return false;
+        }
+
         /// <summary>
         /// 查询一条记录
         /// </summary>

+ 15 - 8
Util/BusinessUtil.cs

@@ -23,19 +23,23 @@ namespace MySystem
         public static List<Dictionary<string, object>> BussinessRecordForMonth(int MerchantId, string TradeMonth, int pageSize, int pageNum)
         {
             List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
+            if(!new MerchantTradeSummaryService().CheckTableExist(TradeMonth))
+            {
+                return dataList;
+            }
             List<Dictionary<string, object>> source = new MerchantTradeSummaryService().List2(new List<FieldItem>(), " and MerchantId=" + MerchantId, TradeMonth, pageNum, pageSize);
             // var infos = UserTradeDbconn.GetDateTradeList(MerchantId,TradeMonth);
             foreach (Dictionary<string, object> subdata in source)
             {
                 Dictionary<string, object> curData = new Dictionary<string, object>();
                 curData.Add("TradeDate", subdata["TradeDate"].ToString()); //日期
-                curData.Add("TotalAmount", subdata["TotalAmount"].ToString()); //营业总金额
+                curData.Add("TotalAmount", subdata["TradeAmount"].ToString()); //营业总金额
                 curData.Add("InFactAmount", subdata["InFactAmount"].ToString()); //实收总金额
                 curData.Add("ActAmount", subdata["ActAmount"].ToString()); //活动总金额
                 curData.Add("NonActAmount", subdata["NonActAmount"].ToString()); //非活动总金额
-                curData.Add("WeChatInFactAmount", subdata["WeChatInFactAmount"].ToString()); //微信实收
+                curData.Add("WeChatInFactAmount", subdata["WeChatInfactAmount"].ToString()); //微信实收
                 curData.Add("AliPayInFactAmount", subdata["AliPayInFactAmount"].ToString()); //支付宝实收
-                curData.Add("OrderCount", subdata["OrderCount"].ToString()); //订单数
+                curData.Add("OrderCount", subdata["OderCount"].ToString()); //订单数
                 dataList.Add(curData);
             }
             return dataList;
@@ -89,10 +93,10 @@ namespace MySystem
             {
                 Dictionary<string, object> curData = new Dictionary<string, object>();
                 curData.Add("Id", subdata["Id"].ToString()); //订单Id
-                curData.Add("TradeDate", "支付时间" + " " + DateTime.Parse(subdata["CreateDate"].ToString()).ToString("HH:mm:ss")); //日期
+                curData.Add("TradeDate", DateTime.Parse(subdata["CreateDate"].ToString()).ToString("HH:mm:ss")); //日期
                 curData.Add("PayMode", subdata["PayMode"].ToString()); //支付方式(1 支付宝 2 微信)
                 curData.Add("IsAct", subdata["IsAct"].ToString()); //是否活动(1 是 0 否)
-                curData.Add("PayMoney", "+" + subdata["PayMoney"].ToString()); //订单金额
+                curData.Add("PayMoney", subdata["PayMoney"].ToString()); //订单金额
                 dataList.Add(curData);
             }
             return dataList;
@@ -117,18 +121,21 @@ namespace MySystem
                 obj.Add("PayMoney", subdata["PayMoney"].ToString()); //是否活动(1 是 0 否)
                 obj.Add("IsAct", subdata["IsAct"].ToString()); //是否活动(1 是 0 否)
                 obj.Add("OrderNo", subdata["OrderNo"].ToString()); //订单号
-                Dictionary<string, object> cdata = new Dictionary<string, object>();
                 List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
                 List<Dictionary<string, object>> dics = new ConsumerProfitService().List(new List<FieldItem>(), " and OrderId=" + int.Parse(subdata["Id"].ToString()) + "", 1, 999);
+
                 foreach (Dictionary<string, object> dic in dics)
                 {
+                    Dictionary<string, object> cdata = new Dictionary<string, object>();
                     var CreateDate = DateTime.Parse(subdata["CreateDate"].ToString());
                     var TradeDate = CreateDate.Month + "月" + CreateDate.Day + "日" + " " + CreateDate.ToString("HH:mm");
                     cdata.Add("ProfitDate", TradeDate); //分红时间
-                    cdata.Add("ProfitAmount", "+" + dic["GetMoney"].ToString()); //分红金额
+                    cdata.Add("ProfitAmount", dic["GetMoney"].ToString()); //分红金额
                     dataList.Add(cdata);
                 }
-                obj.Add("ProfitTotalAmount", new ConsumerProfitService().Sum(" and OrderId=" + int.Parse(subdata["Id"].ToString()) + "", "GetMoney") + "(元)"); //分红总金额
+                obj.Add("ProfitTotalAmount", new ConsumerProfitService().Sum("GetMoney", " and OrderId=" + int.Parse(subdata["Id"].ToString()) + "")["GetMoney"]); //分红总金额
+                MerchantInfo merchant = new MerchantInfoService().Query(int.Parse(function.CheckInt(subdata["MerchantId"].ToString())));
+                obj.Add("MerchantName", merchant.Name); //门店名称
                 obj.Add("ProfitList", dataList); //订单分红记录列表
             }
             return obj;

+ 13 - 6
Util/UserTradeDbconn.cs

@@ -24,14 +24,21 @@ namespace MySystem
             string fieldList = "";
             foreach(string field in fields.Split(','))
             {
-                fieldList += "sum(" + fieldList + ") " + fieldList + ",";
+                fieldList += "sum(" + field + ") " + field + ",";
             }
-            DataTable dt = CustomerSqlConn.dtable("select " + fieldList.TrimEnd(',') + " from MerchantTradeSummary" + TradeDate + " where MerchantId=" + MerchantId + " and ", AppConfig.Base.StatConnRds);
+            DataTable dt = CustomerSqlConn.dtable("select " + fieldList.TrimEnd(',') + " from MerchantTradeSummary" + TradeDate + " where MerchantId=" + MerchantId + "", AppConfig.Base.StatConnRds);
             if(dt.Rows.Count > 0)
             {
                 foreach(string field in fields.Split(','))
                 {
-                    AmtList.Add(field, dt.Rows[0][0].ToString());
+                    AmtList.Add(field, dt.Rows[0][field].ToString());
+                }
+            }
+            else
+            {
+                foreach(string field in fields.Split(','))
+                {
+                    AmtList.Add(field, "0");
                 }
             }
             return AmtList;
@@ -47,13 +54,13 @@ namespace MySystem
         public List<Dictionary<string, object>> GetDateTradeList(int MerchantId, string TradeMonth, string fields)
         {
             List<Dictionary<string, object>> AmtList = new List<Dictionary<string, object>>();
-            DataTable dt = CustomerSqlConn.dtable("select " + fields + " from MerchantTradeSummary" + TradeMonth + " where MerchantId=" + MerchantId + " and Trade", AppConfig.Base.StatConnRds);
+            DataTable dt = CustomerSqlConn.dtable("select " + fields + " from MerchantTradeSummary" + TradeMonth + " where MerchantId=" + MerchantId + "", AppConfig.Base.StatConnRds);
             if(dt.Rows.Count > 0)
             {
                 Dictionary<string, object> Item = new Dictionary<string, object>();
                 foreach(string field in fields.Split(','))
                 {
-                    Item.Add(field, dt.Rows[0][0].ToString());
+                    Item.Add(field, dt.Rows[0][field].ToString());
                 }
                 AmtList.Add(Item);
             }
@@ -84,7 +91,7 @@ namespace MySystem
                 {
                     foreach(string field in fields.Split(','))
                     {
-                        Item.Add(field, function.CheckNum(dt.Rows[0][0].ToString()));
+                        Item.Add(field, function.CheckNum(dt.Rows[0][field].ToString()));
                     }
                 }
                 else