瀏覽代碼

feat: 优惠劵对接

赖奇 1 年之前
父節點
當前提交
88bac4db68

+ 48 - 0
apps/web-ele/src/api/coupon/coupon1.ts

@@ -0,0 +1,48 @@
+import type { Coupon1Entity, PageConfig } from '@vben/types';
+
+import { adaptBackendRequest } from '@vben/utils';
+
+import { requestClient } from '#/api/request';
+
+interface Coupon1PartialEntity
+  extends Partial<Omit<Coupon1Entity, 'couponmc'>> {
+  couponmc?: string;
+}
+
+interface Coupon1QueryParams extends Coupon1PartialEntity, PageConfig {}
+
+/**
+ * 生产企业信息_列表
+ */
+export async function getCoupon1ListApi(params: Coupon1QueryParams) {
+  return requestClient.post<any>('/api/query/list?pagevalue=33', {
+    ...params,
+  });
+}
+
+/**
+ * 优惠券信息_详情
+ */
+export async function getCoupon1DetailApi(data: { couponid: string }) {
+  return requestClient.post<any>(
+    '/api/query/view?pagevalue=34',
+    {
+      ...adaptBackendRequest(data),
+    },
+    { formatData: true }, // 格式化返回数据
+  );
+}
+
+/**
+ * 优惠券信息_新增
+ */
+export async function addCoupon1Api(data: Coupon1Entity) {
+  return requestClient.post<any>('/api/add?pagevalue=35', { ...data });
+}
+
+/**
+ * 优惠券信息_编辑
+ */
+export async function editCoupon1Api(data: Coupon1Entity) {
+  return requestClient.post<any>('/api/up?pagevalue=36', { ...data });
+}

+ 48 - 0
apps/web-ele/src/api/coupon/coupon2.ts

@@ -0,0 +1,48 @@
+import type { Coupon2Entity, PageConfig } from '@vben/types';
+
+import { adaptBackendRequest } from '@vben/utils';
+
+import { requestClient } from '#/api/request';
+
+interface Coupon2PartialEntity
+  extends Partial<Omit<Coupon2Entity, 'coupon2code'>> {
+  coupon2code?: string;
+}
+
+interface Coupon2QueryParams extends Coupon2PartialEntity, PageConfig {}
+
+/**
+ * 我的优惠券信息_列表
+ */
+export async function getCoupon2ListApi(params: Coupon2QueryParams) {
+  return requestClient.post<any>('/api/query/list?pagevalue=38', {
+    ...params,
+  });
+}
+
+/**
+ * 我的优惠券信息_详情
+ */
+export async function getCoupon2DetailApi(data: { coupon2sid: string }) {
+  return requestClient.post<any>(
+    '/api/query/view?pagevalue=39',
+    {
+      ...adaptBackendRequest(data),
+    },
+    { formatData: true }, // 格式化返回数据
+  );
+}
+
+/**
+ * 我的优惠券信息_新增
+ */
+export async function addCoupon2Api(data: Coupon2Entity) {
+  return requestClient.post<any>('/api/add?pagevalue=40', { ...data });
+}
+
+/**
+ * 我的优惠券信息_编辑
+ */
+export async function editCoupon2Api(data: Coupon2Entity) {
+  return requestClient.post<any>('/api/up?pagevalue=41', { ...data });
+}

+ 0 - 0
apps/web-ele/src/api/product-manage/index.ts → apps/web-ele/src/api/product/index.ts


+ 0 - 0
apps/web-ele/src/api/scqy-manage/index.ts → apps/web-ele/src/api/scqy/index.ts


+ 0 - 0
apps/web-ele/src/api/customer-manage/index.ts → apps/web-ele/src/api/user/index.ts


+ 67 - 112
apps/web-ele/src/views/coupon-manage/form.vue

@@ -1,151 +1,82 @@
 <script lang="ts" setup>
