|
|
@@ -21,13 +21,17 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.client.feign.ISerialClient;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
+import org.springblade.salesPart.corps.service.ICorpsAttnService;
|
|
|
+import org.springblade.salesPart.corps.service.ICorpsDescService;
|
|
|
import org.springblade.salesPart.entity.*;
|
|
|
import org.springblade.salesPart.excel.ProductLaunchImportExcel;
|
|
|
import org.springblade.salesPart.goods.mapper.GoodsDescMapper;
|
|
|
import org.springblade.salesPart.productLaunch.service.IProductLaunchFilesService;
|
|
|
+import org.springblade.salesPart.shoppingCart.mapper.ShoppingCartMapper;
|
|
|
import org.springblade.salesPart.vo.ProductLaunchVO;
|
|
|
import org.springblade.salesPart.productLaunch.mapper.ProductLaunchMapper;
|
|
|
import org.springblade.salesPart.productLaunch.service.IProductLaunchService;
|
|
|
@@ -38,6 +42,7 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
@@ -56,6 +61,10 @@ public class ProductLaunchServiceImpl extends ServiceImpl<ProductLaunchMapper, P
|
|
|
private final GoodsDescMapper goodsDescMapper;
|
|
|
private final ISysClient iSysClient;
|
|
|
private final IProductLaunchFilesService productLaunchFilesService;
|
|
|
+ private final ICorpsAttnService corpsAttnService;//客户联系人
|
|
|
+ private final ICorpsDescService corpsDescService;//客户
|
|
|
+ private final ISerialClient serialClient;//生成系统编号
|
|
|
+ private final ShoppingCartMapper shoppingCartMapper;
|
|
|
|
|
|
@Override
|
|
|
public PjProductLaunch getMessageById(PjProductLaunch productLaunch) {
|
|
|
@@ -77,6 +86,7 @@ public class ProductLaunchServiceImpl extends ServiceImpl<ProductLaunchMapper, P
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public PjProductLaunch saveMessage(PjProductLaunch productLaunch) {
|
|
|
|
|
|
if (productLaunch.getId() != null) {
|
|
|
@@ -110,6 +120,22 @@ public class ProductLaunchServiceImpl extends ServiceImpl<ProductLaunchMapper, P
|
|
|
|
|
|
//如果有共享公司 生成共享数据
|
|
|
if (ObjectUtil.isNotEmpty(productLaunch.getSharedCompany())){
|
|
|
+
|
|
|
+ LambdaQueryWrapper<PjProductLaunch> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(PjProductLaunch::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjProductLaunch::getBillType, 1)
|
|
|
+ .eq(PjProductLaunch::getIsDeleted, 0)
|
|
|
+ .eq(PjProductLaunch::getGoodsId, productLaunch.getGoodsId())
|
|
|
+ .eq(PjProductLaunch::getSourceCompanyId, productLaunch.getSalesCompanyId());
|
|
|
+
|
|
|
+ List<PjProductLaunch> list = baseMapper.selectList(queryWrapper);
|
|
|
+ if (ObjectUtil.isNotEmpty(list)){
|
|
|
+ list.forEach(e -> {
|
|
|
+ e.setWhetherShare(1);
|
|
|
+ baseMapper.updateById(e);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
String[] companyIds = productLaunch.getSharedCompany().split(",");
|
|
|
for (String id : companyIds) {
|
|
|
PjProductLaunch launch = new PjProductLaunch();
|
|
|
@@ -117,6 +143,7 @@ public class ProductLaunchServiceImpl extends ServiceImpl<ProductLaunchMapper, P
|
|
|
|
|
|
LambdaQueryWrapper<PjProductLaunch> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
lambdaQueryWrapper.eq(PjProductLaunch::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjProductLaunch::getIsDeleted, 0)
|
|
|
.eq(PjProductLaunch::getBillType, 1)
|
|
|
.eq(PjProductLaunch::getGoodsId, productLaunch.getGoodsId())
|
|
|
.eq(PjProductLaunch::getSalesCompanyId, id)
|
|
|
@@ -127,11 +154,13 @@ public class ProductLaunchServiceImpl extends ServiceImpl<ProductLaunchMapper, P
|
|
|
|
|
|
launch.setId(null);
|
|
|
launch.setBillType(1);
|
|
|
+ launch.setWhetherShare(0);
|
|
|
launch.setCreateUser(AuthUtil.getUserId());
|
|
|
launch.setCreateTime(new Date());
|
|
|
launch.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
|
|
|
launch.setSourceId(productLaunch.getId());
|
|
|
launch.setSourceCompanyId(productLaunch.getSalesCompanyId());
|
|
|
+ launch.setTenantId(AuthUtil.getTenantId());
|
|
|
R<Dept> dept = iSysClient.getDept(Long.valueOf(id));
|
|
|
if (ObjectUtil.isNotEmpty(dept)) {
|
|
|
launch.setSalesCompanyId(Long.valueOf(id));
|
|
|
@@ -144,6 +173,7 @@ public class ProductLaunchServiceImpl extends ServiceImpl<ProductLaunchMapper, P
|
|
|
}else {
|
|
|
launch.setUpdateTime(new Date());
|
|
|
launch.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ launch.setWhetherShare(0);
|
|
|
baseMapper.updateById(launch);
|
|
|
}
|
|
|
}
|
|
|
@@ -158,7 +188,7 @@ public class ProductLaunchServiceImpl extends ServiceImpl<ProductLaunchMapper, P
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(selectList)){
|
|
|
selectList.forEach(e -> {
|
|
|
- e.setIsDeleted(1);
|
|
|
+ e.setWhetherShare(1);
|
|
|
baseMapper.updateById(e);
|
|
|
});
|
|
|
}
|
|
|
@@ -174,6 +204,7 @@ public class ProductLaunchServiceImpl extends ServiceImpl<ProductLaunchMapper, P
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public R importProductLaunch(List<ProductLaunchImportExcel> data, Boolean isCovered) {
|
|
|
if (CollectionUtils.isEmpty(data)) {
|
|
|
throw new SecurityException("导入数据不能为空");
|
|
|
@@ -192,6 +223,8 @@ public class ProductLaunchServiceImpl extends ServiceImpl<ProductLaunchMapper, P
|
|
|
if (ObjectUtil.isNotEmpty(pjGoodsDesc)){
|
|
|
//商品id
|
|
|
productLaunch.setGoodsId(pjGoodsDesc.getId());
|
|
|
+ productLaunch.setBrandId(pjGoodsDesc.getBrandId());
|
|
|
+ productLaunch.setBrandName(pjGoodsDesc.getBrandName());
|
|
|
}else {
|
|
|
throw new RuntimeException("商品名称错误或商品不存在");
|
|
|
}
|
|
|
@@ -212,18 +245,6 @@ public class ProductLaunchServiceImpl extends ServiceImpl<ProductLaunchMapper, P
|
|
|
productLaunch.setPriceTwo(e.getPriceTwo());
|
|
|
productLaunch.setPriceThree(e.getPriceThree());
|
|
|
productLaunch.setPriceFour(e.getPriceFour());
|
|
|
- productLaunch.setPriceFive(e.getPriceFive());
|
|
|
- productLaunch.setPriceSix(e.getPriceSix());
|
|
|
- productLaunch.setPriceSeven(e.getPriceSeven());
|
|
|
- productLaunch.setPriceEight(e.getPriceEight());
|
|
|
- productLaunch.setNextDayDeliveryPriceOne(e.getNextDayDeliveryPriceOne());
|
|
|
- productLaunch.setNextDayDeliveryPriceTwo(e.getNextDayDeliveryPriceTwo());
|
|
|
- productLaunch.setNextDayDeliveryPriceThree(e.getNextDayDeliveryPriceThree());
|
|
|
- productLaunch.setNextDayDeliveryPriceFour(e.getNextDayDeliveryPriceFour());
|
|
|
- productLaunch.setNextDayDeliveryPriceFive(e.getNextDayDeliveryPriceFive());
|
|
|
- productLaunch.setNextDayDeliveryPriceSix(e.getNextDayDeliveryPriceSix());
|
|
|
- productLaunch.setNextDayDeliveryPriceSeven(e.getNextDayDeliveryPriceSeven());
|
|
|
- productLaunch.setNextDayDeliveryPriceEight(e.getNextDayDeliveryPriceEight());
|
|
|
|
|
|
// 如果名称相等 就认为重复
|
|
|
LambdaQueryWrapper<PjProductLaunch> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
@@ -237,6 +258,7 @@ public class ProductLaunchServiceImpl extends ServiceImpl<ProductLaunchMapper, P
|
|
|
productLaunch.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
|
|
|
productLaunch.setCreateTime(new Date());
|
|
|
productLaunch.setCreateUser(AuthUtil.getUserId());
|
|
|
+ productLaunch.setTenantId(AuthUtil.getTenantId());
|
|
|
baseMapper.insert(productLaunch);
|
|
|
}else {
|
|
|
productLaunch.setId(one.getId());
|
|
|
@@ -269,4 +291,135 @@ public class ProductLaunchServiceImpl extends ServiceImpl<ProductLaunchMapper, P
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 小程序详情
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public PjProductLaunch getAppMessageById(PjProductLaunch productLaunch) {
|
|
|
+ PjProductLaunch detail = baseMapper.selectById(productLaunch.getId());
|
|
|
+
|
|
|
+ //获得附件
|
|
|
+ detail.setFilesList(productLaunchFilesService.list(new QueryWrapper<PjProductLaunchFiles>()
|
|
|
+ .eq("pid", productLaunch.getId())
|
|
|
+ .eq("is_deleted", 0)));
|
|
|
+
|
|
|
+ PjCorpsDesc corpsDesc = null;
|
|
|
+ //根据当前登录人获得客户
|
|
|
+ PjCorpsAttn corpsAttn = corpsAttnService.getAttn(AuthUtil.getUserId());
|
|
|
+ if (ObjectUtil.isNotEmpty(corpsAttn)){
|
|
|
+ corpsDesc = corpsDescService.getCorpsDesc(corpsAttn.getPid());
|
|
|
+ if (ObjectUtil.isEmpty(corpsDesc)){
|
|
|
+ throw new RuntimeException("当前用户客户不存在");
|
|
|
+ }else {
|
|
|
+ if (ObjectUtil.isNotEmpty(corpsDesc.getPriceSystem())){
|
|
|
+ if ("售价1".equals(corpsDesc.getPriceSystem())){
|
|
|
+ detail.setMallPrice(detail.getPriceOne());
|
|
|
+ }else if ("售价2".equals(corpsDesc.getPriceSystem())){
|
|
|
+ detail.setMallPrice(detail.getPriceTwo());
|
|
|
+ }else if ("售价3".equals(corpsDesc.getPriceSystem())){
|
|
|
+ detail.setMallPrice(detail.getPriceThree());
|
|
|
+ }else if ("售价4".equals(corpsDesc.getPriceSystem())){
|
|
|
+ detail.setMallPrice(detail.getPriceFour());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ detail.setMallPrice(detail.getPriceOne());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (detail.getBillType() != 1){
|
|
|
+ LambdaQueryWrapper<PjProductLaunch> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(PjProductLaunch::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjProductLaunch::getBillType, 1)
|
|
|
+ .eq(PjProductLaunch::getIsDeleted, 0)
|
|
|
+ .eq(PjProductLaunch::getGoodsId, detail.getGoodsId())
|
|
|
+ .eq(PjProductLaunch::getSalesCompanyId, detail.getSalesCompanyId());
|
|
|
+
|
|
|
+ List<PjProductLaunch> list = baseMapper.selectList(queryWrapper);
|
|
|
+ detail.setShareList(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ return detail;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 详情选择所属公司修改价格
|
|
|
+ *
|
|
|
+ * @param productLaunch
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public PjProductLaunch appModifyPrice(PjProductLaunch productLaunch) {
|
|
|
+ PjProductLaunch detail = baseMapper.selectById(productLaunch.getId());
|
|
|
+
|
|
|
+ PjCorpsDesc corpsDesc = null;
|
|
|
+ //根据当前登录人获得客户
|
|
|
+ PjCorpsAttn corpsAttn = corpsAttnService.getAttn(AuthUtil.getUserId());
|
|
|
+ if (ObjectUtil.isNotEmpty(corpsAttn)){
|
|
|
+ corpsDesc = corpsDescService.getCorpsDesc(corpsAttn.getPid());
|
|
|
+ if (ObjectUtil.isEmpty(corpsDesc)){
|
|
|
+ throw new RuntimeException("当前用户客户不存在");
|
|
|
+ }else {
|
|
|
+ if (ObjectUtil.isNotEmpty(corpsDesc.getPriceSystem())){
|
|
|
+ if ("售价1".equals(corpsDesc.getPriceSystem())){
|
|
|
+ detail.setMallPrice(detail.getPriceOne());
|
|
|
+ }else if ("售价2".equals(corpsDesc.getPriceSystem())){
|
|
|
+ detail.setMallPrice(detail.getPriceTwo());
|
|
|
+ }else if ("售价3".equals(corpsDesc.getPriceSystem())){
|
|
|
+ detail.setMallPrice(detail.getPriceThree());
|
|
|
+ }else if ("售价4".equals(corpsDesc.getPriceSystem())){
|
|
|
+ detail.setMallPrice(detail.getPriceFour());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ detail.setMallPrice(detail.getPriceOne());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return detail;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 加入购物车
|
|
|
+ *
|
|
|
+ * @param productLaunch
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public R addToCart(PjProductLaunch productLaunch) {
|
|
|
+ // 获取系统编号
|
|
|
+ R billNo = serialClient.getBillNo("GWC", "GWC", "GWC");
|
|
|
+ if (billNo.getCode() != 200) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return R.fail(500, "生成系统编号失败");
|
|
|
+ }
|
|
|
+ PjShoppingCart shoppingCart = new PjShoppingCart();
|
|
|
+ shoppingCart.setBillNo((String) billNo.getData());
|
|
|
+ shoppingCart.setCreateUser(AuthUtil.getUserId());
|
|
|
+ shoppingCart.setCreateTime(new Date());
|
|
|
+ shoppingCart.setTenantId(AuthUtil.getTenantId());
|
|
|
+
|
|
|
+ //商品名称
|
|
|
+ PjGoodsDesc goodsDesc = goodsDescMapper.selectById(productLaunch.getGoodsId());
|
|
|
+ shoppingCart.setGoodsName(goodsDesc.getCname());
|
|
|
+ shoppingCart.setGoodsNo(goodsDesc.getCode());
|
|
|
+ shoppingCart.setPropertyName(goodsDesc.getSpecificationAndModel());
|
|
|
+ shoppingCart.setPattern(goodsDesc.getBrandItem());
|
|
|
+ shoppingCart.setGoodsDescription(goodsDesc.getGoodsDescription());
|
|
|
+ shoppingCart.setUnits(goodsDesc.getUnit());
|
|
|
+ shoppingCart.setBrandId(goodsDesc.getBrandId());
|
|
|
+ shoppingCart.setBrandName(goodsDesc.getBrandName());
|
|
|
+ shoppingCart.setGoodsNum(productLaunch.getGoodsNum());
|
|
|
+ shoppingCart.setSalesCompanyId(productLaunch.getSalesCompanyId());
|
|
|
+ shoppingCart.setSalesCompanyName(productLaunch.getSalesCompanyName());
|
|
|
+ shoppingCart.setPrice(productLaunch.getMallPrice());
|
|
|
+ shoppingCart.setProductLaunchId(productLaunch.getId());
|
|
|
+ shoppingCart.setSalesCompanyId(productLaunch.getSalesCompanyId());
|
|
|
+ shoppingCart.setSalesCompanyName(productLaunch.getSalesCompanyName());
|
|
|
+
|
|
|
+ shoppingCartMapper.insert(shoppingCart);
|
|
|
+ return R.success("操作成功");
|
|
|
+ }
|
|
|
+
|
|
|
}
|