From 705909e14fe4e9f2fc261ee4eb40a8b41fa2f6d4 Mon Sep 17 00:00:00 2001 From: wzp <2880584989@qq.com> Date: 星期二, 12 七月 2022 17:37:26 +0800 Subject: [PATCH] 增加免密登陆的token --- web/web/GwOrder.ashx | 574 +++++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 471 insertions(+), 103 deletions(-) diff --git a/web/web/GwOrder.ashx b/web/web/GwOrder.ashx index 7e9019d..041cf20 100644 --- a/web/web/GwOrder.ashx +++ b/web/web/GwOrder.ashx @@ -9,6 +9,7 @@ { private GwOrderDao _Dao = new GwOrderDao(); private GwSpDao _GwSpDao = new GwSpDao(); + private GwClientDao _GwClientDao = new GwClientDao(); private GwOpGroupDao _GwOpGroupDao = new GwOpGroupDao(); private GwProductDao _GwProductDao = new GwProductDao(); private SysXhDao _SysXhDao = new SysXhDao(); @@ -22,10 +23,18 @@ private List<GwOpGroup> _GroupList; private List<GwProduct> _ProductList; //浜у搧鍙婁骇鍝佸垎绫� //private List<GwProduct> _ProductClassList; //浜у搧鍒嗙被 + + private int _userId = -1; + private string _userType = ""; + private string _account = ""; public override JsonPageResult ProcessRequestInternal(PageContext<SysUser> context) { string @string = context.GetString("action"); + _userId = context.SessionObject.UserID; + _userType = context.SessionObject.UserType; + _account = context.SessionObject.Account; + switch (@string) { case "delete": @@ -46,6 +55,8 @@ return this.Cancel(context); //鍙栨秷 case "audit": return this.Audit(context); //璁㈠崟瀹℃牳 + case "getOrderBySpId": + return this.GetOrderBySpId(context); //璁㈠崟瀹℃牳 default: throw new Exception("Invalid Action=" + @string); @@ -58,16 +69,18 @@ //Console.WriteLine("List.............[" + context.GetInt("name") + "][" + context.GetInt("classes") + "]"); string spId = context.GetString("spId"); string clientId = context.GetString("clientId"); - string clientName = context.GetString("clientName"); + string compay = context.GetString("compay"); int flag = context.GetInt("flag"); DateTime startDate = context.GetDateTime("startDate"); - DateTime endDate = context.GetDateTime("endDate"); + DateTime endDate = context.GetDateTime("endDate")==DateTime.Parse("0001-01-01 00:00:00")? DateTime.Now : context.GetDateTime("endDate"); int recordCount = 0; int pageSize = context.GetInt("pageSize", 50); int pageIndex = context.GetInt("pageIndex", 1); + + string permissionsSQL = new GwClientDao().GetClientPermissions(_userId, _userType, "GWC"); - List<GwOrder> list = _Dao.LoadInfoList(spId, clientId, clientName, flag, startDate, endDate, pageSize, pageIndex, out recordCount); + List<GwOrder> list = _Dao.LoadInfoList(spId, clientId, compay, flag, startDate, endDate.AddDays(1.0), pageSize, pageIndex, permissionsSQL, out recordCount); string str1 = ""; if (list != null && list.Count > 0) @@ -78,17 +91,20 @@ { ++num; - str1 += "<tr><td>" + bean.OrderId + "</td>"; - str1 = str1 + "<td>" + bean.SpId + "</td>"; - str1 = str1 + "<td>" + bean.ClientId + "-" + bean.ClientName + "</td>"; + //str1 += "<tr><td>" + bean.OrderId + "</td>"; + str1 = str1 + "<tr><td>" + bean.SpId + "</td>"; + str1 = str1 + "<td>" + bean.ClientId + "</td>"; + str1 = str1 + "<td>" + bean.Company + "</td>"; str1 = str1 + "<td>" + ProductToName(bean.ProductId) + "</td>"; //str1 = str1 + "<td>" + bean.ComboId + "</td>"; str1 = str1 + "<td>" + bean.BasicNum + "</td>"; str1 = str1 + "<td>" + bean.GivingNum + "</td>"; - str1 = str1 + string.Format("<td>{0}鍏�/鏉�</td>", (object)(Convert.ToDecimal(bean.Price) / new Decimal(1000))); + str1 = str1 + string.Format("<td>{0}</td>", (object)(Convert.ToDecimal(bean.Price) / new Decimal(1000))); str1 = str1 + "<td>" + bean.OrderNumTotal + "</td>"; - str1 = str1 + string.Format("<td>{0}鍏�</td>", (object)(Convert.ToDecimal(bean.OrderAmountTotal) / new Decimal(1000)));; + str1 = str1 + string.Format("<td>{0}</td>", (object)(Convert.ToDecimal(bean.OrderAmountTotal) / new Decimal(1000))); + str1 = str1 + string.Format("<td>{0}</td>", (object)(Convert.ToDecimal(bean.PayAmount) / new Decimal(1000))); str1 = str1 + "<td>" + bean.BeforeBalanceNum + "</td>"; + str1 = str1 + "<td>" + bean.Auditor + "</td>"; str1 = str1 + "<td>" + bean.Creator + "</td>"; str1 = str1 + "<td>" + bean.CreateTime + "</td>"; str1 = str1 + "<td>" + StatusToName(bean.Status) + "</td>"; @@ -101,7 +117,7 @@ } } else - str1 += "<tr><td colspan=\"14\" style=\"padding-left:5px; text-align: center;\">鏆傛棤淇℃伅</td></tr>"; + str1 += "<tr><td colspan=\"16\" style=\"padding-left:5px; text-align: center;\">鏆傛棤淇℃伅</td></tr>"; return new JsonPageResult(true, new { @@ -115,16 +131,18 @@ { string spId = context.GetString("spId"); string clientId = context.GetString("clientId"); - string clientName = context.GetString("clientName"); + string company = context.GetString("company"); int flag = context.GetInt("flag"); DateTime startDate = context.GetDateTime("startDate"); - DateTime endDate = context.GetDateTime("endDate"); + DateTime endDate = context.GetDateTime("endDate")==DateTime.Parse("0001-01-01 00:00:00")? DateTime.Now : context.GetDateTime("endDate"); int recordCount = 0; int pageSize = context.GetInt("pageSize", 50); int pageIndex = context.GetInt("pageIndex", 1); + + string permissionsSQL = new GwClientDao().GetClientPermissions(_userId, _userType, "GWC"); - List<GwOrder> list = _Dao.LoadInfoList(spId, clientId, clientName, flag, startDate, endDate, pageSize, pageIndex, out recordCount); + List<GwOrder> list = _Dao.LoadInfoList(spId, clientId, company, flag, startDate, endDate.AddDays(1.0), pageSize, pageIndex, permissionsSQL, out recordCount); string str1 = ""; if (list != null && list.Count > 0) @@ -135,17 +153,20 @@ { ++num; - str1 += "<tr><td>" + bean.OrderId + "</td>"; - str1 = str1 + "<td>" + bean.SpId + "</td>"; - str1 = str1 + "<td>" + bean.ClientId + "-" + bean.ClientName + "</td>"; + //str1 += "<tr><td>" + bean.OrderId + "</td>"; + str1 = str1 + "<tr><td>" + bean.SpId + "</td>"; + str1 = str1 + "<td>" + bean.ClientId + "</td>"; + str1 = str1 + "<td>" + bean.Company + "</td>"; str1 = str1 + "<td>" + ProductToName(bean.ProductId) + "</td>"; //str1 = str1 + "<td>" + bean.ComboId + "</td>"; str1 = str1 + "<td>" + bean.BasicNum + "</td>"; str1 = str1 + "<td>" + bean.GivingNum + "</td>"; - str1 = str1 + string.Format("<td>{0}鍏�/鏉�</td>", (object)(Convert.ToDecimal(bean.Price) / new Decimal(1000))); + str1 = str1 + string.Format("<td>{0}</td>", (object)(Convert.ToDecimal(bean.Price) / new Decimal(1000))); str1 = str1 + "<td>" + bean.OrderNumTotal + "</td>"; - str1 = str1 + string.Format("<td>{0}鍏�</td>", (object)(Convert.ToDecimal(bean.OrderAmountTotal) / new Decimal(1000)));; + str1 = str1 + string.Format("<td>{0}</td>", (object)(Convert.ToDecimal(bean.OrderAmountTotal) / new Decimal(1000))); + str1 = str1 + string.Format("<td>{0}</td>", (object)(Convert.ToDecimal(bean.PayAmount) / new Decimal(1000))); str1 = str1 + "<td>" + bean.BeforeBalanceNum + "</td>"; + str1 = str1 + "<td>" + bean.Auditor + "</td>"; str1 = str1 + "<td>" + bean.Creator + "</td>"; str1 = str1 + "<td>" + bean.CreateTime + "</td>"; str1 = str1 + "<td>" + StatusToName(bean.Status) + "</td>"; @@ -162,7 +183,7 @@ } } else - str1 += "<tr><td colspan=\"14\" style=\"padding-left:5px; text-align: center;\">鏆傛棤淇℃伅</td></tr>"; + str1 += "<tr><td colspan=\"16\" style=\"padding-left:5px; text-align: center;\">鏆傛棤淇℃伅</td></tr>"; return new JsonPageResult(true, new { @@ -170,34 +191,39 @@ TotalCount = recordCount }); } - + private JsonPageResult GwOrderList(PageContext<SysUser> context) { - /** - string string1 = context.GetString("SpID"); - string string2 = context.GetString("ClientID"); - string string3 = context.GetString("ClientName"); - string str1 = context.GetString("sDate"); - string str2 = context.GetString("EndTime"); - if (string.IsNullOrEmpty(str1)) - str1 = DateTime.Now.AddDays(-1.0).ToString("yyyy-MM-dd"); - if (string.IsNullOrEmpty(str2)) - str2 = DateTime.Now.ToString("yyyy-MM-dd"); - **/ + /** + string string1 = context.GetString("SpID"); + string string2 = context.GetString("ClientID"); + string string3 = context.GetString("ClientName"); + string str1 = context.GetString("sDate"); + string str2 = context.GetString("EndTime"); + if (string.IsNullOrEmpty(str1)) + str1 = DateTime.Now.AddDays(-1.0).ToString("yyyy-MM-dd"); + if (string.IsNullOrEmpty(str2)) + str2 = DateTime.Now.ToString("yyyy-MM-dd"); + **/ - + string spId = context.GetString("spId"); string clientId = context.GetString("clientId"); - string clientName = context.GetString("clientName"); + string company = context.GetString("company"); int flag = context.GetInt("flag"); + //string startDate = context.GetString("startDate"); + //string endDate = context.GetString("endDate"); DateTime startDate = context.GetDateTime("startDate"); - DateTime endDate = context.GetDateTime("endDate"); + DateTime endDate = context.GetDateTime("endDate")==DateTime.Parse("0001-01-01 00:00:00")? DateTime.Now : context.GetDateTime("endDate"); int recordCount = 0; int pageSize = context.GetInt("pageSize", 50); int pageIndex = context.GetInt("pageIndex", 1); + + string permissionsSQL = new GwClientDao().GetClientPermissions(_userId, _userType, "GWC"); - List<GwOrder> list = _Dao.LoadInfoList(spId, clientId, clientName, flag, startDate, endDate, pageSize, pageIndex, out recordCount); + //List<GwOrder> list = _Dao.LoadInfoList(spId, clientId, clientName, flag, Convert.ToDateTime(startDate), Convert.ToDateTime(endDate).AddDays(1.0), pageSize, pageIndex, out recordCount); + List<GwOrder> list = _Dao.LoadInfoList(spId, clientId, company, flag, startDate, endDate.AddDays(1.0), pageSize, pageIndex, permissionsSQL, out recordCount); string str1 = ""; if (list != null && list.Count > 0) @@ -208,23 +234,26 @@ { ++num; - str1 += "<tr><td>" + bean.OrderId + "</td>"; - str1 = str1 + "<td>" + bean.SpId + "</td>"; - str1 = str1 + "<td>" + bean.ClientId + "-" + bean.ClientName + "</td>"; + //str1 += "<tr><td>" + bean.OrderId + "</td>"; + str1 = str1 + "<tr><td>" + bean.SpId + "</td>"; + str1 = str1 + "<td>" + bean.ClientId + "</td>"; + str1 = str1 + "<td>" + bean.Company + "</td>"; str1 = str1 + "<td>" + ProductToName(bean.ProductId) + "</td>"; //str1 = str1 + "<td>" + bean.ComboId + "</td>"; str1 = str1 + "<td>" + bean.BasicNum + "</td>"; str1 = str1 + "<td>" + bean.GivingNum + "</td>"; - str1 = str1 + string.Format("<td>{0}鍏�/鏉�</td>", (object)(Convert.ToDecimal(bean.Price) / new Decimal(1000))); + str1 = str1 + string.Format("<td>{0}</td>", (object)(Convert.ToDecimal(bean.Price) / new Decimal(1000))); str1 = str1 + "<td>" + bean.OrderNumTotal + "</td>"; - str1 = str1 + string.Format("<td>{0}鍏�</td>", (object)(Convert.ToDecimal(bean.OrderAmountTotal) / new Decimal(1000)));; + str1 = str1 + string.Format("<td>{0}</td>", (object)(Convert.ToDecimal(bean.OrderAmountTotal) / new Decimal(1000))); + str1 = str1 + string.Format("<td>{0}</td>", (object)(Convert.ToDecimal(bean.PayAmount) / new Decimal(1000))); str1 = str1 + "<td>" + bean.BeforeBalanceNum + "</td>"; + str1 = str1 + "<td>" + bean.Auditor + "</td>"; str1 = str1 + "<td>" + bean.Creator + "</td>"; str1 = str1 + "<td>" + bean.CreateTime + "</td>"; str1 = str1 + "<td>" + StatusToName(bean.Status) + "</td>"; //str1 = str1 + "<td>" + bean.Remark + "</td>"; - str1 += "<td class=\"text-right\">"; + str1 += "<td class=\"text-center\">"; str1 += string.Format("<a href=\"javascript:;\" data-orderid=\"{0}\" class=\"action-modal-detail btn btn-success btn-xs\"><i class=\"fa fa-search\"></i> 鏌ョ湅</a> ", (object) bean.OrderId); //str1 += string.Format("<a href=\"javascript:;\" data-orderid=\"{0}\" class=\"action-modal-audit btn btn-success btn-xs\"><i class=\"fa fa-search\"></i> 瀹℃牳</a> ", (object) bean.OrderId); //if(bean.Status == 0) { @@ -235,7 +264,7 @@ } } else - str1 += "<tr><td colspan=\"14\" style=\"padding-left:5px; text-align: center;\">鏆傛棤淇℃伅</td></tr>"; + str1 += "<tr><td colspan=\"16\" style=\"padding-left:5px; text-align: center;\">鏆傛棤淇℃伅</td></tr>"; return new JsonPageResult(true, new { @@ -282,12 +311,31 @@ //璁㈠崟瀹℃牳 private JsonPageResult Audit(PageContext<SysUser> context) { + string spId = context.GetString("spId"); string orderId = context.GetString("orderId"); + Int64 basicNum = context.GetInt64("basicNum"); + Int64 givingNum = context.GetInt64("givingNum"); + string clientId = ""; + Int64 payAmount = 0; + Int64 tmpPayAmount = Math.Max((int) (context.GetDecimal("payAmount", new Decimal(4, 0, 0, false, (byte) 2)) * new Decimal(1000)), 0); + payAmount = tmpPayAmount; + //double price = context.GetDecimal(price); + int num = Math.Max((int) (context.GetDecimal("price", new Decimal(4, 0, 0, false, (byte) 2)) * new Decimal(1000)), 0); + string remark = context.GetString("remark"); int status = context.GetInt("status"); //0-瀹℃牳涓嶉�氳繃锛�1-瀹℃牳閫氳繃 string auditReason = context.GetString("auditReason"); + if (status == 0 && string.IsNullOrEmpty(auditReason) ) + { + throw new ArgumentException("璇疯緭鍏ヤ笉閫氳繃鍘熷洜锛�"); + } + DateTime createTime = DateTime.Now; + string creator = context.OperatorID; + string beforeFlowCode = null; //涔嬪墠鐨勬祦绋嬬紪鐮� - string currentFlowCode = null; //褰撳墠鐨勬祦绋嬬紪鐮� + int nowSort = 0; + string nowFlowCode = null; //褰撳墠鐨勬祦绋嬬紪鐮� + int nextSort = 0; string nextFlowCode = null; //涓嬩竴涓祦绋嬬紪鐮� @@ -297,12 +345,181 @@ if (gwOrder.Status !=0 && gwOrder.Status !=1) throw new ArgumentException("璇ヨ鍗曞凡澶勭悊,鎿嶄綔澶辫触锛�"); + clientId = gwOrder.ClientId; + + //鑾峰彇璁㈠崟瀹℃牳娴佺▼ + string flowGroup = null; //娴佺▼缁勫悎 + string[] flowGroupS = null; + string[] flowCodeS = null; + string flowCode = null; + int sort = 0; + string flowNodeCode = null; + int orderStatus = 0; //璁㈠崟鐘舵�� + + SysFlow SysFlow = new SysFlow(); + SysFlow.FlowCode = "F_DDSH"; //璁㈠崟娴佺▼ + SysFlow.Status = 1; //鐘舵�侊細0-绂佺敤锛�1-鍚敤 + + SysFlow sysFlow = _SysFlowDao.Get(SysFlow); + if (sysFlow == null) + { + throw new ArgumentException("璁㈠崟瀹℃牳娴佺▼涓嶅瓨鍦紝璇风郴缁熺鐞嗛厤缃紒"); + } + + //渚嬶細1#KHSH|2#CWSH + flowGroup = sysFlow.FlowGroup; + + GwOrderAudit gworderAudit = new GwOrderAudit(); - gworderAudit.AuditStatus = 1; + //gworderAudit.AuditStatus = 1; gworderAudit.OrderId = orderId; List<GwOrderAudit> gworderAuditList = _GwOrderAuditDao.List(gworderAudit); if(gworderAuditList==null || gworderAuditList.Count<=0 ) { + //鑾峰彇瀹℃牳娴佺▼鐨勭涓�鐜妭 + nowSort = 0; + } + else + { + //鑾峰彇瀹℃牳娴佺▼鐨勪笅鐜妭 + GwOrderAudit gwOrderAudit = gworderAuditList[0]; + nowSort = gwOrderAudit.AuditSort; + + } + + //鑾峰彇瀹℃牳娴佺▼鐨勭涓�鐜妭娴佺▼浠g爜 + nowFlowCode = getNextFlowCode(flowGroup, nowSort); + + if(string.IsNullOrEmpty(nowFlowCode)) + { + //褰撳墠澶勭悊娌℃湁娴佺▼浠g爜 + throw new ArgumentException("娴佺▼澶勭悊宸插畬鎴愶紝璇疯仈绯荤鐞嗗憳锛�"); + } + else + { + object[] tmpFlowCode = splitFlowCodes(nowFlowCode); + if(tmpFlowCode==null) + { + throw new ArgumentException("娴佺▼浠g爜涓叉牸寮忛敊璇紝璇疯仈绯荤鐞嗗憳锛�"); + } + else + { + nowSort = int.Parse(tmpFlowCode[0].ToString() ); + flowCode = tmpFlowCode[1].ToString(); + } + + + //鑾峰彇鐢ㄦ埛鏉冮檺 + SysFlowNode newSysFlowNode = new SysFlowNode(); + newSysFlowNode.BusinessType = 1; //涓氬姟绫诲瀷:1-鍏呭�硷紱99-鍏朵粬 + newSysFlowNode.FlowNodeCode = flowCode; + newSysFlowNode.UserId = creator; + + List<SysFlowNode> newSysFlowNodeList = _SysFlowNodeDao.IsAuth(newSysFlowNode); + if(newSysFlowNodeList==null || newSysFlowNodeList.Count <=0 ) + { + throw new ArgumentException("鐢ㄦ埛鏃犲鏍告潈闄愶紝璇疯仈绯荤鐞嗗憳锛�"); + } + else + { + nextSort = nowSort + 1; + //鑾峰彇瀹℃牳娴佺▼鐨勭涓�鐜妭娴佺▼浠g爜 + nextFlowCode = getNextFlowCode(flowGroup, nextSort); + + } + + } + + //淇濆瓨璁㈠崟瀹℃牳琛� + string auditId = _SysXhDao.getXh("GW_ORDER_AUDIT"); //鑾峰彇鐢熸垚璁㈠崟瀹℃牳ID + this._GwOrderAuditDao.Add(new GwOrderAudit() + { + AuditId = auditId, + OrderId = orderId, + AuditSort = nowSort, + AuditStatus = status, + Auditor = creator, + AuditReason = auditReason, + AuditTime = createTime + + }); + + //瀹℃牳涓嶉�氳繃 + if (status==0) + { + + orderStatus = 3; + //status:0-寰呭鏍革紙宸叉彁浜わ級锛�1-瀹℃牳涓紱2-瀹℃牳閫氳繃锛�3-瀹℃牳涓嶉�氳繃锛�4-鍙栨秷锛� + this._Dao.UpdateStatus(orderStatus, orderId); + + } + else if(status==1) + { + Int64 beforeBasicNum = 0; + Int64 beforeGivingNum = 0; + Int64 balance = 0; + Int64 topUpAmountTotal = 0; + if (string.IsNullOrEmpty(nextFlowCode)) + { + orderStatus = 2; + + //鑾峰彇璐﹀彿淇℃伅 + GwSp gwSp = _GwSpDao.Get(spId); + + beforeBasicNum = gwSp.BasicNum; + beforeGivingNum = gwSp.GivingNum; + //balance = Convert.ToInt32(gwSp.Balance); + + //鑾峰彇瀹㈡埛淇℃伅 + GwClient gwClient = _GwClientDao.Get(gwSp.ClientID); + balance = Int64.Parse(gwClient.Balance.ToString() ); + topUpAmountTotal = Int64.Parse(gwClient.Top_up_Amount_Total.ToString() ); + + //涓�1-棰勪粯璐� + //if (gwSp.ChargeType==1 && (balance + payAmount) < num * basicNum) + if (gwClient.ChargeType==1 && (balance + payAmount) < num * basicNum) + { + throw new ArgumentException("瀹㈡埛浣欓鍙婂厖鍊奸噾棰濅笉瓒宠喘涔帮紝璇疯皟鏁村悗鎻愪氦锛�"); + } + + //gwSp.Balance = balance - num * basicNum; + //gwSp.BasicNum = beforeBasicNum + basicNum; + //gwSp.GivingNum = beforeGivingNum + givingNum; + //鏇存柊璐﹀彿鍏呭�兼暟鎹� + _GwSpDao.UpdateBalanceByOrder( payAmount, basicNum , givingNum , spId ); + + + //鏈夊厖鍊奸噾棰濇椂锛屾洿鏂板鎴风疮璁″厖鍊奸噾棰濓紙鍘橈級 + if (payAmount > 0 || basicNum > 0 ) { + //GwClient gwClient = new GwClient(); + //gwClient = new GwClient(); + //gwClient.Balance = ((balance + payAmount) - num * basicNum) ; //鍏呭�间綑棰�:鍗曚綅锛堝帢锛� + //gwClient.Top_up_Amount_Total = topUpAmountTotal + payAmount; //鍏呭�奸噾棰�:鍗曚綅锛堝帢锛� + //gwClient.ClientID = clientId; + + //鏇存柊瀹㈡埛鍏呭�兼暟鎹� + _GwClientDao.UpdateClientAmount(payAmount-( num * basicNum), payAmount, clientId ); + } + } + else + { + orderStatus = 1; + } + //status:0-寰呭鏍革紙宸叉彁浜わ級锛�1-瀹℃牳涓紱2-瀹℃牳閫氳繃锛�3-瀹℃牳涓嶉�氳繃锛�4-鍙栨秷锛� + //this._Dao.UpdateStatus(orderStatus, orderId); + + //鑾峰彇璁㈠崟 + //GwOrder newGwOrder = _Dao.Get(orderId); + //newGwOrder.BasicNum = basicNum; + //newGwOrder.GivingNum = givingNum; + //newGwOrder.OrderNumTotal = basicNum + givingNum; + //newGwOrder.OrderAmountTotal = basicNum * num ; + //newGwOrder.BeforeBalanceNum = beforeGivingNum + beforeGivingNum; + //newGwOrder.Status = orderStatus; + //鏇存柊璁㈠崟 + _Dao.UpdateBalanceAndStatus(basicNum, givingNum, basicNum + givingNum, basicNum * num, payAmount, beforeGivingNum + beforeGivingNum, orderStatus, orderId ); + + //Dao.Update(newGwOrder); } @@ -313,7 +530,8 @@ //涓嶆槸鏈�鍚庡鏍哥幆鑺傛椂锛岀珯鍐呴�氱煡 //status:0-寰呭鏍革紙宸叉彁浜わ級锛�1-瀹℃牳涓紱2-瀹℃牳閫氳繃锛�3-瀹℃牳涓嶉�氳繃锛�4-鍙栨秷锛� - this._Dao.UpdateStatus(status, orderId); + //this._Dao.UpdateStatus(status, orderId); + return new JsonPageResult(true, "瀹℃牳鎿嶄綔鎴愬姛锛�"); } @@ -326,20 +544,23 @@ string clientId = context.GetString("clientId"); string productId = context.GetString("productId"); //string comboId = context.GetString("comboId"); - int basicNum = context.GetInt("basicNum", 0); - int givingNum = context.GetInt("givingNum", 0); + Int64 basicNum = context.GetInt("basicNum", 0); + Int64 givingNum = context.GetInt("givingNum", 0); int price = 0; - int orderNumTotal = context.GetInt("orderNumTotal", 0); - int orderAmountTotal = context.GetInt("orderAmountTotal", 0); - int beforeBalanceNum = context.GetInt("beforeBalanceNum", 0); + Int64 orderNumTotal = context.GetInt("orderNumTotal", 0); + Int64 orderAmountTotal = context.GetInt("orderAmountTotal", 0); + Int64 payAmount = 0; + Int64 beforeBalanceNum = context.GetInt("beforeBalanceNum", 0); //瀹㈡湇浜哄憳鎻愪氦璁㈠崟鏃剁殑鐘舵�佷负1-瀹℃牳涓�� int status = 1; //0-寰呭鏍革紙宸叉彁浜わ級锛�1-瀹℃牳涓紱2-瀹℃牳閫氳繃锛�3-瀹℃牳涓嶉�氳繃锛�4-鍙栨秷锛涚敵璇疯鍗曞湪鏈鏍告儏鍐典笅鍙互鍙栨秷銆� string remark = context.GetString("remark"); DateTime createTime = DateTime.Now; string creator = context.OperatorID; - int num = Math.Max((int) (context.GetDecimal("price", new Decimal(4, 0, 0, false, (byte) 2)) * new Decimal(1000)), 1); + Int64 tmpPayAmount = Math.Max((Int64) (context.GetDecimal("payAmount", new Decimal(4, 0, 0, false, (byte) 2)) * new Decimal(1000)), 0); + payAmount = tmpPayAmount; + int num = Math.Max((int) (context.GetDecimal("price", new Decimal(4, 0, 0, false, (byte) 2)) * new Decimal(1000)), 0); price = num; //鏍¢獙 @@ -352,16 +573,40 @@ if (string.IsNullOrEmpty(clientId)) { - throw new ArgumentException("瀹㈡埛涓嶈兘涓虹┖锛�"); + throw new ArgumentException("瀹㈡埛璐﹀彿涓嶈兘涓虹┖锛�"); } if (string.IsNullOrEmpty(spId)) { - throw new ArgumentException("璐﹀彿涓嶈兘涓虹┖锛�"); + throw new ArgumentException("鐭俊璐﹀彿涓嶈兘涓虹┖锛�"); } - if (basicNum<=0 && givingNum <= 0) + if (basicNum<=0 && givingNum <= 0 && payAmount <=0) { - throw new ArgumentException("鍩烘湰鏉℃暟鎴栬禒閫佹潯鏁板繀椤诲ぇ浜庨浂锛�"); + throw new ArgumentException("鍏呭�奸噾棰濇垨鍩烘湰鏉℃暟鎴栬禒閫佹潯鏁板繀椤诲ぇ浜庨浂锛�"); + } + + //鑾峰彇璐﹀彿淇℃伅 + GwSp gwSp = _GwSpDao.Get(spId); + Int64 balance = 0; + if (gwSp == null) + { + throw new ArgumentException("璐﹀彿涓嶅瓨鍦紒"); + } + else if (gwSp.Status==0) + { + throw new ArgumentException("璐﹀彿宸茬鐢紒"); + } + + + //鑾峰彇瀹㈡埛淇℃伅 + GwClient gwClient = _GwClientDao.Get(gwSp.ClientID); + balance = Int64.Parse(gwClient.Balance.ToString() ); + + //涓�1-棰勪粯璐� + //if (gwSp.ChargeType==1 && (balance + payAmount) < num * basicNum) + if (gwClient.ChargeType==1 && (balance + payAmount) < num * basicNum) + { + throw new ArgumentException("瀹㈡埛浣欓鍙婂厖鍊奸噾棰濅笉瓒宠喘涔帮紝璇疯皟鏁村悗鎻愪氦锛�"); } //鑾峰彇璁㈠崟瀹℃牳娴佺▼ @@ -414,26 +659,14 @@ //鑾峰彇鐢ㄦ埛鏉冮檺 SysFlowNode sysFlowNode = new SysFlowNode(); - sysFlowNode.BusinessType = 1; //涓氬姟绫诲瀷:1-鍏呭�硷紱99-鍏朵粬 - sysFlowNode.FlowNodeCode = flowNodeCode; - sysFlowNode.UserId = creator; - - List<SysFlowNode> sysFlowNodeList = _SysFlowNodeDao.IsAuth(sysFlowNode); - if(sysFlowNodeList==null || sysFlowNodeList.Count <=0 ) - { - throw new ArgumentException("鐢ㄦ埛娌℃湁鍏呭�兼潈闄愶紝璇疯仈绯荤鐞嗗憳锛�"); - } - + sysFlowNode.BusinessType = 1; //涓氬姟绫诲瀷:1-鍏呭�硷紱99-鍏朵粬 + sysFlowNode.FlowNodeCode = flowNodeCode; + sysFlowNode.UserId = creator; - //鑾峰彇璁㈠崟淇℃伅 - GwSp gwSp = _GwSpDao.Get(spId); - if (gwSp == null) + List<SysFlowNode> sysFlowNodeList = _SysFlowNodeDao.IsAuth(sysFlowNode); + if(sysFlowNodeList==null || sysFlowNodeList.Count <=0 ) { - throw new ArgumentException("璐﹀彿涓嶅瓨鍦紒"); - } - else if (gwSp.Status==0) - { - throw new ArgumentException("璐﹀彿宸茬鐢紒"); + throw new ArgumentException("鐢ㄦ埛娌℃湁鍏呭�兼潈闄愶紝璇疯仈绯荤鐞嗗憳锛�"); } productId = gwSp.ProductId; @@ -442,7 +675,7 @@ orderNumTotal = basicNum + givingNum; orderAmountTotal = basicNum * price; - + string orderId = _SysXhDao.getXh("GW_ORDER"); //鑾峰彇鐢熸垚璁㈠崟ID this._Dao.Add(new GwOrder() { @@ -456,6 +689,7 @@ Price = price, //鍗曚环鎹㈢畻 OrderNumTotal = orderNumTotal, OrderAmountTotal = orderAmountTotal, + PayAmount = payAmount, BeforeBalanceNum = beforeBalanceNum, Status = status, Remark = remark, @@ -464,19 +698,22 @@ }); - - string auditId = _SysXhDao.getXh("GW_ORDER_AUDIT"); //鑾峰彇鐢熸垚璁㈠崟瀹℃牳ID - this._GwOrderAuditDao.Add(new GwOrderAudit() + //娴佺▼缁勫悎涓虹┖鏃� + if (!string.IsNullOrEmpty(flowGroup)) { - AuditId = auditId, - OrderId = orderId, - AuditSort = sort, - AuditStatus = status, - Auditor = creator, - //AuditReason = null, - AuditTime = createTime + string auditId = _SysXhDao.getXh("GW_ORDER_AUDIT"); //鑾峰彇鐢熸垚璁㈠崟瀹℃牳ID + this._GwOrderAuditDao.Add(new GwOrderAudit() + { + AuditId = auditId, + OrderId = orderId, + AuditSort = sort, + AuditStatus = status, + Auditor = creator, + //AuditReason = null, + AuditTime = createTime - }); + }); + } return new JsonPageResult(true, "鐢熸垚璁㈠崟淇℃伅鎴愬姛锛�"); @@ -490,19 +727,23 @@ string clientId = context.GetString("clientId"); string productId = context.GetString("productId"); string comboId = context.GetString("clientId"); - int basicNum = context.GetInt("basicNum", 0); - int givingNum = context.GetInt("givingNum", 0); + Int64 basicNum = context.GetInt("basicNum", 0); + Int64 givingNum = context.GetInt("givingNum", 0); int price = 0; - int orderNumTotal = context.GetInt("orderNumTotal", 0); - int orderAmountTotal = context.GetInt("orderAmountTotal", 0); - int beforeBalanceNum = context.GetInt("beforeBalanceNum", 0); + Int64 orderNumTotal = context.GetInt("orderNumTotal", 0); + Int64 orderAmountTotal = context.GetInt("orderAmountTotal", 0); + Int64 payAmount = 0; + Int64 beforeBalanceNum = context.GetInt("beforeBalanceNum", 0); int status = 0; string remark = context.GetString("remark"); DateTime createTime = DateTime.Now; string creator = context.OperatorID; - int num = Math.Max((int) (context.GetDecimal("price", new Decimal(4, 0, 0, false, (byte) 2)) * new Decimal(1000)), 1); + Int64 tmpPayAmount = Math.Max((Int64) (context.GetDecimal("payAmount", new Decimal(4, 0, 0, false, (byte) 2)) * new Decimal(1000)), 0); + payAmount = tmpPayAmount; + + int num = Math.Max((int) (context.GetDecimal("price", new Decimal(4, 0, 0, false, (byte) 2)) * new Decimal(1000)), 0); price = num; //鏍¢獙 @@ -515,11 +756,11 @@ if (string.IsNullOrEmpty(clientId)) { - throw new ArgumentException("瀹㈡埛涓嶈兘涓虹┖锛�"); + throw new ArgumentException("瀹㈡埛璐﹀彿涓嶈兘涓虹┖锛�"); } if (string.IsNullOrEmpty(spId)) { - throw new ArgumentException("璐﹀彿涓嶈兘涓虹┖锛�"); + throw new ArgumentException("鐭俊璐﹀彿涓嶈兘涓虹┖锛�"); } if (basicNum<=0 && givingNum <= 0) @@ -539,6 +780,7 @@ Price = price, //鍗曚环鎹㈢畻 OrderNumTotal = orderNumTotal, OrderAmountTotal = orderAmountTotal, + PayAmount = payAmount, BeforeBalanceNum = beforeBalanceNum, Status = status, Remark = remark, @@ -554,6 +796,55 @@ private JsonPageResult Get(PageContext<SysUser> context) { return new JsonPageResult(true, this._Dao.Get(context.GetString("orderId"))); + } + + //鏍规嵁瀹㈡埛API璐﹀彿鑾峰彇鍏呭�煎垵濮嬩俊鎭� + private JsonPageResult GetOrderBySpId(PageContext<SysUser> context) + { + string spId = context.GetString("spId"); + + if (!string.IsNullOrEmpty(spId)) + { + GwSp gwSp = new GwSpDao().Get(spId); + if(gwSp==null) + { + throw new ArgumentException("璐﹀彿涓嶅瓨鍦紒"); + + } + else if (gwSp.Status==0) + { + throw new ArgumentException("璐﹀彿鐘舵�佸凡鍋滅敤锛�"); + + } + + + GwOrder gwOrder = new GwOrder(); + + GwClient gwClient = new GwClient(); + using (GwClientDao gwClientDao = new GwClientDao()) + { + gwClient = gwClientDao.Get(gwSp.ClientID); + gwOrder.Company = gwClient.Company; + gwOrder.Balance = long.Parse(gwClient.Balance.ToString() ); //浣欓 + } + + gwOrder.SpId = gwSp.SpID; + gwOrder.ClientId = gwSp.ClientID; + gwOrder.ProductId = gwSp.ProductId; + gwOrder.ProductName = gwSp.ProductName; + gwOrder.Price = gwSp.Price; + gwOrder.BasicNum = gwSp.BasicNum; //鍩烘湰鏉℃暟 + gwOrder.GivingNum = gwSp.GivingNum; + + return new JsonPageResult(true, gwOrder); + } + else + { + throw new ArgumentException("璇烽�夋嫨鐭俊璐﹀彿锛�"); + + } + + } //鑾峰彇閫氶亾鍒楄〃 @@ -601,9 +892,9 @@ if (classes == -1) return string.Empty; else if(classes == 0) - return "0-浜у搧鍒嗙被"; + return "浜у搧鍒嗙被"; else if(classes == 1) - return "1-浜у搧"; + return "浜у搧"; return string.Empty; } @@ -614,9 +905,9 @@ if (isDefault == -1) return string.Empty; else if(isDefault == 0) - return "0-涓�у寲"; + return "涓�у寲"; else if(isDefault == 1) - return "1-绯荤粺榛樿"; + return "绯荤粺榛樿"; return string.Empty; } @@ -627,9 +918,9 @@ if (isEnable == -1) return string.Empty; else if(isEnable == 0) - return "0-鍋滅敤"; + return "鍋滅敤"; else if(isEnable == 1) - return "1-鍚敤"; + return "鍚敤"; return string.Empty; } @@ -651,15 +942,15 @@ if (status == -1) return string.Empty; else if(status == 0) - return "0-寰呭鏍革紙宸叉彁浜わ級"; + return "寰呭鏍革紙宸叉彁浜わ級"; else if(status == 1) - return "1-瀹℃牳涓�"; + return "瀹℃牳涓�"; else if(status == 2) - return "2-瀹℃牳閫氳繃"; + return "瀹℃牳閫氳繃"; else if(status == 3) - return "3-瀹℃牳涓嶉�氳繃"; + return "瀹℃牳涓嶉�氳繃"; else if(status == 4) - return "4-鍙栨秷"; + return "鍙栨秷"; return string.Empty; } @@ -703,4 +994,81 @@ return string.Empty; } + + //鑾峰彇娴佺▼缁勪腑鐨勪笅涓�涓祦绋� + public string getNextFlowCode(string flowGroup, int sort) + { + if (string.IsNullOrEmpty(flowGroup) ) + { + return null; + } + + string[] flowGroups = null; + string[] flowCodes = null; + int nextSort = 0; + string flowCode = null; + string sortAndFlowCode = null; + flowGroups = flowGroup.Split('|'); + Console.WriteLine(flowGroups.Length); + if (flowGroups.Length > 1) + { + for (int i=0; i<flowGroups.Length; i++) + { + sortAndFlowCode = flowGroups[i]; + if (string.IsNullOrEmpty(sortAndFlowCode)) + { + continue; + } + else + { + flowCodes = sortAndFlowCode.Split('#'); + if(flowCodes.Length!=2) + { + + throw new ArgumentException("娴佺▼缁勫悎涓插瓨鍦ㄦ牸寮忛敊璇紒"); + } + else + { + nextSort = string.IsNullOrEmpty(flowCodes[0])? 0: Convert.ToInt32(flowCodes[0]); //搴忓彿 + flowCode = flowCodes[1]; //娴佺▼浠g爜 + + if (nextSort<=sort) + { + continue; + } + + //return flowCode; + return sortAndFlowCode; + + } + } + + } + } + + return ""; + } + + + //鎷嗗垎娴佺▼搴忓彿鍜屾祦绋嬩唬鐮� + public object[] splitFlowCodes(string sortAndFlowCode) + { + if(string.IsNullOrEmpty(sortAndFlowCode) ) + { + return null; + } + + string[] splitFlowCodes = sortAndFlowCode.Split('#'); + if (splitFlowCodes.Length != 2) + { + throw new ArgumentException("娴佺▼缁勫悎涓叉牸寮忛敊璇紒"); + + } + else + { + return splitFlowCodes; + } + + } + } \ No newline at end of file -- Gitblit v1.9.1