Example #1
0
        public Response SetSalesInvoice(string token, [FromBody] SalesInvoiceParam sip)
        {
            Response response = new Response();

            if (string.IsNullOrEmpty(token) || !token.Equals(_token))
            {
                response.code    = "404";
                response.message = "Invild token";
            }
            else
            {
                int insertCount = 0;
                var data        = SalesInvoiceHelper.SetSalesInvoice(sip, ref insertCount);

                if (data == null)
                {
                    response.code    = "500";
                    response.message = "process failed";
                }
                else
                {
                    response.code    = "200";
                    response.content = data;
                    response.message = insertCount > 0 ? "new record created" : "no record created";
                }
            }
            return(response);
        }
        /// <summary>
        /// 根据传入SO相关信息设置开票区间
        /// </summary>
        public static List <SalesInvoice> SetSalesInvoice(SalesInvoiceParam sip, ref int insertCount)
        {
            try
            {
                if (sip == null)
                {
                    throw new Exception("SalesInvoiceParam is null");
                }
                // 执行设置开票区间

                List <SalesInvoice> lstSalesInvoice = factory.SetSalesInvoice(sip, ref insertCount);

                return(lstSalesInvoice);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(new Log()
                {
                    message = ex.Message
                }, "SetSalesInvoice");
                return(null);
            }
        }