coupon2.ts 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. import type { Coupon2Entity, PageConfig } from '@vben/types';
  2. import dayjs from 'dayjs';
  3. import { requestClient } from '#/api/request';
  4. interface Coupon2PartialEntity
  5. extends Partial<Omit<Coupon2Entity, 'coupon2code'>> {
  6. coupon2code?: string;
  7. }
  8. interface Coupon2QueryParams
  9. extends Omit<Coupon2PartialEntity, 'coupon2adddatetime'>,
  10. PageConfig {
  11. couponmc?: string;
  12. coupon2code?: string;
  13. usersname?: string;
  14. usersphone?: string;
  15. productsname?: string;
  16. productsmodel?: string;
  17. productsjjlx?: string;
  18. coupon2adddatetime?: string[];
  19. }
  20. /**
  21. * 我的优惠券信息_列表
  22. */
  23. export async function getCoupon2ListApi(data: Coupon2QueryParams) {
  24. return requestClient.post<any>('/api/query/list?pagevalue=101', {
  25. pageindex: data.pageindex,
  26. rows: data.rows,
  27. });
  28. }
  29. /**
  30. * 我的优惠券信息_详情
  31. */
  32. export async function getCoupon2DetailApi(data: { coupon2sid: string }) {
  33. return requestClient.post<any>(
  34. '/api/query/view?pagevalue=102',
  35. {
  36. 'coupon2sid.value': data.coupon2sid,
  37. },
  38. { formatData: true }, // 格式化返回数据
  39. );
  40. }
  41. /**
  42. * 我的优惠券信息_新增
  43. */
  44. export async function addCoupon2Api(data: Coupon2Entity) {
  45. return requestClient.post<any>('/api/add?pagevalue=40', { ...data });
  46. }
  47. /**
  48. * 我的优惠券信息_编辑
  49. */
  50. export async function editCoupon2Api(data: Coupon2Entity) {
  51. return requestClient.post<any>('/api/up?pagevalue=41', { ...data });
  52. }
  53. /**
  54. * 我的优惠券_审核_列表(用于admin)
  55. */
  56. export async function getCoupon2AuditListApi(data: Coupon2QueryParams) {
  57. const {
  58. pageindex,
  59. rows,
  60. couponmc,
  61. coupon2code,
  62. usersname,
  63. usersphone,
  64. coupon2sype,
  65. productsname,
  66. productsmodel,
  67. productsjjlx,
  68. coupon2adddatetime,
  69. } = data;
  70. const queryParams: Record<string, any> = {
  71. pageindex,
  72. rows,
  73. };
  74. if (couponmc) {
  75. queryParams['coupon2mc.like'] = couponmc;
  76. }
  77. if (coupon2code) {
  78. queryParams['coupon2code.like'] = coupon2code;
  79. }
  80. if (usersname) {
  81. queryParams['usersname.like'] = usersname;
  82. }
  83. if (usersphone) {
  84. queryParams['usersphone.like'] = usersphone;
  85. }
  86. if (coupon2sype !== undefined && coupon2sype !== null) {
  87. queryParams['coupon2sype.value'] = coupon2sype;
  88. }
  89. if (productsname) {
  90. queryParams['productsname.like'] = productsname;
  91. }
  92. if (productsmodel) {
  93. queryParams['productsmodel.like'] = productsmodel;
  94. }
  95. if (productsjjlx) {
  96. queryParams['productsjjlx.like'] = productsjjlx;
  97. }
  98. if (coupon2adddatetime && coupon2adddatetime.length > 0) {
  99. queryParams['coupon2adddatetime.start'] = dayjs(coupon2adddatetime[0])
  100. .startOf('day')
  101. .format('YYYY-MM-DD HH:mm:ss');
  102. queryParams['coupon2adddatetime.end'] = dayjs(coupon2adddatetime[1])
  103. .endOf('day')
  104. .format('YYYY-MM-DD HH:mm:ss');
  105. }
  106. queryParams['coupon2adddatetime.sort'] = 1;
  107. return requestClient.post<any>('/api/query/list?pagevalue=117', queryParams);
  108. }
  109. /**
  110. * 我的优惠券_编辑_列表(用于经销商查询优惠劵列表)
  111. */
  112. export async function getCoupon2EditListApi(data: Coupon2QueryParams) {
  113. const {
  114. pageindex,
  115. rows,
  116. couponmc,
  117. coupon2code,
  118. usersname,
  119. usersphone,
  120. coupon2sype,
  121. productsname,
  122. productsmodel,
  123. productsjjlx,
  124. coupon2adddatetime,
  125. } = data;
  126. const queryParams: Record<string, any> = {
  127. pageindex,
  128. rows,
  129. };
  130. if (couponmc) {
  131. queryParams['coupon2mc.like'] = couponmc;
  132. }
  133. if (coupon2code) {
  134. queryParams['coupon2code.like'] = coupon2code;
  135. }
  136. if (usersname) {
  137. queryParams['usersname.like'] = usersname;
  138. }
  139. if (usersphone) {
  140. queryParams['usersphone.like'] = usersphone;
  141. }
  142. if (coupon2sype !== undefined && coupon2sype !== null) {
  143. queryParams['coupon2sype.value'] = coupon2sype;
  144. }
  145. if (productsname) {
  146. queryParams['productsname.like'] = productsname;
  147. }
  148. if (productsmodel) {
  149. queryParams['productsmodel.like'] = productsmodel;
  150. }
  151. if (productsjjlx) {
  152. queryParams['productsjjlx.like'] = productsjjlx;
  153. }
  154. if (coupon2adddatetime && coupon2adddatetime.length > 0) {
  155. queryParams['coupon2adddatetime.start'] = dayjs(coupon2adddatetime[0])
  156. .startOf('day')
  157. .format('YYYY-MM-DD HH:mm:ss');
  158. queryParams['coupon2adddatetime.end'] = dayjs(coupon2adddatetime[1])
  159. .endOf('day')
  160. .format('YYYY-MM-DD HH:mm:ss');
  161. }
  162. queryParams['coupon2adddatetime.sort'] = 1;
  163. return requestClient.post<any>('/api/query/list?pagevalue=120', queryParams);
  164. }
  165. /**
  166. * 我的优惠券_审核_详情
  167. */
  168. export async function getCoupon2AuditDetailApi(data: { coupon2sid: string }) {
  169. return requestClient.post<any>(
  170. '/api/query/view?pagevalue=118',
  171. {
  172. 'coupon2sid.value': data.coupon2sid,
  173. },
  174. { formatData: true },
  175. );
  176. }
  177. /**
  178. * 更新购机者信息
  179. */
  180. export async function updateCoupon2UserInfoApi(data: any) {
  181. return requestClient.post<any>('/api/nlua/call?pagevalue=119', {
  182. ...data,
  183. });
  184. }
  185. /**
  186. * 我的优惠券信息_审核
  187. */
  188. export async function auditCoupon2Api(data: Coupon2Entity) {
  189. return requestClient.post<any>('/api/up?pagevalue=104', { ...data });
  190. }