public IHttpActionResult PayOrder([FromBody] PayOrderParam param)
        {
            SimpleResult result = new SimpleResult();
            IRecordsOfConsumptionService _service   = new RecordsOfConsumptionService();
            ICouponService      _couponService      = new CouponService();
            IUseWalletService   _useWalletService   = new UseWalletService();
            IStoreService       _stoeservice        = new StoreService();
            IProductInfoService _productInfoService = new ProductInfoService();

            try
            {
                if (UserAuthorization)
                {
                    LogHelper.WriteLog("PayOrder接口");
                    LogHelper.WriteLog("productCode  param.userCode" + param.paytype);
                    LogHelper.WriteLog("productCode param.money " + param.money);
                    LogHelper.WriteLog("productCode param.orderCode" + param.orderCode);
                    LogHelper.WriteLog("productCode param.peopleCount" + param.peopleCount);
                    LogHelper.WriteLog("productCode param.productCode" + param.productCode);
                    LogHelper.WriteLog("productCode param.storeId" + param.storeId);
                    LogHelper.WriteLog("productCode param.userCode " + param.userCode);
                    LogHelper.WriteLog("productCode param.couponCode " + param.couponCode);
                    var isExistProduct = _productInfoService.IsExistProduct(param.productCode);
                    if (!isExistProduct)
                    {
                        result.Status   = Result.SYSTEM_ERROR;
                        result.Msg      = "商品已失效或不存在";
                        result.Resource = null;
                    }
                    if (param.paytype == 0)
                    {
                        LogHelper.WriteLog("会员支付 " + param.paytype);

                        var isPay = true;
                        if (!string.IsNullOrEmpty(param.couponCode))
                        {
                            var n = _couponService.Exist(param.couponCode);
                            if (n == 1)
                            {
                                result.Status   = Result.SYSTEM_ERROR;
                                result.Msg      = "优惠卷不存在";
                                result.Resource = null;
                                isPay           = false;
                            }
                            else if (n == 2)
                            {
                                result.Status   = Result.SYSTEM_ERROR;
                                result.Msg      = "优惠卷已经被使用";
                                result.Resource = null;
                                isPay           = false;
                            }
                        }

                        if (isPay)
                        {
                            if (_useWalletService.ExistMoney(param.userCode, param.money))
                            {
                                var re = _service.PayOrder(param.productCode, param.userCode, param.peopleCount, param.dateTime, param.money, param.storeId, param.orderCode, param.couponCode);
                                result.Resource = "SUCCEED";
                                result.Status   = Result.SUCCEED;
                                LogHelper.WriteLog("result.Status " + Result.SUCCEED);
                            }
                            else
                            {
                                result.Status   = Result.SYSTEM_ERROR;
                                result.Msg      = "账号余额不足";
                                result.Resource = null;
                                LogHelper.WriteLog("result.Status " + Result.SYSTEM_ERROR);
                            }
                        }
                    }
                    else
                    {
                        var isPay = true;
                        if (!string.IsNullOrEmpty(param.couponCode))
                        {
                            var n = _couponService.Exist(param.couponCode);
                            if (n == 1)
                            {
                                result.Status   = Result.SYSTEM_ERROR;
                                result.Msg      = "优惠卷不存在";
                                result.Resource = null;
                                isPay           = false;
                            }
                            else if (n == 2)
                            {
                                result.Status   = Result.SYSTEM_ERROR;
                                result.Msg      = "优惠卷已经被使用";
                                result.Resource = null;
                                isPay           = false;
                            }
                        }
                        if (isPay)
                        {
                            using (var scope = new TransactionScope())//创建事务
                            {
                                LogHelper.WriteLog("微信支付 " + param.userCode);
                                IUserStoreService _userStoreservice = new UserStoreService();
                                var store        = _stoeservice.GetStore(param.storeId);
                                var couponser    = _couponService.GetCouponByCode(param.couponCode);
                                var userStoreser = _userStoreservice.GetUserStorebyUserCodestoreCode(param.userCode, param.storeId);
                                if (userStoreser != null)
                                {
                                    if (param.money != 0)
                                    {
                                        //生成微信预支付订单
                                        var wxprepay = Common.wxPayOrderSomething(userStoreser.OpenID, param.money.ToString(), couponser?.CouponTypeName, store);
                                        if (wxprepay != null)
                                        {
                                            var order = _service.WxPayOrder(param.productCode, param.userCode, param.peopleCount, param.dateTime, param.money, wxprepay.prepayid, param.storeId, param.orderCode, param.couponCode);
                                            if (!string.IsNullOrEmpty(param.couponCode))
                                            {
                                                _couponService.UsedUpdate(param.couponCode, param.userCode, order.OrderCode);
                                            }
                                            WxOrder wxorder = new WxOrder();
                                            wxorder.orderCode    = order.OrderCode;
                                            wxorder.wxJsApiParam = wxprepay.wxJsApiParam;
                                            wxorder.prepayid     = wxprepay.prepayid;
                                            wxorder.IsWxPay      = true;
                                            result.Resource      = wxorder;
                                            result.Status        = Result.SUCCEED;
                                        }
                                        else
                                        {
                                            result.Msg    = "微信下单失败,重新提交订单";
                                            result.Status = Result.SYSTEM_ERROR;
                                        }
                                    }
                                    else
                                    {
                                        var order = _service.WxPayNoMoneyOrder(param.productCode, param.userCode, param.peopleCount, param.dateTime, param.money, null, param.couponCode);
                                        _couponService.UsedUpdate(param.couponCode, param.userCode, order.OrderCode);
                                        LogHelper.WriteLog("更新的钱包和优惠券couponCode: " + param.couponCode);

                                        LogHelper.WriteLog("报表写入数据开始");
                                        IFinancialStatementsService _financialStatementsService = new FinancialStatementService();
                                        LogHelper.WriteLog("报表表数据更新");
                                        financialStatements fs = _financialStatementsService.getData(param.userCode, order, "微信");
                                        LogHelper.WriteLog("报表表数据更新完成");

                                        _financialStatementsService.Insert(fs);
                                        LogHelper.WriteLog("报表写入数据结束" + fs.Code);
                                        WxOrder wxorder = new WxOrder();
                                        wxorder.orderCode = order.OrderCode;
                                        result.Resource   = "SUCCEED";
                                        result.Status     = Result.SUCCEED;
                                    }
                                }
                                else
                                {
                                    result.Resource = "";
                                    result.Status   = Result.SYSTEM_ERROR;
                                }
                                scope.Complete();//这是最后提交事务
                            }
                        }
                    }
                }
                else
                {
                    result.Status   = ResultType;
                    result.Resource = ReAccessToken;
                    result.Msg      = TokenMessage;
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("WxPayOrder PayOrder ", ex);
                result.Status = Result.FAILURE;
                result.Msg    = ex.Message;

                LogHelper.WriteLog("微信支付", ex);
            }
            LogHelper.WriteLog("PayOrder result" + Json(result));
            return(Json(result));
        }