Total Complexity | 5 |
Complexity/F | 2.5 |
Lines of Code | 35 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | const ModelStore = require('../../model/catering/store') |
||
2 | const ServiceCustomer = require('../../services/catering/customer') |
||
3 | const ApiError = require('../../util/api_error') |
||
|
|||
4 | const Validate = require('request-validate') |
||
5 | const _ = require('underscore') |
||
6 | const ConfigOss = require('../../../config/oss') |
||
7 | |||
8 | module.exports = { |
||
9 | storeList: async function (sellerId) { |
||
10 | let result = await ModelStore.getSellerStores(sellerId) |
||
11 | |||
12 | // 默认开店 |
||
13 | if (result.length <= 0) { |
||
14 | let customerInfo = await ServiceCustomer.getCustomerInfo(sellerId) |
||
15 | let storeInfo = { |
||
16 | seller_id: customerInfo.id, |
||
17 | name: customerInfo.nickname, |
||
18 | thumb: customerInfo.avatar, |
||
19 | store_type_id: 0, theme: '', tel: '', wechat: '', license: '', address: '', |
||
20 | approve_status: 0, status: 1, audit_id: 0 |
||
21 | } |
||
22 | let storeRes = await ModelStore.add(storeInfo) |
||
23 | storeInfo.id = storeRes.insertId |
||
24 | result = [storeInfo] |
||
25 | } |
||
26 | |||
27 | result.forEach(element => { |
||
28 | element.preview_thumb = '' |
||
29 | if (element.thumb && element.thumb.indexOf('http') < 0) element.preview_thumb = ConfigOss.catering.view_server + element.thumb + '?x-oss-process=style/preview' |
||
30 | }) |
||
31 | |||
32 | return result |
||
33 | }, |
||
34 | |||
35 | } |
||
36 |