import { Rule, RuleType } from '@midwayjs/validate'; import { ApiProperty } from '@midwayjs/swagger'; import _ = require('lodash'); import { FrameworkErrorEnum, SearchBase, ServiceError } from 'free-midway-component'; import { getDataFromTarget } from '../util/util'; export class FetchVO_groupAfterSale { constructor(data: object) { for (const key of Object.keys(this)) { this[key] = _.get(data, key); } } @ApiProperty({ description: '数据id' }) _id: string = undefined; @ApiProperty({ description: '订单' }) 'order': string = undefined; @ApiProperty({ description: '顾客' }) 'customer': string = undefined; @ApiProperty({ description: '售后类型' }) 'type': string = undefined; @ApiProperty({ description: '申请理由' }) 'reason': string = undefined; @ApiProperty({ description: '申请售后描述' }) 'desc': string = undefined; @ApiProperty({ description: '凭证图片' }) 'file': Array = undefined; @ApiProperty({ description: '快递信息' }) 'transport': object = undefined; @ApiProperty({ description: '售后申请时间' }) 'apply_time': string = undefined; @ApiProperty({ description: '售后结束时间' }) 'end_time': string = undefined; @ApiProperty({ description: '售后状态' }) 'status': string = undefined; @ApiProperty({ description: '退款金额' }) 'money': number = undefined; @ApiProperty({ description: '处理人' }) 'deal_person': string = undefined; } export class QueryDTO_groupAfterSale extends SearchBase { constructor() { const like_prop = []; const props = ['order', 'customer', 'type', 'apply_time', 'end_time', 'deal_person', 'status']; super({ like_prop, props }); } @ApiProperty({ description: '订单' }) 'order': string = undefined; @ApiProperty({ description: '顾客' }) 'customer': string = undefined; @ApiProperty({ description: '售后类型' }) 'type': string = undefined; @ApiProperty({ description: '售后申请时间' }) 'apply_time': string = undefined; @ApiProperty({ description: '售后结束时间' }) 'end_time': string = undefined; @ApiProperty({ description: '处理人' }) 'deal_person': string = undefined; @ApiProperty({ description: '状态' }) 'status': string = undefined; } export class QueryVO_groupAfterSale extends FetchVO_groupAfterSale {} export class CreateDTO_groupAfterSale { @ApiProperty({ description: '订单' }) @Rule(RuleType['string']().required().error(new ServiceError('缺少订单信息', FrameworkErrorEnum.NEED_BODY))) 'order': string = undefined; @ApiProperty({ description: '顾客' }) @Rule(RuleType['string']().required().error(new ServiceError('缺少订单信息', FrameworkErrorEnum.NEED_BODY))) 'customer': string = undefined; @ApiProperty({ description: '售后类型' }) @Rule(RuleType['string']().required().error(new ServiceError('缺少订单信息', FrameworkErrorEnum.NEED_BODY))) 'type': string = undefined; @ApiProperty({ description: '申请理由' }) @Rule(RuleType['string']().empty()) 'reason': string = undefined; @ApiProperty({ description: '申请售后描述' }) @Rule(RuleType['string']().empty()) 'desc': string = undefined; @ApiProperty({ description: '凭证图片' }) @Rule(RuleType['array']().empty()) 'file': Array = undefined; @ApiProperty({ description: '快递信息' }) @Rule(RuleType['object']().empty()) 'transport': object = undefined; @ApiProperty({ description: '售后申请时间' }) @Rule(RuleType['string']().empty()) 'apply_time': string = undefined; @ApiProperty({ description: '售后结束时间' }) @Rule(RuleType['string']().empty()) 'end_time': string = undefined; @ApiProperty({ description: '售后状态' }) @Rule(RuleType['string']().empty()) 'status': string = undefined; @ApiProperty({ description: '退款金额' }) @Rule(RuleType['number']().empty()) 'money': number = undefined; @ApiProperty({ description: '处理人' }) @Rule(RuleType['string']().empty()) 'deal_person': string = undefined; } export class CreateVO_groupAfterSale extends FetchVO_groupAfterSale {} export class UpdateDTO_groupAfterSale extends CreateDTO_groupAfterSale { @ApiProperty({ description: '数据id' }) @Rule(RuleType['string']().empty()) '_id': string = undefined; @ApiProperty({ description: '团长建议' }) @Rule(RuleType['string']().empty()) leader_suggest: boolean = undefined; } export class UpdateVO_groupAfterSale extends FetchVO_groupAfterSale {} export class AdminView { constructor(data) { const dl = ['_id', 'apply_time', 'end_time', 'type', 'reason', 'desc', 'file', 'status', 'transport', 'money', 'leader_suggest']; for (const i of dl) this[i] = _.get(data, i); this.customer = getDataFromTarget(data, 'customer', ['_id', 'name', 'phone']); this.address = getDataFromTarget(data, 'order.address', ['_id', 'name', 'phone', 'province', 'city', 'area', 'address']); this.shop = getDataFromTarget(data, 'order.shop', ['_id', 'name']); this.goods = getDataFromTarget(data, 'order.goods', ['_id', 'name', 'file']); this.goodsSpec = getDataFromTarget(data, 'order.goodsSpec', ['_id', 'name', 'file']); let price = 0; // const is_leader = _.get(data, 'customer.is_leader', '1'); // if (is_leader === '0') price = _.get(data, 'order.config.leader_price'); // else price = _.get(data, 'order.config.price'); this.goodsSpec.price = price; this.goodsSpec.freight = _.get(data, 'order.config.freight'); this.goodsSpec.num = _.get(data, 'order.num'); this.pay = _.get(data, 'order.pay.pay_money'); this.deal_person = getDataFromTarget(data, 'deal_person', ['_id', 'name']); } customer: { _id: string; name: string; phone: string; }; address: { _id: string; name: string; phone: string; province: string; city: string; area: string; address: string; }; shop: { _id: string; name: string; }; goods: { _id: string; name: string; file: Array; }; goodsSpec: { _id: string; name: string; file: Array; num: number; price: number; freight: number; }; total_detail: Array; apply_time: string; end_time: string; type: string; reason: string; desc: string; deal_person: string; file: Array; status: string; transport: object; money: number; pay: number; // 订单支付总额 leader_suggest: boolean; } export class UserListView { constructor(data) { const dl = ['_id', 'apply_time', 'type', 'status', 'money', 'leader_suggest']; for (const i of dl) this[i] = _.get(data, i); this.shop = getDataFromTarget(data, 'order.shop', ['_id', 'name']); this.goods = getDataFromTarget(data, 'order.goods', ['_id', 'name', 'file']); this.spec = getDataFromTarget(data, 'order.goodsSpec', ['_id', 'name', 'file']); } _id: string; apply_time: string; shop: { _id: string; name: string; }; type: string; status: string; money: number; goods: { _id: string; name: string; file: Array; }; spec: { _id: string; name: string; file: Array; }; leader_suggest: boolean; }