+import type { Coupon1Entity } from '@vben/types';
+
 import { computed, ref } from 'vue';
 
 import { useVbenModal } from '@vben/common-ui';
 
+import { ElMessage } from 'element-plus';
+
 import { useVbenForm, z } from '#/adapter/form';
-import { getCustomerDetailApi } from '#/api/customer-manage';
+import {
+  addCoupon1Api,
+  editCoupon1Api,
+  getCoupon1DetailApi,
+} from '#/api/coupon/coupon1';
+import { $t } from '#/locales';
 
+const emit = defineEmits(['finish']);
 const data = ref();
+const formType = ref<'create' | 'detail' | 'edit'>('create');
 
-const getTitle = computed(() => (data.value?.create ? '新增客户' : '编辑客户'));
+const titleMap = {
+  create: '新增优惠券',
+  detail: '优惠券详情',
+  edit: '编辑优惠券',
+} as const;
+
+const getTitle = computed(() => titleMap[formType.value]);
 
 const [BaseForm, baseFormApi] = useVbenForm({
   showDefaultActions: false,
   // 所有表单项共用,可单独在表单内覆盖
   commonConfig: {
-    labelWidth: 120,
+    labelWidth: 140,
     // 所有表单项
     componentProps: {
       class: 'w-full',
     },
   },
+  wrapperClass: 'grid-cols-1 lg:grid-cols-2',
   schema: [
-    // { title: '用户名称', field: 'usersname' },
-    // { title: '用户性质', field: 'usersnature' },
-    // { title: '用户证件号码', field: 'usersidcardnumber' },
-    // { title: '用户开户银行名称', field: 'usersbankname' },
-    // { title: '用户开户银行账号', field: 'usersbanknumber' },
-    // { title: '用户手机号', field: 'usersphone' },
-    // { title: '用户邮箱', field: 'usersemail' },
-    // { title: '用户地址', field: 'usersaddress' },
-    // { title: '用户联系手机号', field: 'userscontactphone' },
-    // { title: '用户联系邮箱', field: 'userscontactemail' },
-    // { title: '用户联系地址', field: 'userscontactaddress' },
-    {
-      component: 'Input',
-      fieldName: 'usersname',
-      label: '用户名称',
-      componentProps: {
-        placeholder: '请输入用户名称',
-        allowClear: true,
-      },
-      rules: z.string().min(1, { message: '请输入用户名称' }),
-    },
-    {
-      component: 'Input',
-      fieldName: 'usersnature',
-      label: '用户性质',
-      componentProps: {
-        placeholder: '请输入用户性质',
-        allowClear: true,
-      },
-      rules: z.number().min(1, { message: '请输入用户性质' }),
-    },
-    {
-      component: 'Input',
-      fieldName: 'usersidcardnumber',
-      label: '用户证件号码',
-      componentProps: {
-        placeholder: '请输入用户证件号码',
-        allowClear: true,
-      },
-      rules: z.string().min(1, { message: '请输入用户证件号码' }),
-    },
-    {
-      component: 'Input',
-      fieldName: 'usersbankname',
-      label: '用户开户银行名称',
-      componentProps: {
-        placeholder: '请输入用户开户银行名称',
-        allowClear: true,
-      },
-      rules: z.string().min(1, { message: '请输入用户开户银行名称' }),
-    },
-    {
-      component: 'Input',
-      fieldName: 'usersbanknumber',
-      label: '用户开户银行账号',
-      componentProps: {
-        placeholder: '请输入用户开户银行账号',
-        allowClear: true,
-      },
-      rules: z.string().min(1, { message: '请输入用户开户银行账号' }),
-    },
+    // { title: '优惠券名称', field: 'couponmc' },
+    // { title: '优惠券可用产品', field: 'couponproductids' },
+    // { title: '优惠券是否可用', field: 'couponsfky' },
     {
       component: 'Input',
-      fieldName: 'usersphone',
-      label: '用户手机号',
+      fieldName: 'couponmc',
+      label: '优惠券名称',
       componentProps: {
-        placeholder: '请输入用户手机号',
+        placeholder: $t('ui.placeholder.input'),
         allowClear: true,
       },
-      rules: z.string().min(1, { message: '请输入用户手机号' }),
+      rules: z.string().min(1, { message: '请输入优惠券名称' }),
     },
     {
       component: 'Input',
-      fieldName: 'usersemail',
-      label: '用户邮箱',
+      fieldName: 'couponproductids',
+      label: '优惠券可用产品',
       componentProps: {
-        placeholder: '请输入用户邮箱',
+        placeholder: $t('ui.placeholder.input'),
         allowClear: true,
       },
-      rules: z.string().min(1, { message: '请输入用户邮箱' }),
+      rules: z.string().min(1, { message: '请输入优惠券可用产品' }),
     },
     {
       component: 'Input',
-      fieldName: 'usersaddress',
-      label: '用户地址',
+      fieldName: 'couponsfky',
+      label: '优惠券是否可用',
       componentProps: {
-        placeholder: '请输入用户地址',
+        placeholder: $t('ui.placeholder.input'),
         allowClear: true,
       },
-      rules: z.string().min(1, { message: '请输入用户地址' }),
-    },
-    {
-      component: 'Input',
-      fieldName: 'userscontactphone',
-      label: '用户联系手机号',
-      componentProps: {
-        placeholder: '请输入用户联系手机号',
-        allowClear: true,
-      },
-      rules: z.string().min(1, { message: '请输入用户联系手机号' }),
-    },
-    {
-      component: 'Input',
-      fieldName: 'userscontactemail',
-      label: '用户联系邮箱',
-      componentProps: {
-        placeholder: '请输入用户联系邮箱',
-        allowClear: true,
-      },
-      rules: z.string().min(1, { message: '请输入用户联系邮箱' }),
-    },
-    {
-      component: 'Input',
-      fieldName: 'userscontactaddress',
-      label: '用户联系地址',
-      componentProps: {
-        placeholder: '请输入用户联系地址',
-        allowClear: true,
-      },
-      rules: z.string().min(1, { message: '请输入用户联系地址' }),
+      rules: z.string().min(1, { message: '请输入优惠券是否可用' }),
     },
   ],
 });
 
 const [Modal, modalApi] = useVbenModal({
+  class: 'w-7/12',
   onCancel() {
     modalApi.close();
   },
@@ -156,23 +87,47 @@ const [Modal, modalApi] = useVbenModal({
       return;
     }
 
-    modalApi.close();
-    // const values = await baseFormApi.getValues();
+    try {
+      // 调用新增或编辑接口
+      const apiMap = {
+        create: () => addCoupon1Api(validate.values as Coupon1Entity),
+        edit: () =>
+          editCoupon1Api({
+            ...validate.values,
+            'couponid.value': data.value.row.couponid,
+          } as any),
+      };
+
+      if (formType.value === 'detail') {
+        modalApi.close();
+        return;
+      }
 
-    // console.log(Object.keys(values));
+      await apiMap[formType.value]();
+      ElMessage.success('操作成功');
+
+      emit('finish');
+      modalApi.close();
+    } catch {}
   },
   async onOpenChange(isOpen) {
     if (isOpen) {
       data.value = modalApi.getData();
 
-      if (data.value.create) {
+      formType.value = data.value.formType;
+
+      baseFormApi.setState({
+        commonConfig: { disabled: formType.value === 'detail' },
+      });
+
+      if (data.value.formType === 'create') {
         return;
       }
 
       try {
         modalApi.setState({ loading: true });
-        const detailData = await getCustomerDetailApi({
-          usersid: data.value.row.usersid,
+        const detailData = await getCoupon1DetailApi({
+          couponid: data.value.row.couponid,
         });
 
         baseFormApi.setValues(detailData);

+ 31 - 40
apps/web-ele/src/views/coupon-manage/index.vue

@@ -7,10 +7,10 @@ import { Page, useVbenModal } from '@vben/common-ui';
 import { MdiDetail, MdiEdit } from '@vben/icons';
 
 import { useVbenVxeGrid } from '#/adapter/vxe-table';
-// import { getCustomerListApi } from '#/api/customer-manage';
+import { getCoupon1ListApi } from '#/api/coupon/coupon1';
 import { $t } from '#/locales';
 
-import CustomerForm from './form.vue';
+import Coupon1Form from './form.vue';
 
 const formOptions: VbenFormProps = {
   // 默认展开
@@ -22,23 +22,15 @@ const formOptions: VbenFormProps = {
   schema: [
     {
       component: 'Input',
-      fieldName: 'usersname',
-      label: '用户名称',
-      componentProps: {
-        placeholder: $t('ui.placeholder.input'),
-        allowClear: true,
-      },
-    },
-    {
-      component: 'Input',
-      fieldName: 'usersphone',
-      label: '用户手机号',
+      fieldName: 'couponmc',
+      label: '优惠券名称',
       componentProps: {
         placeholder: $t('ui.placeholder.input'),
         allowClear: true,
       },
     },
   ],
+  wrapperClass: 'grid-cols-1 md:grid-cols-3 lg:grid-cols-5',
 };
 
 const gridOptions: VxeGridProps<any> = {
@@ -62,29 +54,25 @@ const gridOptions: VxeGridProps<any> = {
       result: 'Data',
       total: 'Total',
     },
-    // ajax: {
-    //   query: async ({ page }, formValues) => {
-    //     return await getCustomerListApi({
-    //       pageindex: page.currentPage,
-    //       rows: page.pageSize,
-    //       ...formValues,
-    //     });
-    //   },
-    // },
+    ajax: {
+      query: async ({ page }, formValues) => {
+        return await getCoupon1ListApi({
+          pageindex: page.currentPage,
+          rows: page.pageSize,
+          ...formValues,
+        });
+      },
+    },
   },
 
   columns: [
-    { title: '用户名称', field: 'usersname' },
-    { title: '用户性质', field: 'usersnature' },
-    { title: '用户证件号码', field: 'usersidcardnumber' },
-    { title: '用户开户银行名称', field: 'usersbankname' },
-    { title: '用户开户银行账号', field: 'usersbanknumber' },
-    { title: '用户手机号', field: 'usersphone' },
-    { title: '用户邮箱', field: 'usersemail' },
-    { title: '用户地址', field: 'usersaddress' },
-    { title: '用户联系手机号', field: 'userscontactphone' },
-    { title: '用户联系邮箱', field: 'userscontactemail' },
-    { title: '用户联系地址', field: 'userscontactaddress' },
+    { title: '优惠券名称', field: 'couponmc' },
+    { title: '优惠券可用产品', field: 'couponproductids' },
+    { title: '优惠券是否可用', field: 'couponsfky' },
+    { title: '优惠券创建时间', field: 'couponcreatedate' },
+    { title: '优惠券创建人', field: 'couponcreateuser' },
+    { title: '优惠券更新时间', field: 'couponupdate' },
+    { title: '优惠券更新人', field: 'couponupuser' },
     {
       title: '操作',
       field: 'action',
@@ -95,29 +83,32 @@ const gridOptions: VxeGridProps<any> = {
   ],
 };
 
-const [Grid] = useVbenVxeGrid({ gridOptions, formOptions });
+const [Grid, gridApi] = useVbenVxeGrid({ gridOptions, formOptions });
 
 const [Modal, modalApi] = useVbenModal({
   fullscreenButton: false,
   closeOnClickModal: false,
   closeOnPressEscape: false,
-  connectedComponent: CustomerForm,
+  connectedComponent: Coupon1Form,
 });
 
 /* 创建 */
 function handleCreate() {
-  modalApi.setData({ create: true }).open();
+  modalApi.setData({ formType: 'create' }).open();
 }
 
 /* 编辑 */
 function handleEdit(row: any) {
-  modalApi.setData({ row }).open();
+  modalApi.setData({ formType: 'edit', row }).open();
 }
 
 /* 详情 */
 function handleDetail(row: any) {
-  modalApi.setData({ row }).open();
-  // router.push(`/system/users/detail/${row.userName}`);
+  modalApi.setData({ formType: 'detail', row }).open();
+}
+
+function handleFinish() {
+  gridApi.reload();
 }
 </script>
 
@@ -142,6 +133,6 @@ function handleDetail(row: any) {
         />
       </template>
     </Grid>
-    <Modal />
+    <Modal @finish="handleFinish" />
   </Page>
 </template>

+ 1 - 1
apps/web-ele/src/views/customer-manage/form.vue

@@ -12,7 +12,7 @@ import {
   addCustomerApi,
   editCustomerApi,
   getCustomerDetailApi,
-} from '#/api/customer-manage';
+} from '#/api/user';
 
 const emit = defineEmits(['finish']);
 const data = ref();

+ 1 - 1
apps/web-ele/src/views/customer-manage/index.vue

@@ -7,7 +7,7 @@ import { Page, useVbenModal } from '@vben/common-ui';
 import { MdiDetail, MdiEdit } from '@vben/icons';
 
 import { useVbenVxeGrid } from '#/adapter/vxe-table';
-import { getCustomerListApi } from '#/api/customer-manage';
+import { getCustomerListApi } from '#/api/user';
 import { $t } from '#/locales';
 
 import CustomerForm from './form.vue';

+ 1 - 1
apps/web-ele/src/views/product-manage/form.vue

@@ -12,7 +12,7 @@ import {
   addProductApi,
   editProductApi,
   getProductDetailApi,
-} from '#/api/product-manage';
+} from '#/api/product';
 
 const emit = defineEmits(['finish']);
 const data = ref();

+ 1 - 1
apps/web-ele/src/views/product-manage/index.vue

@@ -7,7 +7,7 @@ import { Page, useVbenModal } from '@vben/common-ui';
 import { MdiDetail, MdiEdit } from '@vben/icons';
 
 import { useVbenVxeGrid } from '#/adapter/vxe-table';
-import { getProductListApi } from '#/api/product-manage';
+import { getProductListApi } from '#/api/product';
 import { $t } from '#/locales';
 
 import ProductForm from './form.vue';

+ 1 - 1
apps/web-ele/src/views/scqy-manage/form.vue

@@ -8,7 +8,7 @@ import { useVbenModal } from '@vben/common-ui';
 import { ElMessage } from 'element-plus';
 
 import { useVbenForm, z } from '#/adapter/form';
-import { addScqyApi, editScqyApi, getScqyDetailApi } from '#/api/scqy-manage';
+import { addScqyApi, editScqyApi, getScqyDetailApi } from '#/api/scqy';
 
 const emit = defineEmits(['finish']);
 const data = ref();

+ 1 - 1
apps/web-ele/src/views/scqy-manage/index.vue

@@ -7,7 +7,7 @@ import { Page, useVbenModal } from '@vben/common-ui';
 import { MdiDetail, MdiEdit } from '@vben/icons';
 
 import { useVbenVxeGrid } from '#/adapter/vxe-table';
-import { getScqyListApi } from '#/api/scqy-manage';
+import { getScqyListApi } from '#/api/scqy';
 import { $t } from '#/locales';
 
 import ScqyForm from './form.vue';

+ 33 - 0
packages/types/src/coupon1.ts

@@ -0,0 +1,33 @@
+/** 优惠券信息*/
+// CREATE TABLE `coupon1` (
+//   `couponid` varchar(50) NOT NULL COMMENT '优惠券流水号',
+//   `couponmc` varchar(50) DEFAULT NULL COMMENT '优惠券名称',
+//   `couponproductids` varchar(5000) DEFAULT NULL COMMENT '优惠券可用产品',
+//   `couponsfky` tinyint(2) DEFAULT NULL COMMENT '优惠券是否可用',
+//   `couponcreatedate` datetime DEFAULT NULL COMMENT '优惠券创建时间',
+//   `couponcreateuser` varchar(50) DEFAULT NULL COMMENT '优惠券创建人',
+//   `couponupdate` datetime DEFAULT NULL COMMENT '优惠券更新时间',
+//   `couponupuser` varchar(50) DEFAULT NULL COMMENT '优惠券更新人',
+//   PRIMARY KEY (`couponid`)
+// ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='优惠券信息';
+
+interface Coupon1Entity {
+  /** 优惠券id */
+  couponid: string;
+  /** 优惠券名称 */
+  couponmc: string;
+  /** 优惠券可用产品 */
+  couponproductids: string;
+  /** 优惠券是否可用 */
+  couponsfky: number;
+  /** 优惠券创建时间 */
+  couponcreatedate: string;
+  /** 优惠券创建人 */
+  couponcreateuser: string;
+  /** 优惠券更新时间 */
+  couponupdate: string;
+  /** 优惠券更新人 */
+  couponupuser: string;
+}
+
+export type { Coupon1Entity };

+ 37 - 0
packages/types/src/coupon2.ts

@@ -0,0 +1,37 @@
+/** 我的优惠券信息*/
+// CREATE TABLE `coupon2` (
+//   `coupon2sid` varchar(50) NOT NULL COMMENT '优惠券id',
+//   `coupon2code` varchar(50) DEFAULT NULL COMMENT '优惠券代码',
+//   `coupon2adddatetime` datetime DEFAULT NULL COMMENT '优惠券申请时间',
+//   `coupon2reviewdatetime` datetime DEFAULT NULL COMMENT '优惠券审核时间',
+//   `coupon2userid` varchar(50) DEFAULT NULL COMMENT '关联申请人id',
+//   `coupon2sype` tinyint(2) DEFAULT NULL COMMENT '优惠券(0:申请中,1:审核通过,2:审核失败)',
+//   `coupon2isused` tinyint(2) DEFAULT NULL COMMENT '是否已使用(0:未使用,1:已使用)',
+//   `coupon2productids` varchar(5000) DEFAULT NULL COMMENT '可用产品id',
+//   `coupon2coupon1id` varchar(50) DEFAULT NULL COMMENT '关联主券id',
+//   PRIMARY KEY (`coupon2sid`) USING BTREE,
+//   KEY `couponsid` (`coupon2sid`)
+// ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='我的优惠券信息';
+
+interface Coupon2Entity {
+  /** 优惠券id */
+  coupon2sid: string;
+  /** 优惠券代码 */
+  coupon2code: string;
+  /** 优惠券申请时间 */
+  coupon2adddatetime: string;
+  /** 优惠券审核时间 */
+  coupon2reviewdatetime: string;
+  /** 关联申请人id */
+  coupon2userid: string;
+  /** 优惠券(0:申请中,1:审核通过,2:审核失败) */
+  coupon2sype: number;
+  /** 是否已使用(0:未使用,1:已使用) */
+  coupon2isused: number;
+  /** 可用产品id */
+  coupon2productids: string;
+  /** 关联主券id */
+  coupon2coupon1id: string;
+}
+
+export type { Coupon2Entity };

+ 2 - 0
packages/types/src/index.ts

@@ -1,4 +1,6 @@
 export type * from './base';
+export type * from './coupon1';
+export type * from './coupon2';
 export type * from './product';
 export type * from './scqy';
 export type * from './user';