Ejemplo n.º 1
0
        static ProcurementConfig()
        {
            string path = Directory.GetCurrentDirectory() + "/Configs/progress.json";

            using StreamReader sr = new StreamReader(path);
            string text = sr.ReadToEnd();

            JObject json = (JObject)JObject.Parse(text)["procurement"];

            foreach (var item in json.Properties())
            {
                JArray jarr = JArray.FromObject(item.Values());
                _progress_conf.Add(item.Name, new List <ProcurementItem>());
                foreach (var it in jarr)
                {
                    ProcurementItem pi = new ProcurementItem
                    {
                        id = (int)it["id"]
                    };
                    switch (it["act"].ToString())
                    {
                    case "apply":
                        pi.act = EProcurementAction.Apply;
                        break;

                    case "procurement":
                        pi.act = EProcurementAction.Procurement;
                        break;
                    }
                    _progress_conf[item.Name].Add(pi);
                }
            }
        }
        /// <summary>
        /// 验证审核的订单
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        private async Task <Result> VerifyAuditOrder(In <AuditOrder> inData)
        {
            var    data   = inData.data;
            Result result = new Result();

            if (data == null)
            {
                result.msg = "参数错误";
                return(result);
            }
            if (string.IsNullOrWhiteSpace(data.order_sn?.Trim()))
            {
                result.msg = "订单不存在";
                return(result);
            }
            data.order_sn = data.order_sn.Trim();
            DBHelper      db    = new DBHelper();
            t_procurement order = await ProcurementDao.GetOrder(db, data.order_sn);

            db.Close();
            if (order == null)
            {
                result.msg = "订单不存在";
                return(result);
            }
            int             pass_step = ProcurementConfig.PassStep(order.department_id, order.position_id);
            ProcurementItem step      = ProcurementConfig.CurrentStep(order.department_id, pass_step, order.audit_step);

            if (step == null || step.act != EProcurementAction.Apply || inData.user.position_id != step.id)
            {
                result.msg = "无权审批改订单";
                return(result);
            }
            if (string.IsNullOrWhiteSpace(data.flag?.Trim()) || !int.TryParse(data.flag, out int audit_flag) || !Enum.IsDefined(typeof(EAuditFlag), audit_flag))
            {
                result.msg = "审批状态错误";
                return(result);
            }
            data.flag = data.flag.Trim();

            if (audit_flag == (int)EAuditFlag.Reject && string.IsNullOrWhiteSpace(data.remark?.Trim()))
            {
                result.msg = "请填写拒绝理由";
                return(result);
            }
            data.remark = data.remark?.Trim();
            if (data.remark?.Length > 100)
            {
                result.msg = "拒绝理由最多100个字符";
                return(result);
            }

            result.result = true;
            return(result);
        }