|
@@ -1,7 +1,10 @@
|
|
|
package org.jeecg.modules.platCode.service.impl;
|
|
|
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.jeecg.modules.platCode.entity.PlatCommissionContract;
|
|
|
import org.jeecg.modules.platCode.entity.PlatCommissionOrder;
|
|
|
import org.jeecg.modules.platCode.entity.PlatCommissionOrderProduct;
|
|
|
+import org.jeecg.modules.platCode.mapper.PlatCommissionContractMapper;
|
|
|
import org.jeecg.modules.platCode.mapper.PlatCommissionOrderProductMapper;
|
|
|
import org.jeecg.modules.platCode.mapper.PlatCommissionOrderMapper;
|
|
|
import org.jeecg.modules.platCode.service.IPlatCommissionOrderService;
|
|
@@ -9,6 +12,7 @@ import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
import java.io.Serializable;
|
|
|
import java.util.List;
|
|
|
import java.util.Collection;
|
|
@@ -16,62 +20,93 @@ import java.util.Collection;
|
|
|
/**
|
|
|
* @Description: 佣金订单
|
|
|
* @Author: jeecg-boot
|
|
|
- * @Date: 2025-02-12
|
|
|
+ * @Date: 2025-02-12
|
|
|
* @Version: V1.0
|
|
|
*/
|
|
|
@Service
|
|
|
public class PlatCommissionOrderServiceImpl extends ServiceImpl<PlatCommissionOrderMapper, PlatCommissionOrder> implements IPlatCommissionOrderService {
|
|
|
|
|
|
- @Autowired
|
|
|
- private PlatCommissionOrderMapper platCommissionOrderMapper;
|
|
|
- @Autowired
|
|
|
- private PlatCommissionOrderProductMapper platCommissionOrderProductMapper;
|
|
|
-
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public void saveMain(PlatCommissionOrder platCommissionOrder, List<PlatCommissionOrderProduct> platCommissionOrderProductList) {
|
|
|
- platCommissionOrderMapper.insert(platCommissionOrder);
|
|
|
- if(platCommissionOrderProductList!=null && platCommissionOrderProductList.size()>0) {
|
|
|
- for(PlatCommissionOrderProduct entity:platCommissionOrderProductList) {
|
|
|
- //外键设置
|
|
|
- entity.setHeadId(platCommissionOrder.getId());
|
|
|
- platCommissionOrderProductMapper.insert(entity);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public void updateMain(PlatCommissionOrder platCommissionOrder,List<PlatCommissionOrderProduct> platCommissionOrderProductList) {
|
|
|
- platCommissionOrderMapper.updateById(platCommissionOrder);
|
|
|
-
|
|
|
- //1.先删除子表数据
|
|
|
- platCommissionOrderProductMapper.deleteByMainId(platCommissionOrder.getId());
|
|
|
-
|
|
|
- //2.子表数据重新插入
|
|
|
- if(platCommissionOrderProductList!=null && platCommissionOrderProductList.size()>0) {
|
|
|
- for(PlatCommissionOrderProduct entity:platCommissionOrderProductList) {
|
|
|
- //外键设置
|
|
|
- entity.setHeadId(platCommissionOrder.getId());
|
|
|
- platCommissionOrderProductMapper.insert(entity);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public void delMain(String id) {
|
|
|
- platCommissionOrderProductMapper.deleteByMainId(id);
|
|
|
- platCommissionOrderMapper.deleteById(id);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public void delBatchMain(Collection<? extends Serializable> idList) {
|
|
|
- for(Serializable id:idList) {
|
|
|
- platCommissionOrderProductMapper.deleteByMainId(id.toString());
|
|
|
- platCommissionOrderMapper.deleteById(id);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private PlatCommissionOrderMapper platCommissionOrderMapper;
|
|
|
+ @Autowired
|
|
|
+ private PlatCommissionOrderProductMapper platCommissionOrderProductMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PlatCommissionContractMapper platCommissionContractMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void saveMain(PlatCommissionOrder platCommissionOrder, List<PlatCommissionOrderProduct> platCommissionOrderProductList) {
|
|
|
+ platCommissionOrderMapper.insert(platCommissionOrder);
|
|
|
+
|
|
|
+ String getCommissionContract = platCommissionOrder.getCommissionContract();
|
|
|
+ if (StringUtils.isNotBlank(getCommissionContract)) {
|
|
|
+ PlatCommissionContract ent = platCommissionContractMapper.selectById(getCommissionContract);
|
|
|
+ ent.setIsUsed(1);
|
|
|
+ platCommissionContractMapper.selectById(ent);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (platCommissionOrderProductList != null && platCommissionOrderProductList.size() > 0) {
|
|
|
+ for (PlatCommissionOrderProduct entity : platCommissionOrderProductList) {
|
|
|
+ //外键设置
|
|
|
+ entity.setId(null);
|
|
|
+ entity.setHeadId(platCommissionOrder.getId());
|
|
|
+ platCommissionOrderProductMapper.insert(entity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void updateMain(PlatCommissionOrder platCommissionOrder, List<PlatCommissionOrderProduct> platCommissionOrderProductList) {
|
|
|
+
|
|
|
+ PlatCommissionOrder platCommissionOrderOld = platCommissionOrderMapper.selectById(platCommissionOrder.getId());
|
|
|
+ String getCommissionContractOld = platCommissionOrderOld.getCommissionContract();
|
|
|
+
|
|
|
+ String getCommissionContract = platCommissionOrder.getCommissionContract();
|
|
|
+
|
|
|
+ if(StringUtils.isNotBlank(getCommissionContractOld) && !getCommissionContractOld.equals(getCommissionContract)){
|
|
|
+ PlatCommissionContract ent = platCommissionContractMapper.selectById(getCommissionContractOld);
|
|
|
+ ent.setIsUsed(0);
|
|
|
+ platCommissionContractMapper.selectById(ent);
|
|
|
+ }
|
|
|
+
|
|
|
+ platCommissionOrderMapper.updateById(platCommissionOrder);
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(getCommissionContract)) {
|
|
|
+ PlatCommissionContract ent = platCommissionContractMapper.selectById(getCommissionContract);
|
|
|
+ ent.setIsUsed(1);
|
|
|
+ platCommissionContractMapper.selectById(ent);
|
|
|
+ }
|
|
|
+ //1.先删除子表数据
|
|
|
+ platCommissionOrderProductMapper.deleteByMainId(platCommissionOrder.getId());
|
|
|
+
|
|
|
+ //2.子表数据重新插入
|
|
|
+ if (platCommissionOrderProductList != null && platCommissionOrderProductList.size() > 0) {
|
|
|
+ for (PlatCommissionOrderProduct entity : platCommissionOrderProductList) {
|
|
|
+ //外键设置
|
|
|
+ entity.setId(null);
|
|
|
+ entity.setHeadId(platCommissionOrder.getId());
|
|
|
+ platCommissionOrderProductMapper.insert(entity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void delMain(String id) {
|
|
|
+ platCommissionOrderProductMapper.deleteByMainId(id);
|
|
|
+ platCommissionOrderMapper.deleteById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void delBatchMain(Collection<? extends Serializable> idList) {
|
|
|
+ for (Serializable id : idList) {
|
|
|
+ platCommissionOrderProductMapper.deleteByMainId(id.toString());
|
|
|
+ platCommissionOrderMapper.deleteById(id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|