Selaa lähdekoodia

活动权益新增

zuy 2 vuotta sitten
vanhempi
säilyke
210b28052f

+ 92 - 0
admin-web/src/components/pdf/index.vue

@@ -0,0 +1,92 @@
+<style scoped lang="scss">
+
+</style>
+<template>
+  <div class="system-dialog-container">
+    <el-dialog
+        title="文件预览"
+        v-model="state.dialog.isShowDialog"
+        width="820px"
+        fullscreen
+        draggable
+        destroy-on-close
+        :close-on-click-modal="false"
+        @close="onClose"
+        align-center>
+<!--            <iframe :src="state.pdfUrl"
+                    ref="pdfViewer"
+                    height="100%"
+                    width="100%"
+                    style="position: absolute"></iframe>-->
+<!--
+      <VuePdfApp
+          file-name="文件名"
+          style="width:100%;height:100%"
+          :pdf="state.pdfData">
+
+      </VuePdfApp>
+-->
+
+<!--      <pdf-viewer :src="state.pdfData" :scale="1" :autoresize="true"></pdf-viewer>-->
+
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button @click="onCancel" size="default"> 关闭</el-button>
+        </div>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+
+<script setup lang="ts" name="InvoiceDialog">
+import {defineAsyncComponent, reactive, onMounted, ref} from 'vue';
+import u from "/@/utils/u"
+// import pdfjsLib from "pdfjs-dist";
+// import "pdfjs-dist/pdf.worker.min.js";
+// import { pdfViewer } from "pdfjs-dist";
+
+
+// 定义子组件向父组件传值/事件
+const formRef = ref();
+//定义初始变量,重置使用
+const initState = () => ({
+  pdfUrl: '',
+  pdfData:null,
+  dialog: {
+    isShowDialog: false,
+    type: '',
+    title: '',
+    submitTxt: '',
+  },
+})
+
+// 定义变量内容
+const state = reactive(initState());
+
+
+// 打开弹窗
+const open = (url: string) => {
+  // loadPdf(url);
+  const serverUrl = import.meta.env.VITE_API_URL
+  state.pdfUrl = `${serverUrl}/file/preview`
+  state.dialog.isShowDialog = true;
+  console.log("openxxx")
+};
+// 关闭弹窗
+const onClose = () => {
+  state.dialog.isShowDialog = false;
+  Object.assign(state, initState())
+};
+// 取消
+const onCancel = () => {
+  onClose();
+};
+
+
+// 暴露变量
+defineExpose({
+  open
+});
+
+
+</script>

+ 102 - 1
admin-web/src/views/admin/activity/dialog.vue

@@ -28,6 +28,18 @@
               class="w100">
           </el-input>
         </el-form-item>
+        <el-form-item label="活动描述" prop="remark" class="w100">
+          <el-input
+              maxlength="500"
+              show-word-limit
+              type="textarea"
+              :rows="3"
+              v-model.trim="state.ruleForm.activityDesc"
+              placeholder="活动描述"
+              clearable
+              class="w100">
+          </el-input>
+        </el-form-item>
         <el-form-item label="开始时间" prop="startTime">
           <ext-date-picker
               v-model.trim="state.ruleForm.startTime"
@@ -131,6 +143,70 @@
 
 
         <el-divider content-position="left">关联权益</el-divider>
