浏览代码

Merge branch 'DuGuYang' into feature-dgy-功能测试

DuGuYang 1 年之前
父节点
当前提交
b69513c47b

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

@@ -325,6 +325,7 @@ namespace MySystem.Areas.Api.Controllers.v1
                 {
                     ActFlag = false;
                 }
+                if (merchant.IsAct == 0) ActFlag = false;
                 ConsumerOrders order = maindb.ConsumerOrders.Add(new ConsumerOrders()
                 {
                     // Id = PublicFunction.MakeConsumerOrderId(),

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

@@ -196,6 +196,7 @@ namespace MySystem.Areas.Api.Controllers.v1
             Dictionary<string, string> AccountTypes = GetAccountTypes();
             MerchantAddInfo query = MerchantAddInfoDbconn.Instance.Get(Id) ?? new MerchantAddInfo();
             List<SettleData> Settles = GetSettles(query.SubjectType);
+            Obj.Add("Kind", 1); //通道(1 直连 2 银联)
             Obj.Add("ContactName", query.ContactName); //管理员姓名
             Obj.Add("ContactIdNumber", query.ContactIdNumber); //管理员身份证件号码
             Obj.Add("OpenId", query.OpenId); //管理员微信openid

+ 7 - 1
Areas/Api/Controllers/v1/MainServer/MerchantInfoController.cs

@@ -244,6 +244,7 @@ namespace MySystem.Areas.Api.Controllers.v1
             int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
             MerchantInfo merchant = MerchantInfoDbconn.Instance.Get(Id) ?? new MerchantInfo();
             MerchantAddInfo addinfo = MerchantAddInfoDbconn.Instance.Get(Id) ?? new MerchantAddInfo();
+            Obj.Add("Kind", 1); //通道(1 直连 2 银联)
             Obj.Add("MerchantName", merchant.Name); //商户名称
             Obj.Add("LegalName", addinfo.CertLegalPerson); //企业法人
             Obj.Add("MerchantMobile", addinfo.MobilePhone); //商户手机号
@@ -543,6 +544,7 @@ namespace MySystem.Areas.Api.Controllers.v1
             int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
             MerchantInfo query = MerchantInfoDbconn.Instance.Get(Id) ?? new MerchantInfo();
             MerchantAddInfo addInfo = MerchantAddInfoDbconn.Instance.Get(Id) ?? new MerchantAddInfo();
+            Obj.Add("MerchantChannel", 1); //商户进件渠道(1 直连 2 银联)
             Obj.Add("Name", query.Name); //名称
             Obj.Add("CreateDate", query.CreateDate == null ? "" : query.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss")); //提交时间
             List<Dictionary<string, object>> AuditResult = new List<Dictionary<string, object>>();
@@ -695,6 +697,7 @@ namespace MySystem.Areas.Api.Controllers.v1
                 TotalActual += decimal.Parse(dic["TotalActual"]);
                 Start = Start.AddDays(1);
             }
+            Obj.Add("MerchantChannel", 1); //商户进件渠道(1 直连 2 银联)
             Obj.Add("TotalAmount", TotalAmount); //营总收益
             Obj.Add("TotalOrder", TotalOrder); //累计订单
             Obj.Add("TotalUser", TotalUser); //会员数
@@ -775,7 +778,8 @@ namespace MySystem.Areas.Api.Controllers.v1
             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("YesterDayActual", decimal.Parse(function.CheckNum(UserTradeDbconn.Instance.GetTrade(Id, yesterday, "InFactAmount")["InFactAmount"].ToString())).ToString("f2")); //昨日收入
+            Obj.Add("YesterDayActual", decimal.Parse(new MerchantAmountSummayService().Sum("TotalActual", " and MerchantId=" + Id + " and TradeDate='" + yesterday + "'")["TotalActual"]).ToString("f2")); //昨日收入
             Obj.Add("SettleAmount", ""); //待结算金额
             return Obj;
         }
@@ -799,6 +803,7 @@ namespace MySystem.Areas.Api.Controllers.v1
             int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
             MerchantInfo query = MerchantInfoDbconn.Instance.Get(Id) ?? new MerchantInfo();
             MerchantAddInfo merchantAddInfo = maindb.MerchantAddInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantAddInfo();
+            Obj.Add("Kind", 1); //通道(1 直连 2 银联)
             Obj.Add("Name", query.Name); //名称
             Obj.Add("Mobile", query.Mobile); //手机号
             Obj.Add("IsAuth", query.IsAuth); //是否认证
@@ -890,6 +895,7 @@ namespace MySystem.Areas.Api.Controllers.v1
                 MerchantQrCode code = new MerchantQrCodeService().Query(Sn);
                 MerchantInfo query = new MerchantInfoService().Query(code.MerchantId);
                 MerchantParamSet set = new MerchantParamSetService().Query(code.MerchantId);
+                Obj.Add("Kind", 1); //通道(1 直连 2 银联)
                 Obj.Add("Name", query.Name); //名称
                 Obj.Add("Mobile", query.Mobile); //手机号
                 Obj.Add("IsAuth", query.IsAuth); //是否认证

+ 95 - 23
Controllers/HomeController.cs

@@ -7,6 +7,7 @@ using Library;
 using LitJson;
 using System;
 using System.IO;
+using System.Text.RegularExpressions;
 
 namespace MySystem.Controllers
 {
@@ -57,31 +58,102 @@ namespace MySystem.Controllers
         public string test()
         {
             string result = "";
-            // List<ReceiverList> Receivers = new List<ReceiverList>();
-            // Receivers.Add(new ReceiverList()
-            // {
-            //     type = "MERCHANT_ID",  //分账接收方类型
-            //     account = "1611167423",  //分账接收方账号
-            //     amount = 1,  //分账金额
-            //     description = "服务费",  //分账描述
-            // });
-            // Receivers.Add(new ReceiverList()
-            // {
-            //     type = "PERSONAL_OPENID",  //分账接收方类型
-            //     account = "ooDpv5LkCKEguE-LMZO-rSV4TDpk",  //分账接收方账号
-            //     amount = 1,  //分账金额
-            //     description = "优惠",  //分账描述
-            // });
-            // result = new WeChatFunction().ProfitShare("1645266943", "4200001846202306021274142861", "2023060214014405449699901", Receivers);
-            // result = new WeChatFunction().AddReceive("1645266943", "PERSONAL_OPENID", "ooDpv5LkCKEguE-LMZO-rSV4TDpk", "", "USER");
-            // result = new WeChatFunction().QueryProfitShare("1645266943", "4200001815202306025662773463", "2023060213335030713572885");
-            // result += new WeChatFunction().Unfreeze("1647917209","4200001851202306296256433756","2023062914544345583469577", "结算");
-            // result += new WeChatFunction().Unfreeze("1647917209","4200001871202306297971809063","2023062914503970424085049", "结算");
-            // result += new WeChatFunction().Unfreeze("1647917209","4200001861202306299303626271","2023062914274571909443048", "结算");
+            WebCMSEntities maindb = new WebCMSEntities();
+            List<string> nos = new List<string>();
+            foreach(string no in nos)
+            {
+                ConsumerOrders order = maindb.ConsumerOrders.FirstOrDefault(m => m.OrderNo == no);
+                if (order != null)
+                {
+                    List<ConsumerOrders> suborders = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrders:Divi:" + order.PayMode + ":" + order.MerchantId, 1, 999999);
+                    if (suborders.Count > 0)
+                    {
+                        ConsumerOrders suborder = suborders.FirstOrDefault(m => m.Id == order.Id);
+                        if (suborder != null)
+                        {
+                            order.CurDivi = suborder.CurDivi;
+                            maindb.SaveChanges();
+                            RedisDbconn.Instance.RemoveFromList("ConsumerOrders:Divi:" + order.PayMode + ":" + order.MerchantId, suborder);
+                            order.ReturnFlag = 0;
+                            maindb.SaveChanges();
+                        }
+                    }
+                }
+            }
+            maindb.Dispose();
 
-            // result = new WeChatFunction().ProfitShareReturn("1646405429", "1611167423", "2023060810550382756164803", DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8), 0.02M);
+            return result;
+        }
 
-            // result = new WeChatFunction().GetPublicKey();
+        public string test2()
+        {
+            string result = "ok";
+            WebCMSEntities maindb = new WebCMSEntities();
+            List<string> nos = new List<string>();
+            nos.Add("2023122118000851456243816,288.4");
+            nos.Add("2023122117593143700062399,341.04");
+            nos.Add("2023122117325908930632327,254.15");
+            nos.Add("2023122116415701143090181,312.26");
+            nos.Add("2023122116413711877723909,276.83");
+            nos.Add("2023122114085649698036050,342.45");
+            nos.Add("2023122313533734425618726,299.78");
+            nos.Add("2023122313282248497454670,246.97");
+            nos.Add("2023122311000256069736155,261.82");
+            nos.Add("2023122310594073141191302,304.84");
+            nos.Add("2023122520210853072569713,191.59");
+            nos.Add("2023122518244789260165229,186.53");
+            nos.Add("2023122515274323574090329,275.95");
+            nos.Add("2023122515252336206794004,261.82");
+            nos.Add("2023122619342154468765968,178.31");
+            nos.Add("2023122618011435195726036,258.07");
+            nos.Add("2023122618001597671800401,248.51");
+            nos.Add("2023122615422945713502403,191.84");
+            nos.Add("2023122613362000858247931,227.61");
+            nos.Add("2023122820200788070426381,198.57");
+            nos.Add("2023122820125421416300639,237.29");
+            nos.Add("2023122820123371996899445,182.56");
+            nos.Add("2023122814020384897788563,167.38");
+            nos.Add("2023122811030268206294741,228.91");
+            nos.Add("2023122810460690412361230,210.46");
+            nos.Add("2023122810364031620851479,202.11");
+            nos.Add("2023122811124893906532985,224.09");
+            nos.Add("2023122917185120082183642,152.23");
+            nos.Add("2023122911233689014204746,163.27");
+            nos.Add("2023122911214057116568112,122.39");
+            nos.Add("2023122911184819662469868,180.80");
+            foreach(string sub in nos)
+            {
+                string[] data = sub.Split(',');
+                string no = data[0];
+                decimal CurDivi = decimal.Parse(data[1]);
+                ConsumerOrders order = maindb.ConsumerOrders.FirstOrDefault(m => m.OrderNo == no);
+                if (order != null)
+                {
+                    JsonData ProfitInfo = JsonMapper.ToObject(order.SeoDescription);
+                    int ProfitDays = int.Parse(function.CheckInt(ProfitInfo["ProfitDays"].ToString())); //活动有效时间
+                    if (order.IsAct == 1)
+                    {
+                        if (order.MaxDivi > order.CurDivi)
+                        {
+                            List<ConsumerOrders> suborders = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrders:Divi:" + order.PayMode + ":" + order.MerchantId);
+                            if (suborders.Count > 0)
+                            {
+                                ConsumerOrders suborder = suborders.FirstOrDefault(m => m.Id == order.Id);
+                                if (suborder == null)
+                                {
+                                    order.CurDivi = CurDivi;
+                                    order.SeoDescription = Regex.Replace(function.CheckNull(order.SeoDescription), "\"UpdateDate\":\".*?\"", "\"UpdateDate\":\"" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + "\"");
+                                    order.SeoDescription = Regex.Replace(function.CheckNull(order.SeoDescription), "\"ProfitDays\":.*?,", "\"ProfitDays\":254,");
+                                    RedisDbconn.Instance.AddRightList("ConsumerOrders:Divi:" + order.PayMode + ":" + order.MerchantId, order);
+                                    order.ReturnFlag = 1;
+                                    maindb.SaveChanges();
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            maindb.Dispose();
 
             return result;
         }

+ 78 - 24
Util/BusinessUtil.cs

@@ -2,6 +2,7 @@ using MySystem.MainModels;
 using Library;
 using System.Collections.Generic;
 using System;
+using System.Data;
 
 namespace MySystem
 {
@@ -10,7 +11,7 @@ namespace MySystem
     /// </summary>
     public class BusinessUtil
     {
-        
+
         #region 经营数据记录(月)
         /// <summary>
         /// 经营数据记录(月)
@@ -23,23 +24,50 @@ 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))
+            if (!new MerchantTradeSummaryService().CheckTableExist(TradeMonth))
             {
                 return dataList;
             }
-            List<Dictionary<string, object>> source = new MerchantTradeSummaryService().List2(new List<FieldItem>(), " and MerchantId=" + MerchantId, TradeMonth, pageNum, pageSize, "TradeDate desc");
-            // var infos = UserTradeDbconn.GetDateTradeList(MerchantId,TradeMonth);
-            foreach (Dictionary<string, object> subdata in source)
+            // List<Dictionary<string, object>> source = new MerchantTradeSummaryService().List2(new List<FieldItem>(), " and MerchantId=" + MerchantId, TradeMonth, pageNum, pageSize, "TradeDate desc");
+            // // 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["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("AliPayInFactAmount", subdata["AliPayInFactAmount"].ToString()); //支付宝实收
+            //     curData.Add("OrderCount", subdata["OderCount"].ToString()); //订单数
+            //     curData.Add("Kind", 1); //通道(1 直连 2 银联)
+            //     dataList.Add(curData);
+            // }
+            // return dataList;
+
+            string limit = " limit " + pageSize;
+            if (pageNum > 1)
+            {
+                int skip = (pageNum - 1) * pageSize;
+                limit = " limit " + skip + "," + pageSize;
+            }
+            DataTable dt = CustomerSqlConn.dtable("select TradeDate,sum(TradeAmount) TotalAmount,sum(TotalActual) InFactAmount,sum(if(IsAct=1,TradeAmount,0)) ActAmount,sum(if(IsAct=0,TradeAmount,0)) NonActAmount,sum(if(PayMode=2,TotalActual,0)) WeChatInFactAmount,sum(if(PayMode=1,TotalActual,0)) AliPayInFactAmount,sum(TradeCount) OrderCount from MerchantAmountSummay where MerchantId=" + MerchantId + " and TradeMonth='" + TradeMonth + "' group by TradeDate order by TradeDate desc" + limit, AppConfig.Base.SqlConnStr);
+            if (dt.Rows.Count < 1)
+            {
+                return dataList;
+            }
+            foreach (DataRow subdata in dt.Rows)
             {
                 Dictionary<string, object> curData = new Dictionary<string, object>();
                 curData.Add("TradeDate", subdata["TradeDate"].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("AliPayInFactAmount", subdata["AliPayInFactAmount"].ToString()); //支付宝实收
-                curData.Add("OrderCount", subdata["OderCount"].ToString()); //订单数
+                curData.Add("TotalAmount", decimal.Parse(subdata["TotalAmount"].ToString()).ToString("f2")); //营业总金额
+                curData.Add("InFactAmount", decimal.Parse(subdata["InFactAmount"].ToString()).ToString("f2")); //实收总金额
+                curData.Add("ActAmount", decimal.Parse(subdata["ActAmount"].ToString()).ToString("f2")); //活动总金额
+                curData.Add("NonActAmount", decimal.Parse(subdata["NonActAmount"].ToString()).ToString("f2")); //非活动总金额
+                curData.Add("WeChatInFactAmount", decimal.Parse(subdata["WeChatInfactAmount"].ToString()).ToString("f2")); //微信实收
+                curData.Add("AliPayInFactAmount", decimal.Parse(subdata["AliPayInFactAmount"].ToString()).ToString("f2")); //支付宝实收
+                curData.Add("OrderCount", subdata["OrderCount"].ToString()); //订单数
                 curData.Add("Kind", 1); //通道(1 直连 2 银联)
                 dataList.Add(curData);
             }
@@ -59,19 +87,45 @@ namespace MySystem
         public static List<Dictionary<string, object>> BussinessRecordForHalfYear(int MerchantId, int pageSize, int pageNum)
         {
             List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
-            List<Dictionary<string, object>> source = UserTradeDbconn.Instance.GetMonthTradeList(MerchantId, "TradeAmount,InFactAmount,ActAmount,NonActAmount,WeChatInFactAmount,AliPayInFactAmount,OderCount");
-            foreach (Dictionary<string, object> subdata in source)
+            // List<Dictionary<string, object>> source = UserTradeDbconn.Instance.GetMonthTradeList(MerchantId, "TradeAmount,InFactAmount,ActAmount,NonActAmount,WeChatInFactAmount,AliPayInFactAmount,OderCount");
+            // 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["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("AliPayInFactAmount", subdata["AliPayInFactAmount"].ToString()); //支付宝实收
+            //     curData.Add("OrderCount", subdata["OderCount"].ToString()); //订单数
+            //     dataList.Add(curData);
+            // }
+
+
+            var end = DateTime.Now.ToString("yyyyMM");
+            var start = DateTime.Now.AddMonths(-5).ToString("yyyyMM");
+            DataTable dt = CustomerSqlConn.dtable("SELECT TradeMonth 日期,SUM(TradeAmount) 营业总金额,SUM(TotalActual) 实收总金额,SUM(IF(IsAct=1,TotalActual,0)) 活动总金额,SUM(IF(IsAct=0,TotalActual,0)) 非活动总金额,SUM(IF(PayMode=1,TotalActual,0)) 微信实收,SUM(IF(PayMode=2,TotalActual,0)) 支付宝实收,SUM(TradeCount) 订单数 FROM MerchantAmountSummay WHERE MerchantId=" + MerchantId + " AND TradeMonth>='" + start + "' AND TradeMonth<='" + end + "' GROUP BY TradeMonth ORDER BY TradeMonth DESC", AppConfig.Base.SqlConnStr);
+            if (dt.Rows.Count < 1)
             {
-                Dictionary<string, object> curData = new Dictionary<string, object>();
-                curData.Add("TradeDate", subdata["TradeDate"].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("AliPayInFactAmount", subdata["AliPayInFactAmount"].ToString()); //支付宝实收
-                curData.Add("OrderCount", subdata["OderCount"].ToString()); //订单数
-                dataList.Add(curData);
+                return dataList;
+            }
+            else
+            {
+                foreach (DataRow item in dt.Rows)
+                {
+                    Dictionary<string, object> curData = new Dictionary<string, object>();
+                    var TradeDate = item["日期"].ToString();
+                    curData.Add("TradeDate", TradeDate.Substring(0, 4) + "-" + TradeDate.Substring(TradeDate.Length - 2, 2)); //日期
+                    curData.Add("TotalAmount", decimal.Parse(item["营业总金额"].ToString()).ToString("f2")); //营业总金额
+                    curData.Add("InFactAmount", decimal.Parse(item["实收总金额"].ToString()).ToString("f2")); //实收总金额
+                    curData.Add("ActAmount", decimal.Parse(item["活动总金额"].ToString()).ToString("f2")); //活动总金额
+                    curData.Add("NonActAmount", decimal.Parse(item["非活动总金额"].ToString()).ToString("f2")); //非活动总金额
+                    curData.Add("WeChatInFactAmount", decimal.Parse(item["微信实收"].ToString()).ToString("f2")); //微信实收
+                    curData.Add("AliPayInFactAmount", decimal.Parse(item["支付宝实收"].ToString()).ToString("f2")); //支付宝实收
+                    curData.Add("OrderCount", item["订单数"].ToString()); //订单数
+                    dataList.Add(curData);
+                }
             }
             return dataList;
         }