ts-glitter 20.5.1 → 20.5.3

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.
Files changed (44) hide show
  1. package/lowcode/Entry.js +1 -1
  2. package/lowcode/Entry.ts +1 -1
  3. package/lowcode/cms-plugin/member-setting.js +2 -4
  4. package/lowcode/cms-plugin/member-setting.ts +2 -4
  5. package/lowcode/cms-plugin/module/user-excel.js +25 -21
  6. package/lowcode/cms-plugin/module/user-excel.ts +9 -6
  7. package/lowcode/cms-plugin/stock-history.ts +0 -1
  8. package/lowcode/cms-plugin/user-list.js +98 -97
  9. package/lowcode/cms-plugin/user-list.ts +111 -103
  10. package/lowcode/modules/checkInput.js +2 -2
  11. package/lowcode/modules/checkInput.ts +58 -61
  12. package/lowcode/public-components/checkout/index.js +0 -1
  13. package/lowcode/public-components/checkout/index.ts +0 -1
  14. package/lowcode/public-components/user-manager/um-info.js +49 -48
  15. package/lowcode/public-components/user-manager/um-info.ts +219 -204
  16. package/lowcode/public-components/user-manager/um-order.js +25 -22
  17. package/lowcode/public-components/user-manager/um-order.ts +32 -23
  18. package/lowcode/src/glitterBundle/module/Animation.js +7 -13
  19. package/lowcode/src/glitterBundle/module/Enum.js +2 -6
  20. package/lowcode/src/glitterBundle/module/Html_generate.js +50 -42
  21. package/lowcode/src/glitterBundle/module/PageManager.js +23 -30
  22. package/lowcode/src/glitterBundle/plugins/click-event.js +25 -19
  23. package/lowcode/src/glitterBundle/plugins/dialog-style-editor.js +13 -16
  24. package/lowcode/src/glitterBundle/plugins/editor-elem.js +1 -6
  25. package/lowcode/src/glitterBundle/plugins/editor.js +1 -5
  26. package/lowcode/src/glitterBundle/plugins/html-render.js +2 -5
  27. package/lowcode/src/glitterBundle/plugins/plugin-creater.js +28 -22
  28. package/lowcode/src/glitterBundle/plugins/seo-manager.js +1 -5
  29. package/lowcode/src/glitterBundle/plugins/style-attr.js +1 -5
  30. package/lowcode/src/glitterBundle/plugins/style-editor.js +1 -3
  31. package/package.json +1 -1
  32. package/src/api-public/services/financial-service.js +7 -6
  33. package/src/api-public/services/financial-service.js.map +1 -1
  34. package/src/api-public/services/financial-service.ts +11 -8
  35. package/src/api-public/services/model/handlePaymentTransaction.js +29 -2
  36. package/src/api-public/services/model/handlePaymentTransaction.js.map +1 -1
  37. package/src/api-public/services/model/handlePaymentTransaction.ts +8 -9
  38. package/src/api-public/services/shopping.d.ts +1 -1
  39. package/src/api-public/services/shopping.js +12 -9
  40. package/src/api-public/services/shopping.js.map +1 -1
  41. package/src/api-public/services/shopping.ts +5 -3
  42. package/src/api-public/services/user.js +48 -61
  43. package/src/api-public/services/user.js.map +1 -1
  44. package/src/api-public/services/user.ts +62 -66
