|
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.gree.mall.manager.bean.admin.AdminUserCom;
|
|
|
import com.gree.mall.manager.bean.material.base.MaterialCategoryTree;
|
|
|
+import com.gree.mall.manager.bean.material.base.WebsitNormChargeBean;
|
|
|
import com.gree.mall.manager.bean.material.base.WebsitNormChargeVO;
|
|
|
import com.gree.mall.manager.commonmapper.MaterialMapper;
|
|
|
import com.gree.mall.manager.enums.material.NormTypeEnum;
|
|
@@ -15,14 +16,17 @@ import com.gree.mall.manager.logic.common.CommonLogic;
|
|
|
import com.gree.mall.manager.logic.common.SysDictCompanyLogic;
|
|
|
import com.gree.mall.manager.plus.entity.SysDictCompany;
|
|
|
import com.gree.mall.manager.plus.entity.WebsitNormCharge;
|
|
|
+import com.gree.mall.manager.plus.entity.WebsitNormRela;
|
|
|
import com.gree.mall.manager.plus.service.SysDictCompanyService;
|
|
|
import com.gree.mall.manager.plus.service.WebsitNormChargeService;
|
|
|
+import com.gree.mall.manager.plus.service.WebsitNormRelaService;
|
|
|
import com.gree.mall.manager.utils.excel.ExcelUtils;
|
|
|
import com.gree.mall.manager.zfire.bean.ZfireParamBean;
|
|
|
import com.gree.mall.manager.zfire.util.FieldUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
@@ -48,6 +52,7 @@ public class NormChargeLogic {
|
|
|
private final SysDictCompanyService sysDictCompanyService;
|
|
|
private final SysDictCompanyLogic sysDictCompanyLogic;
|
|
|
private final MaterialCategoryLogic materialCategoryLogic;
|
|
|
+ private final WebsitNormRelaService websitNormRelaService;
|
|
|
|
|
|
public IPage<WebsitNormChargeVO> page(ZfireParamBean zfireParamBean) {
|
|
|
AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
@@ -55,13 +60,19 @@ public class NormChargeLogic {
|
|
|
return materialMapper.websitNormChargePage(new Page(zfireParamBean.getPageNum(), zfireParamBean.getPageSize()), zfireParamBean);
|
|
|
}
|
|
|
|
|
|
- public WebsitNormCharge detail(String id) {
|
|
|
+ public WebsitNormChargeBean detail(String id) {
|
|
|
WebsitNormCharge websitNormCharge = websitNormChargeService.getById(id);
|
|
|
- return websitNormCharge;
|
|
|
+ WebsitNormChargeBean bean = new WebsitNormChargeBean();
|
|
|
+ BeanUtils.copyProperties(websitNormCharge, bean);
|
|
|
+ final List<WebsitNormRela> relas = websitNormRelaService.lambdaQuery()
|
|
|
+ .eq(WebsitNormRela::getNormId, id)
|
|
|
+ .list();
|
|
|
+ bean.setItems(relas);
|
|
|
+ return bean;
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void add(WebsitNormCharge bean) {
|
|
|
+ public void add(WebsitNormChargeBean bean) {
|
|
|
AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
|
|
|
if (StringUtils.isBlank(bean.getNormType())) {
|
|
@@ -81,6 +92,14 @@ public class NormChargeLogic {
|
|
|
this.stockUnitEmptyAdd(bean);
|
|
|
|
|
|
bean.insert();
|
|
|
+
|
|
|
+ if (CollectionUtil.isNotEmpty(bean.getItems())) {
|
|
|
+ for (WebsitNormRela item : bean.getItems()) {
|
|
|
+ item.setCompanyWechatId(bean.getCompanyWechatId())
|
|
|
+ .setNormId(bean.getNormId());
|
|
|
+ }
|
|
|
+ websitNormRelaService.saveBatch(bean.getItems());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void stockUnitEmptyAdd(WebsitNormCharge goods) {
|
|
@@ -161,7 +180,7 @@ public class NormChargeLogic {
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void edit(WebsitNormCharge bean) {
|
|
|
+ public void edit(WebsitNormChargeBean bean) {
|
|
|
AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
|
|
|
WebsitNormCharge oldNormCharge = websitNormChargeService.getById(bean.getNormId());
|
|
@@ -173,6 +192,18 @@ public class NormChargeLogic {
|
|
|
this.stockUnitEmptyAdd(bean);
|
|
|
|
|
|
bean.updateById();
|
|
|
+
|
|
|
+ if (CollectionUtil.isNotEmpty(bean.getItems())) {
|
|
|
+ websitNormRelaService.lambdaUpdate()
|
|
|
+ .eq(WebsitNormRela::getCompanyWechatId, bean.getCompanyWechatId())
|
|
|
+ .eq(WebsitNormRela::getNormId, bean.getNormId())
|
|
|
+ .remove();
|
|
|
+ for (WebsitNormRela item : bean.getItems()) {
|
|
|
+ item.setCompanyWechatId(bean.getCompanyWechatId())
|
|
|
+ .setNormId(bean.getNormId());
|
|
|
+ }
|
|
|
+ websitNormRelaService.saveBatch(bean.getItems());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|