فهرست منبع

开卡申请增加省份,直接开卡,增加代理商

mingfu 1 ماه پیش
والد
کامیت
937669e8fb

+ 3 - 1
back-ui/src/api/dz/cards.js

@@ -183,11 +183,13 @@ export function associateCampus(beginCardNo, endCardNo, campusId) {
 }
 
 // 申请开卡
-export function requestOpenCard(schoolId, beginCardNo, endCardNo) {
+export function requestOpenCard(agentId, province, schoolId, beginCardNo, endCardNo) {
   return request({
     url: "/dz/cards/openCard",
     method: "post",
     params: {
+      agentId: agentId,
+      location: province,
       schoolId,
       begin: beginCardNo,
       end: endCardNo,

+ 3 - 3
back-ui/src/api/dz/open.js

@@ -26,11 +26,11 @@ export function addOpen(data) {
   })
 }
 
-// 修改开卡申请
+// 审核开卡申请
 export function updateOpen(data) {
   return request({
-    url: '/dz/open',
-    method: 'put',
+    url: '/dz/open/audit',
+    method: 'post',
     data: data
   })
 }

+ 82 - 5
back-ui/src/views/dz/cards/components/ApplyCardDialog.vue

@@ -35,7 +35,39 @@
             </el-form-item>
           </div>
         </el-form-item>
-
+        <!-- 代理商 -->
+        <el-form-item label="代理商" prop="agentId" :required="true">
+          <el-select
+              v-model="form.agentId"
+              placeholder="请选择代理商"
+              style="width: 100%"
+              clearable
+          >
+            <el-option
+                v-for="agent in agentList"
+                :key="agent.id"
+                :label="agent.name"
+                :value="agent.id"
+            ></el-option>
+          </el-select>
+        </el-form-item>
+        <!-- 省份 -->
+        <el-form-item label="省份" prop="province">
+          <el-select
+              v-model="form.province"
+              placeholder="请选择省份"
+              style="width: 100%"
+              @change="getCampusListData(this.value)"
+              clearable
+          >
+            <el-option
+                v-for="province in provinceList"
+                :key="province.dictValue"
+                :label="province.dictLabel"
+                :value="province.dictValue"
+            ></el-option>
+          </el-select>
+        </el-form-item>
         <!-- 学校 -->
         <el-form-item label="学校" prop="schoolId">
           <el-select
@@ -72,9 +104,10 @@
 
 <script setup>
 import { ref, computed, watch } from "vue";
-import { requestOpenCard } from "@/api/dz/cards";
+import {getAgentList, requestOpenCard} from "@/api/dz/cards";
 import { listUniversity } from "@/api/dz/school";
 import { associateCampus, getCampusSchoolList } from "@/api/dz/cards";
+import {getPaperProvinces} from "@/api/dz/papers.js";
 
 const props = defineProps({
   modelValue: {
@@ -96,16 +129,20 @@ const visible = computed({
 
 const applyCardFormRef = ref();
 const loading = ref(false);
+const provinceList = ref([]); // 省份列表
+const agentList = ref([]); // 代理商列表
 const schoolList = ref([]);
 const campusList = ref([]);
 
 const form = ref({
+  agentId: null,
   beginCardNo: "",
   endCardNo: "",
   schoolId: null,
 });
 
 const rules = {
+  province: [{ required: true, message: "省份不能为空", trigger: "change" }],
   beginCardNo: [
     { required: true, message: "开始卡号不能为空", trigger: "blur" },
   ],
@@ -113,10 +150,44 @@ const rules = {
   schoolId: [{ required: true, message: "学校不能为空", trigger: "change" }],
 };
 
+
+// 获取代理商列表
+async function getAgentListData() {
+  try {
+    const response = await getAgentList({});
+    if (response.code === 200) {
+      // 处理代理商数据,映射字段名
+      agentList.value = (response.data || []).map((item) => ({
+        id: item.agentId,
+        name: item.name,
+        agentId: item.agentId,
+        deptId: item.deptId,
+        phonenumber: item.phonenumber,
+        schoolName: item.schoolName,
+      }));
+    }
+  } catch (error) {
+    console.error("获取代理商列表失败:", error);
+  }
+}
+
+// 获取省份列表
+async function getProvinceList() {
+  try {
+    const response = await getPaperProvinces();
+    if (response.code === 200) {
+      provinceList.value = response.data || [];
+    }
+    campusList.value = []
+  } catch (error) {
+    console.error("获取省份列表失败:", error);
+  }
+}
+
 // 获取校区列表
 async function getCampusListData() {
   try {
-    const response = await getCampusSchoolList({ campus: false, pageNum: 1, pageSize: 1000 });
+    const response = await getCampusSchoolList({ campus: false, location: form.value.province, pageNum: 1, pageSize: 1000 });
     if (response.code === 200) {
       campusList.value = response.data || [];
     }
@@ -189,6 +260,7 @@ function resetForm() {
   form.value = {
     beginCardNo: "",
     endCardNo: "",
+    agentId: null,
     schoolId: null,
   };
 }
@@ -208,6 +280,8 @@ async function handleSubmit() {
         const begin = form.value.beginCardNo;
         const end = form.value.endCardNo;
         const schoolId = form.value.schoolId;
+        const province = form.value.province;
+        const agentId = form.value.agentId;
 
         if (!begin || !end) {
           throw new Error("请填写完整的卡号段");
@@ -216,7 +290,7 @@ async function handleSubmit() {
           throw new Error("请选择学校");
         }
 
-        await requestOpenCard(schoolId, begin, end);
+        await requestOpenCard(agentId, province, schoolId, begin, end);
         emit("success", "申请开卡成功!");
         visible.value = false;
         resetForm();
@@ -235,7 +309,10 @@ watch(visible, (newVal) => {
   if (!newVal) {
     resetForm();
   } else {
-    getCampusListData();
+    // 获取代理商列表
+    getAgentListData();
+    // 弹窗打开时获取省份列表
+    getProvinceList();
     autoFillCardRange();
   }
 });

+ 3 - 3
back-ui/src/views/dz/open/config/table.js

@@ -53,11 +53,11 @@ const tableConfig = {
     },
     {
       label: "原因",
-      prop: "reason",
+      prop: "auditDesc",
       align: "center",
       minWidth: 120,
       type: "slot",
-      slotName: "reason",
+      slotName: "auditDesc",
     },
   ],
 
@@ -69,7 +69,7 @@ const tableConfig = {
       type: "primary",
       link: true,
       permission: ["dz:open:review"],
-      condition: (row) => row.status === 0, // 只有待审核状态才显示审核按钮
+      condition: (row) => row.status === 1, // 只有待审核状态才显示审核按钮
     },
   ],
 

+ 84 - 22
back-ui/src/views/dz/open/index.vue

@@ -69,8 +69,8 @@
       </template>
 
       <!-- 原因插槽 -->
-      <template #reason="{ row }">
-        <span>{{ row.reason || "-" }}</span>
+      <template #auditDesc="{ row }">
+        <span>{{ row.auditDesc || "-" }}</span>
       </template>
     </Table>
 
@@ -83,8 +83,37 @@
         <el-form-item label="截止卡号" prop="endNo">
           <el-input v-model="form.endNo" placeholder="请输入截至卡号" />
         </el-form-item>
-        <el-form-item label="学校" prop="schoolName">
-          <el-input v-model="form.schoolName" placeholder="请输入学校" />
+        <!-- 省份 -->
+        <el-form-item label="省份" prop="province">
+          <el-select
+              v-model="form.province"
+              placeholder="请选择省份"
+              style="width: 100%"
+              @change="getCampusListData(this.value)"
+              clearable
+          >
+            <el-option
+                v-for="province in provinceList"
+                :key="province.dictValue"
+                :label="province.dictLabel"
+                :value="province.dictValue"
+            ></el-option>
+          </el-select>
+        </el-form-item>
+        <!-- 学校 -->
+        <el-form-item label="学校" prop="schoolId">
+          <el-select
+              v-model="form.schoolId"
+              placeholder="请选择学校"
+              style="width: 100%"
+          >
+            <el-option
+                v-for="school in schoolList"
+                :key="school.id"
+                :label="school.name"
+                :value="school.id"
+            ></el-option>
+          </el-select>
         </el-form-item>
 <!--        <el-form-item label="原因" prop="reason">-->
 <!--          <el-input v-model="form.reason" placeholder="请输入原因" />-->
@@ -139,13 +168,13 @@
       >
         <el-form-item label="审核结果" prop="status">
           <el-radio-group v-model="reviewForm.status">
-            <el-radio :value="1">审核通过</el-radio>
-            <el-radio :value="2">已拒绝</el-radio>
+            <el-radio :value="2">审核通过</el-radio>
+            <el-radio :value="3">已拒绝</el-radio>
           </el-radio-group>
         </el-form-item>
-        <el-form-item label="原因" prop="reason">
+        <el-form-item label="原因" prop="auditDesc">
           <el-input
-            v-model="reviewForm.reason"
+            v-model="reviewForm.auditDesc"
             placeholder="请输入审核原因"
             type="textarea"
             :rows="3"
@@ -168,12 +197,17 @@ import SearchForm from "@/components/SearchForm/index.vue";
 import Table from "@/components/Table/index.vue";
 import formConfig from "./config/form.js";
 import tableConfig from "./config/table.js";
+import {ref} from "vue";
+import {getPaperProvinces} from "@/api/dz/papers.js";
+import {getCampusSchoolList} from "@/api/dz/cards.js";
 
 const { proxy } = getCurrentInstance();
 
 const openList = ref([]);
 const open = ref(false);
 const reviewOpen = ref(false);
+const provinceList = ref([]); // 省份列表
+const schoolList = ref([]); // 学校列表
 const loading = ref(true);
 const showSearch = ref(true);
 const total = ref(0);
@@ -194,12 +228,13 @@ const data = reactive({
   reviewForm: {
     id: null,
     status: null,
-    reason: null,
+    auditDesc: null,
     startNo: null,
     endNo: null,
     applicant: null,
     createTime: null,
-    schoolName: null,
+    province:null,
+    schoolId: null,
   },
   queryParams: {
     pageNum: 1,
@@ -212,7 +247,8 @@ const data = reactive({
     applicant: [{ required: true, message: "申请人不能为空", trigger: "blur" }],
     startNo: [{ required: true, message: "起始卡号不能为空", trigger: "blur" }],
     endNo: [{ required: true, message: "截至卡号不能为空", trigger: "blur" }],
-    schoolName: [{ required: true, message: "学校不能为空", trigger: "blur" }],
+    province: [{ required: true, message: "省份不能为空", trigger: "change" }],
+    schoolId: [{ required: true, message: "学校不能为空", trigger: "change" }],
     status: [
       { required: true, message: "申请状态不能为空", trigger: "change" },
     ],
@@ -221,7 +257,7 @@ const data = reactive({
     status: [
       { required: true, message: "审核结果不能为空", trigger: "change" },
     ],
-    reason: [],
+    auditDesc: [],
   },
 });
 
@@ -237,6 +273,32 @@ function getList() {
   });
 }
 
+
+// 获取省份列表
+async function getProvinceList() {
+  try {
+    const response = await getPaperProvinces();
+    if (response.code === 200) {
+      provinceList.value = response.data || [];
+    }
+    schoolList.value = []
+  } catch (error) {
+    console.error("获取省份列表失败:", error);
+  }
+}
+
+// 获取校区列表
+async function getCampusListData() {
+  try {
+    const response = await getCampusSchoolList({ campus: false, location: form.value.province, pageNum: 1, pageSize: 1000 });
+    if (response.code === 200) {
+      schoolList.value = response.data || [];
+    }
+  } catch (error) {
+    console.error("获取校区列表失败:", error);
+  }
+}
+
 // 计算申请数量
 function calculateQuantity(startNo, endNo) {
   if (!startNo || !endNo) return 0;
@@ -248,9 +310,9 @@ function calculateQuantity(startNo, endNo) {
 // 获取状态文本
 function getStatusText(status) {
   const statusMap = {
-    0: "待审核",
-    1: "审核通过",
-    2: "已拒绝",
+    1: "待审核",
+    2: "审核通过",
+    3: "已拒绝",
   };
   return statusMap[status] || "未知";
 }
@@ -258,9 +320,9 @@ function getStatusText(status) {
 // 获取状态类型
 function getStatusType(status) {
   const typeMap = {
-    0: "warning",
-    1: "success",
-    2: "danger",
+    1: "warning",
+    2: "success",
+    3: "danger",
   };
   return typeMap[status] || "info";
 }
@@ -297,7 +359,7 @@ function resetReview() {
   reviewForm.value = {
     id: null,
     status: null,
-    reason: null,
+    auditDesc: null,
     startNo: null,
     endNo: null,
     applicant: null,
@@ -352,7 +414,7 @@ function handleReview(row) {
   reviewForm.value = {
     id: row.id,
     status: null,
-    reason: null,
+    auditDesc: null,
     startNo: row.startNo || "-",
     endNo: row.endNo || "-",
     applicant: row.applicant || "-",
@@ -401,7 +463,7 @@ function submitReview() {
       const updateData = {
         id: reviewForm.value.id,
         status: reviewForm.value.status,
-        reason: reviewForm.value.reason,
+        auditDesc: reviewForm.value.auditDesc,
       };
       updateOpen(updateData).then((response) => {
         proxy.$modal.msgSuccess("审核成功");
@@ -422,7 +484,7 @@ function handleExport() {
     `open_${new Date().getTime()}.xlsx`
   );
 }
-
+getProvinceList();
 getList();
 </script>
 <style>

+ 2 - 3
ie-admin/src/main/java/com/ruoyi/web/controller/dz/DzCardsController.java

@@ -163,10 +163,9 @@ public class DzCardsController extends BaseController
     @Log(title = "直接开卡", businessType = BusinessType.INSERT)
     @PostMapping("/openCard")
     @ApiOperation("直接开卡")
-    public AjaxResult openCard(@ApiParam("学校") Long schoolId, @ApiParam("开始号") String begin, @ApiParam("结束号") String end)
+    public AjaxResult openCard(@ApiParam("代理商") Long agentId, @ApiParam("省份") String location, @ApiParam("学校") Long schoolId, @ApiParam("开始号") String begin, @ApiParam("结束号") String end)
     {
-        Long agentId = 0L;
-        return AjaxResult.success(dzCardsService.openCard(schoolId, agentId, begin, end));
+        return AjaxResult.success(dzCardsService.openCard(agentId, location, schoolId, begin, end));
     }
 
     @Log(title = "分配校区", businessType = BusinessType.INSERT)

+ 16 - 3
ie-system/src/main/java/com/ruoyi/dz/domain/DzCardsOpen.java

@@ -20,6 +20,10 @@ public class DzCardsOpen extends BaseEntity
     /** 标识 */
     private Long id;
 
+    /** 省份 */
+    @Excel(name = "省份")
+    private String location;
+
     /** 代理 */
     @Excel(name = "代理")
     private Long agentId;
@@ -37,8 +41,8 @@ public class DzCardsOpen extends BaseEntity
     @Excel(name = "结束日期", width = 30, dateFormat = "yyyy-MM-dd")
     private Date endDate;
 
-    /** 校 */
-    @Excel(name = "校")
+    /** 校 */
+    @Excel(name = "校")
     private Long schoolId;
 
     /** 发件人 */
@@ -62,7 +66,16 @@ public class DzCardsOpen extends BaseEntity
     /** 校区 */
     private String schoolName;
 
-    public void setId(Long id) 
+
+    public String getLocation() {
+        return location;
+    }
+
+    public void setLocation(String location) {
+        this.location = location;
+    }
+
+    public void setId(Long id)
     {
         this.id = id;
     }

+ 3 - 2
ie-system/src/main/java/com/ruoyi/dz/service/IDzCardsService.java

@@ -86,13 +86,14 @@ public interface IDzCardsService
 
     /**
      * 开卡
-     * @param schoolId
      * @param agentId
+     * @param location
+     * @param schoolId
      * @param beginNo
      * @param endNo
      * @return
      */
-    public Boolean openCard(Long schoolId, Long agentId, String beginNo, String endNo);
+    public Boolean openCard(Long agentId, String location, Long schoolId, String beginNo, String endNo);
 
     /**
      * 申请开卡

+ 25 - 3
ie-system/src/main/java/com/ruoyi/dz/service/impl/DzCardsServiceImpl.java

@@ -227,13 +227,15 @@ public class DzCardsServiceImpl implements IDzCardsService
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public Boolean openCard(Long schoolId, Long agentId, String beginNo, String endNo) {
+    public Boolean openCard(Long agentId, String location, Long schoolId, String beginNo, String endNo) {
         DzCardsOpen newOpen = new DzCardsOpen();
         newOpen.setAgentId(agentId);
         newOpen.setStartNo(beginNo);
         newOpen.setEndNo(endNo);
         newOpen.setEndDate(DateUtils.addDays(DateUtils.getNowDate(), 14)); // TODO MF 卡默认有效期
         newOpen.setSchoolId(schoolId);
+        newOpen.setLocation(location);
+        newOpen.setSender(SecurityUtils.getLoginUser().getUser().getNickName());
         newOpen.setIsReopen(0);
         newOpen.setStatus(RequestStatus.Accept.getVal());
         dzCardsOpenMapper.insertDzCardsOpen(newOpen);
@@ -245,12 +247,23 @@ public class DzCardsServiceImpl implements IDzCardsService
         if(cards.stream().filter(t -> !t.getPayStatus().equals(PayStatus.UnPay.getVal())).count() > 0) {
             throw new ValidationException("请求打开已开卡: " + beginNo + "-" + endNo);
         }
+        DzAgent dzAgent = dzAgentMapper.selectDzAgentByAgentId(agentId);
         DzCards dzCards = new DzCards();
         cards.stream().forEach(c -> {
             dzCards.setCardId(c.getCardId());
             dzCards.setPayTime(DateUtils.getNowDate());
             dzCards.setPayStatus(PayStatus.Paid.getVal());
             dzCards.setStatus(CardStatus.Paid.getVal());
+            dzCards.setDistributeStatus(CardDistributeStatus.Assign.getVal());
+            dzCards.setAssignLocation(location);
+            dzCards.setAssignSchoolId(schoolId);
+            if(null != dzAgent.getParentId()) {
+                dzCards.setAgentId(dzAgent.getParentId());
+                dzCards.setLeafAgentId(dzAgent.getAgentId());
+            } else {
+                dzCards.setAgentId(dzAgent.getAgentId());
+                dzCards.setLeafAgentId(dzAgent.getAgentId());
+            }
             dzCardsMapper.updateDzCards(dzCards);
         });
         // TODO MF 检查已经使用的或无效的
@@ -262,8 +275,6 @@ public class DzCardsServiceImpl implements IDzCardsService
         SysUser sysUser = SecurityUtils.getLoginUser().getUser();
         if(UserTypeEnum.Agent.getVal().equals(sysUser.getUserType())) {
             dzCardsOpen.setAgentId(sysUser.getUserTypeId());
-        } else {
-            dzCardsOpen.setAgentId(0L);
         }
         dzCardsOpen.setStatus(RequestStatus.Submit.getVal());
         dzCardsOpen.setEndDate(DateUtils.addDays(DateUtils.getNowDate(), 14));
@@ -301,9 +312,20 @@ public class DzCardsServiceImpl implements IDzCardsService
             DzCards dzCards = new DzCards();
             cards.stream().forEach(c -> {
                 dzCards.setCardId(c.getCardId());
+                dzCards.setAssignLocation(exist.getLocation());
+                dzCards.setAssignSchoolId(exist.getSchoolId());
+                DzAgent dzAgent = dzAgentMapper.selectDzAgentByAgentId(exist.getAgentId());
+                if(null != dzAgent.getParentId()) {
+                    dzCards.setAgentId(dzAgent.getParentId());
+                    dzCards.setLeafAgentId(dzAgent.getAgentId());
+                } else {
+                    dzCards.setAgentId(dzAgent.getAgentId());
+                    dzCards.setLeafAgentId(dzAgent.getAgentId());
+                }
                 dzCards.setPayTime(DateUtils.getNowDate());
                 dzCards.setPayStatus(PayStatus.Paid.getVal());
                 dzCards.setStatus(CardStatus.Paid.getVal());
+                dzCards.setDistributeStatus(CardDistributeStatus.Assign.getVal());
                 dzCardsMapper.updateDzCards(dzCards);
             });
         }

+ 7 - 2
ie-system/src/main/resources/mapper/dz/DzCardsOpenMapper.xml

@@ -10,6 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="startNo"    column="start_no"    />
         <result property="endNo"    column="end_no"    />
         <result property="endDate"    column="end_date"    />
+        <result property="location"    column="location"    />
         <result property="schoolId"    column="school_id"    />
         <result property="sender"    column="sender"    />
         <result property="createTime"    column="create_time"    />
@@ -20,7 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectDzCardsOpenVo">
-        select id, agent_id, start_no, end_no, end_date, school_id, sender, create_time, is_reopen, status, audit_desc from dz_cards_open
+        select id, agent_id, start_no, end_no, end_date, location, school_id, sender, create_time, is_reopen, status, audit_desc from dz_cards_open
     </sql>
 
     <select id="selectDzCardsOpenList" parameterType="DzCardsOpen" resultMap="DzCardsOpenResult">
@@ -30,6 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="startNo != null  and startNo != ''"> and start_no = #{startNo}</if>
             <if test="endNo != null  and endNo != ''"> and end_no = #{endNo}</if>
             <if test="endDate != null "> and end_date = #{endDate}</if>
+            <if test="location != null "> and location = #{location}</if>
             <if test="schoolId != null "> and school_id = #{schoolId}</if>
             <if test="sender != null  and sender != ''"> and sender = #{sender}</if>
             <if test="isReopen != null "> and is_reopen = #{isReopen}</if>
@@ -49,6 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="startNo != null">start_no,</if>
             <if test="endNo != null">end_no,</if>
             <if test="endDate != null">end_date,</if>
+            <if test="location != null">location,</if>
             <if test="schoolId != null">school_id,</if>
             <if test="sender != null">sender,</if>
             <if test="createTime != null">create_time,</if>
@@ -60,6 +63,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="startNo != null">#{startNo},</if>
             <if test="endNo != null">#{endNo},</if>
             <if test="endDate != null">#{endDate},</if>
+            <if test="location != null">#{location},</if>
             <if test="schoolId != null">#{schoolId},</if>
             <if test="sender != null">#{sender},</if>
             <if test="createTime != null">#{createTime},</if>
@@ -75,12 +79,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="startNo != null">start_no = #{startNo},</if>
             <if test="endNo != null">end_no = #{endNo},</if>
             <if test="endDate != null">end_date = #{endDate},</if>
+            <if test="location != null">location = #{location},</if>
             <if test="schoolId != null">school_id = #{schoolId},</if>
             <if test="sender != null">sender = #{sender},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="isReopen != null">is_reopen = #{isReopen},</if>
             <if test="status != null">status = #{status},</if>
-            <if test="auditDesc != null "> and audit_desc = #{auditDesc}</if>
+            <if test="auditDesc != null ">audit_desc = #{auditDesc}</if>
         </trim>
         where id = #{id}
     </update>