q-koa 7.9.1 → 7.9.2

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.
@@ -344,7 +344,9 @@ exports.mp_login = async (ctx) => {
344
344
  try {
345
345
  await app.sequelize.transaction(async (transaction) => {
346
346
  const user = await app.model.user.create(
347
- {},
347
+ {
348
+ mp_openid: post.openid,
349
+ },
348
350
  {
349
351
  transaction,
350
352
  }
@@ -1142,3 +1144,27 @@ exports.checkPay = async (ctx) => {
1142
1144
 
1143
1145
  ctx.SUCCESS({ prefix, out_trade_no, ...payResult })
1144
1146
  }
1147
+
1148
+ exports.init_mp_openid = async (ctx) => {
1149
+ const { app, appName } = getAppByCtx(ctx)
1150
+
1151
+ const list = await app.model.user.findAll({
1152
+ where: {
1153
+ mp_openid: '',
1154
+ },
1155
+ include: app.model.mp_user,
1156
+ })
1157
+
1158
+ const result = list.map((item) => {
1159
+ return {
1160
+ id: item.id,
1161
+ mp_openid: item.mp_user.openid,
1162
+ }
1163
+ })
1164
+
1165
+ await app.model.user.bulkCreate(result, {
1166
+ updateOnDuplicate: ['mp_openid'],
1167
+ })
1168
+
1169
+ ctx.SUCCESS(result.length)
1170
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "7.9.1",
3
+ "version": "7.9.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {