Browse Source

主体名称重复校验; bug修改

lzm 3 năm trước cách đây
mục cha
commit
3664b0f9fd

+ 1 - 2
sp-admin/sa-view/tb-invoice-info/tb-invoice-info-list.html

@@ -149,9 +149,8 @@
 						sa.checkNull(this.completeDate.form.invoiceTime, '请选择 [开票时间]');
 						sa.checkNull(this.completeDate.form.invoiceNo, '输入 [发票号]');
 						sa.ajax('/TbInvoiceInfo/complete?' , this.completeDate.form, function(res) {
-							sa.alert('开票成功');
 							this.completeDate.visible = false;
-							this.f5();
+							sa.alert('开票成功', this.f5);
 						}.bind(this))
 					},
 					getCustomer() {

+ 1 - 2
sp-admin/sa-view/tb-invoice-order/tb-invoice-order-list.html

@@ -158,9 +158,8 @@
 						sa.checkNull(this.applyDate.form.isElec, '请选择 [电子发票]');
 
 						sa.ajax('/TbInvoiceInfo/generate', this.applyDate.form, function(res){
-							sa.alert('成功生成开票信息');
 							this.applyDate.visible = false;
-							this.f5();
+							sa.alert('成功生成开票信息', this.f5);
 						}.bind(this));
 					},
 					applyFn(){

+ 1 - 1
sp-server/src/main/java/com/pj/project/tb_entity/TbEntity.java

@@ -30,7 +30,7 @@ public class TbEntity implements Serializable {
 	/**
 	 * 此模块对应的权限码 
 	 */
-	public static final String PERMISSION_CODE = "tb-entity";	
+	public static final String PERMISSION_CODE = "tb-entity-list";
 
 
 	// ---------- 表中字段 ----------

+ 22 - 0
sp-server/src/main/java/com/pj/project/tb_entity/TbEntityService.java

@@ -3,6 +3,8 @@ package com.pj.project.tb_entity;
 import java.util.Date;
 import java.util.List;
 
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.pj.utils.so.SoMap;
@@ -26,10 +28,27 @@ public class TbEntityService extends ServiceImpl<TbEntityMapper, TbEntity> imple
 
 	/** 增 */
 	int add(TbEntity t){
+        if (!validateName(t)) {
+            throw new RuntimeException("该主体名称已存在");
+        }
         t.setCreateTime(new Date());
 		return tbEntityMapper.add(t);
 	}
 
+    private boolean validateName(TbEntity t){
+        String name = t.getName();
+        TbEntity db = this.findByName(name);
+        if(db == null){
+            return true;
+        }
+        return StrUtil.equals(db.getId(), t.getId());
+    }
+
+    public TbEntity findByName(String name){
+        QueryWrapper<TbEntity> qw = new QueryWrapper<>();
+        qw.eq("name", name);
+        return this.getOne(qw);
+    }
 	/** 删 */
 	int delete(Long id){
 		return tbEntityMapper.delete(id);
@@ -37,6 +56,9 @@ public class TbEntityService extends ServiceImpl<TbEntityMapper, TbEntity> imple
 
 	/** 改 */
 	int update(TbEntity t){
+        if (!validateName(t)) {
+            throw new RuntimeException("该主体名称已存在");
+        }
         t.setUpdateTime(new Date());
 	    return tbEntityMapper.update(t);
 	}

+ 1 - 1
sp-server/src/main/java/com/pj/project/tb_invoice_info/TbInvoiceInfo.java

@@ -36,7 +36,7 @@ public class TbInvoiceInfo implements Serializable {
 	/**
 	 * 此模块对应的权限码 
 	 */
-	public static final String PERMISSION_CODE = "tb-invoice-info";
+	public static final String PERMISSION_CODE = "tb-invoice-info-list";
 
 
 	// ---------- 表中字段 ----------

+ 9 - 2
sp-server/src/main/java/com/pj/project/tb_invoice_info/TbInvoiceInfoService.java

@@ -24,6 +24,7 @@ import com.pj.project.tb_invoice_order.TbInvoiceOrder;
 import com.pj.project.tb_invoice_order.TbInvoiceOrderService;
 import com.pj.project4sp.admin.SpAdmin;
 import com.pj.project4sp.admin.SpAdminService;
+import com.pj.project4sp.global.BusinessException;
 import com.pj.utils.so.SoMap;
 import org.springframework.stereotype.Service;
 
@@ -103,6 +104,13 @@ public class TbInvoiceInfoService extends ServiceImpl<TbInvoiceInfoMapper, TbInv
         String customerId = so.getString("customerId");
         String customerName = so.getString("customerName");
 
+        List<String> orderIdList = Arrays.asList(orderIds.split(","));
+        List<TbInvoiceOrder> orderList = tbInvoiceOrderService.listByIds(orderIdList);
+        List<TbInvoiceOrder> collect = orderList.stream().filter(o -> o.getStatus() != 0).collect(Collectors.toList());
+        if(collect.size() > 0){
+            throw new BusinessException("请选择待申请的订单");
+        }
+
         TbEntity entity = tbEntityService.getById(entityId);
         TbInvoiceInfo t = new TbInvoiceInfo();
         t.setEntityId(entityId).setIsElec(isElec).setTotalMoney(totalMoney)
@@ -114,8 +122,7 @@ public class TbInvoiceInfoService extends ServiceImpl<TbInvoiceInfoMapper, TbInv
         .setBank(entity.getBank()).setBankNo(entity.getBankNo()).setEmail(entity.getEmail()).setPhone(entity.getPhone());
         this.save(t);
 
-        List<String> orderIdList = Arrays.asList(orderIds.split(","));
-        List<TbInvoiceOrder> orderList = tbInvoiceOrderService.listByIds(orderIdList);
+
         for (TbInvoiceOrder invoiceOrder : orderList) {
             invoiceOrder.setInfoId(t.getId()).setInfoNo(t.getNo()).setStatus(1);
         }

+ 1 - 1
sp-server/src/main/java/com/pj/project/tb_invoice_order/TbInvoiceOrder.java

@@ -31,7 +31,7 @@ public class TbInvoiceOrder implements Serializable {
 	/**
 	 * 此模块对应的权限码 
 	 */
-	public static final String PERMISSION_CODE = "tb-invoice-order";	
+	public static final String PERMISSION_CODE = "tb-invoice-order-list";
 
 
 	// ---------- 表中字段 ----------