/** * 根据uuid获取类别 * @param {object} params 条件 * @return {object|null} 查找结果 */ async get(params = {}) { const { app } = this; return await app.model.GoodsCategory.get({ ...params, attributes: ['uuid', 'version', 'name', 'createdTime', 'lastModifiedTime'], }); }
/** * 删除用户地址 * @param {object} params - 条件 * @return {string|null} - 删除用户地址uuid */ async remove(params = {}) { const { app } = this; return await app.model.User.Customer.Address.remove(params); }
/** * 下架商品 * @param {object} params - 条件 * @return {string|null} - 商品uuid */ async down(params) { const { app } = this; const { uuid, userUuid, userName, orgUuid, version } = params; const modifyInfo = app.getModifyInfo(userUuid, userName); const goods = { uuid, orgUuid, version, status: 'down', ...modifyInfo }; await app.model.Goods.saveModify(goods); return uuid; }
normarlize(data) { const { ctx } = this ctx.app.model.showAllSchemas().then(console.dir) // console.log('schame') // console.dir(ctx.app.model.User.schema()) ctx.type = 'json' // ctx.body = { // data, // model: Object.keys(this.ctx.model.models) // } ctx.body = data }
/** * 新增送货时间 * @param {object} params - 条件 * @return {string} - 送货时间uuid */ async saveNew(params = {}) { let { deliveryTimeType, userUuid, userName, orgUuid } = params; const { app } = this; const crateInfo = app.getCrateInfo(userUuid, userName); deliveryTimeType = { ...deliveryTimeType, ...crateInfo, orgUuid }; return await app.model.DeliveryTimeType.saveNew(deliveryTimeType); }
/** * 查询送货时间列表 * @param {object} params - 条件 * @return {Array|null} - 查找结果 */ async getList(params = {}) { const { app } = this; const { Sequelize } = app; return await app.model.DeliveryTimeType.getList({ ...params, attributes: ['uuid', 'name', 'remark', [Sequelize.fn('ROUND', Sequelize.col('surcharge'), 2), 'surcharge']], }); }
/** * 根据uuid获取订单,不验证组织 * @param {string} uuid - 条件 * @return {object|null} - 查找结果 */ async getByUuid(uuid) { const { app } = this; return await app.model.GoodsOrder.getByUuid(uuid); }
/** * 审核订单 * @param {object} params - 条件 * @return {string} - 订单uuid */ async audit(params = {}) { const { app } = this; const { openId, nickName, userUuid, userName, orgUuid } = params; const modifyInfo = app.getModifyInfo(openId || userUuid, nickName || userName); return await app.model.GoodsOrder.audit({ ...params, ...modifyInfo, orgUuid }); }
/** * 删除运费方案 * @param {object} params - 条件 * @return {string|null} - 删除运费方案uuid */ async remove(params = {}) { const { app } = this; await app.model.FreightPlan.remove(params); return params.uuid; }
/** * 获取某类别的商品数量 * @param {string} categoryUuid - 类别uuid * @return {number} - 商品数量 */ async countGoodsByCategory(categoryUuid) { return await this.app.model.Goods.countGoodsByCategory(categoryUuid); }
/** * 获取类别分页列表 * @param {object} params - 条件 * @return {object|null} - 查找结果 */ async query(params = {}) { const { app } = this; return await app.model.GoodsCategory.query({ ...params, attributes: ['uuid', 'version', 'name', 'createdTime', 'lastModifiedTime'], }); }
/** * 根据uuid获取送货时间 * @param {object} params - 条件 * @return {object|null} - 查找结果 */ async get(params = {}) { const { app } = this; return await app.model.DeliveryTimeType.get({ ...params, attributes: ['uuid', 'version', 'name', 'remark', 'surcharge', 'createdTime', 'lastModifiedTime'], }); }
/** * 获取类别下拉列表 * @param {object} params - 条件 * @return {object|null} - 查找结果 */ async getDropdownList(params = {}) { const { app } = this; return await app.model.GoodsCategory.getList({ ...params, attributes: ['uuid', 'name'], }); }
/** * 根据uuid获取运费方案 * @param {object} params - 条件 * @return {object|null} 查找结果 */ async get(params = {}) { const { app } = this; return await app.model.FreightPlan.get({ ...params, attributes: ['uuid', 'version', 'name', 'basicFreight', 'freeFreightAmount', 'sysDefault', 'createdTime', 'lastModifiedTime'], }); }
/** * 删除类别 * @param {object} params - 条件 * @return {string|null} - 删除类别uuid */ async remove(params = {}) { const { app } = this; await app.model.GoodsCategory.remove(params); return params.uuid; }