From af6c0e904a3c4f925792327061457f14c6c9936c Mon Sep 17 00:00:00 2001 From: yzh <snbbt@21cn.com> Date: 星期六, 07 五月 2022 16:09:50 +0800 Subject: [PATCH] 优化 --- web/web/GwOrder.ashx | 293 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 267 insertions(+), 26 deletions(-) diff --git a/web/web/GwOrder.ashx b/web/web/GwOrder.ashx index 7e9019d..30c4bfd 100644 --- a/web/web/GwOrder.ashx +++ b/web/web/GwOrder.ashx @@ -170,22 +170,22 @@ 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"); @@ -282,12 +282,22 @@ //璁㈠崟瀹℃牳 private JsonPageResult Audit(PageContext<SysUser> context) { + string spId = context.GetString("spId"); string orderId = context.GetString("orderId"); + int basicNum = context.GetInt("basicNum"); + int givingNum = context.GetInt("givingNum"); + //double price = context.GetDecimal(price); + int num = Math.Max((int) (context.GetDecimal("price", new Decimal(4, 0, 0, false, (byte) 2)) * new Decimal(1000)), 1); + string remark = context.GetString("remark"); int status = context.GetInt("status"); //0-瀹℃牳涓嶉�氳繃锛�1-瀹℃牳閫氳繃 string auditReason = context.GetString("auditReason"); + 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 +307,165 @@ if (gwOrder.Status !=0 && gwOrder.Status !=1) throw new ArgumentException("璇ヨ鍗曞凡澶勭悊,鎿嶄綔澶辫触锛�"); + + + //鑾峰彇璁㈠崟瀹℃牳娴佺▼ + 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) + { + int beforeBasicNum = 0; + int beforeGivingNum = 0; + int balance = 0; + if(string.IsNullOrEmpty(nextFlowCode)) + { + orderStatus = 2; + + //鑾峰彇璐﹀彿淇℃伅 + GwSp gwSp = _GwSpDao.Get(spId); + + beforeBasicNum = gwSp.BasicNum; + beforeGivingNum = gwSp.GivingNum; + balance = Convert.ToInt32(gwSp.Balance); + + //涓�1-棰勪粯璐� + if (gwSp.ChargeType.Equals("1") && gwSp.Balance < num * basicNum ) + { + throw new ArgumentException("璐﹀彿浣欓涓嶈冻锛岃鑱旂郴绠$悊鍛橈紒"); + } + + //gwSp.Balance = balance - num * basicNum; + //gwSp.BasicNum = beforeBasicNum + basicNum; + //gwSp.GivingNum = beforeGivingNum + givingNum; + + _GwSpDao.UpdateBalanceByOrder(balance - num * basicNum + , beforeBasicNum + basicNum + , beforeGivingNum + givingNum + , spId + ); + } + 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, beforeGivingNum + beforeGivingNum,orderStatus, orderId ); + + //Dao.Update(newGwOrder); } @@ -313,7 +476,8 @@ //涓嶆槸鏈�鍚庡鏍哥幆鑺傛椂锛岀珯鍐呴�氱煡 //status:0-寰呭鏍革紙宸叉彁浜わ級锛�1-瀹℃牳涓紱2-瀹℃牳閫氳繃锛�3-瀹℃牳涓嶉�氳繃锛�4-鍙栨秷锛� - this._Dao.UpdateStatus(status, orderId); + //this._Dao.UpdateStatus(status, orderId); + return new JsonPageResult(true, "瀹℃牳鎿嶄綔鎴愬姛锛�"); } @@ -414,16 +578,16 @@ //鑾峰彇鐢ㄦ埛鏉冮檺 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 ) + 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("鐢ㄦ埛娌℃湁鍏呭�兼潈闄愶紝璇疯仈绯荤鐞嗗憳锛�"); + throw new ArgumentException("鐢ㄦ埛娌℃湁鍏呭�兼潈闄愶紝璇疯仈绯荤鐞嗗憳锛�"); } - + //鑾峰彇璁㈠崟淇℃伅 GwSp gwSp = _GwSpDao.Get(spId); @@ -442,7 +606,7 @@ orderNumTotal = basicNum + givingNum; orderAmountTotal = basicNum * price; - + string orderId = _SysXhDao.getXh("GW_ORDER"); //鑾峰彇鐢熸垚璁㈠崟ID this._Dao.Add(new GwOrder() { @@ -464,7 +628,7 @@ }); - + string auditId = _SysXhDao.getXh("GW_ORDER_AUDIT"); //鑾峰彇鐢熸垚璁㈠崟瀹℃牳ID this._GwOrderAuditDao.Add(new GwOrderAudit() { @@ -703,4 +867,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