‘linchangsheng’ il y a 7 mois
Parent
commit
c750cf6be7

+ 33 - 1
src/main/java/com/zfire/mall/manager/logic/k3/K3CustomerLogic.java

@@ -408,12 +408,38 @@ public class K3CustomerLogic {
         return k3CustomerVOIPage;
     }
 
+    @Transactional(rollbackFor = Exception.class)
     public void add(KingDeeCustomer kingDeeCustomer) {
+
+
+        if (kingDeeCustomerService.lambdaQuery().eq(KingDeeCustomer::getNumber,kingDeeCustomer.getNumber()).count() > 0) {
+            throw new RemoteServiceException("存在相同编号的经销商");
+        }
+
+        kingDeeCustomer.setId(kingDeeCustomer.getNumber());
+
         kingDeeCustomer.insert();
+
+        //初始化经销商钱包
+
+        walletLogic.initByK3Customer(kingDeeCustomer.getId());
     }
 
     public void updateCustomer(KingDeeCustomer kingDeeCustomer) {
+        if (kingDeeCustomerService.lambdaQuery().eq(KingDeeCustomer::getNumber,kingDeeCustomer.getNumber())
+                .ne(KingDeeCustomer::getId,kingDeeCustomer.getId())
+                .count() > 0) {
+            throw new RemoteServiceException("存在相同编号的经销商");
+        }
+
+        kingDeeCustomer.setId(kingDeeCustomer.getNumber());
+
         kingDeeCustomer.updateById();
+
+        //初始化经销商钱包
+
+        walletLogic.initByK3Customer(kingDeeCustomer.getId());
+
     }
 
     public void importData(List<Object> datas) {
@@ -431,6 +457,7 @@ public class K3CustomerLogic {
 
             KingDeeCustomer kingDeeCustomer = new KingDeeCustomer();
             kingDeeCustomer.setNumber((String) row.get(0));
+            kingDeeCustomer.setId((String) row.get(0));
             kingDeeCustomer.setName((String)row.get(1));
 
             if (StringUtils.isEmpty((String) row.get(0)) || StringUtils.isEmpty((String) row.get(1)))
@@ -465,6 +492,11 @@ public class K3CustomerLogic {
 
         }
 
-        kingDeeCustomerService.saveBatch(kingDeeCustomers);
+        kingDeeCustomerService.saveOrUpdateBatch(kingDeeCustomers);
+
+
+        //初始化经销商钱包
+
+        walletLogic.initByK3Customer(null);
     }
 }

+ 10 - 0
src/main/java/com/zfire/mall/manager/logic/k3/K3MaterialLogic.java

@@ -168,10 +168,20 @@ public class K3MaterialLogic {
     }
 
     public void edit(KingDeeMaterialBean kingDeeMaterialBean) {
+        if (kingDeeMaterialService.lambdaQuery().eq(KingDeeMaterial::getNumber,kingDeeMaterialBean.getNumber()).count() > 0)
+            throw new RemoteServiceException("物料编号存在重复");
+
+        if (kingDeeMaterialService.lambdaQuery().eq(KingDeeMaterial::getOldNumber,kingDeeMaterialBean.getOldNumber()).count() > 0)
+            throw new RemoteServiceException("产品编号存在重复");
         kingDeeMaterialBean.updateById();
     }
 
     public void add(KingDeeMaterial kingDeeMaterial) {
+        if (kingDeeMaterialService.lambdaQuery().eq(KingDeeMaterial::getNumber,kingDeeMaterial.getNumber()).count() > 0)
+            throw new RemoteServiceException("物料编号存在重复");
+
+        if (kingDeeMaterialService.lambdaQuery().eq(KingDeeMaterial::getOldNumber,kingDeeMaterial.getOldNumber()).count() > 0)
+            throw new RemoteServiceException("产品编号存在重复");
         kingDeeMaterial.insert();
     }
 

+ 13 - 0
src/main/java/com/zfire/mall/manager/logic/k3/K3SupplierLogic.java

@@ -81,10 +81,22 @@ public class K3SupplierLogic {
     }
 
     public void add(KingDeeSupplier kingDeeSupplier) {
+
+        if (kingDeeSupplierService.lambdaQuery().eq(KingDeeSupplier::getNumber,kingDeeSupplier.getNumber()).count() > 0)
+            throw new RemoteServiceException("供应商编号重复");
+
+        kingDeeSupplier.setId(kingDeeSupplier.getNumber());
+
         kingDeeSupplier.insert();
     }
 
     public void updateCustomer(KingDeeSupplier kingDeeSupplier) {
+        if (kingDeeSupplierService.lambdaQuery().eq(KingDeeSupplier::getNumber,kingDeeSupplier.getNumber())
+                .eq(KingDeeSupplier::getId,kingDeeSupplier.getId()).count() > 0)
+            throw new RemoteServiceException("供应商编号重复");
+
+        kingDeeSupplier.setId(kingDeeSupplier.getNumber());
+
         kingDeeSupplier.updateById();
     }
 
@@ -104,6 +116,7 @@ public class K3SupplierLogic {
             KingDeeSupplier kingDeeSupplier = new KingDeeSupplier();
             kingDeeSupplier.setName((String) row.get(0));
             kingDeeSupplier.setNumber((String)row.get(1));
+            kingDeeSupplier.setId((String)row.get(1));
 
             if (com.aliyuncs.utils.StringUtils.isEmpty((String) row.get(0)) || com.aliyuncs.utils.StringUtils.isEmpty((String) row.get(1)))
                 throw new RemoteServiceException("第"+index+"行,供应商名称编号有误,请检查");

+ 28 - 8
src/main/resources/mapper/WalletCommonMapper.xml

@@ -283,16 +283,36 @@
     <insert id="initCustomerWallet">
         insert into customer_wallet(customer_wallet_id,customer_id,customer_number,customer_name,wallet_rebate_id,customer_wallet_name,type)
         select
-            concat(b.id,a.id),
-            b.id,
-            b.number,
-            b.name,
-            a.id,
-            a.name,
-            'COMMONLY'
+        concat(b.id,a.id),
+        b.id,
+        b.number,
+        b.name,
+        a.id,
+        a.name,
+        'COMMONLY'
         from king_dee_wallet a join king_dee_customer b
         left join customer_wallet c on c.wallet_rebate_id = a.id and c.customer_id=b.id
-        where c.customer_wallet_id is null and b.id=#{customerId}
+        where c.customer_wallet_id is null
+        <if test="customerId != null and customerId !=''">
+            and b.id=#{customerId}
+        </if>
+
+        union
+
+        select
+        concat(b.id,a.wallet_rebate_id),
+        b.id,
+        b.number,
+        b.name,
+        a.wallet_rebate_id,
+        a.name,
+        'REBATE'
+        from wallet_rebate a join king_dee_customer b
+        left join customer_wallet c on c.wallet_rebate_id = a.wallet_rebate_id and c.customer_id=b.id
+        where c.customer_wallet_id is null
+        <if test="customerId != null and customerId !=''">
+            and b.id=#{customerId}
+        </if>
     </insert>