+        <el-button size="small" plain type="success" class="ml10" @click="handleAddRightsItem">
+          <SvgIcon name="ele-FolderAdd"/>
+          新增权益
+        </el-button>
+
+        <el-card v-for="(rights,idx) in state.ruleForm.rechargeRightsList" :key="idx" class="mt10" shadow="hover">
+          <template #header>
+            <div class="card-header">
+              <el-button class="button" plain type="danger" size="small" v-auth="'activity.modify'" @click="handleRemoveRightsItem(idx)">删除</el-button>
+            </div>
+          </template>
+          <el-form-item label="权益描述" prop="rightsDesc" class="w100">
+            <el-input
+                maxlength="500"
+                show-word-limit
+                type="textarea"
+                :rows="2"
+                v-model.trim="rights.rightsDesc"
+                placeholder="权益描述"
+                clearable
+                class="w100">
+            </el-input>
+          </el-form-item>
+
+          <el-row :gutter="20">
+            <el-col :span="12">
+              <el-form-item label="最小充值金额" prop="amountMin" >
+                <el-input-number
+                    controls-position="right"
+                    v-model.trim="rights.amountMin"
+                    placeholder="最小充值金额"
+                    clearable
+                    :min="0"
+                    class="wd200">
+                </el-input-number>
+              </el-form-item>
+            </el-col>
+            <el-col :span="12">
+              <el-form-item label="最大充值金额" prop="amountMin" >
+                <el-input-number
+                    controls-position="right"
+                    v-model.trim="rights.amountMax"
+                    placeholder="最大充值金额"
+                    clearable
+                    :min="0"
+                    class="wd200">
+                </el-input-number>
+              </el-form-item>
+
+            </el-col>
+          </el-row>
+
+
+
+          <el-form-item label="折扣" prop="amountMin" >
+            <el-input
+                type="number"
+                v-model.trim="rights.discount"
+                placeholder="折扣:100代表无折扣,75代表75折"
+                clearable
+                class="wd200">
+            </el-input>
+          </el-form-item>
+        </el-card>
 
       </el-form>
 
