trex-model 1.3.9__tar.gz → 1.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of trex-model might be problematic. Click here for more details.
- {trex-model-1.3.9 → trex-model-1.4.1}/PKG-INFO +10 -5
- {trex-model-1.3.9 → trex-model-1.4.1}/setup.py +1 -1
- {trex-model-1.3.9 → trex-model-1.4.1}/trex_model.egg-info/PKG-INFO +10 -5
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/admin_models.py +1 -1
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/analytic_models.py +1 -1
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/coporate_models.py +0 -10
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/customer_models.py +7 -2
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/fb_subsriber_models.py +0 -7
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/import_models.py +1 -5
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/inventory_model.py +3 -11
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/loyalty_models.py +3 -3
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/lucky_draw_models.py +1 -1
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/marketing_models.py +1 -1
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/membership_models.py +2 -3
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/merchant_models.py +27 -3
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/message_model_helper.py +1 -1
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/message_models.py +1 -5
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/ndb_models.py +5 -5
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/pos_models.py +2 -2
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/prepaid_models.py +41 -5
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/product_models.py +2 -5
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/program_models.py +2 -4
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/rating_models.py +1 -1
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/recruit_models.py +0 -4
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/redeem_models.py +1 -2
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/redemption_catalogue_models.py +1 -2
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/referral_program_model.py +3 -6
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/reward_model_helpers.py +1 -1
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/reward_models.py +1 -1
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/system_models.py +1 -1
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/task_models.py +1 -2
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/test_models.py +1 -11
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/transaction_models.py +9 -2
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/user_models.py +30 -11
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/voucher_models.py +1 -1
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/merchant_helpers.py +17 -0
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/program_conf.py +1 -0
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/utils/model/model_util.py +1 -1
- {trex-model-1.3.9 → trex-model-1.4.1}/LICENSE +0 -0
- {trex-model-1.3.9 → trex-model-1.4.1}/MANIFEST.in +0 -0
- {trex-model-1.3.9 → trex-model-1.4.1}/README.md +0 -0
- {trex-model-1.3.9 → trex-model-1.4.1}/setup.cfg +0 -0
- {trex-model-1.3.9 → trex-model-1.4.1}/trex_model.egg-info/SOURCES.txt +0 -0
- {trex-model-1.3.9 → trex-model-1.4.1}/trex_model.egg-info/dependency_links.txt +0 -0
- {trex-model-1.3.9 → trex-model-1.4.1}/trex_model.egg-info/requires.txt +0 -0
- {trex-model-1.3.9 → trex-model-1.4.1}/trex_model.egg-info/top_level.txt +0 -0
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/__init__.py +0 -0
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/conf.py +0 -0
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/__init__.py +0 -0
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/__init__.py +0 -0
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/app_models.py +0 -0
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/customer_model_helpers.py +0 -0
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/model_decorators.py +0 -0
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/spending_base_program_model.py +0 -0
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/model_decorator.py +0 -0
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/prepaid_helpers.py +0 -0
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/pos_conf.py +0 -0
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/utils/__init__.py +0 -0
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/utils/gcloud/__init__.py +0 -0
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/utils/gcloud/datastore_util.py +0 -0
- {trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/utils/model/__init__.py +0 -0
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: trex-model
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.1
|
|
4
4
|
Summary: TRex database module package
|
|
5
5
|
Home-page: https://bitbucket.org/lokjac/trex-model
|
|
6
6
|
Author: Jack Lok
|
|
7
7
|
Author-email: sglok77@gmail.com
|
|
8
|
-
License: UNKNOWN
|
|
9
|
-
Description: This is database modelusing google datastore mode module
|
|
10
|
-
|
|
11
|
-
Platform: UNKNOWN
|
|
12
8
|
Classifier: Programming Language :: Python :: 3
|
|
13
9
|
Classifier: License :: OSI Approved :: MIT License
|
|
14
10
|
Classifier: Operating System :: OS Independent
|
|
15
11
|
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: google-cloud-firestore
|
|
14
|
+
Requires-Dist: google_cloud_datastore
|
|
15
|
+
Requires-Dist: google-cloud-ndb
|
|
16
|
+
Requires-Dist: six
|
|
17
|
+
Requires-Dist: trex-lib
|
|
18
|
+
Requires-Dist: flask-login==0.6.2
|
|
19
|
+
|
|
20
|
+
This is database modelusing google datastore mode module
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: trex-model
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.1
|
|
4
4
|
Summary: TRex database module package
|
|
5
5
|
Home-page: https://bitbucket.org/lokjac/trex-model
|
|
6
6
|
Author: Jack Lok
|
|
7
7
|
Author-email: sglok77@gmail.com
|
|
8
|
-
License: UNKNOWN
|
|
9
|
-
Description: This is database modelusing google datastore mode module
|
|
10
|
-
|
|
11
|
-
Platform: UNKNOWN
|
|
12
8
|
Classifier: Programming Language :: Python :: 3
|
|
13
9
|
Classifier: License :: OSI Approved :: MIT License
|
|
14
10
|
Classifier: Operating System :: OS Independent
|
|
15
11
|
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: google-cloud-firestore
|
|
14
|
+
Requires-Dist: google_cloud_datastore
|
|
15
|
+
Requires-Dist: google-cloud-ndb
|
|
16
|
+
Requires-Dist: six
|
|
17
|
+
Requires-Dist: trex-lib
|
|
18
|
+
Requires-Dist: flask-login==0.6.2
|
|
19
|
+
|
|
20
|
+
This is database modelusing google datastore mode module
|
|
@@ -9,7 +9,7 @@ from trexlib.utils.security_util import generate_user_id, hash_password
|
|
|
9
9
|
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
10
10
|
from trexlib.utils.string_util import random_string
|
|
11
11
|
from trexlib.utils.common.common_util import logger
|
|
12
|
-
from
|
|
12
|
+
from trexconf import conf
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class SuperUser(UserMin):
|
|
@@ -3,7 +3,7 @@ Created on 25 Jan 2021
|
|
|
3
3
|
|
|
4
4
|
@author: jacklok
|
|
5
5
|
'''
|
|
6
|
-
from
|
|
6
|
+
from trexconf import conf as model_conf
|
|
7
7
|
from google.cloud import ndb
|
|
8
8
|
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
9
9
|
from datetime import timedelta
|
|
@@ -5,17 +5,7 @@ Created on 19 Feb 2021
|
|
|
5
5
|
'''
|
|
6
6
|
from google.cloud import ndb
|
|
7
7
|
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel, FullTextSearchable
|
|
8
|
-
from trexmodel.models.datastore.system_models import SentEmail
|
|
9
|
-
from trexmodel.models.datastore.user_models import UserMin
|
|
10
|
-
import trexmodel.conf as model_conf
|
|
11
|
-
from trexlib.utils.security_util import generate_user_id, hash_password
|
|
12
|
-
from trexlib.utils.string_util import random_number
|
|
13
8
|
import logging
|
|
14
|
-
from datetime import datetime, timedelta
|
|
15
|
-
from trexlib.utils.common.date_util import parse_datetime
|
|
16
|
-
from trexmodel import conf
|
|
17
|
-
from google.auth._default import default
|
|
18
|
-
from trexmodel.models.datastore.system_models import Tagging
|
|
19
9
|
|
|
20
10
|
|
|
21
11
|
logger = logging.getLogger('model')
|
|
@@ -13,7 +13,7 @@ from trexlib.utils.string_util import is_not_empty, is_empty
|
|
|
13
13
|
import logging
|
|
14
14
|
from trexlib.utils.common.date_util import convert_date_to_datetime,\
|
|
15
15
|
to_day_of_year
|
|
16
|
-
from
|
|
16
|
+
from trexconf import conf, program_conf
|
|
17
17
|
from six import string_types
|
|
18
18
|
from datetime import datetime, timedelta
|
|
19
19
|
from trexmodel.models.datastore.membership_models import MerchantTierMembership,\
|
|
@@ -46,6 +46,7 @@ class Customer(BaseNModel, DictModel, FullTextSearchable):
|
|
|
46
46
|
birth_day_in_year = ndb.IntegerProperty(required=False)
|
|
47
47
|
gender = ndb.StringProperty(required=False)
|
|
48
48
|
reference_code = ndb.StringProperty(required=True)
|
|
49
|
+
referral_code = ndb.StringProperty(required=False)
|
|
49
50
|
|
|
50
51
|
mobile_app_installed = ndb.BooleanProperty(required=False, default=False)
|
|
51
52
|
|
|
@@ -68,6 +69,8 @@ class Customer(BaseNModel, DictModel, FullTextSearchable):
|
|
|
68
69
|
entitled_membership_reward_summary = ndb.JsonProperty()
|
|
69
70
|
entitled_lucky_draw_ticket_summary = ndb.JsonProperty(required=False)
|
|
70
71
|
|
|
72
|
+
referrer_code = ndb.StringProperty(required=False)
|
|
73
|
+
|
|
71
74
|
kpi_summary = ndb.JsonProperty()
|
|
72
75
|
|
|
73
76
|
device_details = ndb.JsonProperty()
|
|
@@ -79,7 +82,7 @@ class Customer(BaseNModel, DictModel, FullTextSearchable):
|
|
|
79
82
|
'reward_summary', 'entitled_voucher_summary', 'prepaid_summary', 'kpi_summary', 'entitled_lucky_draw_ticket_summary',
|
|
80
83
|
'entitled_birthday_reward_summary', 'tier_membership_key',
|
|
81
84
|
'registered_outlet_key', 'registered_merchant_acct_key', 'registered_datetime', 'modified_datetime',
|
|
82
|
-
'registered_user_acct',
|
|
85
|
+
'registered_user_acct','referral_code',
|
|
83
86
|
|
|
84
87
|
]
|
|
85
88
|
|
|
@@ -267,6 +270,7 @@ class Customer(BaseNModel, DictModel, FullTextSearchable):
|
|
|
267
270
|
for ticket in tickets_list:
|
|
268
271
|
ticket.patch_prize_image_base_url()
|
|
269
272
|
Customer.update_ticket_into_lucky_draw_ticket_summary(customer_acct, ticket.to_configuration())
|
|
273
|
+
|
|
270
274
|
@classmethod
|
|
271
275
|
def get_by_reference_code(cls, reference_code, merchant_acct):
|
|
272
276
|
return cls.query(ndb.AND(cls.reference_code==reference_code, cls.merchant_acct==merchant_acct.create_ndb_key())).get()
|
|
@@ -353,6 +357,7 @@ class Customer(BaseNModel, DictModel, FullTextSearchable):
|
|
|
353
357
|
mobile_phone = user_acct.mobile_phone,
|
|
354
358
|
gender = user_acct.gender,
|
|
355
359
|
reference_code = user_acct.reference_code,
|
|
360
|
+
referral_code = user_acct.referral_code,
|
|
356
361
|
birth_date = user_acct.birth_date,
|
|
357
362
|
birth_date_date_str = user_acct.birth_date_date_str,
|
|
358
363
|
birth_day_in_year = user_acct.birth_day_in_year,
|
|
@@ -7,13 +7,6 @@ Created on 23 Oct 2020
|
|
|
7
7
|
from google.cloud import ndb
|
|
8
8
|
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
9
9
|
|
|
10
|
-
import logging
|
|
11
|
-
from trexlib.utils.security_util import generate_user_id, hash_password
|
|
12
|
-
|
|
13
|
-
from trexlib import conf as lib_conf
|
|
14
|
-
from trexmodel import conf as model_conf
|
|
15
|
-
import json
|
|
16
|
-
from json import JSONEncoder
|
|
17
10
|
from datetime import datetime
|
|
18
11
|
|
|
19
12
|
class FacebookSubscriber(BaseNModel, DictModel):
|
|
@@ -5,17 +5,13 @@ Created on 26 Sep 2023
|
|
|
5
5
|
'''
|
|
6
6
|
|
|
7
7
|
from google.cloud import ndb
|
|
8
|
-
from trexmodel.models.datastore.user_models import UserMin
|
|
9
|
-
from trexlib.utils.security_util import generate_user_id, hash_password
|
|
10
8
|
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
11
9
|
from trexlib.utils.string_util import random_string
|
|
12
|
-
from trexlib.utils.common.common_util import logger
|
|
13
|
-
from trexlib import conf
|
|
14
10
|
from trexmodel.models.datastore.merchant_models import MerchantAcct
|
|
15
11
|
import logging
|
|
16
12
|
import csv, io
|
|
17
13
|
|
|
18
|
-
from
|
|
14
|
+
from trexconf import program_conf
|
|
19
15
|
|
|
20
16
|
logger = logging.getLogger('model')
|
|
21
17
|
|
|
@@ -5,17 +5,9 @@ Created on 19 Aug 2021
|
|
|
5
5
|
'''
|
|
6
6
|
|
|
7
7
|
from google.cloud import ndb
|
|
8
|
-
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
9
|
-
from trexmodel.models.datastore.
|
|
10
|
-
|
|
11
|
-
from trexlib.utils.string_util import is_empty, is_not_empty
|
|
12
|
-
import logging, json
|
|
13
|
-
from trexmodel import conf, program_conf
|
|
14
|
-
from trexlib.utils.string_util import random_string
|
|
15
|
-
from datetime import datetime, timedelta
|
|
16
|
-
from trexmodel.models.datastore.customer_models import Customer
|
|
17
|
-
import trexmodel.conf as model_conf
|
|
18
|
-
from trexmodel.models.datastore.model_decorators import model_transactional
|
|
8
|
+
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
9
|
+
from trexmodel.models.datastore.merchant_models import MerchantUser
|
|
10
|
+
import logging
|
|
19
11
|
|
|
20
12
|
logger = logging.getLogger('model')
|
|
21
13
|
|
|
@@ -8,10 +8,10 @@ from google.cloud import ndb
|
|
|
8
8
|
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
9
9
|
from trexmodel.models.datastore.merchant_models import Outlet
|
|
10
10
|
from trexlib.utils.string_util import random_number
|
|
11
|
-
import logging
|
|
12
|
-
from
|
|
11
|
+
import logging
|
|
12
|
+
from trexconf import conf
|
|
13
13
|
from datetime import datetime
|
|
14
|
-
from google.api_core.operations_v1.operations_client_config import config
|
|
14
|
+
#from google.api_core.operations_v1.operations_client_config import config
|
|
15
15
|
|
|
16
16
|
logger = logging.getLogger('debug')
|
|
17
17
|
|
|
@@ -4,7 +4,7 @@ Created on 12 May 2023
|
|
|
4
4
|
@author: jacklok
|
|
5
5
|
'''
|
|
6
6
|
import logging
|
|
7
|
-
from
|
|
7
|
+
from trexconf import program_conf
|
|
8
8
|
import trexmodel.conf as model_conf
|
|
9
9
|
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
10
10
|
from google.cloud import ndb
|
|
@@ -9,7 +9,7 @@ from trexmodel.models.datastore.merchant_models import MerchantUser,\
|
|
|
9
9
|
MerchantAcct
|
|
10
10
|
from trexlib.utils.string_util import is_not_empty, random_string
|
|
11
11
|
from datetime import datetime
|
|
12
|
-
from
|
|
12
|
+
from trexconf import conf
|
|
13
13
|
import trexmodel.conf as model_conf
|
|
14
14
|
import logging
|
|
15
15
|
|
|
@@ -9,13 +9,12 @@ from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
|
9
9
|
import trexmodel.conf as model_conf
|
|
10
10
|
from trexlib.utils.string_util import is_not_empty, random_string
|
|
11
11
|
from trexmodel.models.datastore.merchant_models import MerchantAcct, \
|
|
12
|
-
MerchantUser
|
|
12
|
+
MerchantUser
|
|
13
13
|
import logging
|
|
14
14
|
from dateutil.relativedelta import relativedelta
|
|
15
|
-
from datetime import timedelta
|
|
16
15
|
|
|
17
16
|
from datetime import datetime
|
|
18
|
-
from
|
|
17
|
+
from trexconf import program_conf
|
|
19
18
|
|
|
20
19
|
logger = logging.getLogger('model')
|
|
21
20
|
|
|
@@ -14,10 +14,9 @@ from trexlib.utils.string_util import random_number, is_empty, is_not_empty,\
|
|
|
14
14
|
split_by_length, random_string
|
|
15
15
|
import logging
|
|
16
16
|
from datetime import datetime, timedelta
|
|
17
|
-
from
|
|
17
|
+
from trexconf import conf, program_conf
|
|
18
18
|
from trexmodel.models.datastore.system_models import Tagging
|
|
19
19
|
from trexmodel.models.datastore.model_decorators import model_transactional
|
|
20
|
-
from trexlib.utils.common.common_util import sort_dict_list
|
|
21
20
|
from trexmodel.program_conf import LOYALTY_PACKAGE_LITE, LOYALTY_PRODUCT
|
|
22
21
|
|
|
23
22
|
logger = logging.getLogger('model')
|
|
@@ -90,7 +89,7 @@ class MerchantAcct(MerchantMin):
|
|
|
90
89
|
dict_properties = ['company_name', 'brand_name', 'contact_name', 'business_reg_no', 'mobile_phone',
|
|
91
90
|
'office_phone', 'fax_phone', 'email', 'account_code', 'country',
|
|
92
91
|
'registered_datetime', 'modified_datetime', 'plan_start_date', 'plan_end_date', 'currency_code',
|
|
93
|
-
'timezone',
|
|
92
|
+
'timezone', 'effective_referral_program_count',
|
|
94
93
|
'published_program_configuration', 'published_referral_program_configuration',
|
|
95
94
|
'published_voucher_configuration', 'membership_configuration',
|
|
96
95
|
'tier_membership_configuration', 'prepaid_configuration', 'lucky_draw_configuration', 'product_modifier_configuration',
|
|
@@ -125,6 +124,31 @@ class MerchantAcct(MerchantMin):
|
|
|
125
124
|
|
|
126
125
|
return LOYALTY_PACKAGE_LITE
|
|
127
126
|
|
|
127
|
+
@property
|
|
128
|
+
def effective_referral_program_count(self):
|
|
129
|
+
if self.published_referral_program_configuration:
|
|
130
|
+
program_count = self.published_referral_program_configuration.get('count',0)
|
|
131
|
+
if program_count>0:
|
|
132
|
+
check_effective_count = 0
|
|
133
|
+
program_list = self.published_referral_program_configuration.get('programs');
|
|
134
|
+
today_date = datetime.today()
|
|
135
|
+
for program_details in program_list:
|
|
136
|
+
start_date_str = program_details.get('start_date')
|
|
137
|
+
start_date = datetime.strptime(start_date_str, '%d-%m-%Y')
|
|
138
|
+
|
|
139
|
+
end_date_str = program_details.get('end_date')
|
|
140
|
+
end_date = datetime.strptime(end_date_str, '%d-%m-%Y')
|
|
141
|
+
|
|
142
|
+
if start_date<=today_date and today_date<=end_date:
|
|
143
|
+
check_effective_count+=1
|
|
144
|
+
|
|
145
|
+
return check_effective_count
|
|
146
|
+
|
|
147
|
+
else:
|
|
148
|
+
return program_count
|
|
149
|
+
|
|
150
|
+
return 0
|
|
151
|
+
|
|
128
152
|
@property
|
|
129
153
|
def outlet_limit(self):
|
|
130
154
|
if self.account_plan:
|
|
@@ -7,7 +7,7 @@ from trexmodel.program_conf import REWARD_FORMAT_MAP, REWARD_FORMAT_PREPAID
|
|
|
7
7
|
from trexmodel.models.datastore.message_models import Message
|
|
8
8
|
from trexmodel.conf import MESSAGE_CATEGORY_REWARD, MESSAGE_STATUS_NEW,\
|
|
9
9
|
MESSAGE_CATEGORY_REDEEM
|
|
10
|
-
from
|
|
10
|
+
from trexconf import program_conf
|
|
11
11
|
from babel.numbers import format_currency
|
|
12
12
|
import logging
|
|
13
13
|
|
|
@@ -7,13 +7,9 @@ Created on 9 Nov 2023
|
|
|
7
7
|
from google.cloud import ndb
|
|
8
8
|
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
9
9
|
from trexmodel.models.datastore.user_models import User
|
|
10
|
-
|
|
10
|
+
from datetime import datetime
|
|
11
11
|
import logging
|
|
12
|
-
from datetime import datetime, timedelta
|
|
13
|
-
from trexlib.utils.common.date_util import parse_datetime
|
|
14
12
|
from trexmodel import conf
|
|
15
|
-
from google.auth._default import default
|
|
16
|
-
from trexmodel.models.datastore.system_models import Tagging
|
|
17
13
|
from trexmodel.conf import MESSAGE_STATUS_SET, MESSAGE_STATUS_NEW, MESSAGE_CATEGORY_SYSTEM,\
|
|
18
14
|
MESSAGE_STATUS_READ, MESSAGE_CATEGORIES, MESSAGE_CATEGORY_ANNOUNCEMENT
|
|
19
15
|
from trexmodel.models.datastore.transaction_models import CustomerTransaction
|
|
@@ -12,9 +12,9 @@ from six import string_types
|
|
|
12
12
|
from trexlib.utils.common.date_util import increase_date
|
|
13
13
|
import logging
|
|
14
14
|
#from google.cloud.ndb._datastore_query import Cursor
|
|
15
|
-
from google.cloud.ndb import Cursor
|
|
16
|
-
from
|
|
17
|
-
from
|
|
15
|
+
#from google.cloud.ndb import Cursor
|
|
16
|
+
from trexconf import conf as lib_conf
|
|
17
|
+
from trexconf import conf as model_conf
|
|
18
18
|
from google.cloud.datastore.helpers import GeoPoint
|
|
19
19
|
|
|
20
20
|
logger = logging.getLogger('model')
|
|
@@ -288,7 +288,7 @@ class BaseNModel(DictModel, NDBModel):
|
|
|
288
288
|
def count_with_condition_query(cls, query, limit=model_conf.MAX_FETCH_RECORD):
|
|
289
289
|
|
|
290
290
|
|
|
291
|
-
return query.count(limit=limit
|
|
291
|
+
return query.count(limit=limit)
|
|
292
292
|
|
|
293
293
|
@classmethod
|
|
294
294
|
def list_all(cls, offset=0, start_cursor=None, return_with_cursor=False, keys_only=False,
|
|
@@ -411,7 +411,7 @@ class FullTextSearchable(ndb.Model):
|
|
|
411
411
|
|
|
412
412
|
logger.debug('query=%s', query)
|
|
413
413
|
|
|
414
|
-
return query.count(limit=limit
|
|
414
|
+
return query.count(limit=limit)
|
|
415
415
|
|
|
416
416
|
|
|
417
417
|
|
|
@@ -3,8 +3,8 @@ from google.cloud import ndb
|
|
|
3
3
|
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
4
4
|
from trexmodel.models.datastore.merchant_models import Outlet
|
|
5
5
|
from trexlib.utils.string_util import random_number, is_not_empty
|
|
6
|
-
import logging
|
|
7
|
-
from
|
|
6
|
+
import logging
|
|
7
|
+
from trexconf import conf
|
|
8
8
|
from datetime import datetime
|
|
9
9
|
from trexmodel.models.datastore.product_models import ProductCatalogue
|
|
10
10
|
from trexmodel.models.datastore.model_decorators import model_transactional
|
|
@@ -9,11 +9,9 @@ from trexmodel.models.datastore.user_models import User
|
|
|
9
9
|
from trexmodel.models.datastore.merchant_models import MerchantAcct, Outlet, MerchantUser
|
|
10
10
|
import logging, json
|
|
11
11
|
from trexmodel import conf, program_conf
|
|
12
|
-
from trexlib.utils.string_util import
|
|
13
|
-
from datetime import datetime
|
|
14
|
-
import trexmodel.conf as model_conf
|
|
12
|
+
from trexlib.utils.string_util import random_number, is_not_empty
|
|
13
|
+
from datetime import datetime
|
|
15
14
|
from trexlib.utils.common.common_util import sort_dict_list
|
|
16
|
-
from trexmodel.utils.model.model_util import generate_transaction_id
|
|
17
15
|
from dateutil.relativedelta import relativedelta
|
|
18
16
|
from trexmodel.program_conf import PRODUCT_TYPES, LOYALTY_PRODUCT
|
|
19
17
|
from trexlib.utils.crypto_util import encrypt
|
|
@@ -568,9 +566,11 @@ class CustomerPrepaidReward(BaseNModel,DictModel):
|
|
|
568
566
|
topup_prepaid_rate = CustomerPrepaidReward.__calculate_topup_prepaid_rate(prepaid_scheme_details)
|
|
569
567
|
|
|
570
568
|
topup_by_key = None
|
|
569
|
+
topup_by_username = None
|
|
571
570
|
|
|
572
571
|
if topup_by:
|
|
573
572
|
topup_by_key = topup_by.create_ndb_key()
|
|
573
|
+
topup_by_username = topup_by.username
|
|
574
574
|
|
|
575
575
|
if topup_datetime is None:
|
|
576
576
|
topup_datetime = datetime.utcnow()
|
|
@@ -591,7 +591,7 @@ class CustomerPrepaidReward(BaseNModel,DictModel):
|
|
|
591
591
|
invoice_id = invoice_id,
|
|
592
592
|
|
|
593
593
|
topup_by = topup_by_key,
|
|
594
|
-
|
|
594
|
+
topup_by_username = topup_by_username,
|
|
595
595
|
topup_datetime = topup_datetime,
|
|
596
596
|
)
|
|
597
597
|
|
|
@@ -599,6 +599,42 @@ class CustomerPrepaidReward(BaseNModel,DictModel):
|
|
|
599
599
|
|
|
600
600
|
return prepaid_topup_reward
|
|
601
601
|
|
|
602
|
+
@staticmethod
|
|
603
|
+
def create(customer_acct, topup_outlet,
|
|
604
|
+
topup_amount=0, topup_unit=0, topup_prepaid_rate = 1,
|
|
605
|
+
prepaid_amount=.0, prepaid_scheme_details={},
|
|
606
|
+
topup_datetime=None, topup_by=None,
|
|
607
|
+
transaction_id=None, invoice_id=None,
|
|
608
|
+
):
|
|
609
|
+
|
|
610
|
+
merchant_acct = customer_acct.registered_merchant_acct
|
|
611
|
+
|
|
612
|
+
topup_by_key = None
|
|
613
|
+
topup_by_username = None
|
|
614
|
+
|
|
615
|
+
if topup_by:
|
|
616
|
+
topup_by_key = topup_by.create_ndb_key()
|
|
617
|
+
topup_by_username = topup_by.username
|
|
618
|
+
|
|
619
|
+
CustomerPrepaidReward(
|
|
620
|
+
parent = customer_acct.create_ndb_key(),
|
|
621
|
+
merchant_acct = merchant_acct.create_ndb_key(),
|
|
622
|
+
topup_outlet = topup_outlet.create_ndb_key() if topup_outlet else None,
|
|
623
|
+
topup_amount = topup_amount,
|
|
624
|
+
topup_unit = topup_unit,
|
|
625
|
+
prepaid_amount = prepaid_amount,
|
|
626
|
+
topup_prepaid_rate = topup_prepaid_rate,
|
|
627
|
+
used_prepaid_amount = .0,
|
|
628
|
+
prepaid_scheme_details = prepaid_scheme_details,
|
|
629
|
+
|
|
630
|
+
transaction_id = transaction_id,
|
|
631
|
+
invoice_id = invoice_id,
|
|
632
|
+
|
|
633
|
+
topup_by = topup_by_key,
|
|
634
|
+
topup_by_username = topup_by_username,
|
|
635
|
+
topup_datetime = topup_datetime,
|
|
636
|
+
|
|
637
|
+
)
|
|
602
638
|
|
|
603
639
|
@staticmethod
|
|
604
640
|
def delete_all_by_customer(customer):
|
|
@@ -5,14 +5,11 @@ Created on 23 Jul 2021
|
|
|
5
5
|
'''
|
|
6
6
|
from google.cloud import ndb
|
|
7
7
|
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel, FullTextSearchable
|
|
8
|
-
from trexmodel.models.datastore.user_models import User
|
|
9
8
|
from trexmodel.models.datastore.merchant_models import MerchantAcct, MerchantUser
|
|
10
9
|
from trexlib.utils.string_util import is_empty, is_not_empty
|
|
11
|
-
import logging
|
|
12
|
-
from
|
|
10
|
+
import logging
|
|
11
|
+
from trexconf import conf
|
|
13
12
|
from trexlib.utils.string_util import random_string
|
|
14
|
-
from datetime import datetime, timedelta
|
|
15
|
-
from trexmodel.models.datastore.customer_models import Customer
|
|
16
13
|
import trexmodel.conf as model_conf
|
|
17
14
|
from trexmodel.models.datastore.model_decorators import model_transactional
|
|
18
15
|
from flask_babel import gettext
|
|
@@ -7,11 +7,9 @@ from google.cloud import ndb
|
|
|
7
7
|
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
8
8
|
import trexmodel.conf as model_conf
|
|
9
9
|
from trexlib.utils.string_util import is_not_empty, random_string
|
|
10
|
-
from trexmodel.models.datastore.merchant_models import MerchantAcct,
|
|
11
|
-
MerchantUser
|
|
12
|
-
from trexmodel.models.datastore.coporate_models import CorporateAcct
|
|
10
|
+
from trexmodel.models.datastore.merchant_models import MerchantAcct,MerchantUser
|
|
13
11
|
import logging
|
|
14
|
-
from
|
|
12
|
+
from trexconf import conf, program_conf
|
|
15
13
|
from datetime import datetime
|
|
16
14
|
from trexmodel.models.datastore.model_decorators import model_transactional
|
|
17
15
|
from trexlib.utils.common.common_util import sort_list, sort_dict_list
|
|
@@ -7,7 +7,7 @@ from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
|
7
7
|
from google.cloud import ndb
|
|
8
8
|
from trexmodel.models.datastore.merchant_models import MerchantAcct, Outlet
|
|
9
9
|
from trexmodel.models.datastore.user_models import User
|
|
10
|
-
from
|
|
10
|
+
from trexconf import conf
|
|
11
11
|
from datetime import datetime, timedelta
|
|
12
12
|
import logging
|
|
13
13
|
|
|
@@ -6,10 +6,6 @@ Created on 27 Mar 2024
|
|
|
6
6
|
|
|
7
7
|
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
8
8
|
from google.cloud import ndb
|
|
9
|
-
from trexmodel.models.datastore.merchant_models import MerchantAcct, Outlet
|
|
10
|
-
from trexmodel.models.datastore.user_models import User
|
|
11
|
-
from trexmodel import conf
|
|
12
|
-
from datetime import datetime, timedelta
|
|
13
9
|
import logging
|
|
14
10
|
from builtins import staticmethod
|
|
15
11
|
|
|
@@ -10,12 +10,11 @@ from trexmodel.models.datastore.user_models import User
|
|
|
10
10
|
from trexmodel.models.datastore.merchant_models import MerchantAcct, Outlet, MerchantUser
|
|
11
11
|
from trexlib.utils.string_util import is_empty, is_not_empty
|
|
12
12
|
import logging, json
|
|
13
|
-
from
|
|
13
|
+
from trexconf import conf, program_conf
|
|
14
14
|
from datetime import datetime, timedelta
|
|
15
15
|
from trexmodel.utils.model.model_util import generate_transaction_id
|
|
16
16
|
from trexmodel.models.datastore.reward_models import CustomerPointReward,\
|
|
17
17
|
CustomerStampReward, CustomerEntitledVoucher
|
|
18
|
-
from trexmodel.models.datastore.model_decorators import model_transactional
|
|
19
18
|
from trexmodel.models.datastore.customer_models import Customer
|
|
20
19
|
from trexmodel.models.datastore.transaction_models import CustomerTransaction
|
|
21
20
|
from trexmodel.models.datastore.prepaid_models import CustomerPrepaidReward
|
{trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/redemption_catalogue_models.py
RENAMED
|
@@ -7,8 +7,7 @@ import logging
|
|
|
7
7
|
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
8
8
|
from google.cloud import ndb
|
|
9
9
|
from datetime import datetime
|
|
10
|
-
import
|
|
11
|
-
from trexmodel import program_conf
|
|
10
|
+
from trexconf import program_conf, conf as model_conf
|
|
12
11
|
from trexmodel.models.datastore.merchant_models import MerchantUser,\
|
|
13
12
|
MerchantAcct
|
|
14
13
|
from trexlib.utils.string_util import is_not_empty, is_empty
|
|
@@ -7,15 +7,12 @@ Created on 8 Apr 2024
|
|
|
7
7
|
from google.cloud import ndb
|
|
8
8
|
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
9
9
|
import trexmodel.conf as model_conf
|
|
10
|
-
from trexlib.utils.string_util import is_not_empty
|
|
11
|
-
from trexmodel.models.datastore.merchant_models import MerchantAcct,
|
|
12
|
-
MerchantUser
|
|
13
|
-
from trexmodel.models.datastore.coporate_models import CorporateAcct
|
|
10
|
+
from trexlib.utils.string_util import is_not_empty
|
|
11
|
+
from trexmodel.models.datastore.merchant_models import MerchantAcct, MerchantUser
|
|
14
12
|
import logging
|
|
15
|
-
from
|
|
13
|
+
from trexconf import conf, program_conf
|
|
16
14
|
from datetime import datetime
|
|
17
15
|
from trexmodel.models.datastore.model_decorators import model_transactional
|
|
18
|
-
from trexlib.utils.common.common_util import sort_list, sort_dict_list
|
|
19
16
|
from builtins import staticmethod
|
|
20
17
|
|
|
21
18
|
|
|
@@ -9,7 +9,7 @@ from dateutil.relativedelta import relativedelta
|
|
|
9
9
|
from trexlib.utils.string_util import is_not_empty
|
|
10
10
|
|
|
11
11
|
import logging
|
|
12
|
-
from
|
|
12
|
+
from trexconf import program_conf
|
|
13
13
|
from trexmodel.models.datastore.reward_models import CustomerEntitledVoucher
|
|
14
14
|
from trexmodel.models.datastore.voucher_models import MerchantVoucher
|
|
15
15
|
|
|
@@ -12,7 +12,7 @@ from trexmodel.models.datastore.program_models import MerchantProgram,\
|
|
|
12
12
|
from trexmodel.models.datastore.voucher_models import MerchantVoucher
|
|
13
13
|
from trexlib.utils.string_util import is_empty, is_not_empty
|
|
14
14
|
import logging
|
|
15
|
-
from
|
|
15
|
+
from trexconf import conf, program_conf
|
|
16
16
|
from trexlib.utils.string_util import random_string
|
|
17
17
|
from datetime import datetime, timedelta
|
|
18
18
|
from trexmodel.utils.model.model_util import generate_transaction_id,\
|
|
@@ -5,18 +5,8 @@ Created on 16 May 2021
|
|
|
5
5
|
'''
|
|
6
6
|
|
|
7
7
|
from google.cloud import ndb
|
|
8
|
-
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
9
|
-
from trexmodel.models.datastore.system_models import SentEmail
|
|
10
|
-
from trexmodel.models.datastore.user_models import UserMin
|
|
11
|
-
import trexmodel.conf as model_conf
|
|
12
|
-
from trexlib.utils.security_util import generate_user_id, hash_password
|
|
13
|
-
from trexlib.utils.string_util import random_number
|
|
8
|
+
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
14
9
|
import logging
|
|
15
|
-
from datetime import datetime, timedelta
|
|
16
|
-
from trexlib.utils.common.date_util import parse_datetime
|
|
17
|
-
from trexmodel import conf
|
|
18
|
-
from google.auth._default import default
|
|
19
|
-
from trexmodel.models.datastore.system_models import Tagging
|
|
20
10
|
|
|
21
11
|
|
|
22
12
|
logger = logging.getLogger('model')
|
|
@@ -13,7 +13,7 @@ from trexlib.utils.string_util import is_not_empty
|
|
|
13
13
|
from trexmodel.models.datastore.merchant_models import MerchantAcct, Outlet,\
|
|
14
14
|
MerchantUser
|
|
15
15
|
import logging
|
|
16
|
-
from
|
|
16
|
+
from trexconf import conf, program_conf
|
|
17
17
|
from datetime import datetime, timedelta
|
|
18
18
|
from trexmodel.utils.model.model_util import generate_transaction_id
|
|
19
19
|
from trexmodel.models.datastore.membership_models import MerchantMembership,\
|
|
@@ -327,7 +327,14 @@ class CustomerTransaction(SalesTransaction):
|
|
|
327
327
|
transact_datetime=transact_datetime, reward_giveaway_method=program_conf.PROGRAM_REWARD_GIVEAWAY_METHOD_MANUAL,
|
|
328
328
|
is_sales_transaction = is_sales_transaction, allow_to_revert=allow_to_revert,
|
|
329
329
|
is_membership_purchase=is_membership_purchase, is_membership_renew=is_membership_renew,
|
|
330
|
-
)
|
|
330
|
+
)
|
|
331
|
+
|
|
332
|
+
@staticmethod
|
|
333
|
+
def create_referral_transaction(customer, transact_outlet=None, transact_datetime=None, ):
|
|
334
|
+
return CustomerTransaction.create_system_transaction(customer, transact_outlet=transact_outlet,
|
|
335
|
+
transact_datetime=transact_datetime, reward_giveaway_method=program_conf.PROGRAM_REWARD_GIVEAWAY_METHOD_REFERRAL,
|
|
336
|
+
allow_to_revert=False,
|
|
337
|
+
)
|
|
331
338
|
|
|
332
339
|
@staticmethod
|
|
333
340
|
def create_from_sales_transaction(customer, sales_transaction):
|
|
@@ -5,19 +5,16 @@ Created on 10 Apr 2020
|
|
|
5
5
|
'''
|
|
6
6
|
from google.cloud import ndb
|
|
7
7
|
from trexmodel.models.datastore.ndb_models import BaseNModel, DictModel
|
|
8
|
-
from trexlib.utils.string_util import random_number,
|
|
8
|
+
from trexlib.utils.string_util import random_number, random_string,\
|
|
9
9
|
is_empty
|
|
10
10
|
from flask_login import UserMixin
|
|
11
11
|
import logging
|
|
12
12
|
from trexlib.utils.security_util import generate_user_id, hash_password
|
|
13
13
|
|
|
14
|
-
from
|
|
15
|
-
from
|
|
16
|
-
import json
|
|
17
|
-
from json import JSONEncoder
|
|
14
|
+
from trexconf import conf as lib_conf
|
|
15
|
+
from trexconf import conf as model_conf, conf
|
|
18
16
|
from trexlib.utils.common.date_util import to_day_of_year
|
|
19
17
|
from datetime import datetime, timedelta
|
|
20
|
-
from flask_babel import gettext
|
|
21
18
|
from trexmodel.conf import USER_STATUS_ANONYMOUS, ACCOUNT_LOCKED_IN_MINUTES
|
|
22
19
|
|
|
23
20
|
logger = logging.getLogger("model")
|
|
@@ -127,6 +124,7 @@ class UserBase(UserMin):
|
|
|
127
124
|
# User System Generated fields
|
|
128
125
|
#---------------------------------------------------------------------------
|
|
129
126
|
reference_code = ndb.StringProperty(required=True)
|
|
127
|
+
referral_code = ndb.StringProperty(required=True)
|
|
130
128
|
|
|
131
129
|
#---------------------------------------------------------------------------
|
|
132
130
|
# User Mutual Mandatory fields
|
|
@@ -202,16 +200,33 @@ class UserBase(UserMin):
|
|
|
202
200
|
|
|
203
201
|
@classmethod
|
|
204
202
|
def list_by_email(cls, email):
|
|
205
|
-
return
|
|
206
|
-
|
|
203
|
+
return cls.query(ndb.AND(User.email==email)).fetch(limit=conf.MAX_FETCH_RECORD)
|
|
204
|
+
|
|
207
205
|
@classmethod
|
|
208
206
|
def get_by_mobile_phone(cls, mobile_phone):
|
|
209
207
|
return User.query(ndb.AND(User.mobile_phone==mobile_phone, User.deleted==False)).get()
|
|
210
208
|
|
|
209
|
+
@classmethod
|
|
210
|
+
def get_by_referral_code(cls, referral_code):
|
|
211
|
+
return User.query(ndb.AND(User.referral_code==referral_code)).get()
|
|
212
|
+
|
|
211
213
|
@classmethod
|
|
212
214
|
def get_by_reset_password_token(cls, request_reset_password_token):
|
|
213
215
|
return User.query(ndb.AND(User.request_reset_password_token==request_reset_password_token)).get()
|
|
214
216
|
|
|
217
|
+
@classmethod
|
|
218
|
+
def count_all(cls):
|
|
219
|
+
return cls.count(limit=conf.MAX_FETCH_RECORD)
|
|
220
|
+
|
|
221
|
+
@classmethod
|
|
222
|
+
def _generate_referral_code(cls):
|
|
223
|
+
referral_code = random_string(8, is_human_mistake_safe=True)
|
|
224
|
+
checking_user = cls.get_by_referral_code(referral_code)
|
|
225
|
+
while checking_user is not None:
|
|
226
|
+
referral_code = random_string(8, is_human_mistake_safe=True)
|
|
227
|
+
checking_user = cls.get_by_referral_code(referral_code)
|
|
228
|
+
return referral_code
|
|
229
|
+
|
|
215
230
|
@classmethod
|
|
216
231
|
def create(cls, name=None, email=None, mobile_phone=None,
|
|
217
232
|
gender=None, birth_date=None,
|
|
@@ -241,8 +256,9 @@ class UserBase(UserMin):
|
|
|
241
256
|
reference_code=reference_code, status=status,
|
|
242
257
|
)
|
|
243
258
|
|
|
244
|
-
hashed_password
|
|
245
|
-
created_user.password
|
|
259
|
+
hashed_password = hash_password(user_id, password)
|
|
260
|
+
created_user.password = hashed_password
|
|
261
|
+
created_user.referral_code = cls._generate_referral_code()
|
|
246
262
|
|
|
247
263
|
|
|
248
264
|
created_user.is_email_verified = is_email_verified
|
|
@@ -266,11 +282,14 @@ class UserBase(UserMin):
|
|
|
266
282
|
|
|
267
283
|
mobile_phone = kwargs.get('mobile_phone')
|
|
268
284
|
password = kwargs.get('password')
|
|
269
|
-
status = kwargs.get('status')
|
|
285
|
+
#status = kwargs.get('status')
|
|
270
286
|
|
|
271
287
|
if mobile_phone:
|
|
272
288
|
mobile_phone = mobile_phone.replace(" ", "")
|
|
273
289
|
|
|
290
|
+
if is_empty(user_acct.referral_code):
|
|
291
|
+
user_acct.referral_code = cls._generate_referral_code()
|
|
292
|
+
|
|
274
293
|
kwargs['mobile_phone'] = mobile_phone
|
|
275
294
|
|
|
276
295
|
for key, value in kwargs.items():
|
|
@@ -10,7 +10,7 @@ from trexlib.utils.string_util import is_not_empty
|
|
|
10
10
|
from trexmodel.models.datastore.merchant_models import MerchantAcct, \
|
|
11
11
|
MerchantUser
|
|
12
12
|
import logging
|
|
13
|
-
from
|
|
13
|
+
from trexconf import program_conf
|
|
14
14
|
from datetime import datetime
|
|
15
15
|
from trexmodel.program_conf import VOUCHER_REWARD_TYPE,\
|
|
16
16
|
VOUCHER_REWARD_MAX_QUANTITY,\
|
|
@@ -2,6 +2,7 @@ from trexmodel.models.datastore.pos_models import InvoiceNoGeneration,\
|
|
|
2
2
|
RoundingSetup, DinningOption, PosPaymentMethod
|
|
3
3
|
from trexmodel.models.datastore.merchant_models import ReceiptSetup, Outlet,\
|
|
4
4
|
BannerFile
|
|
5
|
+
from trexlib.utils.string_util import is_not_empty
|
|
5
6
|
|
|
6
7
|
def construct_merchant_acct_info(merchant_acct):
|
|
7
8
|
account_settings = {
|
|
@@ -31,6 +32,8 @@ def construct_merchant_acct_info(merchant_acct):
|
|
|
31
32
|
|
|
32
33
|
}
|
|
33
34
|
|
|
35
|
+
referral_program_settings = merchant_acct.program_settings.get('referral_program', {})
|
|
36
|
+
|
|
34
37
|
info = {
|
|
35
38
|
'key' : merchant_acct.key_in_str,
|
|
36
39
|
'company_name' : merchant_acct.company_name,
|
|
@@ -43,7 +46,21 @@ def construct_merchant_acct_info(merchant_acct):
|
|
|
43
46
|
'account_settings' : account_settings,
|
|
44
47
|
'outlets' : outlet_json_list,
|
|
45
48
|
'banners' : banner_listing,
|
|
49
|
+
|
|
46
50
|
}
|
|
51
|
+
if is_not_empty(referral_program_settings):
|
|
52
|
+
|
|
53
|
+
info['referral_program_settings'] = {
|
|
54
|
+
'program_count' : merchant_acct.effective_referral_program_count,
|
|
55
|
+
'referrer_promote_title' : referral_program_settings.get('referrer_promote_title'),
|
|
56
|
+
'referrer_promote_desc' : referral_program_settings.get('referrer_promote_desc'),
|
|
57
|
+
'referrer_promote_image' : referral_program_settings.get('referrer_promote_image'),
|
|
58
|
+
'referee_promote_title' : referral_program_settings.get('referee_promote_title'),
|
|
59
|
+
'referee_promote_desc' : referral_program_settings.get('referee_promote_desc'),
|
|
60
|
+
'referee_promote_image' : referral_program_settings.get('referee_promote_image'),
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
47
64
|
return info
|
|
48
65
|
|
|
49
66
|
def construct_outlet_info(outlet):
|
|
@@ -219,6 +219,7 @@ PROGRAM_REWARD_GIVEAWAY_METHOD_MANUAL = 'manual'
|
|
|
219
219
|
PROGRAM_REWARD_GIVEAWAY_METHOD_SYSTEM = 'system'
|
|
220
220
|
PROGRAM_REWARD_GIVEAWAY_METHOD_TIER = 'tier'
|
|
221
221
|
PROGRAM_REWARD_GIVEAWAY_METHOD_REDEEM = 'redeem'
|
|
222
|
+
PROGRAM_REWARD_GIVEAWAY_METHOD_REFERRAL = 'referral'
|
|
222
223
|
|
|
223
224
|
GIVEAWAY_SYSTEM_CONDITION_NEW_MEMBERSHIP = 'new_membership'
|
|
224
225
|
GIVEAWAY_SYSTEM_CONDITION_RENEW_MEMBERSHIP = 'renew_membership'
|
|
@@ -7,7 +7,7 @@ from google.cloud import ndb
|
|
|
7
7
|
from google.oauth2 import service_account
|
|
8
8
|
from google.auth import crypt
|
|
9
9
|
import io, json, logging
|
|
10
|
-
from
|
|
10
|
+
from trexconf import conf as model_conf
|
|
11
11
|
import six
|
|
12
12
|
from datetime import datetime
|
|
13
13
|
from trexlib.utils.string_util import random_number
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{trex-model-1.3.9 → trex-model-1.4.1}/trexmodel/models/datastore/spending_base_program_model.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|