| | |
| | | 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"); |
| | |
| | | //订单审核 |
| | | 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; //下一个流程编码 |
| | | |
| | | |
| | |
| | | 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; |
| | | |
| | | } |
| | | |
| | | //获取审核流程的第一环节流程代码 |
| | | nowFlowCode = getNextFlowCode(flowGroup, nowSort); |
| | | |
| | | if(string.IsNullOrEmpty(nowFlowCode)) |
| | | { |
| | | //当前处理没有流程代码 |
| | | throw new ArgumentException("流程处理已完成,请联系管理员!"); |
| | | } |
| | | else |
| | | { |
| | | object[] tmpFlowCode = splitFlowCodes(nowFlowCode); |
| | | if(tmpFlowCode==null) |
| | | { |
| | | throw new ArgumentException("流程代码串格式错误,请联系管理员!"); |
| | | } |
| | | 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; |
| | | //获取审核流程的第一环节流程代码 |
| | | 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); |
| | | |
| | | } |
| | | |
| | |
| | | //不是最后审核环节时,站内通知 |
| | | |
| | | //status:0-待审核(已提交);1-审核中;2-审核通过;3-审核不通过;4-取消; |
| | | this._Dao.UpdateStatus(status, orderId); |
| | | //this._Dao.UpdateStatus(status, orderId); |
| | | |
| | | return new JsonPageResult(true, "审核操作成功!"); |
| | | |
| | | } |
| | |
| | | |
| | | //获取用户权限 |
| | | 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); |
| | |
| | | orderNumTotal = basicNum + givingNum; |
| | | orderAmountTotal = basicNum * price; |
| | | |
| | | |
| | | |
| | | string orderId = _SysXhDao.getXh("GW_ORDER"); //获取生成订单ID |
| | | this._Dao.Add(new GwOrder() |
| | | { |
| | |
| | | |
| | | }); |
| | | |
| | | |
| | | |
| | | string auditId = _SysXhDao.getXh("GW_ORDER_AUDIT"); //获取生成订单审核ID |
| | | this._GwOrderAuditDao.Add(new GwOrderAudit() |
| | | { |
| | |
| | | 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]; //流程代码 |
| | | |
| | | 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; |
| | | } |
| | | |
| | | } |
| | | |
| | | } |