From 7e7f901b2172281dc294dfbc67e6ad00625f09f4 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期一, 04 三月 2024 10:11:21 +0800
Subject: [PATCH] 合并代码

---
 cloud-server-management/src/main/webapp/static/modular/system/cpPayment/cpPayment.js |  215 ++++++++++++++++++++++++++++++-----------------------
 1 files changed, 123 insertions(+), 92 deletions(-)

diff --git a/cloud-server-management/src/main/webapp/static/modular/system/cpPayment/cpPayment.js b/cloud-server-management/src/main/webapp/static/modular/system/cpPayment/cpPayment.js
index 4bfbcac..c9f6f43 100644
--- a/cloud-server-management/src/main/webapp/static/modular/system/cpPayment/cpPayment.js
+++ b/cloud-server-management/src/main/webapp/static/modular/system/cpPayment/cpPayment.js
@@ -1,20 +1,21 @@
 /**
  * 车辆管理管理初始化
  */
-var TCompetition = {
-    id: "TCompetitionTable",	//表格id
+var TQuestion = {
+    id: "TQuestionTable",	//表格id
     seItem: null,		//选中的条目
     table: null,
     layerIndex: -1
 };
 var role =$("#roleType").val()
+var appUserId ;
 /**
  * 初始化表格的列
  */
-TCompetition.initColumn = function () {
+TQuestion.initColumn = function () {
     return [
-        {field: 'selectItem', checkbox: true},
-        {title: 'id', field: 'id', visible: true, align: 'center', valign: 'middle'},
+        {field: 'selectItem', radio: true},
+        {title: '序号', field: 'id', visible: true, align: 'center', valign: 'middle'},
         {title: '所在省市', field: 'provinceAndCity', visible: role==1?true:false, align: 'center', valign: 'middle'},
         {title:  '门店名称', field: 'storeName', visible: true, align: 'center', valign: 'middle'},
         {title:  '课包类型', field: 'coursePackageType', visible: true, align: 'center', valign: 'middle'},
@@ -75,13 +76,13 @@
 /**
  * 检查是否选中
  */
-TCompetition.check = function () {
+TQuestion.check = function () {
     var selected = $('#' + this.id).bootstrapTable('getSelections');
     if(selected.length == 0){
             Feng.info("请先选中表格中的某一记录!");
         return false;
     }else{
-        TCompetition.seItem = selected[0];
+        TQuestion.seItem = selected[0];
         return true;
     }
 };
@@ -89,7 +90,7 @@
 /**
  * 点击添加车辆管理
  */
-TCompetition.openAddTCompetition = function () {
+TQuestion.openAddTQuestion = function () {
     var index = layer.open({
         type: 2,
         title: '添加',
@@ -104,7 +105,7 @@
 /**
  * 打开查看车辆管理详情
  */
-TCompetition.openTCompetitionDetail = function () {
+TQuestion.openTCompetitionDetail = function () {
     if (this.check()) {
         var index = layer.open({
             type: 2,
@@ -112,12 +113,12 @@
             area: ['100%', '100%'], //宽高
             fix: false, //不固定
             maxmin: true,
-            content: Feng.ctxPath + '/tShop/tShop_update/' + TCompetition.seItem.id
+            content: Feng.ctxPath + '/tShop/tShop_update/' + TQuestion.seItem.id
         });
         this.layerIndex = index;
     }
 };
-TCompetition.info = function () {
+TQuestion.info = function () {
     if (this.check()) {
         var index = layer.open({
             type: 2,
@@ -125,12 +126,12 @@
             area: ['100%', '100%'], //宽高
             fix: false, //不固定
             maxmin: true,
-            content: Feng.ctxPath + '/tShop/tShop_info/' + TCompetition.seItem.id
+            content: Feng.ctxPath + '/tShop/tShop_info/' + TQuestion.seItem.id
         });
         this.layerIndex = index;
     }
 };
-TCompetition.gift = function () {
+TQuestion.gift = function () {
     if (this.check()) {
         var index = layer.open({
             type: 2,
@@ -138,12 +139,12 @@
             area: ['100%', '100%'], //宽高
             fix: false, //不固定
             maxmin: true,
-            content: Feng.ctxPath + '/tShop/tShop_gift/' + TCompetition.seItem.id
+            content: Feng.ctxPath + '/tShop/tShop_gift/' + TQuestion.seItem.id
         });
         this.layerIndex = index;
     }
 };
-TCompetition.indexSet = function () {
+TQuestion.indexSet = function () {
     if (this.check()) {
         var index = layer.open({
             type: 2,
@@ -151,7 +152,7 @@
             area: ['100%', '100%'], //宽高
             fix: false, //不固定
             maxmin: true,
-            content: Feng.ctxPath + '/tShop/tShop_indexSet/' + TCompetition.seItem.id
+            content: Feng.ctxPath + '/tShop/tShop_indexSet/' + TQuestion.seItem.id
         });
         this.layerIndex = index;
     }
@@ -160,9 +161,9 @@
 /**
  * 删除车辆管理
  */
-TCompetition.delete = function () {
+TQuestion.delete = function () {
     if (this.check()) {
-        var nickname = TCompetition.seItem.carLicensePlate;
+        var nickname = TQuestion.seItem.carLicensePlate;
         if (nickname == "" || nickname == null || nickname == undefined){
                 nickname = "该车辆";
         }else{
@@ -185,7 +186,7 @@
                 }else {
                     swal("Hapus berhasil!", "Anda berhasil menghapus" + nickname + "。", "success");
                 }
-                TCompetition.table.refresh();
+                TQuestion.table.refresh();
             }, function (data) {
                 if(language==1){
                     swal("删除失败", data.responseJSON.message + "!", "warning");
@@ -201,7 +202,7 @@
         });
     }
 };
-TCompetition.oneChange = function (e) {
+TQuestion.oneChange = function (e) {
     console.log(111)
     var oneId=$(e).val();
     console.log(oneId)
@@ -219,13 +220,12 @@
     ajax.start();
 };
 
-TCompetition.nextStore = function (e) {
+TQuestion.nextStore = function (e) {
     var oneId=$(e).val();
     console.log(oneId)
     var content = "<option value=''>请选择</option>";
     var ajax = new $ax(Feng.ctxPath + "/coursePackage/getCoursePackageByStoreId", function(data){
         if(data!=null){
-
             $.each(data, function(k,v) {
                 content += "<option value='"+v.id+"'>"+v.name+"</option>";
             });
@@ -235,14 +235,14 @@
     ajax.set("storeId",oneId);
     ajax.start();
 };
-TCompetition.addSubmit = function(){
+TQuestion.addSubmit = function(){
     var data = {
-        appUserId:"",
-        studentId:"",
-        coursePackageId:"",
-        payType:7,
-        classHours:"",
-        originalPrice:"",
+        appUserId:null,
+        studentId:null,
+        coursePackageId:null,
+        payType:null,
+        classHours:null,
+        originalPrice:null,
         cashPayment:null,
         playPaiCoin:null,
         totalClassHours:null,
@@ -250,9 +250,9 @@
         absencesNumber:null,
         payUserType:2,
         payStatus:1,
-        orderNumber:2,
+        orderNumber:null,
         payUserId:2,
-        status:null,
+        status:1,
         withdrawalTime:"",
         certificate:"",
         state:1,
@@ -260,27 +260,31 @@
         useTime:"",
         payUserName:"",
     };
-    data.appUserId            = appUserId
+    data.appUserId            = appUserId;
     data.studentId                = $("#student").val()
     data.coursePackageId       = $("#coursePackageName").val()
     data.cashPayment             = $("#cashPayment").val()
     data.playPaiCoin          = $("#playPaiCoin").val()
-
-    if($("#studentId").val()=='' ){
-        Feng.info("请选择学员")
-        return;
+    data.classHours          = $('#courseTime option:selected').text()
+    if (role == 1){
+        if($("#studentId").val()=='' ){
+            Feng.info("请选择学员")
+            return;
+        }
+        if($("#pCode").val()=='' ){
+            Feng.info("请选择省")
+            return;
+        }
+        if($("#cCode").val()=='' ){
+            Feng.info("请选择市")
+            return;
+        }
     }
-    if($("#pCode").val()=='' ){
-        Feng.info("请选择省")
-        return;
-    }
-    if($("#cCode").val()=='' ){
-        Feng.info("请选择市")
-        return;
-    }
-    if($("#store").val()==''){
-        Feng.info("请选择门店")
-        return;
+    if (role!=3){
+        if($("#store").val()==''){
+            Feng.info("请选择门店")
+            return;
+        }
     }
     if($("#coursePackageType").val()=='' ){
         Feng.info("请选择课包类型")
@@ -290,31 +294,47 @@
         Feng.info("请选择课包名称")
         return;
     }
-    if($("#courseTime").val()==''){
-        Feng.info("请选择课时规格")
+    if (role == 1) {
+        if ($("#courseTime").val() == '') {
+            Feng.info("请选择课时规格")
+            return;
+        }
+    }
+    if($("#cashPayment").val()==''){
+        Feng.info("请输入支付金额")
         return;
     }
-    if($("#cashPayment").val()=='' || $("#playPaiCoin").val()==''){
-        Feng.info("请输入支付金额或请输入玩湃币支付")
+    if($("#playPaiCoin").val()==''){
+        Feng.info("请输入玩湃币支付")
         return;
     }
     $.ajax({
-        url: Feng.ctxPath + "/tSite/changeState",
+        url: Feng.ctxPath + "/cpPayment/addCoursePackagePayment/"+ $("#courseTime").val(),
         type: "POST",
         contentType: "application/json", // 设置请求头的 Content-Type
-        data: JSON.stringify(data1), // 将数据转换为 JSON 字符串
+        data: JSON.stringify(data), // 将数据转换为 JSON 字符串
         success: function(response) {
-            Feng.success("上架成功!");
-            TSite.search();
+            if (response == "5001"){
+                Feng.error("当前课包预约人数已满!")
+            }else{
+                Feng.success("上架成功!");
+                TQuestion.close();
+                TQuestion.search();
+            }
         },
         error: function(xhr, status, error) {
             var errorMessage = xhr.responseText ? xhr.responseText : "上架失败!";
             Feng.error("您的网络异常!");
         }
     });
-
 };
-TCompetition.getCoursePackage = function (e) {
+/**
+ * 关闭此对话框
+ */
+TQuestion.close = function() {
+    parent.layer.close(window.parent.TQuestion.layerIndex);
+}
+TQuestion.getCoursePackage = function (e) {
     var oneId=$(e).val();
     console.log(oneId)
     var content = "<option value=''>请选择</option>";
@@ -330,7 +350,23 @@
     ajax.set("storeId",oneId);
     ajax.start();
 };
-TCompetition.twoChange = function (e) {
+TQuestion.getCoursePackageConfig = function (e) {
+    var oneId=$(e).val();
+    console.log(oneId)
+    var content = "<option value=''>请选择</option>";
+    var ajax = new $ax(Feng.ctxPath + "/cpPayment/getCoursePackageConfig", function(data){
+        if(data!=null){
+
+            $.each(data, function(k,v) {
+                content += "<option value='"+v.id+"'>"+v.classHours+"</option>";
+            });
+            $("#courseTime").empty().append(content);
+        }
+    });
+    ajax.set("id",oneId);
+    ajax.start();
+};
+TQuestion.twoChange = function (e) {
     var oneId=e;
     var content = "<option value=''>请选择</option>";
     var ajax = new $ax(Feng.ctxPath + "/tCompetition/onChange", function(data){
@@ -345,24 +381,21 @@
     ajax.set("oneId",oneId);
     ajax.start();
 };
-TCompetition.threeChange = function (e) {
-    var oneId=e;
-    console.log("看看奥")
-    console.log(oneId)
+
+TQuestion.threeChange = function (e) {
     var content1 = "<option value=''>请选择门店</option>";
     var ajax2=new $ax(Feng.ctxPath + "/cpPayment/getStore", function(data){
-        console.log("看看返回数据")
-        console.log(data)
         $.each(data, function(k,v) {
             content1 += "<option value='"+v.id+"'>"+v.name+"</option>";
         });
         $("#store").empty().append(content1);
     });
-    ajax2.set("city",oneId);
+    ajax2.set("city",e);
     ajax2.start();
 };
-var appUserId ;
-TCompetition.getStudent = function () {
+
+
+TQuestion.getStudent = function () {
     var phone = $("#vipPhone").val();
     var phoneRegex = /^1[3456789]\d{9}$/;
     // 使用正则表达式进行验证
@@ -408,7 +441,7 @@
                             fix: false, //不固定
                             maxmin: true,
                             // todo 写用户管理路径
-                            content: Feng.ctxPath + '/cpPayment/add'
+                            content: Feng.ctxPath + '/appUser/add'
                         });
                         this.layerIndex = index;
                     },
@@ -445,7 +478,7 @@
                                     fix: false, //不固定
                                     maxmin: true,
                                     // todo 写用户管理路径
-                                    content: Feng.ctxPath + '/cpPayment/add'
+                                    content: Feng.ctxPath + '/appUser/addStudent/'+appUserId
                                 });
                                 this.layerIndex = index;
                             },
@@ -461,7 +494,7 @@
                         if (option.text === province) {
                             option.selected = true;
                             console.log(option.value)
-                            TCompetition.twoChange(option.value);
+                            TQuestion.twoChange(option.value);
                             break; // 找到匹配的选项后,可以选择停止遍历
                         }
                     }
@@ -474,7 +507,7 @@
                             option.selected = true;
                             c =  option.text;
 
-                            TCompetition.threeChange(c)
+                            TQuestion.threeChange(c)
 
                             break; // 找到匹配的选项后,可以选择停止遍历
                         }
@@ -490,11 +523,11 @@
 
 };
 
-TCompetition.freeze = function () {
+TQuestion.freeze = function () {
     if (this.check()) {
         var ajax = new $ax(Feng.ctxPath + "/tShop/freeze", function (data) {
             Feng.success("冻结成功!");
-            TCompetition.table.refresh();
+            TQuestion.table.refresh();
         }, function (data) {
             Feng.error("冻结失败!" + data.responseJSON.message + "!");
         });
@@ -502,20 +535,19 @@
         ajax.start();
     }
 };
-TCompetition.unfreeze = function () {
+TQuestion.unfreeze = function () {
     if (this.check()) {
         var selected = $('#' + this.id).bootstrapTable('getSelections');
         console.log("看看选择")
         console.log(selected)
         const data1 = {
-            ids:[],
+            ids:TQuestion.seItem.id,
             payUserName:""
         };
-        selected.forEach(function(obj) {
-            var id = "";
-             id = obj.id;
-            data1.ids.push(id);
-        });
+        if (TQuestion.seItem.payStatus == 2){
+            Feng.error("订单已支付!不能再手动支付了")
+            return;
+        }
         console.log(data1)
         $.ajax({
             url: Feng.ctxPath + "/cpPayment/pay",
@@ -524,7 +556,7 @@
             data: JSON.stringify(data1), // 将数据转换为 JSON 字符串
             success: function(response) {
                 Feng.success("支付成功!");
-                TCompetition.table.refresh();
+                TQuestion.table.refresh();
             },
             error: function(xhr, status, error) {
                 var errorMessage = xhr.responseText ? xhr.responseText : "上架失败!";
@@ -533,13 +565,13 @@
         });
     }
 };
-TCompetition.reload = function () {
+TQuestion.reload = function () {
     if (this.check()) {
         let id = this.seItem.id
         var operation = function(){
             var ajax = new $ax(Feng.ctxPath + "/tCity/pwd", function (data) {
                 Feng.success("重置成功!");
-                TCompetition.table.refresh();
+                TQuestion.table.refresh();
             }, function (data) {
                 Feng.error("重置失败!" + data.responseJSON.message + "!");
             });
@@ -551,7 +583,7 @@
 
 };
 
-TCompetition.carInsurance = function () {
+TQuestion.carInsurance = function () {
     if (this.check()) {
         var index = layer.open({
             type: 2,
@@ -570,24 +602,23 @@
 /**
  * 查询车辆管理列表
  */
-TCompetition.search = function () {
+TQuestion.search = function () {
     var queryData = {};
     if ($('#pCode option:selected').text()!="全部"){
         queryData['province'] = $('#pCode option:selected').text();
     }else{
         queryData['province'] = "";
     }
-
     queryData['city'] = $("#cCode").val();
     queryData['coursePackageTypeId'] = $("#coursePackage").val();
     queryData['coursePackageTypeName'] = $("#coursePackageName").val();
     queryData['payStatus'] = $("#state").val();
     queryData['payUser'] = $("#payUser").val();
     queryData['payStudent'] = $("#payStudent").val();
-    TCompetition.table.refresh({query: queryData});
+    TQuestion.table.refresh({query: queryData});
 };
 
-TCompetition.resetSearch = function () {
+TQuestion.resetSearch = function () {
     $("#pCode").val("");
     $("#cCode").val("");
     $("#coursePackage").val("");
@@ -595,14 +626,14 @@
     $("#state").val("");
     $("#payUser").val("");
     $("#payStudent").val("");
-    TCompetition.search();
+    TQuestion.search();
 };
 
 $(function () {
-    var defaultColunms = TCompetition.initColumn();
-    var table = new BSTable(TCompetition.id, "/cpPayment/listAll", defaultColunms);
+    var defaultColunms = TQuestion.initColumn();
+    var table = new BSTable(TQuestion.id, "/cpPayment/listAll", defaultColunms);
     table.setPaginationType("client");
-    TCompetition.table = table.init();
+    TQuestion.table = table.init();
 });
 
 

--
Gitblit v1.7.1