groupAfterSale.interface.ts 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. import { Rule, RuleType } from '@midwayjs/validate';
  2. import { ApiProperty } from '@midwayjs/swagger';
  3. import _ = require('lodash');
  4. import { FrameworkErrorEnum, SearchBase, ServiceError } from 'free-midway-component';
  5. import { getDataFromTarget } from '../util/util';
  6. export class FetchVO_groupAfterSale {
  7. constructor(data: object) {
  8. for (const key of Object.keys(this)) {
  9. this[key] = _.get(data, key);
  10. }
  11. }
  12. @ApiProperty({ description: '数据id' })
  13. _id: string = undefined;
  14. @ApiProperty({ description: '订单' })
  15. 'order': string = undefined;
  16. @ApiProperty({ description: '顾客' })
  17. 'customer': string = undefined;
  18. @ApiProperty({ description: '售后类型' })
  19. 'type': string = undefined;
  20. @ApiProperty({ description: '申请理由' })
  21. 'reason': string = undefined;
  22. @ApiProperty({ description: '申请售后描述' })
  23. 'desc': string = undefined;
  24. @ApiProperty({ description: '凭证图片' })
  25. 'file': Array<any> = undefined;
  26. @ApiProperty({ description: '快递信息' })
  27. 'transport': object = undefined;
  28. @ApiProperty({ description: '售后申请时间' })
  29. 'apply_time': string = undefined;
  30. @ApiProperty({ description: '售后结束时间' })
  31. 'end_time': string = undefined;
  32. @ApiProperty({ description: '售后状态' })
  33. 'status': string = undefined;
  34. @ApiProperty({ description: '退款金额' })
  35. 'money': number = undefined;
  36. @ApiProperty({ description: '处理人' })
  37. 'deal_person': string = undefined;
  38. }
  39. export class QueryDTO_groupAfterSale extends SearchBase {
  40. constructor() {
  41. const like_prop = [];
  42. const props = ['order', 'customer', 'type', 'apply_time', 'end_time', 'deal_person', 'status'];
  43. super({ like_prop, props });
  44. }
  45. @ApiProperty({ description: '订单' })
  46. 'order': string = undefined;
  47. @ApiProperty({ description: '顾客' })
  48. 'customer': string = undefined;
  49. @ApiProperty({ description: '售后类型' })
  50. 'type': string = undefined;
  51. @ApiProperty({ description: '售后申请时间' })
  52. 'apply_time': string = undefined;
  53. @ApiProperty({ description: '售后结束时间' })
  54. 'end_time': string = undefined;
  55. @ApiProperty({ description: '处理人' })
  56. 'deal_person': string = undefined;
  57. @ApiProperty({ description: '状态' })
  58. 'status': string = undefined;
  59. }
  60. export class QueryVO_groupAfterSale extends FetchVO_groupAfterSale {}
  61. export class CreateDTO_groupAfterSale {
  62. @ApiProperty({ description: '订单' })
  63. @Rule(RuleType['string']().required().error(new ServiceError('缺少订单信息', FrameworkErrorEnum.NEED_BODY)))
  64. 'order': string = undefined;
  65. @ApiProperty({ description: '顾客' })
  66. @Rule(RuleType['string']().required().error(new ServiceError('缺少订单信息', FrameworkErrorEnum.NEED_BODY)))
  67. 'customer': string = undefined;
  68. @ApiProperty({ description: '售后类型' })
  69. @Rule(RuleType['string']().required().error(new ServiceError('缺少订单信息', FrameworkErrorEnum.NEED_BODY)))
  70. 'type': string = undefined;
  71. @ApiProperty({ description: '申请理由' })
  72. @Rule(RuleType['string']().empty())
  73. 'reason': string = undefined;
  74. @ApiProperty({ description: '申请售后描述' })
  75. @Rule(RuleType['string']().empty())
  76. 'desc': string = undefined;
  77. @ApiProperty({ description: '凭证图片' })
  78. @Rule(RuleType['array']().empty())
  79. 'file': Array<any> = undefined;
  80. @ApiProperty({ description: '快递信息' })
  81. @Rule(RuleType['object']().empty())
  82. 'transport': object = undefined;
  83. @ApiProperty({ description: '售后申请时间' })
  84. @Rule(RuleType['string']().empty())
  85. 'apply_time': string = undefined;
  86. @ApiProperty({ description: '售后结束时间' })
  87. @Rule(RuleType['string']().empty())
  88. 'end_time': string = undefined;
  89. @ApiProperty({ description: '售后状态' })
  90. @Rule(RuleType['string']().empty())
  91. 'status': string = undefined;
  92. @ApiProperty({ description: '退款金额' })
  93. @Rule(RuleType['number']().empty())
  94. 'money': number = undefined;
  95. @ApiProperty({ description: '处理人' })
  96. @Rule(RuleType['string']().empty())
  97. 'deal_person': string = undefined;
  98. }
  99. export class CreateVO_groupAfterSale extends FetchVO_groupAfterSale {}
  100. export class UpdateDTO_groupAfterSale extends CreateDTO_groupAfterSale {
  101. @ApiProperty({ description: '数据id' })
  102. @Rule(RuleType['string']().empty())
  103. '_id': string = undefined;
  104. @ApiProperty({ description: '团长建议' })
  105. @Rule(RuleType['string']().empty())
  106. leader_suggest: boolean = undefined;
  107. }
  108. export class UpdateVO_groupAfterSale extends FetchVO_groupAfterSale {}
  109. export class AdminView {
  110. constructor(data) {
  111. const dl = ['_id', 'apply_time', 'end_time', 'type', 'reason', 'desc', 'file', 'status', 'transport', 'money', 'leader_suggest'];
  112. for (const i of dl) this[i] = _.get(data, i);
  113. this.customer = getDataFromTarget(data, 'customer', ['_id', 'name', 'phone']);
  114. this.address = getDataFromTarget(data, 'order.address', ['_id', 'name', 'phone', 'province', 'city', 'area', 'address']);
  115. this.shop = getDataFromTarget(data, 'order.shop', ['_id', 'name']);
  116. this.goods = getDataFromTarget(data, 'order.goods', ['_id', 'name', 'file']);
  117. this.goodsSpec = getDataFromTarget(data, 'order.goodsSpec', ['_id', 'name', 'file']);
  118. let price = 0;
  119. // const is_leader = _.get(data, 'customer.is_leader', '1');
  120. // if (is_leader === '0') price = _.get(data, 'order.config.leader_price');
  121. // else
  122. price = _.get(data, 'order.config.price');
  123. this.goodsSpec.price = price;
  124. this.goodsSpec.freight = _.get(data, 'order.config.freight');
  125. this.goodsSpec.num = _.get(data, 'order.num');
  126. this.pay = _.get(data, 'order.pay.pay_money');
  127. this.deal_person = getDataFromTarget(data, 'deal_person', ['_id', 'name']);
  128. }
  129. customer: {
  130. _id: string;
  131. name: string;
  132. phone: string;
  133. };
  134. address: {
  135. _id: string;
  136. name: string;
  137. phone: string;
  138. province: string;
  139. city: string;
  140. area: string;
  141. address: string;
  142. };
  143. shop: {
  144. _id: string;
  145. name: string;
  146. };
  147. goods: {
  148. _id: string;
  149. name: string;
  150. file: Array<any>;
  151. };
  152. goodsSpec: {
  153. _id: string;
  154. name: string;
  155. file: Array<any>;
  156. num: number;
  157. price: number;
  158. freight: number;
  159. };
  160. total_detail: Array<any>;
  161. apply_time: string;
  162. end_time: string;
  163. type: string;
  164. reason: string;
  165. desc: string;
  166. deal_person: string;
  167. file: Array<any>;
  168. status: string;
  169. transport: object;
  170. money: number;
  171. pay: number; // 订单支付总额
  172. leader_suggest: boolean;
  173. }
  174. export class UserListView {
  175. constructor(data) {
  176. const dl = ['_id', 'apply_time', 'type', 'status', 'money', 'leader_suggest'];
  177. for (const i of dl) this[i] = _.get(data, i);
  178. this.shop = getDataFromTarget(data, 'order.shop', ['_id', 'name']);
  179. this.goods = getDataFromTarget(data, 'order.goods', ['_id', 'name', 'file']);
  180. this.spec = getDataFromTarget(data, 'order.goodsSpec', ['_id', 'name', 'file']);
  181. }
  182. _id: string;
  183. apply_time: string;
  184. shop: {
  185. _id: string;
  186. name: string;
  187. };
  188. type: string;
  189. status: string;
  190. money: number;
  191. goods: {
  192. _id: string;
  193. name: string;
  194. file: Array<any>;
  195. };
  196. spec: {
  197. _id: string;
  198. name: string;
  199. file: Array<any>;
  200. };
  201. leader_suggest: boolean;
  202. }