owl-cli 7.19.0 → 7.21.0
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.
- package/docs/image.png +0 -0
- package/docs/tree.md +25 -0
- package/examples/models/owlsys/organization/orgs.json +1 -1
- package/examples/models/owlsys/region/mall_region/api/src/eventHandlers/autoSetRegionFullPath_addAfter.jsx +25 -0
- package/examples/models/owlsys/region/mall_region/api/src/eventHandlers/autoSetRegionFullPath_updateBefore.jsx +23 -0
- package/examples/models/owlsys/region/region.json +81 -0
- package/examples/models/owlsys/user/{org_user/api/src/plugins/addToOrgUser.jsx → org_member/api/src/plugins/addToOrgMember.jsx} +8 -12
- package/examples/models/owlsys/user/{org_user.json → org_member.json} +7 -7
- package/examples/owlsysApps/owlService/build.xml +29 -0
- package/examples/owlsysApps/owlService/src/handlers/getSensitiveWord.jsx +25 -0
- package/examples/owlsysApps/owlService/src/icon.png +0 -0
- package/examples/owlsysApps/owlService/src/meta.json +58 -0
- package/examples/owlsysApps/owlService/src/pages/home.jsx +16 -0
- package/examples/owlsysApps/owlService/src/pages/home.jsxp +27 -0
- package/examples/owlsysApps/owlService/src/services/cart/CartService.jsx +25 -0
- package/examples/owlsysApps/owlService/src/services/cart/CartUtil.jsx +421 -0
- package/examples/owlsysApps/owlService/src/services/cart/OrderService.jsx +15 -0
- package/examples/owlsysApps/owlService/src/services/cart/OrderUtil.jsx +122 -0
- package/examples/owlsysApps/owlService/src/services/common/CommonUtil.jsx +257 -0
- package/examples/owlsysApps/owlService/src/services/common/IdCardService.jsx +42 -0
- package/examples/owlsysApps/owlService/src/services/common/ImageUtil.jsx +69 -0
- package/examples/owlsysApps/owlService/src/services/common/OwlDigestUtil.jsx +35 -0
- package/examples/owlsysApps/owlService/src/services/common/SearchUtil.jsx +212 -0
- package/examples/owlsysApps/owlService/src/services/common/SettingUtil.jsx +38 -0
- package/examples/owlsysApps/owlService/src/services/datacenter/BuyCouponOrderUtil.jsx +20 -0
- package/examples/owlsysApps/owlService/src/services/datacenter/PointCouponOrderUtil.jsx +20 -0
- package/examples/owlsysApps/owlService/src/services/ewallet/AigcEWalletUtil.jsx +96 -0
- package/examples/owlsysApps/owlService/src/services/ewallet/AigcOrgEWalletUtil.jsx +77 -0
- package/examples/owlsysApps/owlService/src/services/ewallet/EWalletUtil.jsx +87 -0
- package/examples/owlsysApps/owlService/src/services/ewallet/OrgEWalletUtil.jsx +77 -0
- package/examples/owlsysApps/owlService/src/services/history/ProductHistoryUtil.jsx +24 -0
- package/examples/owlsysApps/owlService/src/services/lottery/LotteryUtil.jsx +563 -0
- package/examples/owlsysApps/owlService/src/services/message/MessageUtil.jsx +34 -0
- package/examples/owlsysApps/owlService/src/services/message/WxMessageUtil.jsx +32 -0
- package/examples/owlsysApps/owlService/src/services/order/OrderAddHelper.jsx +111 -0
- package/examples/owlsysApps/owlService/src/services/order/OrderLogUtil.jsx +57 -0
- package/examples/owlsysApps/owlService/src/services/order/OrderRefundUtil.jsx +138 -0
- package/examples/owlsysApps/owlService/src/services/order/OrderUseDcTicketHelper.jsx +153 -0
- package/examples/owlsysApps/owlService/src/services/order/OrderUseTicketHelper.jsx +161 -0
- package/examples/owlsysApps/owlService/src/services/order/OrderUtil.jsx +139 -0
- package/examples/owlsysApps/owlService/src/services/order/PayRecordHelper.jsx +212 -0
- package/examples/owlsysApps/owlService/src/services/order/RefundOrderHelper.jsx +36 -0
- package/examples/owlsysApps/owlService/src/services/order/RefundRecordHelper.jsx +69 -0
- package/examples/owlsysApps/owlService/src/services/order/ReturnOrderHelper.jsx +61 -0
- package/examples/owlsysApps/owlService/src/services/order/ValidateCodeHelper.jsx +20 -0
- package/examples/owlsysApps/owlService/src/services/org/OrgUtil.jsx +408 -0
- package/examples/owlsysApps/owlService/src/services/permission/permissionHelper.jsx +0 -0
- package/examples/owlsysApps/owlService/src/services/product/PriceUtil.jsx +19 -0
- package/examples/owlsysApps/owlService/src/services/product/ProductCategoryUtil.jsx +37 -0
- package/examples/owlsysApps/owlService/src/services/product/ProductLogUtil.jsx +52 -0
- package/examples/owlsysApps/owlService/src/services/product/ProductUtil.jsx +392 -0
- package/examples/owlsysApps/owlService/src/services/product/SkuSearchUtil.jsx +71 -0
- package/examples/owlsysApps/owlService/src/services/product/SkuUtil.jsx +75 -0
- package/examples/owlsysApps/owlService/src/services/region/RegionUtil.jsx +46 -0
- package/examples/owlsysApps/owlService/src/services/resell/ResellBrokerageUtil.jsx +151 -0
- package/examples/owlsysApps/owlService/src/services/resell/ResellerUtil.jsx +107 -0
- package/examples/owlsysApps/owlService/src/services/user/InvoiceService.jsx +59 -0
- package/examples/owlsysApps/owlService/src/services/user/LoginService.jsx +46 -0
- package/examples/owlsysApps/owlService/src/services/user/OrgInvoiceService.jsx +59 -0
- package/examples/owlsysApps/owlService/src/services/user/OrgUserAddressService.jsx +99 -0
- package/examples/owlsysApps/owlService/src/services/user/UserAddressService.jsx +85 -0
- package/examples/owlsysApps/owlService/src/services/user/UserCategoryUtil.jsx +46 -0
- package/examples/owlsysApps/owlService/src/services/user/UserLogUtil.jsx +27 -0
- package/examples/owlsysApps/owlService/src/services/user/UserThirdUtil.jsx +22 -0
- package/examples/owlsysApps/owlService/src/services/user/UserUtil.jsx +76 -0
- package/examples/owlsysApps/owlShell/src/handlers/changePassword.jsx +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,563 @@
|
|
|
1
|
+
//#import DateUtil.js
|
|
2
|
+
//#import $owl_mall_u:services/modelService.jsx
|
|
3
|
+
//#import $owl_lottery_activity:services/modelService.jsx
|
|
4
|
+
//#import $owl_lottery_activity_item:services/modelService.jsx
|
|
5
|
+
//#import $owl_lottery_hit_record:services/modelService.jsx
|
|
6
|
+
//#import $owl_lottery_qualification_amount:services/modelService.jsx
|
|
7
|
+
//#import $owl_mall_big_member_integrallog:services/modelService.jsx
|
|
8
|
+
//#import $wsBigMemberInterface:services/TotappsCRMService.jsx
|
|
9
|
+
//#import $wsBigMemberInterface:services/BigMemberEnumUtil.jsx
|
|
10
|
+
//#import $wsBigMemberInterface:services/BigMemberUtil.jsx
|
|
11
|
+
//#import $commonService:services/FreeGetCardUtil.jsx
|
|
12
|
+
//#import $commonService:services/CommonUtil.jsx
|
|
13
|
+
//#import $owlService:services/common/CommonUtil.jsx
|
|
14
|
+
|
|
15
|
+
var LotteryUtil = (function () {
|
|
16
|
+
var f = {
|
|
17
|
+
doAward: function (lotteryActivityId, userId) {
|
|
18
|
+
var lockId = "LockDoAward_" + lotteryActivityId;
|
|
19
|
+
owl_lottery_activityService.lock(lockId);
|
|
20
|
+
try {
|
|
21
|
+
var jUser = owl_mall_uService.get(userId);
|
|
22
|
+
var jLotteryActivity = owl_lottery_activityService.get(lotteryActivityId);
|
|
23
|
+
if (!f.isMatchLotteryRule(jLotteryActivity, jUser)) {
|
|
24
|
+
return {code: "301", msg: jLotteryActivity.show_msg_2 || "无抽奖资格"};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var total = jLotteryActivity.amount;
|
|
28
|
+
var items = f.getItems(jLotteryActivity.id);
|
|
29
|
+
|
|
30
|
+
var availableItems = [];
|
|
31
|
+
for (var i = 0; i < items.length; i++) {
|
|
32
|
+
var jItem = items[i];
|
|
33
|
+
|
|
34
|
+
//只取有库存的奖项来参与中奖
|
|
35
|
+
$.log("LotteryUtil.jsx...doAward...lotteryActivityId=" + lotteryActivityId + "...jItem.id=" + jItem.id + "...jItem.amount=" + jItem.amount + "...jItem.unit_amount=" + jItem.unit_amount + "...jItem.rate=" + jItem.rate);
|
|
36
|
+
if (Number(jItem.amount) < Number(jItem.unit_amount)) {
|
|
37
|
+
//将总参与人数减掉没有奖品的中奖区间
|
|
38
|
+
total = total - Number(jItem.rate);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
availableItems.push(jItem);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
$.log("LotteryUtil.jsx...doAward...lotteryActivityId=" + lotteryActivityId + "...userId=" + userId + "...total=" + total);
|
|
46
|
+
var jItem = f.doRandomAward(availableItems, total);
|
|
47
|
+
if (jItem) {
|
|
48
|
+
if (Number(jItem.amount) >= Number(jItem.unit_amount)) {
|
|
49
|
+
var jHitRecord = {};
|
|
50
|
+
jHitRecord.lottery_activity_id = jLotteryActivity.id;
|
|
51
|
+
jHitRecord.lottery_activity_name = jLotteryActivity.name;
|
|
52
|
+
jHitRecord.create_time = new Date().getTime();
|
|
53
|
+
jHitRecord.user_id = userId;
|
|
54
|
+
jHitRecord.user_mobile = jUser.mobile || "";
|
|
55
|
+
jHitRecord.is_win = "n";
|
|
56
|
+
jHitRecord.is_true = "y";
|
|
57
|
+
jHitRecord.is_accept = "n";
|
|
58
|
+
jHitRecord.item_id = jItem.id;
|
|
59
|
+
jHitRecord.item_name = jItem.name;
|
|
60
|
+
jHitRecord.item_type = jItem.type;
|
|
61
|
+
owl_lottery_hit_recordService.add(jHitRecord);
|
|
62
|
+
|
|
63
|
+
//扣减抽奖资格次数
|
|
64
|
+
f.reduceHitAmount(jLotteryActivity, jUser, jHitRecord);
|
|
65
|
+
|
|
66
|
+
//扣减奖品库存
|
|
67
|
+
jItem = owl_lottery_activity_itemService.get(jItem.id);
|
|
68
|
+
jItem.amount = Number(jItem.amount) - 1;
|
|
69
|
+
owl_lottery_activity_itemService.update(jItem);
|
|
70
|
+
|
|
71
|
+
if (jItem.type != "none") {
|
|
72
|
+
//jHitRecord之前先设置is_win=n,因为前面的代码暂时需要用到抽奖记录,如果是中奖了,这里要设置is_win=y
|
|
73
|
+
jHitRecord = owl_lottery_hit_recordService.get(jHitRecord.id);
|
|
74
|
+
jHitRecord.is_win = "y";
|
|
75
|
+
owl_lottery_hit_recordService.update(jHitRecord);
|
|
76
|
+
|
|
77
|
+
//根据不同的奖品类型发放奖品
|
|
78
|
+
f.doGiveAward(jLotteryActivity, jItem, jUser, jHitRecord);
|
|
79
|
+
|
|
80
|
+
return {code: "0", msg: jItem.show_msg || jLotteryActivity.show_msg_0 || "恭喜,中奖了!", data: jHitRecord};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return {code: "1", msg: jLotteryActivity.show_msg_1 || "未中奖"};
|
|
86
|
+
} finally {
|
|
87
|
+
owl_lottery_activityService.unlock(lockId);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
isMatchLotteryRule: function (jLotteryActivity, jUser) {
|
|
91
|
+
var userId = jUser.id;
|
|
92
|
+
var lotteryActivityId = jLotteryActivity.id;
|
|
93
|
+
var type = jLotteryActivity.type;
|
|
94
|
+
$.log("LotteryUtil.jsx...isMatchLotteryRule...lotteryActivityId=" + lotteryActivityId + "...userId=" + userId + "...type=" + type);
|
|
95
|
+
if (type == "byDay") {
|
|
96
|
+
//每天可抽奖
|
|
97
|
+
var jQualification = owl_lottery_qualification_amountService.get("owl_lottery_qualification_amount_" + lotteryActivityId + "_" + userId);
|
|
98
|
+
var default_amount = 0;//默认已抽奖次数
|
|
99
|
+
var amount = 0;//剩余可用数量
|
|
100
|
+
if (jQualification) {
|
|
101
|
+
amount = jQualification.amount || 0;
|
|
102
|
+
var last_used_time = jQualification.last_used_time;
|
|
103
|
+
if (last_used_time) {
|
|
104
|
+
var curTime = new Date().getTime();
|
|
105
|
+
var curDate = DateUtil.getShortDate(curTime);
|
|
106
|
+
var lastDate = DateUtil.getShortDate(new Date(last_used_time).getTime());//默认抽奖资格计算日期
|
|
107
|
+
if (curDate == lastDate) {
|
|
108
|
+
default_amount = Number(jQualification.default_amount || 0);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
var defaultLotteryAmount = f.getDefaultQualificationAmount(jLotteryActivity, jUser, Number(jLotteryActivity.lottery_amount || 0));//默认可抽奖次数
|
|
114
|
+
var canUseAmount = defaultLotteryAmount - default_amount + amount;
|
|
115
|
+
$.log("LotteryUtil.jsx...isMatchLotteryRule...lotteryActivityId=" + lotteryActivityId + "...userId=" + userId + "...111...defaultLotteryAmount=" + defaultLotteryAmount + "...default_amount=" + default_amount + "...amount=" + amount + "...canUseAmount=" + canUseAmount);
|
|
116
|
+
if (canUseAmount > 0) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
} else if (type == "dyna") {
|
|
121
|
+
//动态抽奖资格
|
|
122
|
+
var jQualification = owl_lottery_qualification_amountService.get("owl_lottery_qualification_amount_" + lotteryActivityId + "_" + userId);
|
|
123
|
+
var default_amount = 0;//默认已抽奖次数
|
|
124
|
+
var amount = 0;//剩余可用数量
|
|
125
|
+
if (jQualification) {
|
|
126
|
+
default_amount = Number(jQualification.default_amount || 0);
|
|
127
|
+
amount = Number(jQualification.amount || 0);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
var defaultLotteryAmount = f.getDefaultQualificationAmount(jLotteryActivity, jUser, 0);//默认可抽奖次数
|
|
131
|
+
var canUseAmount = defaultLotteryAmount - default_amount + amount;
|
|
132
|
+
$.log("LotteryUtil.jsx...isMatchLotteryRule...lotteryActivityId=" + lotteryActivityId + "...userId=" + userId + "...222...defaultLotteryAmount=" + defaultLotteryAmount + "...default_amount=" + default_amount + "...amount=" + amount + "...canUseAmount=" + canUseAmount);
|
|
133
|
+
if (canUseAmount > 0) {
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return false;
|
|
138
|
+
} else if (type == "point") {
|
|
139
|
+
//积分抽奖
|
|
140
|
+
var jArgs = TotappsCRMService.getArgs();
|
|
141
|
+
var branchcode = "124";
|
|
142
|
+
var memberId = null;
|
|
143
|
+
var bigMemberInfo = jUser.bigMemberInfo;
|
|
144
|
+
if (bigMemberInfo && bigMemberInfo.memberid) {
|
|
145
|
+
memberId = bigMemberInfo.memberid;
|
|
146
|
+
}
|
|
147
|
+
if (!memberId) {
|
|
148
|
+
var memberInfo = BigMemberUtil.getMemberInfoByUser(jArgs, jUser, branchcode, true);
|
|
149
|
+
memberId = memberInfo.memberid;
|
|
150
|
+
}
|
|
151
|
+
if (!memberId) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
var totalLessPoint = BigMemberUtil.getMemberPoint(jArgs, branchcode, memberId);
|
|
155
|
+
$.log("LotteryUtil.jsx...isMatchLotteryRule...lotteryActivityId=" + lotteryActivityId + "...userId=" + userId + "...333...totalLessPoint=" + totalLessPoint);
|
|
156
|
+
if (totalLessPoint >= Number(jLotteryActivity.lottery_point)) {
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
return false;
|
|
162
|
+
},
|
|
163
|
+
/**
|
|
164
|
+
* 扣减抽奖资格
|
|
165
|
+
*/
|
|
166
|
+
reduceHitAmount: function (jLotteryActivity, jUser, jHitRecord) {
|
|
167
|
+
var userId = jUser.id;
|
|
168
|
+
var lotteryActivityId = jLotteryActivity.id;
|
|
169
|
+
var type = jLotteryActivity.type;
|
|
170
|
+
$.log("LotteryUtil.jsx...reduceHitAmount...lotteryActivityId=" + lotteryActivityId + "...userId=" + userId + "...type=" + type);
|
|
171
|
+
if (type == "byDay") {
|
|
172
|
+
//每天可抽奖
|
|
173
|
+
var jQualification = owl_lottery_qualification_amountService.get("owl_lottery_qualification_amount_" + lotteryActivityId + "_" + userId);
|
|
174
|
+
var default_amount = 0;//默认已抽奖次数
|
|
175
|
+
var lastDate = "";
|
|
176
|
+
var curTime = new Date().getTime();
|
|
177
|
+
var curDate = DateUtil.getShortDate(curTime);
|
|
178
|
+
if (jQualification) {
|
|
179
|
+
default_amount = jQualification.default_amount;
|
|
180
|
+
var last_used_time = jQualification.last_used_time;
|
|
181
|
+
if (last_used_time) {
|
|
182
|
+
lastDate = DateUtil.getShortDate(new Date(last_used_time).getTime());//默认抽奖资格计算日期
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (curDate == lastDate) {
|
|
186
|
+
jQualification.default_amount = Number(default_amount) + 1;
|
|
187
|
+
} else {
|
|
188
|
+
jQualification.default_amount = 1;
|
|
189
|
+
}
|
|
190
|
+
jQualification.last_used_time = new Date().getTime();
|
|
191
|
+
owl_lottery_qualification_amountService.update(jQualification);
|
|
192
|
+
|
|
193
|
+
$.log("LotteryUtil.jsx...reduceHitAmount...lotteryActivityId=" + lotteryActivityId + "...userId=" + userId + "...update...default_amount=" + jQualification.default_amount);
|
|
194
|
+
} else {
|
|
195
|
+
jQualification = {};
|
|
196
|
+
jQualification.lottery_activity_id = lotteryActivityId;
|
|
197
|
+
jQualification.user_id = userId;
|
|
198
|
+
jQualification.amount = 0;
|
|
199
|
+
jQualification.default_amount = 1;
|
|
200
|
+
jQualification.last_used_time = new Date().getTime();
|
|
201
|
+
owl_lottery_qualification_amountService.add(jQualification);
|
|
202
|
+
|
|
203
|
+
$.log("LotteryUtil.jsx...reduceHitAmount...lotteryActivityId=" + lotteryActivityId + "...userId=" + userId + "...add...default_amount=" + jQualification.default_amount);
|
|
204
|
+
}
|
|
205
|
+
} else if (type == "dyna") {
|
|
206
|
+
//动态抽奖资格
|
|
207
|
+
var jQualification = owl_lottery_qualification_amountService.get("owl_lottery_qualification_amount_" + lotteryActivityId + "_" + userId);
|
|
208
|
+
var default_amount = 0;//默认已抽奖次数
|
|
209
|
+
var amount = 0;//剩余可用数量
|
|
210
|
+
var defaultLotteryAmount = f.getDefaultQualificationAmount(jLotteryActivity, jUser, 0);//默认可抽奖次数
|
|
211
|
+
if (jQualification) {
|
|
212
|
+
default_amount = Number(jQualification.default_amount || 0);
|
|
213
|
+
amount = Number(jQualification.amount || 0);
|
|
214
|
+
|
|
215
|
+
if (default_amount < defaultLotteryAmount) {
|
|
216
|
+
jQualification.default_amount = default_amount + 1;
|
|
217
|
+
} else {
|
|
218
|
+
jQualification.amount = amount - 1;
|
|
219
|
+
}
|
|
220
|
+
jQualification.last_used_time = new Date().getTime();
|
|
221
|
+
owl_lottery_qualification_amountService.update(jQualification);
|
|
222
|
+
$.log("LotteryUtil.jsx...reduceHitAmount...lotteryActivityId=" + lotteryActivityId + "...userId=" + userId + "...update...amount=" + jQualification.amount + "...default_amount=" + jQualification.default_amount);
|
|
223
|
+
} else {
|
|
224
|
+
jQualification = {};
|
|
225
|
+
jQualification.lottery_activity_id = lotteryActivityId;
|
|
226
|
+
jQualification.user_id = userId;
|
|
227
|
+
jQualification.default_amount = 1;
|
|
228
|
+
jQualification.amount = 0;
|
|
229
|
+
jQualification.last_used_time = new Date().getTime();
|
|
230
|
+
owl_lottery_qualification_amountService.add(jQualification);
|
|
231
|
+
$.log("LotteryUtil.jsx...reduceHitAmount...lotteryActivityId=" + lotteryActivityId + "...userId=" + userId + "...add...amount=" + jQualification.amount + "...default_amount=" + jQualification.default_amount);
|
|
232
|
+
}
|
|
233
|
+
} else if (type == "point") {
|
|
234
|
+
//积分抽奖
|
|
235
|
+
if (!jLotteryActivity.lottery_point) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
var jArgs = TotappsCRMService.getArgs();
|
|
239
|
+
var branchcode = "124";
|
|
240
|
+
var memberId = null;
|
|
241
|
+
var bigMemberInfo = jUser.bigMemberInfo;
|
|
242
|
+
if (bigMemberInfo && bigMemberInfo.memberid) {
|
|
243
|
+
memberId = bigMemberInfo.memberid;
|
|
244
|
+
}
|
|
245
|
+
if (!memberId) {
|
|
246
|
+
var memberInfo = BigMemberUtil.getMemberInfoByUser(jArgs, jUser, branchcode, true);
|
|
247
|
+
memberId = memberInfo.memberid;
|
|
248
|
+
}
|
|
249
|
+
if (!memberId) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
var totalLessPoint = BigMemberUtil.getMemberPoint(jArgs, branchcode, memberId);
|
|
253
|
+
$.log("LotteryUtil.jsx...reduceHitAmount...lotteryActivityId=" + lotteryActivityId + "...userId=" + userId + "...totalLessPoint=" + totalLessPoint + "...lottery_point=" + jLotteryActivity.lottery_point);
|
|
254
|
+
f.reduceUserPoint(jArgs, totalLessPoint, jLotteryActivity.lottery_point, branchcode, userId, memberId, jHitRecord.id);
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
/**
|
|
258
|
+
* 根据会员所属分类获取默认可抽奖资格次数
|
|
259
|
+
*/
|
|
260
|
+
getDefaultQualificationAmount: function (jLotteryActivity, jUser, defaultValue) {
|
|
261
|
+
var defaultAmountList = jLotteryActivity.default_amount;
|
|
262
|
+
|
|
263
|
+
$.log("LotteryUtil.jsx...getDefaultQualificationAmount...lotteryActivityId=" + jLotteryActivity.id + "...defaultValue=" + defaultValue + "...jLotteryActivity=" + JSON.stringify(jLotteryActivity));
|
|
264
|
+
|
|
265
|
+
var user_catIds = CommonUtilEx.getUserCatIds(jUser.id);
|
|
266
|
+
var maxDefaultAmount = defaultValue;
|
|
267
|
+
if (defaultAmountList) {
|
|
268
|
+
defaultAmountList.forEach(function (jRecord) {
|
|
269
|
+
var user_cat_id = jRecord.user_cat_id;
|
|
270
|
+
var amount = jRecord.amount;
|
|
271
|
+
if (user_cat_id && amount) {
|
|
272
|
+
//所有会员都属于普通会员
|
|
273
|
+
if (user_cat_id == "owl_mall_u_category__c_101_o" || CommonUtil.isExist(user_catIds, user_cat_id)) {
|
|
274
|
+
if (maxDefaultAmount < Number(amount)) {
|
|
275
|
+
maxDefaultAmount = Number(amount);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
return maxDefaultAmount;
|
|
282
|
+
},
|
|
283
|
+
getLastHitRecord: function (lotteryActivityId, userId) {
|
|
284
|
+
var searchArgs = {};
|
|
285
|
+
searchArgs.lottery_activity_id = lotteryActivityId;
|
|
286
|
+
searchArgs.user_id = userId;
|
|
287
|
+
var searchResult = owl_lottery_hit_recordService.search(null, searchArgs, null, 0, 1, [{"owl_createTime": {order: "desc"}}]);
|
|
288
|
+
|
|
289
|
+
if (searchResult.state === 'ok') {
|
|
290
|
+
var list = searchResult.list;
|
|
291
|
+
if (list && list.length > 0) {
|
|
292
|
+
return list[0];
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return null;
|
|
296
|
+
},
|
|
297
|
+
getItems: function (lotteryActivityId) {
|
|
298
|
+
var searchArgs = {};
|
|
299
|
+
searchArgs.lottery_activity_id = lotteryActivityId;
|
|
300
|
+
var searchResult = owl_lottery_activity_itemService.search(null, searchArgs, null, 0, 200, [{"owl_createTime": {order: "desc"}}]);
|
|
301
|
+
|
|
302
|
+
if (searchResult.state === 'ok') {
|
|
303
|
+
return searchResult.list;
|
|
304
|
+
}
|
|
305
|
+
return [];
|
|
306
|
+
},
|
|
307
|
+
/**
|
|
308
|
+
* 根据奖品类型发奖
|
|
309
|
+
*/
|
|
310
|
+
doGiveAward: function (jLotteryActivity, jItem, jUser, jHitRecord) {
|
|
311
|
+
var lotteryActivityId = jLotteryActivity.id;
|
|
312
|
+
var userId = jUser.id;
|
|
313
|
+
var type = jItem.type;
|
|
314
|
+
if (type == "ticket") {
|
|
315
|
+
//送券奖
|
|
316
|
+
if (!jItem.ticket_type_id || !jItem.unit_amount) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
var freeRes = FreeGetCardUtil.doGiveCard(userId, jItem.ticket_type_id, Number(jItem.unit_amount), "", "", "", "", "", "lottery", null);
|
|
320
|
+
$.log("LotteryUtil.jsx...doGiveAward...freeRes=" + JSON.stringify(freeRes));
|
|
321
|
+
} else if (type == "point") {
|
|
322
|
+
//送积分奖
|
|
323
|
+
if (!jItem.unit_amount) {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
var jArgs = TotappsCRMService.getArgs();
|
|
327
|
+
var branchcode = "124";
|
|
328
|
+
var memberId = null;
|
|
329
|
+
var bigMemberInfo = jUser.bigMemberInfo;
|
|
330
|
+
if (bigMemberInfo && bigMemberInfo.memberid) {
|
|
331
|
+
memberId = bigMemberInfo.memberid;
|
|
332
|
+
}
|
|
333
|
+
if (!memberId) {
|
|
334
|
+
var memberInfo = BigMemberUtil.getMemberInfoByUser(jArgs, jUser, branchcode, true);
|
|
335
|
+
memberId = memberInfo.memberid;
|
|
336
|
+
}
|
|
337
|
+
if (!memberId) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
var totalLessPoint = BigMemberUtil.getMemberPoint(jArgs, branchcode, memberId);
|
|
341
|
+
f.givePoint(jArgs, totalLessPoint, jItem.unit_amount, branchcode, userId, memberId, jHitRecord.id);
|
|
342
|
+
} else if (type == "lottery") {
|
|
343
|
+
//抽奖机会
|
|
344
|
+
if (!jItem.unit_amount) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
var jQualification = owl_lottery_qualification_amountService.get("owl_lottery_qualification_amount_" + lotteryActivityId + "_" + userId);
|
|
348
|
+
if (!jQualification) {
|
|
349
|
+
jQualification = {};
|
|
350
|
+
jQualification.lottery_activity_id = lotteryActivityId;
|
|
351
|
+
jQualification.user_id = userId;
|
|
352
|
+
jQualification.amount = Number(jItem.unit_amount);
|
|
353
|
+
jQualification.default_amount = 0;
|
|
354
|
+
owl_lottery_qualification_amountService.add(jQualification);
|
|
355
|
+
} else {
|
|
356
|
+
jQualification.amount = Number(jQualification.amount || 0) + Number(jItem.unit_amount);
|
|
357
|
+
owl_lottery_qualification_amountService.update(jQualification);
|
|
358
|
+
}
|
|
359
|
+
} else if (type == "other") {
|
|
360
|
+
//其他奖品
|
|
361
|
+
|
|
362
|
+
} else if (type == "usergroup") {
|
|
363
|
+
//会员组特权
|
|
364
|
+
if (!jItem.user_cat_id) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
var jUserCategory = owl_mall_u_categoryService.get(jItem.user_cat_id);
|
|
368
|
+
if (!jUserCategory) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
var user_catIds = CommonUtilEx.getUserCatIds(jUser.id);
|
|
373
|
+
if (CommonUtil.isExist(user_catIds, jItem.user_cat_id)) {
|
|
374
|
+
//已经是属于该会员组了,就不继续了
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
jUser = owl_mall_uService.get(jUser.id);
|
|
379
|
+
var user_categories = jUser.user_categories;
|
|
380
|
+
if (!user_categories) {
|
|
381
|
+
user_categories = [];
|
|
382
|
+
jUser.user_categories = user_categories;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
var jCategory = {
|
|
386
|
+
"id": jUserCategory.id,
|
|
387
|
+
"name": jUserCategory.name,
|
|
388
|
+
"createTime": new Date().getTime()
|
|
389
|
+
};
|
|
390
|
+
if (jItem.user_cat_begin_time) {
|
|
391
|
+
jCategory.beginTime = new Date(jItem.user_cat_begin_time).getTime();
|
|
392
|
+
}
|
|
393
|
+
if (jItem.user_cat_end_time) {
|
|
394
|
+
jCategory.endTime = new Date(jItem.user_cat_end_time).getTime();
|
|
395
|
+
}
|
|
396
|
+
user_categories.push(jCategory);
|
|
397
|
+
owl_mall_uService.update(jUser);
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
doRandomAward: function (items, rangeNum) {
|
|
401
|
+
try {
|
|
402
|
+
if (items.length > 0) {
|
|
403
|
+
var randomNum = f.getRandomInt(1, rangeNum);//产生中奖随机数
|
|
404
|
+
|
|
405
|
+
var hitPercents = [];//中奖机率,排列与上面对应
|
|
406
|
+
var i = 0;
|
|
407
|
+
for (var k = 0; k < items.length; k++) {
|
|
408
|
+
var jItem = items[k];
|
|
409
|
+
hitPercents[i] = jItem.rate;
|
|
410
|
+
//以下算出每个中奖级别的中奖范围
|
|
411
|
+
var beginNum = 0;
|
|
412
|
+
var endNum = 0;
|
|
413
|
+
for (var j = 0; j < i; j++) {
|
|
414
|
+
beginNum += hitPercents[j];//此值是这个的简化:rangeNum * hitPercents[j] / rangeNum;
|
|
415
|
+
}
|
|
416
|
+
endNum = beginNum + hitPercents[i];
|
|
417
|
+
|
|
418
|
+
if (randomNum > beginNum && randomNum <= endNum) {
|
|
419
|
+
return jItem;
|
|
420
|
+
}
|
|
421
|
+
i++;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
} catch (e) {
|
|
425
|
+
//出异常默认不中奖
|
|
426
|
+
}
|
|
427
|
+
return null;
|
|
428
|
+
},
|
|
429
|
+
getRandomInt: function (min, max) {
|
|
430
|
+
min = Math.ceil(min);
|
|
431
|
+
max = Math.floor(max);
|
|
432
|
+
return Math.floor(Math.random() * (max - min + 1)) + min; //含最大值,含最小值
|
|
433
|
+
},
|
|
434
|
+
reduceUserPoint: function (jArgs, totalLessPoint, amount, branchcode, userId, memberId, order_id) {
|
|
435
|
+
var curTime = new Date().getTime();
|
|
436
|
+
var billdate = DateUtil.getStringDate(curTime, "yyyyMMddHHmmss");
|
|
437
|
+
var posno = BigMemberEnumUtil.POS_NO;//终端编码,例如收银机编号,无法提供时约定固定值
|
|
438
|
+
var billno = "";//交易小票号,无法提供时约定固定值
|
|
439
|
+
var logId = owl_mall_big_member_integrallogService.getId({});
|
|
440
|
+
|
|
441
|
+
amount = Number(0 - Number(amount)).toFixed(2);
|
|
442
|
+
|
|
443
|
+
var tranReason = BigMemberEnumUtil.lotteryReduce;
|
|
444
|
+
var merchantId = "0";
|
|
445
|
+
var shopName = "江豚网";
|
|
446
|
+
|
|
447
|
+
var data = {
|
|
448
|
+
type: tranReason.big,
|
|
449
|
+
billdate: billdate,
|
|
450
|
+
point: amount,
|
|
451
|
+
cno: logId,
|
|
452
|
+
saleid: logId,
|
|
453
|
+
posno: posno,
|
|
454
|
+
billno: billno,
|
|
455
|
+
actcode: "",
|
|
456
|
+
othernotype: "5",
|
|
457
|
+
otherno: memberId
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
var postData = TotappsCRMService.getPostData(jArgs, branchcode);
|
|
461
|
+
postData.data = data;
|
|
462
|
+
|
|
463
|
+
var result = TotappsCRMService.updatePoint(jArgs, postData);
|
|
464
|
+
var jResult = JSON.parse(result);
|
|
465
|
+
|
|
466
|
+
var ret = {};
|
|
467
|
+
if (Number(jResult.rescode) != 0) {
|
|
468
|
+
ret.state = "err";
|
|
469
|
+
ret.msg = "积分扣减失败,失败原因:" + jResult.restext;
|
|
470
|
+
return ret;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
//增加交易明细记录....begin
|
|
475
|
+
var transactionLog = {};
|
|
476
|
+
transactionLog.id = logId;
|
|
477
|
+
transactionLog.merchantId = merchantId;
|
|
478
|
+
transactionLog.branchcode = branchcode;
|
|
479
|
+
transactionLog.shopName = shopName;
|
|
480
|
+
transactionLog.memberId = memberId;
|
|
481
|
+
transactionLog.userId = userId;
|
|
482
|
+
transactionLog.beforeAmount = Number(totalLessPoint).toFixed(2);
|
|
483
|
+
transactionLog.amount = amount;
|
|
484
|
+
transactionLog.afterAmount = Number((Number(transactionLog.beforeAmount) + Number(amount))).toFixed(2);
|
|
485
|
+
transactionLog.reason = tranReason.name;
|
|
486
|
+
transactionLog.orderId = order_id;
|
|
487
|
+
transactionLog.type = "reduce";
|
|
488
|
+
transactionLog.source_id = tranReason.ws;
|
|
489
|
+
transactionLog.source_name = tranReason.name;
|
|
490
|
+
transactionLog.createTime = new Date().getTime();
|
|
491
|
+
owl_mall_big_member_integrallogService.add(transactionLog);
|
|
492
|
+
|
|
493
|
+
ret.state = "ok";
|
|
494
|
+
ret.msg = "扣减积分成功";
|
|
495
|
+
return ret;
|
|
496
|
+
},
|
|
497
|
+
givePoint: function (jArgs, totalLessPoint, amount, branchcode, userId, memberId, order_id) {
|
|
498
|
+
var curTime = new Date().getTime();
|
|
499
|
+
var billdate = DateUtil.getStringDate(curTime, "yyyyMMddHHmmss");
|
|
500
|
+
var posno = BigMemberEnumUtil.POS_NO;//终端编码,例如收银机编号,无法提供时约定固定值
|
|
501
|
+
var billno = "";//交易小票号,无法提供时约定固定值
|
|
502
|
+
var logId = owl_mall_big_member_integrallogService.getId({});
|
|
503
|
+
|
|
504
|
+
amount = Number(amount).toFixed(2);
|
|
505
|
+
|
|
506
|
+
var tranReason = BigMemberEnumUtil.lotteryGive;
|
|
507
|
+
var merchantId = "0";
|
|
508
|
+
var shopName = "江豚网";
|
|
509
|
+
|
|
510
|
+
var data = {
|
|
511
|
+
type: tranReason.big,
|
|
512
|
+
billdate: billdate,
|
|
513
|
+
point: amount,
|
|
514
|
+
cno: logId,
|
|
515
|
+
saleid: logId,
|
|
516
|
+
posno: posno,
|
|
517
|
+
billno: billno,
|
|
518
|
+
actcode: "",
|
|
519
|
+
othernotype: "5",
|
|
520
|
+
otherno: memberId
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
var postData = TotappsCRMService.getPostData(jArgs, branchcode);
|
|
524
|
+
postData.data = data;
|
|
525
|
+
|
|
526
|
+
var result = TotappsCRMService.updatePoint(jArgs, postData);
|
|
527
|
+
var jResult = JSON.parse(result);
|
|
528
|
+
|
|
529
|
+
var ret = {};
|
|
530
|
+
if (Number(jResult.rescode) != 0) {
|
|
531
|
+
ret.state = "err";
|
|
532
|
+
ret.msg = "发放积分失败,失败原因:" + jResult.restext;
|
|
533
|
+
return ret;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
//增加交易明细记录....begin
|
|
538
|
+
var transactionLog = {};
|
|
539
|
+
transactionLog.id = logId;
|
|
540
|
+
transactionLog.merchantId = merchantId;
|
|
541
|
+
transactionLog.branchcode = branchcode;
|
|
542
|
+
transactionLog.shopName = shopName;
|
|
543
|
+
transactionLog.memberId = memberId;
|
|
544
|
+
transactionLog.userId = userId;
|
|
545
|
+
transactionLog.beforeAmount = Number(totalLessPoint).toFixed(2);
|
|
546
|
+
transactionLog.amount = amount;
|
|
547
|
+
transactionLog.afterAmount = Number((Number(transactionLog.beforeAmount) + Number(amount))).toFixed(2);
|
|
548
|
+
transactionLog.reason = tranReason.name;
|
|
549
|
+
transactionLog.orderId = order_id;
|
|
550
|
+
transactionLog.type = "recharge";
|
|
551
|
+
transactionLog.source_id = tranReason.ws;
|
|
552
|
+
transactionLog.source_name = tranReason.name;
|
|
553
|
+
transactionLog.createTime = new Date().getTime();
|
|
554
|
+
owl_mall_big_member_integrallogService.add(transactionLog);
|
|
555
|
+
|
|
556
|
+
ret.state = "ok";
|
|
557
|
+
ret.msg = "发放积分成功";
|
|
558
|
+
return ret;
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
return f;
|
|
562
|
+
|
|
563
|
+
})();
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#import $owl_message_read:services/modelService.jsx
|
|
2
|
+
|
|
3
|
+
var MessageUtil = (function () {
|
|
4
|
+
var f = {
|
|
5
|
+
getReadState: function (messageId, toObjId){
|
|
6
|
+
var key = "owl_message_read_" + messageId + "_" + toObjId;
|
|
7
|
+
var jMessageRead = owl_message_readService.get(key);
|
|
8
|
+
if (jMessageRead && jMessageRead.state == "1") {
|
|
9
|
+
return "1";
|
|
10
|
+
}
|
|
11
|
+
return "0";
|
|
12
|
+
},
|
|
13
|
+
updateToRead: function (messageId, toObjId) {
|
|
14
|
+
var key = "owl_message_read_" + messageId + "_" + toObjId;
|
|
15
|
+
var jMessageRead = owl_message_readService.get(key);
|
|
16
|
+
if (jMessageRead) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
jMessageRead = {
|
|
21
|
+
"_t": "message_read",
|
|
22
|
+
"message_id": messageId,
|
|
23
|
+
"toObjId": toObjId,
|
|
24
|
+
"state": "1",
|
|
25
|
+
"_orgId": "0",
|
|
26
|
+
"_orgIds": ["0"],
|
|
27
|
+
"createTime": new Date().getTime()
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
owl_message_readService.add(jMessageRead);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
return f;
|
|
34
|
+
})();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#import $owl_wxmessage_que:services/modelService.jsx
|
|
2
|
+
//#import $owlService:services/user/UserThirdUtil.jsx
|
|
3
|
+
|
|
4
|
+
var WxMessageUtil = (function () {
|
|
5
|
+
var f = {
|
|
6
|
+
doAddMessageQue: function (userId, template_id, page, jContent) {
|
|
7
|
+
try {
|
|
8
|
+
var jThirdOpenId = UserThirdUtil.getThirdOpenId("owl_user_third_openid_source_wx7a495c566f2277c0", "openid", userId);
|
|
9
|
+
if (!jThirdOpenId || !jThirdOpenId.openid) {
|
|
10
|
+
//如果存在openid信息,则发送小程序订阅信息
|
|
11
|
+
$.log("WxMessageUtil...stop...openid is null...userId=" + userId + "...template_id=" + template_id);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
var appid = "wx7a495c566f2277c0";
|
|
15
|
+
|
|
16
|
+
var jMessageQue = {};
|
|
17
|
+
jMessageQue.template_id = template_id;
|
|
18
|
+
jMessageQue.user_id = userId;
|
|
19
|
+
jMessageQue.openid = jThirdOpenId.openid;
|
|
20
|
+
jMessageQue.appid = appid;
|
|
21
|
+
jMessageQue.page = page;
|
|
22
|
+
jMessageQue.content = JSON.stringify(jContent);
|
|
23
|
+
|
|
24
|
+
owl_wxmessage_queService.add(jMessageQue);
|
|
25
|
+
$.log("WxMessageUtil...add que ok...userId=" + userId + "...template_id=" + template_id + "...id=" + jMessageQue.id);
|
|
26
|
+
} catch (e) {
|
|
27
|
+
$.log("WxMessageUtil...userId=" + userId + "...template_id=" + template_id + "...id=" + jMessageQue.id + "...error=" + e);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
return f;
|
|
32
|
+
})();
|