//http://localhost:10010//api/RecordsOfConsumption/IsWriteOffUser?userCode=1
        public IHttpActionResult IsWriteOffUser(string userCode)
        {
            SimpleResult result = new SimpleResult();
            IRecordsOfConsumptionService _service = new RecordsOfConsumptionService();

            try
            {
                if (UserAuthorization)
                {
                    var use = userInfo.GetUserByCode(userCode);
                    if (use != null)
                    {
                        var re = _service.IsWriteOffUser(use.Phone);
                        result.Resource = re;
                        result.Status   = Result.SUCCEED;
                    }
                    else
                    {
                        result.Msg    = "没有当前用户";
                        result.Status = Result.SYSTEM_ERROR;
                    }
                }
                else
                {
                    result.Status   = Result.FAILURE;
                    result.Resource = ReAccessToken;
                    result.Msg      = TokenMessage;
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("IsWriteOffUser userCode" + userCode, ex);
                result.Status = Result.FAILURE;
                result.Msg    = ex.Message;
            }
            return(Json(result));
        }
        public IHttpActionResult WriteOff(string userCode, string orderCode)
        {
            LogHelper.WriteLog("WriteOff userCode" + userCode);
            LogHelper.WriteLog("WriteOff orderCode" + orderCode);
            SimpleResult result = new SimpleResult();
            IRecordsOfConsumptionService _service          = new RecordsOfConsumptionService();
            IWriteOffService             _writeOffServicee = new WriteOffService();
            IOrderService _orderservice = new OrderService();

            try
            {
                if (UserAuthorization)
                {
                    var use = userInfo.GetUserByCode(userCode);
                    if (use != null)
                    {
                        if (_service.IsWriteOffUser(use.Phone))
                        {
                            var order = _orderservice.GetOrderByCode(orderCode);
                            if (order != null && !order.IsWriteOff)
                            {
                                order.IsWriteOff = true;
                                if (_orderservice.UpdateOrder(order) > 0)
                                {
                                    result.Status = Result.SUCCEED;
                                    IFinancialStatementsService _financialStatementsService = new FinancialStatementService();
                                    //写入核销数据到报表中
                                    financialStatements fs = null;
                                    if (string.IsNullOrEmpty(order.WxPrepayId))
                                    {
                                        var recordsOfConsumption = _service.GetRecordsOfConsumptionByOrderCode(orderCode);
                                        fs = _financialStatementsService.getWriteOff(use.UserName, order.UserCode, orderCode, "会员卡", recordsOfConsumption?.RecordsAccountPrincipalMoney);
                                    }
                                    else
                                    {
                                        fs = _financialStatementsService.getWriteOff(use.UserName, order.UserCode, orderCode, "微信", null);
                                    }
                                    LogHelper.WriteLog("financialStatements " + fs.Code);
                                    if (fs != null)
                                    {
                                        _financialStatementsService.Insert(fs);
                                    }
                                }
                                else
                                {
                                    result.Msg    = "订单已经被核销";
                                    result.Status = Result.SYSTEM_ERROR;
                                }
                            }
                            else
                            {
                                result.Msg    = "订单已经被核销";
                                result.Status = Result.SYSTEM_ERROR;
                            }
                        }
                        else
                        {
                            result.Msg    = "您不是核销人员。";
                            result.Status = Result.SYSTEM_ERROR;
                        }
                    }
                    else
                    {
                        result.Msg    = "没有当前用户";
                        result.Status = Result.SYSTEM_ERROR;
                    }
                }
                else
                {
                    result.Status   = Result.FAILURE;
                    result.Resource = ReAccessToken;
                    result.Msg      = TokenMessage;
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("WriteOff userCode" + userCode + " orderCode" + orderCode, ex);
                result.Status = Result.FAILURE;
                result.Msg    = ex.Message;
            }
            LogHelper.WriteLog("WriteOff result" + Json(result));
            return(Json(result));
        }