@@ -160,7 +236,8 @@ const formRef = ref();
 const initState = () => ({
   action:'',
   ruleForm: {
-    id: 0
+    id: 0,
+    rechargeRightsList:[] as Array<any>
   },
   btnLoading: false,
   dialog: {
@@ -209,6 +286,16 @@ const onCancel = () => {
 };
 // 提交
 const onSubmit = () => {
+  let rechargeRightsList = state.ruleForm.rechargeRightsList;
+  if(!u.isEmptyOrNull(rechargeRightsList)){
+    for (let i = 0; i < rechargeRightsList.length; i++){
+      const item: any = rechargeRightsList[i];
+      if(item.amountMin>item.amountMax){
+        Msg.message(`权益最小充值金额不能大于最大充值金额`,'error')
+        return false;
+      }
+    }
+  }
   formRef.value.validate((valid:boolean) => {
     if(valid){
       state.btnLoading = true;
@@ -235,6 +322,7 @@ const handleFormChange = (formData: any) => {
 const loadData = (id: number) => {
   $get(`activity/${id}`).then((res: any) => {
     state.ruleForm = res;
+    state.ruleForm.rechargeRightsList = res.rechargeRightsList||[]
   })
 }
 
@@ -246,6 +334,19 @@ const handleStationChange = (applyStation:number)=>{
 
 }
 
+const handleAddRightsItem = ()=>{
+  state.ruleForm.rechargeRightsList.unshift({
+    rightsDesc:'',
+    amountMin:0,
+    amountMax:0,
+    discount:100,
+  })
+}
+
+const handleRemoveRightsItem= (idx:number)=>{
+  state.ruleForm.rechargeRightsList.splice(idx,1)
+}
+
 // 暴露变量
 defineExpose({
   open

+ 1 - 1
admin-web/src/views/admin/activity/index.vue

@@ -131,7 +131,7 @@
               <ext-d-label type="Activity.allowStacke" v-model="row[field.prop]"></ext-d-label>
             </template>
             <template v-else-if="field.prop==='action'">
-              <el-button v-auth="'banner.modify'" size="small" plain type="warning" @click="onRowClick('edit',row)">编辑</el-button>
+              <el-button v-auth="'banner.list'" size="small" plain type="success" @click="onRowClick('view',row)">查看</el-button>
               <el-button v-auth="'banner.modify'" size="small" plain type="danger" @click="onRowTerminal(row)">终止</el-button>
             </template>
             <template v-else>

+ 5 - 2
admin-web/src/views/admin/invoice/index.vue

@@ -124,7 +124,7 @@
             <template v-if="field.prop==='expand'">
               <el-row class="pd10">
                 <el-col :span="12">
-                  <h4>关联订单明细</h4>
+                  <h4 class="pd5">关联订单明细</h4>
                   <el-table :data="row.orderDetails" width="400" border>
                     <el-table-column label="充电订单" prop="startChargeSeq"/>
                     <el-table-column label="总金额(元)" prop="totalMoney">
@@ -156,6 +156,9 @@
             <template v-else-if="field.prop==='totalMoney'">
               {{ u.fmt.fmtMoney(row[field.prop]) }}
             </template>
+            <template v-else-if="field.prop==='invoiceAmount'">
+              {{ u.fmt.fmtMoney(row[field.prop]) }}
+            </template>
             <template v-else-if="field.prop==='elecMoney'">
               {{ u.fmt.fmtMoney(row[field.prop]) }}
             </template>
@@ -221,7 +224,7 @@ const state = reactive({
       {type: 'expand', prop: 'expand', width: 30, fixed: 'left'},
       {label: '申请号', prop: 'applyId', align: 'center', fixed: 'left', width: 220},
       {label: '发票状态', prop: 'status', align: 'center', fixed: 'left', width: 100},
-      {label: '发票金额()', prop: 'invoiceAmount', resizable: true, width: 150},
+      {label: '发票金额()', prop: 'invoiceAmount', resizable: true, width: 150},
       {label: '订单总金额(元)', prop: 'totalMoney', resizable: true, width: 150},
       {label: '总服务费(元)', prop: 'serviceMoney', resizable: true, width: 140},
       {label: '开票人', prop: 'biller', resizable: true, width: 130},

+ 11 - 2
admin/src/test/java/TestCase.java

@@ -1,16 +1,25 @@
 import cn.hutool.crypto.digest.DigestAlgorithm;
 import cn.hutool.crypto.digest.Digester;
+import cn.hutool.http.HttpUtil;
 import org.junit.jupiter.api.Test;
 
+import java.io.File;
+
 
 public class TestCase {
 
     @Test
-    public void test1(){
+    public void test1() {
         Digester MD5 = new Digester(DigestAlgorithm.MD5);
         String mobile = "15071072750";
-        String password=  "1234";
+        String password = "1234";
         String s = MD5.digestHex(password.concat(MD5.digestHex(mobile).substring(0, 5)));
         System.out.println(s);
     }
+
+    @Test
+    public void testPDF() {
+        File f = new File("/data/home/zuy/01.pdf");
+        HttpUtil.downloadFile("https://pay.wechatpay.cn/invoicing/fapiao/fapiao-file?token=AASkCcgAAAABAAAAAAAzwnqoYS46n1SlLY9LZSAAAABf4m5a0FKM5L7DnWkBpnsWBa_izWKMwHtR4d-e-BZcbJiO9Zp2_EqQBHFU1Sx4XNahl8QS826lV2C2FkLWjX456dPwJToQIQq5Q3zVyNoLKkh_kVpVFOz2saVVPkBvhU4rshjhZntlCjTAVFNzsY6uYDi-1XGHw6QnZoWFg8zUggWS8yN-6Bxc22R6JOO_CPDE6ih6uRZMQuDeSA&mchid=1635831469&openid=ox6fm6KbWb8Y8q0-xFs3kPREaPm8&invoice_code=144032309110&invoice_no=44452848&fapiao_id=1170499328033161216",f);
+    }
 }

+ 1 - 1
service/src/main/java/com/kym/service/admin/impl/ActivityServiceImpl.java

@@ -79,8 +79,8 @@ public class ActivityServiceImpl extends ServiceImpl<ActivityMapper, Activity> i
     public void createActivity(ActivityVo activityVo) {
         // 新增activity
         var activity = new Activity();
-        activity.setId(IDGenerator.INS().nextId());
         BeanUtils.copyProperties(activityVo, activity);
+        activity.setId(IDGenerator.INS().nextId());
         save(activity);
 
         // 新增activityStation