Laravel 5 mongo DB的倍增列的Eloquent总和

时间:2015-12-18 09:28:21

标签: php mongodb laravel-5

(function () {

    loadAppSettings().then(function () {
        alert(1)
    }).catch(function(){
            alert(0)
    });

    function loadAppSettings() {
        var $http = angular.injector(["ng"]).get("$http");

        return $http.get("oops").then(
            function (response) {
                angular.module("app").constant("appSettings", response.data);
            }
        ).catch(
            function (errorResponse) {
                console.error("app settings couldn't load.")
            }
        );
    }
})();

我想要两个字段的乘法(Total * CurrencyRate) 我试过这个查询::

This is my invoices mongo table 

{
    '_id': ObjectId("565d78336fe444611a8b4593"),
    'TransactionID': 'X020',
    'Type': 'SALESINVOICE',
    'InvoiceNumber': 'ABC020',
    'Date': '2015-11-01 00:00:00',
    'DueDate': '2015-12-01 00:00:00',
    'CurrencyCode': 'GBP',
    'CurrencyRate': NumberLong(1.2),
    'Total': NumberLong(200),
    'PlannedPaymentDate': '',
    'HasAttachments': 0,
    'UpdatedDate': '2015-12-01 10:36:35',
    'AmountDue': NumberLong(200),
    'AmountPaid': 0,
    'Status': 'OPEN',
    'AmountCredited': 0,
    'AmountDebited': 0,
    'Source': 1,
    'InvoiceID': 'csv_1_X020',
    'ExpectedPaymentDate': '2015-12-01 00:00:00',
    'ContactID': 1,
    'ValidateStatus': 'IMPORT',
    'StatusChangeDate': ''
}

并尝试了更多::

DB::connection($this->MongoSchemaName)->collection($this->InvoicesTable)->where('Type', 'PAYMENT')->where('ContactID', (int)$customer->ContactID)->select(DB::raw('sum(Total*CurrencyRate)'))->first();

但是没有得到确切的输出所有时间我得到0

0 个答案:

没有答案