Explorar el Código

调整扣费绑定模块

huangpeifeng hace 3 años
padre
commit
e19dbf5253

+ 15 - 3
sp-admin/sa-view/tb-account/tb-account-add.html

@@ -112,8 +112,8 @@
             },
             // 提交数据
             ok: function () {
-                // 表单校验
-                let m = this.m;
+                let that = this;
+                let m = {...this.m};
                 sa.checkNull(m.preTopupMoney, '预存金额不能为空!');
                 if(!this.computeChange()){
                     return;
@@ -125,7 +125,19 @@
                 m.preTopupMoney = this.encrypt(m.preTopupMoney,key);
                 m.id = sa.p('id', 0);
                 sa.ajax('/TbAccount/recharge2', sa.removeNull(m), function (res) {
-                                sa.alert('充值成功', this.clean);
+                    layer.open({
+                        content: '充值成功!',//内容区域
+                        move: false,//是否可以拖动,默认可以拖动
+                        btn: ['确定'],
+                        btn1: function(index){
+                        //    layer.close(index);//关闭弹框
+                            that.clean();
+                        },
+                        cancel: function(){
+                            that.clean();
+                        }
+                    });
+
                 }.bind(this));
 
             },

+ 6 - 10
sp-admin/sa-view/tb-deduction-bind/tb-deduction-bind-add.html

@@ -57,7 +57,6 @@
         },
         el: '.vue-box',
         data: {
-            customerId:sa.p('customerId', 0),
             id: sa.p('id', 0),		// 获取超链接中的id参数(0=添加,非0=修改)
             m: null,		// 实体对象
         },
@@ -70,7 +69,7 @@
                     customerName: '',		// 客户名称
                     deductMoney: '',		// 扣除金额
                     bindCar: '',		// 绑定车辆
-                    bindTime: sa.forDatetime(new Date()),		// 绑定时间
+                    bindTime: undefined,		// 绑定时间
                     unbindTime: undefined,		// 解绑时候
                     createBy: '',		// 创建人
                     createTime: undefined,		// 创建时间