@@ -212,6 +212,7 @@ export class User {
212
212
  delete userData.repeat_password;
213
213
  const findAuth = await this.findAuthUser(account);
214
214
  const userID = findAuth ? findAuth.user : User.generateUserID();
215
+
215
216
  if (
216
217
  register_form.list.find((dd: any) => {
217
218
  return dd.key === 'email' && `${dd.hidden}` !== 'true' && dd.required;
@@ -288,6 +289,11 @@ export class User {
288
289
  userData: {},
289
290
  });
290
291
 
292
+ const rebate_value = parseInt(userData.rebate, 10);
293
+ if (!isNaN(rebate_value) && rebate_value > 0) {
294
+ await new Rebate(this.app).insertRebate(userID, rebate_value, '匯入會員購物金');
295
+ }
296
+
291
297
  return usData;
292
298
  } catch (e: any) {
293
299
  console.error(e);
@@ -837,9 +843,7 @@ export class User {
837
843
  if (type === 'userID') {
838
844
  query2.push(`userID=${db.escape(query)}`);
839
845
  } else if (type === 'email_or_phone') {
840
- query2.push(
841
- `((email=${db.escape(query)}) or (phone=${db.escape(query)}))`
842
- );
846
+ query2.push(`((email=${db.escape(query)}) or (phone=${db.escape(query)}))`);
843
847
  } else {
844
848
  query2.push(`email=${db.escape(query)}`);
845
849
  }
@@ -2178,100 +2182,98 @@ export class User {
2178
2182
  }
2179
2183
 
2180
2184
  public async updateUserData(userID: string, par: any, manager: boolean = false) {
2181
- const userData = await (async () => {
2182
- const getUser = await db.query(
2183
- `select *
2184
- from \`${this.app}\`.\`t_user\`
2185
- where userID = ${db.escape(userID)}
2185
+ const getUser = await db.query(
2186
+ `SELECT * FROM \`${this.app}\`.t_user WHERE userID = ${db.escape(userID)}
2186
2187
  `,
2187
- []
2188
- );
2189
- return getUser[0] ?? {};
2190
- })();
2188
+ []
2189
+ );
2190
+ const userData = getUser[0] ?? {};
2191
2191
 
2192
- try {
2193
- if (!userData.userData) {
2194
- return { data: {} };
2195
- }
2192
+ if (!userData.userData) {
2193
+ return { data: {} };
2194
+ }
2196
2195
 
2197
- const login_config = await this.getConfigV2({
2198
- key: 'login_config',
2199
- user_id: 'manager',
2200
- });
2201
- const register_form = await this.getConfigV2({
2202
- key: 'custom_form_register',
2203
- user_id: 'manager',
2204
- });
2196
+ try {
2197
+ const login_config = await this.getConfigV2({ key: 'login_config', user_id: 'manager' });
2198
+ const register_form = await this.getConfigV2({ key: 'custom_form_register', user_id: 'manager' });
2205
2199
 
2206
2200
  register_form.list = register_form.list ?? [];
2207
2201
  FormCheck.initialRegisterForm(register_form.list);
2208
2202
 
2203
+ const userDataVerify = await redis.getValue(`verify-${userData.userData.email}`);
2204
+ const parDataVerify = await redis.getValue(`verify-${par.userData.email}`);
2205
+
2206
+ // 更改密碼驗證
2209
2207
  if (par.userData.pwd) {
2210
- if ((await redis.getValue(`verify-${userData.userData.email}`)) === par.userData.verify_code) {
2208
+ if (userDataVerify === par.userData.verify_code) {
2209
+ const pwd = await tool.hashPwd(par.userData.pwd);
2211
2210
  await db.query(
2212
- `update \`${this.app}\`.\`t_user\`
2213
- set pwd=?
2214
- where userID = ${db.escape(userID)}`,
2215
- [await tool.hashPwd(par.userData.pwd)]
2211
+ `UPDATE \`${this.app}\`.t_user SET pwd = ? WHERE userID = ${db.escape(userID)}
2212
+ `,
2213
+ [pwd]
2216
2214
  );
2217
2215
  } else {
2218
- throw exception.BadRequestError('BAD_REQUEST', 'Verify code error.', {
2219
- msg: 'email-verify-false',
2216
+ throw exception.BadRequestError('BAD_REQUEST', 'Password verify code error.', {
2217
+ msg: 'password-verify-false',
2220
2218
  });
2221
2219
  }
2222
2220
  }
2223
2221
 
2222
+ // 更改信箱驗證
2224
2223
  if (par.userData.email && par.userData.email !== userData.userData.email) {
2225
2224
  const count = (
2226
2225
  await db.query(
2227
- `select count(1)
2228
- from \`${this.app}\`.\`t_user\`
2229
- where (userData ->>'$.email' = ${db.escape(par.userData.email)})
2230
- and (userID != ${db.escape(userID)}) `,
2226
+ `SELECT count(1)
2227
+ FROM \`${this.app}\`.t_user
2228
+ WHERE (userData->>'$.email' = ${db.escape(par.userData.email)})
2229
+ AND (userID != ${db.escape(userID)})`,
2231
2230
  []
2232
2231
  )
2233
2232
  )[0]['count(1)'];
2233
+
2234
2234
  if (count) {
2235
- throw exception.BadRequestError('BAD_REQUEST', 'Already exists.', {
2235
+ throw exception.BadRequestError('BAD_REQUEST', 'User email already exists.', {
2236
2236
  msg: 'email-exists',
2237
2237
  });
2238
2238
  }
2239
+
2239
2240
  if (
2241
+ !manager &&
2240
2242
  login_config.email_verify &&
2241
- par.userData.verify_code !== (await redis.getValue(`verify-${par.userData.email}`)) &&
2242
- register_form.list.find((dd: any) => {
2243
- return dd.key === 'email' && `${dd.hidden}` !== 'true';
2244
- })
2243
+ par.userData.verify_code !== parDataVerify &&
2244
+ register_form.list.some((r: any) => r.key === 'email' && `${r.hidden}` !== 'true')
2245
2245
  ) {
2246
- throw exception.BadRequestError('BAD_REQUEST', 'Verify code error.', {
2246
+ throw exception.BadRequestError('BAD_REQUEST', 'ParData email verify code error.', {
2247
2247
  msg: 'email-verify-false',
2248
2248
  });
2249
2249
  }
2250
2250
  }
2251
2251
 
2252
+ // 更改手機驗證
2252
2253
  if (par.userData.phone && par.userData.phone !== userData.userData.phone) {
2253
2254
  const count = (
2254
2255
  await db.query(
2255
- `select count(1)
2256
- from \`${this.app}\`.\`t_user\`
2257
- where (userData ->>'$.phone' = ${db.escape(par.userData.phone)})
2258
- and (userID != ${db.escape(userID)}) `,
2256
+ `SELECT count(1)
2257
+ FROM \`${this.app}\`.t_user
2258
+ WHERE (userData->>'$.phone' = ${db.escape(par.userData.phone)})
2259
+ AND (userID != ${db.escape(userID)}) `,
2259
2260
  []
2260
2261
  )
2261
2262
  )[0]['count(1)'];
2263
+
2262
2264
  if (count) {
2263
- throw exception.BadRequestError('BAD_REQUEST', 'Already exists.', {
2265
+ throw exception.BadRequestError('BAD_REQUEST', 'User phone already exists.', {
2264
2266
  msg: 'phone-exists',
2265
2267
  });
2266
2268
  }
2269
+
2267
2270
  if (
2271
+ !manager &&
2268
2272
  login_config.phone_verify &&
2269
2273
  !(await PhoneVerify.verify(par.userData.phone, par.userData.verify_code_phone)) &&
2270
- register_form.list.find((dd: any) => {
2271
- return dd.key === 'phone' && `${dd.hidden}` !== 'true';
2272
- })
2274
+ register_form.list.some((dd: any) => dd.key === 'phone' && `${dd.hidden}` !== 'true')
2273
2275
  ) {
2274
- throw exception.BadRequestError('BAD_REQUEST', 'Verify code error.', {
2276
+ throw exception.BadRequestError('BAD_REQUEST', 'ParData phone verify code error.', {
2275
2277
  msg: 'phone-verify-false',
2276
2278
  });
2277
2279
  }
@@ -2282,10 +2284,8 @@ export class User {
2282
2284
 
2283
2285
  if (par.userData.phone) {
2284
2286
  await db.query(
2285
- `update \`${this.app}\`.t_checkout
2286
- set email=?
2287
- where id > 0
2288
- and email = ?`,
2287
+ `UPDATE \`${this.app}\`.t_checkout SET email = ? WHERE id > 0 AND email = ?
2288
+ `,
2289
2289
  [par.userData.phone, `${userData.userData.phone}`]
2290
2290
  );
2291
2291
  userData.account = par.userData.phone;
@@ -2293,10 +2293,8 @@ export class User {
2293
2293
 
2294
2294
  if (par.userData.email) {
2295
2295
  await db.query(
2296
- `update \`${this.app}\`.t_checkout
2297
- set email=?
2298
- where id > 0
2299
- and email = ?`,
2296
+ `UPDATE \`${this.app}\`.t_checkout SET email = ? WHERE id > 0 AND email = ?
2297
+ `,
2300
2298
  [par.userData.email, `${userData.userData.email}`]
2301
2299
  );
2302
2300
  userData.account = par.userData.email;
@@ -2304,8 +2302,8 @@ export class User {
2304
2302
 
2305
2303
  par.userData = await this.checkUpdate({
2306
2304
  updateUserData: par.userData,
2307
- userID: userID,
2308
- manager: manager,
2305
+ userID,
2306
+ manager,
2309
2307
  });
2310
2308
 
2311
2309
  delete par.userData.verify_code;
@@ -2320,13 +2318,11 @@ export class User {
2320
2318
  delete par.account;
2321
2319
  }
2322
2320
 
2323
- const data = (await db.query(
2324
- `update \`${this.app}\`.t_user
2325
- SET ?
2326
- WHERE 1 = 1
2327
- and userID = ?`,
2321
+ const data = await db.query(
2322
+ `UPDATE \`${this.app}\`.t_user SET ? WHERE 1 = 1 AND userID = ?
2323
+ `,
2328
2324
  [par, userID]
2329
- )) as any;
2325
+ );
2330
2326
 
2331
2327
  await UserUpdate.update(this.app, userID);
2332
2328