@@ -82,10 +81,7 @@
             ok: function () {
                 // 表单校验
                 let m = this.m;
-                // sa.checkNull(m.id, '请输入 [主键]');
-                // sa.checkNull(m.customerId, '请输入 [客户id]');
-                // sa.checkNull(m.customerName, '请输入 [客户名称]');
-                // sa.checkNull(m.deductMoney, '请输入 [扣除金额]');
+
                 sa.checkNull(m.bindCar, '请输入 [绑定车辆]');
                 if(!sa.isCarNo(m.bindCar)){
                     sa.error("请输入正确的车牌号!");
@@ -107,10 +103,10 @@
         mounted: function () {
             // 初始化数据
             this.m = this.createModel();
-            this.m.customerId = this.customerId;
-            sa.ajax('/TbDeductionBind/getList', sa.removeNull(this.m), function (res) {
-                if(res.data && res.data.length>0){
-                    this.m.customerName = res.data[0].customerName;
+            // this.m.customerId = this.customerId;
+            sa.ajax('/TbDeductionBind/getBindByLogin', function (res) {
+                if(res.data){
+                    this.m = res.data;
                 }else {
                     sa.alert('未能查找到客户详细数据,车辆绑定窗口将在5秒后关闭!');
                     setTimeout(function(){ sa.closeCurrIframe() }, 5000)

+ 1 - 5
sp-admin/sa-view/tb-deduction-bind/tb-deduction-bind-list.html

@@ -165,11 +165,7 @@
             },
             // 车辆绑定
             add: function (data) {
-                if(!this.addCustomerId){
-                    sa.error2("请选定客户进行绑定!")
-                    return;
-                }
-                sa.showIframe('车辆绑定', 'tb-deduction-bind-add.html?customerId='+ this.addCustomerId, '1000px', '90%');
+                sa.showIframe('车辆绑定', 'tb-deduction-bind-add.html', '1000px', '90%');
             },
             // 删除
             del: function (data) {

+ 1 - 1
sp-admin/sa-view/tb-deduction-bind/tb-deduction-bind-unbind.html

@@ -34,7 +34,7 @@
 <!--                <sa-item type="text" name="主键" v-model="m.id" br></sa-item>-->
 <!--                <sa-item type="text" name="客户id" v-model="m.customerId" br></sa-item>-->
                 <sa-item type="text" name="客户名称" v-model="m.customerName" :disabled="true" br></sa-item>
-                <sa-item id="ast" type="text" name="解绑车辆" v-model="m.bindCar" br></sa-item>
+                <sa-item id="ast" type="text" name="解绑车辆" v-model="m.bindCar" :disabled="true" br></sa-item>
                 <sa-item id="ast" name="解绑时间" br>
                     <el-date-picker
                             v-model="m.unbindTime"

+ 4 - 19
sp-server/src/main/java/com/pj/project/tb_deduction_bind/TbDeductionBindController.java

@@ -107,24 +107,9 @@ public class TbDeductionBindController {
     }
 
 
-    // ------------------------- 前端接口 -------------------------
-
-
-    /**
-     * 改 - 不传不改 [G]
-     */
-    @RequestMapping("updateByNotNull")
-    public AjaxJson updateByNotNull(Long id) {
-        AjaxError.throwBy(true, "如需正常调用此接口,请删除此行代码");
-        // 鉴别身份,是否为数据创建者
-        long userId = SP.publicMapper.getColumnByIdToLong(TbDeductionBind.TABLE_NAME, "user_id", id);
-        AjaxError.throwBy(userId != StpUserUtil.getLoginIdAsLong(), "此数据您无权限修改");
-        // 开始修改 (请只保留需要修改的字段)
-        SoMap so = SoMap.getRequestSoMap();
-        so.clearNotIn("id", "customerId", "customerName", "deductMoney", "bindCar", "bindTime", "unbindTime", "createBy", "createTime", "updateTime", "updateBy").clearNull().humpToLineCase();
-        int line = SP.publicMapper.updateBySoMapById(TbDeductionBind.TABLE_NAME, so, id);
-        return AjaxJson.getByLine(line);
+    @RequestMapping("getBindByLogin")
+    public AjaxJson getTbDeductionBindByLogin() {
+        TbDeductionBind t = tbDeductionBindService.getTbDeductionBindByLogin();
+        return AjaxJson.getSuccessData(t);
     }
-
-
 }

+ 6 - 3
sp-server/src/main/java/com/pj/project/tb_deduction_bind/TbDeductionBindMapper.xml

@@ -5,9 +5,9 @@
     <!-- 增 [G] -->
     <insert id="add">
         insert into tb_deduction_bind (id, customer_id, customer_name, deduct_money, bind_car, bind_time, unbind_time,
-                                       create_by, create_time, update_time, update_by)
+                                       create_by, create_time, update_time, update_by, fee_fail_record)
         values (#{id}, #{customerId}, #{customerName}, #{deductMoney}, #{bindCar}, #{bindTime}, #{unbindTime},
-                #{createBy}, #{createTime}, #{updateTime}, #{updateBy})
+                #{createBy}, #{createTime}, #{updateTime}, #{updateBy}, #{feeFailRecord})
     </insert>
 
     <!-- 删 -->
@@ -30,7 +30,8 @@
             create_by     = #{createBy},
             create_time   = #{createTime},
             update_time   = #{updateTime},
-            update_by     = #{updateBy}
+            update_by     = #{updateBy},
+            fee_fail_record = #{feeFailRecord}
         where id = #{id}
     </update>
 
@@ -51,6 +52,7 @@
         <result property="createTime" column="create_time"/>
         <result property="updateTime" column="update_time"/>
         <result property="updateBy" column="update_by"/>
+        <result property="feeFailRecord" column="fee_fail_record"/>
     </resultMap>
 
     <!-- 公共查询sql片段 -->
@@ -81,6 +83,7 @@
             <if test=' this.has("updateTime") '>and update_time = #{updateTime}</if>
             <if test=' this.has("updateBy") '>and update_by like "%" #{updateBy} "%" </if>
             <if test=' this.has("startTime") '> and date(create_time) between #{startTime} and #{endTime} </if>
+            <if test=' this.has("feeFailRecord") '>and fee_fail_record like "%" #{feeFailRecord} "%" </if>
         </where>
         order by
         <choose>

+ 31 - 3
sp-server/src/main/java/com/pj/project/tb_deduction_bind/TbDeductionBindService.java

@@ -12,6 +12,8 @@ import com.pj.constants.UserTypeEnum;
 import com.pj.current.satoken.StpUserUtil;
 import com.pj.project.tb_account.AutomaticPay;
 import com.pj.project.tb_business_car.TbBusinessCar;
+import com.pj.project.tb_costomer.TbCostomer;
+import com.pj.project.tb_costomer.TbCostomerService;
 import com.pj.project.tb_deduction_record.TbDeductionRecord;
 import com.pj.project4sp.SP;
 import com.pj.utils.AesUtil;
@@ -43,7 +45,8 @@ public class TbDeductionBindService extends ServiceImpl<TbDeductionBindMapper, T
      */
     @Autowired
     TbDeductionBindMapper tbDeductionBindMapper;
-
+    @Resource
+    TbCostomerService tbCostomerService;
 
     /**
      * 查集合 - 根据条件(参数为空时代表忽略指定条件)
@@ -60,7 +63,8 @@ public class TbDeductionBindService extends ServiceImpl<TbDeductionBindMapper, T
                 so.put("endTime",jsonArray.get(1));
             }
         }
-        return tbDeductionBindMapper.getTbDeductionBindList(so);
+      //  return tbDeductionBindMapper.getTbDeductionBindList(so);
+        return tbDeductionBindMapper.getList(so);
     }
 
     public TbDeductionBind getById(Long id) {
@@ -84,7 +88,7 @@ public class TbDeductionBindService extends ServiceImpl<TbDeductionBindMapper, T
             throw new AjaxError("车牌号不能为空!");
         }
         if(NbUtil.isNullStr(bind.getCustomerId())){
-            throw new AjaxError("请选定客户进行绑定!");
+            throw new AjaxError("登陆用户信息已经失效,请重新登陆!");
         }
         bind.setBindCar(bind.getBindCar().trim().toUpperCase());
         bind.setId(null);
@@ -110,6 +114,9 @@ public class TbDeductionBindService extends ServiceImpl<TbDeductionBindMapper, T
         if(NbUtil.isNullStr(unbind.getBindCar())){
             throw new AjaxError("车牌号不能为空!");
         }
+        if(!checkBind(unbind.getCustomerId(),unbind.getBindCar())){
+            throw new AjaxError(unbind.getBindCar()+" 不是"+unbind.getCustomerName()+" 绑定的车辆,不能解绑!");
+        }
         unbind.setUpdateBy(StpUserUtil.getLoginName());
         unbind.setUpdateTime(new Date());
         return tbDeductionBindMapper.updateById(unbind)>0;
@@ -229,4 +236,25 @@ public class TbDeductionBindService extends ServiceImpl<TbDeductionBindMapper, T
         return ObjectUtil.isNotEmpty(idMap)? AesUtil.toStr(idMap.get("id")):null;
     }
 
+    /**
+     * 根据当前登陆用户封装一个绑定对象
+     * @return
+     */
+    public TbDeductionBind getTbDeductionBindByLogin(){
+        TbDeductionBind bind = new TbDeductionBind();
+        String customerId = StpUserUtil.getCustomerId();
+        if(NbUtil.isNull(customerId)){
+            throw new AjaxError("登陆用户信息已经失效,请重新登陆!");
+        }
+        TbCostomer tbCostomer = tbCostomerService.getById(customerId);
+        if(tbCostomer==null){
+            throw new AjaxError("登陆用户还没绑定客户信息,不能绑定车辆!");
+        }
+        bind.setBindTime(new Date());
+        bind.setCreateTime(new Date());
+        bind.setCreateBy(StpUserUtil.getLoginName());
+        bind.setCustomerId(tbCostomer.getId());
+        bind.setCustomerName(tbCostomer.getName());
+        return bind;
+    }
 }