新增dou店铺商品同步到商品库功能
This commit is contained in:
parent
4ecdf58e53
commit
5688523882
|
|
@ -1,10 +1,7 @@
|
||||||
package cn.qihangerp.api.dou.controller;
|
package cn.qihangerp.api.dou.controller;
|
||||||
|
|
||||||
|
|
||||||
import cn.qihangerp.common.AjaxResult;
|
import cn.qihangerp.common.*;
|
||||||
import cn.qihangerp.common.PageQuery;
|
|
||||||
import cn.qihangerp.common.PageResult;
|
|
||||||
import cn.qihangerp.common.TableDataInfo;
|
|
||||||
import cn.qihangerp.domain.bo.LinkErpGoodsSkuBo;
|
import cn.qihangerp.domain.bo.LinkErpGoodsSkuBo;
|
||||||
import cn.qihangerp.module.goods.domain.OGoodsSku;
|
import cn.qihangerp.module.goods.domain.OGoodsSku;
|
||||||
import cn.qihangerp.module.goods.service.OGoodsSkuService;
|
import cn.qihangerp.module.goods.service.OGoodsSkuService;
|
||||||
|
|
@ -19,6 +16,9 @@ import lombok.AllArgsConstructor;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@RequestMapping("/dou/goods")
|
@RequestMapping("/dou/goods")
|
||||||
@RestController
|
@RestController
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
|
@ -48,6 +48,12 @@ public class DouGoodsController extends BaseController {
|
||||||
{
|
{
|
||||||
return AjaxResult.success(skuService.getById(id));
|
return AjaxResult.success(skuService.getById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联
|
||||||
|
* @param bo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@PostMapping(value = "/sku/linkErp")
|
@PostMapping(value = "/sku/linkErp")
|
||||||
public AjaxResult linkErp(@RequestBody LinkErpGoodsSkuBo bo)
|
public AjaxResult linkErp(@RequestBody LinkErpGoodsSkuBo bo)
|
||||||
{
|
{
|
||||||
|
|
@ -57,13 +63,44 @@ public class DouGoodsController extends BaseController {
|
||||||
if(StringUtils.isBlank(bo.getErpGoodsSkuId())){
|
if(StringUtils.isBlank(bo.getErpGoodsSkuId())){
|
||||||
return AjaxResult.error(500,"缺少参数oGoodsSkuId");
|
return AjaxResult.error(500,"缺少参数oGoodsSkuId");
|
||||||
}
|
}
|
||||||
OGoodsSku oGoodsSku = oGoodsSkuService.getById(bo.getErpGoodsSkuId());
|
ResultVo resultVo = skuService.linkErpGoodsSku(bo);
|
||||||
if(oGoodsSku == null) return AjaxResult.error(1500,"未找到系统商品sku");
|
if(resultVo.getCode()==0)
|
||||||
DouGoodsSku sku = new DouGoodsSku();
|
return success();
|
||||||
sku.setId(bo.getId());
|
else return AjaxResult.error(resultVo.getMsg());
|
||||||
sku.setOGoodsSkuId(bo.getErpGoodsSkuId());
|
|
||||||
skuService.updateById(sku);
|
// OGoodsSku oGoodsSku = oGoodsSkuService.getById(bo.getErpGoodsSkuId());
|
||||||
return success();
|
// if(oGoodsSku == null) return AjaxResult.error(1500,"未找到系统商品sku");
|
||||||
|
// DouGoodsSku sku = new DouGoodsSku();
|
||||||
|
// sku.setId(bo.getId());
|
||||||
|
// sku.setOGoodsSkuId(bo.getErpGoodsSkuId());
|
||||||
|
// skuService.updateById(sku);
|
||||||
|
// return success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送商品到OMS
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/push_oms")
|
||||||
|
@ResponseBody
|
||||||
|
public AjaxResult pushOms(@RequestBody String[] ids) {
|
||||||
|
if (ids == null || ids.length == 0) return AjaxResult.error("缺少参数");
|
||||||
|
int success = 0;
|
||||||
|
int isExist = 0;
|
||||||
|
int fail = 0;
|
||||||
|
for (String id : ids) {
|
||||||
|
ResultVo resultVo = goodsService.pushToOms(Long.parseLong(id));
|
||||||
|
if(resultVo.getCode()==0) success++;
|
||||||
|
else if(resultVo.getCode()==ResultVoEnum.DataExist.getIndex()) isExist++;
|
||||||
|
else fail++;
|
||||||
|
}
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("success", success);
|
||||||
|
map.put("isExist", isExist);
|
||||||
|
map.put("fail", fail);
|
||||||
|
map.put("total", success + isExist+fail);
|
||||||
|
return success(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
@ -31,7 +32,7 @@ public class DouGoods implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 商品ID,抖店系统生成,店铺下唯一
|
* 商品ID,抖店系统生成,店铺下唯一
|
||||||
*/
|
*/
|
||||||
private Long productId;
|
private String productId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品类型;0-普通;1-新客商品;3-虚拟;6-玉石闪购;7-云闪购 ;127-其他类型;
|
* 商品类型;0-普通;1-新客商品;3-虚拟;6-玉石闪购;7-云闪购 ;127-其他类型;
|
||||||
|
|
@ -39,7 +40,13 @@ public class DouGoods implements Serializable {
|
||||||
private Long productType;
|
private Long productType;
|
||||||
private Long marketPrice;
|
private Long marketPrice;
|
||||||
private Long discountPrice;
|
private Long discountPrice;
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "#.##")
|
||||||
|
public double getFormattedPrice() {
|
||||||
|
if(marketPrice == null){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return marketPrice / 100;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 商品标题。
|
* 商品标题。
|
||||||
*/
|
*/
|
||||||
|
|
@ -98,7 +105,7 @@ public class DouGoods implements Serializable {
|
||||||
/**
|
/**
|
||||||
* erp商品id
|
* erp商品id
|
||||||
*/
|
*/
|
||||||
private Long oGoodsId;
|
private Long erpGoodsId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拉取时间
|
* 拉取时间
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 抖店商品Sku表
|
* 抖店商品Sku表
|
||||||
|
|
@ -141,12 +142,12 @@ public class DouGoodsSku implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 商品id(o_goods外键)
|
* 商品id(o_goods外键)
|
||||||
*/
|
*/
|
||||||
private String oGoodsId;
|
private String erpGoodsId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品skuid(o_goods_sku外键)
|
* 商品skuid(o_goods_sku外键)
|
||||||
*/
|
*/
|
||||||
private String oGoodsSkuId;
|
private String erpGoodsSkuId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 店铺id
|
* 店铺id
|
||||||
|
|
@ -163,5 +164,16 @@ public class DouGoodsSku implements Serializable {
|
||||||
*/
|
*/
|
||||||
private String img;
|
private String img;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拉取时间
|
||||||
|
*/
|
||||||
|
private Date pullTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
private Date modifyTime;
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
}
|
}
|
||||||
|
|
@ -16,4 +16,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
public interface DouGoodsService extends IService<DouGoods> {
|
public interface DouGoodsService extends IService<DouGoods> {
|
||||||
PageResult<DouGoods> queryPageList(DouGoodsBo bo, PageQuery pageQuery);
|
PageResult<DouGoods> queryPageList(DouGoodsBo bo, PageQuery pageQuery);
|
||||||
ResultVo<Integer> saveGoods(Long shopId, DouGoods goods);
|
ResultVo<Integer> saveGoods(Long shopId, DouGoods goods);
|
||||||
|
ResultVo pushToOms(Long taoGoodsId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ package cn.qihangerp.module.open.dou.service;
|
||||||
|
|
||||||
import cn.qihangerp.common.PageQuery;
|
import cn.qihangerp.common.PageQuery;
|
||||||
import cn.qihangerp.common.PageResult;
|
import cn.qihangerp.common.PageResult;
|
||||||
|
import cn.qihangerp.common.ResultVo;
|
||||||
|
import cn.qihangerp.domain.bo.LinkErpGoodsSkuBo;
|
||||||
import cn.qihangerp.module.open.dou.domain.DouGoodsSku;
|
import cn.qihangerp.module.open.dou.domain.DouGoodsSku;
|
||||||
import cn.qihangerp.module.open.dou.domain.bo.DouGoodsBo;
|
import cn.qihangerp.module.open.dou.domain.bo.DouGoodsBo;
|
||||||
import cn.qihangerp.module.open.dou.domain.vo.DouGoodsSkuListVo;
|
import cn.qihangerp.module.open.dou.domain.vo.DouGoodsSkuListVo;
|
||||||
|
|
@ -15,4 +17,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
*/
|
*/
|
||||||
public interface DouGoodsSkuService extends IService<DouGoodsSku> {
|
public interface DouGoodsSkuService extends IService<DouGoodsSku> {
|
||||||
PageResult<DouGoodsSkuListVo> queryPageList(DouGoodsBo bo, PageQuery pageQuery);
|
PageResult<DouGoodsSkuListVo> queryPageList(DouGoodsBo bo, PageQuery pageQuery);
|
||||||
|
ResultVo linkErpGoodsSku(LinkErpGoodsSkuBo bo);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,15 @@
|
||||||
package cn.qihangerp.module.open.dou.service.impl;
|
package cn.qihangerp.module.open.dou.service.impl;
|
||||||
|
|
||||||
|
|
||||||
import cn.qihangerp.common.PageQuery;
|
import cn.qihangerp.common.PageQuery;
|
||||||
import cn.qihangerp.common.PageResult;
|
import cn.qihangerp.common.PageResult;
|
||||||
import cn.qihangerp.common.ResultVo;
|
import cn.qihangerp.common.ResultVo;
|
||||||
|
import cn.qihangerp.common.ResultVoEnum;
|
||||||
import cn.qihangerp.common.utils.StringUtils;
|
import cn.qihangerp.common.utils.StringUtils;
|
||||||
|
import cn.qihangerp.module.goods.domain.OGoods;
|
||||||
|
import cn.qihangerp.module.goods.domain.OGoodsInventory;
|
||||||
import cn.qihangerp.module.goods.domain.OGoodsSku;
|
import cn.qihangerp.module.goods.domain.OGoodsSku;
|
||||||
|
import cn.qihangerp.module.goods.mapper.OGoodsInventoryMapper;
|
||||||
|
import cn.qihangerp.module.goods.mapper.OGoodsMapper;
|
||||||
import cn.qihangerp.module.goods.mapper.OGoodsSkuMapper;
|
import cn.qihangerp.module.goods.mapper.OGoodsSkuMapper;
|
||||||
import cn.qihangerp.module.open.dou.domain.DouGoods;
|
import cn.qihangerp.module.open.dou.domain.DouGoods;
|
||||||
import cn.qihangerp.module.open.dou.domain.DouGoodsSku;
|
import cn.qihangerp.module.open.dou.domain.DouGoodsSku;
|
||||||
|
|
@ -13,6 +17,8 @@ import cn.qihangerp.module.open.dou.domain.bo.DouGoodsBo;
|
||||||
import cn.qihangerp.module.open.dou.mapper.DouGoodsMapper;
|
import cn.qihangerp.module.open.dou.mapper.DouGoodsMapper;
|
||||||
import cn.qihangerp.module.open.dou.mapper.DouGoodsSkuMapper;
|
import cn.qihangerp.module.open.dou.mapper.DouGoodsSkuMapper;
|
||||||
import cn.qihangerp.module.open.dou.service.DouGoodsService;
|
import cn.qihangerp.module.open.dou.service.DouGoodsService;
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|
@ -20,8 +26,10 @@ import lombok.AllArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author TW
|
* @author TW
|
||||||
|
|
@ -35,6 +43,9 @@ public class DouGoodsServiceImpl extends ServiceImpl<DouGoodsMapper, DouGoods>
|
||||||
private final DouGoodsMapper mapper;
|
private final DouGoodsMapper mapper;
|
||||||
private final DouGoodsSkuMapper skuMapper;
|
private final DouGoodsSkuMapper skuMapper;
|
||||||
private final OGoodsSkuMapper goodsSkuMapper;
|
private final OGoodsSkuMapper goodsSkuMapper;
|
||||||
|
private final OGoodsMapper goodsMapper;
|
||||||
|
private final OGoodsInventoryMapper inventoryMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<DouGoods> queryPageList(DouGoodsBo bo, PageQuery pageQuery) {
|
public PageResult<DouGoods> queryPageList(DouGoodsBo bo, PageQuery pageQuery) {
|
||||||
LambdaQueryWrapper<DouGoods> queryWrapper = new LambdaQueryWrapper<DouGoods>()
|
LambdaQueryWrapper<DouGoods> queryWrapper = new LambdaQueryWrapper<DouGoods>()
|
||||||
|
|
@ -43,6 +54,11 @@ public class DouGoodsServiceImpl extends ServiceImpl<DouGoodsMapper, DouGoods>
|
||||||
;
|
;
|
||||||
|
|
||||||
Page<DouGoods> goodsPage = mapper.selectPage(pageQuery.build(), queryWrapper);
|
Page<DouGoods> goodsPage = mapper.selectPage(pageQuery.build(), queryWrapper);
|
||||||
|
if(goodsPage.getRecords()!=null && goodsPage.getRecords().size()>0){
|
||||||
|
for(DouGoods goods : goodsPage.getRecords()){
|
||||||
|
goods.setSkuList(skuMapper.selectList(new LambdaQueryWrapper<DouGoodsSku>().eq(DouGoodsSku::getProductId,goods.getProductId())));
|
||||||
|
}
|
||||||
|
}
|
||||||
return PageResult.build(goodsPage);
|
return PageResult.build(goodsPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -62,9 +78,11 @@ public class DouGoodsServiceImpl extends ServiceImpl<DouGoodsMapper, DouGoods>
|
||||||
|
|
||||||
mapper.updateById(goods);
|
mapper.updateById(goods);
|
||||||
// 删除sku
|
// 删除sku
|
||||||
skuMapper.delete(new LambdaQueryWrapper<DouGoodsSku>().eq(DouGoodsSku::getProductId,goods.getProductId()));
|
// skuMapper.delete(new LambdaQueryWrapper<DouGoodsSku>().eq(DouGoodsSku::getProductId,goods.getProductId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Long erpGoodsId=0L;
|
||||||
|
String erpGoodsNum="";
|
||||||
// 添加sku
|
// 添加sku
|
||||||
if(goods.getSkuList()!=null && !goods.getSkuList().isEmpty()){
|
if(goods.getSkuList()!=null && !goods.getSkuList().isEmpty()){
|
||||||
for (var item : goods.getSkuList()){
|
for (var item : goods.getSkuList()){
|
||||||
|
|
@ -75,13 +93,200 @@ public class DouGoodsServiceImpl extends ServiceImpl<DouGoodsMapper, DouGoods>
|
||||||
if(StringUtils.isNotEmpty(item.getCode())) {
|
if(StringUtils.isNotEmpty(item.getCode())) {
|
||||||
List<OGoodsSku> oGoodsSkus = goodsSkuMapper.selectList(new LambdaQueryWrapper<OGoodsSku>().eq(OGoodsSku::getSkuCode, item.getCode()));
|
List<OGoodsSku> oGoodsSkus = goodsSkuMapper.selectList(new LambdaQueryWrapper<OGoodsSku>().eq(OGoodsSku::getSkuCode, item.getCode()));
|
||||||
if(oGoodsSkus!=null && !oGoodsSkus.isEmpty()){
|
if(oGoodsSkus!=null && !oGoodsSkus.isEmpty()){
|
||||||
item.setOGoodsId(oGoodsSkus.get(0).getGoodsId().toString());
|
erpGoodsId = oGoodsSkus.get(0).getGoodsId();
|
||||||
item.setOGoodsSkuId(oGoodsSkus.get(0).getId().toString());
|
erpGoodsNum = oGoodsSkus.get(0).getGoodsNum();
|
||||||
|
item.setErpGoodsId(oGoodsSkus.get(0).getGoodsId().toString());
|
||||||
|
item.setErpGoodsSkuId(oGoodsSkus.get(0).getId().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
skuMapper.insert(item);
|
List<DouGoodsSku> pddGoodsSkus = skuMapper.selectList(new LambdaQueryWrapper<DouGoodsSku>().eq(DouGoodsSku::getSpecId, item.getSpecId()));
|
||||||
|
if(pddGoodsSkus!=null && !pddGoodsSkus.isEmpty()){
|
||||||
|
item.setModifyTime(new Date());
|
||||||
|
skuMapper.updateById(item);
|
||||||
|
}else {
|
||||||
|
item.setPullTime(new Date());
|
||||||
|
skuMapper.insert(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(erpGoodsId>0){
|
||||||
|
DouGoods updateGoods = new DouGoods();
|
||||||
|
updateGoods.setId(goods.getId());
|
||||||
|
updateGoods.setErpGoodsId(erpGoodsId);
|
||||||
|
updateGoods.setOuterProductId(erpGoodsNum);
|
||||||
|
mapper.updateById(goods);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResultVo.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
@Override
|
||||||
|
public ResultVo pushToOms(Long taoGoodsId) {
|
||||||
|
DouGoods shopGoods = mapper.selectById(taoGoodsId);
|
||||||
|
if(shopGoods==null) return ResultVo.error("店铺商品数据不存在");
|
||||||
|
|
||||||
|
List<DouGoodsSku> shopGoodsSkus = skuMapper.selectList(new LambdaQueryWrapper<DouGoodsSku>().eq(DouGoodsSku::getProductId, shopGoods.getProductId()));
|
||||||
|
if(shopGoodsSkus==null || shopGoodsSkus.isEmpty()) return ResultVo.error("店铺商品Sku数据不存在");
|
||||||
|
|
||||||
|
String goodsNum ="";
|
||||||
|
if(org.springframework.util.StringUtils.hasText(shopGoods.getOuterProductId())){
|
||||||
|
goodsNum = shopGoods.getOuterProductId();
|
||||||
|
// 用商家编码查询
|
||||||
|
List<OGoods> erpGoodsList = goodsMapper.selectList(new LambdaQueryWrapper<OGoods>()
|
||||||
|
.eq(OGoods::getGoodsNum, goodsNum));
|
||||||
|
if(erpGoodsList!=null && !erpGoodsList.isEmpty()){
|
||||||
|
// 存在=======关联
|
||||||
|
//更新shopGoods
|
||||||
|
DouGoods shopGoodsUpdate = new DouGoods();
|
||||||
|
shopGoodsUpdate.setId(shopGoods.getId());
|
||||||
|
shopGoodsUpdate.setErpGoodsId(erpGoodsList.get(0).getId());
|
||||||
|
mapper.updateById(shopGoodsUpdate);
|
||||||
|
|
||||||
|
List<OGoodsSku> oGoodsSkus = goodsSkuMapper.selectList(new LambdaQueryWrapper<OGoodsSku>()
|
||||||
|
.eq(OGoodsSku::getGoodsId, erpGoodsList.get(0).getId())
|
||||||
|
);
|
||||||
|
//更新skus
|
||||||
|
for (var sku:shopGoodsSkus){
|
||||||
|
if(org.springframework.util.StringUtils.hasText(sku.getCode())){
|
||||||
|
List<OGoodsSku> oGoodsSkuList = oGoodsSkus.stream().filter(x -> x.getSkuCode().equals(sku.getCode())).collect(Collectors.toList());
|
||||||
|
if(oGoodsSkuList!=null && !oGoodsSkuList.isEmpty()){
|
||||||
|
//更新ShopGoodsSku
|
||||||
|
DouGoodsSku shopGoodsSkuUpdate = new DouGoodsSku();
|
||||||
|
shopGoodsSkuUpdate.setId(sku.getId());
|
||||||
|
shopGoodsSkuUpdate.setErpGoodsId(oGoodsSkuList.get(0).getGoodsId().toString());
|
||||||
|
shopGoodsSkuUpdate.setErpGoodsSkuId(oGoodsSkuList.get(0).getId().toString());
|
||||||
|
|
||||||
|
skuMapper.updateById(shopGoodsSkuUpdate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResultVo.success("商品已存在,更新关联");
|
||||||
|
}
|
||||||
|
|
||||||
|
}else {
|
||||||
|
goodsNum = shopGoods.getProductId().toString();
|
||||||
|
// 用商品ID查询
|
||||||
|
List<OGoods> erpGoodsList = goodsMapper.selectList(new LambdaQueryWrapper<OGoods>()
|
||||||
|
.eq(OGoods::getGoodsNum, goodsNum));
|
||||||
|
if(erpGoodsList!=null && !erpGoodsList.isEmpty()){
|
||||||
|
return ResultVo.error(ResultVoEnum.DataExist.getIndex(),"商品已存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 添加商品
|
||||||
|
OGoods erpGoods = new OGoods();
|
||||||
|
erpGoods.setName(shopGoods.getName());
|
||||||
|
erpGoods.setImage(shopGoods.getImg());
|
||||||
|
erpGoods.setGoodsNum(goodsNum);
|
||||||
|
erpGoods.setCategoryId(0L);
|
||||||
|
erpGoods.setRemark("DOU店铺商品同步");
|
||||||
|
erpGoods.setStatus(1);
|
||||||
|
erpGoods.setDisable(1);
|
||||||
|
if (shopGoods.getMarketPrice() != null) {
|
||||||
|
erpGoods.setRetailPrice(BigDecimal.valueOf(shopGoods.getMarketPrice()/100));
|
||||||
|
}
|
||||||
|
erpGoods.setCreateBy("DOU店铺商品同步");
|
||||||
|
erpGoods.setCreateTime(new Date());
|
||||||
|
goodsMapper.insert(erpGoods);
|
||||||
|
|
||||||
|
//更新shopGoods
|
||||||
|
DouGoods shopGoodsUpdate = new DouGoods();
|
||||||
|
shopGoodsUpdate.setId(shopGoods.getId());
|
||||||
|
shopGoodsUpdate.setErpGoodsId(erpGoods.getId());
|
||||||
|
mapper.updateById(shopGoodsUpdate);
|
||||||
|
|
||||||
|
// 添加商品SKU
|
||||||
|
for (var sku:shopGoodsSkus){
|
||||||
|
OGoodsSku erpGoodsSku = new OGoodsSku();
|
||||||
|
erpGoodsSku.setGoodsId(erpGoods.getId());
|
||||||
|
erpGoodsSku.setGoodsName(erpGoods.getName());
|
||||||
|
erpGoodsSku.setGoodsNum(erpGoods.getGoodsNum());
|
||||||
|
//122216927:77835123:家具结构:框架结构;1627207:25326567650:颜色分类:奶油白【进口荔枝纹头层牛皮+碳素钢木排骨架】;21433:50753444:尺寸:1500mm*2000mm
|
||||||
|
// 组合规格
|
||||||
|
String colorLabel="";
|
||||||
|
String colorValue="";
|
||||||
|
String sizeLabel="";
|
||||||
|
String sizeValue="";
|
||||||
|
String styleLabel="";
|
||||||
|
String styleValue="";
|
||||||
|
//组合属性
|
||||||
|
if(org.springframework.util.StringUtils.hasText(sku.getSpecDetailName1())) {
|
||||||
|
colorValue=sku.getSpecDetailName1();
|
||||||
|
colorLabel="颜色分类";
|
||||||
|
}else{
|
||||||
|
colorValue="默认";
|
||||||
|
colorLabel="颜色分类";
|
||||||
|
}
|
||||||
|
if(org.springframework.util.StringUtils.hasText(sku.getSpecDetailName2())) {
|
||||||
|
sizeValue=sku.getSpecDetailName2();
|
||||||
|
sizeLabel="尺寸";
|
||||||
|
}
|
||||||
|
if(org.springframework.util.StringUtils.hasText(sku.getSpecDetailName3())) {
|
||||||
|
styleValue=sku.getSpecDetailName3();
|
||||||
|
styleLabel="款式";
|
||||||
|
}
|
||||||
|
|
||||||
|
erpGoodsSku.setColorId(0L);
|
||||||
|
erpGoodsSku.setColorLabel(colorLabel);
|
||||||
|
erpGoodsSku.setColorValue(colorValue);
|
||||||
|
erpGoodsSku.setSizeId(0L);
|
||||||
|
erpGoodsSku.setSizeLabel(sizeLabel);
|
||||||
|
erpGoodsSku.setSizeValue(sizeValue);
|
||||||
|
erpGoodsSku.setStyleId(0L);
|
||||||
|
erpGoodsSku.setStyleLabel(styleLabel);
|
||||||
|
erpGoodsSku.setStyleValue(styleValue);
|
||||||
|
String skuName="";
|
||||||
|
if(org.springframework.util.StringUtils.hasText(colorValue)){
|
||||||
|
skuName += colorValue+" ";
|
||||||
|
}
|
||||||
|
if(org.springframework.util.StringUtils.hasText(sizeValue)){
|
||||||
|
skuName += sizeValue+" ";
|
||||||
|
}
|
||||||
|
if(org.springframework.util.StringUtils.hasText(styleValue)){
|
||||||
|
skuName += styleValue+" ";
|
||||||
|
}
|
||||||
|
if(!org.springframework.util.StringUtils.hasText(skuName)){
|
||||||
|
skuName = "默认";
|
||||||
|
}
|
||||||
|
erpGoodsSku.setSkuName(skuName);
|
||||||
|
erpGoodsSku.setSkuCode(sku.getCode());
|
||||||
|
erpGoodsSku.setColorImage(erpGoods.getImage());
|
||||||
|
|
||||||
|
if(sku.getPrice()!=null){
|
||||||
|
erpGoodsSku.setRetailPrice(BigDecimal.valueOf(sku.getPrice()/100));
|
||||||
|
}
|
||||||
|
erpGoodsSku.setStatus(1);
|
||||||
|
goodsSkuMapper.insert(erpGoodsSku);
|
||||||
|
|
||||||
|
// 初始化商品库存
|
||||||
|
OGoodsInventory inventory = new OGoodsInventory();
|
||||||
|
|
||||||
|
inventory.setGoodsId(erpGoods.getId());
|
||||||
|
inventory.setGoodsNum(erpGoods.getGoodsNum());
|
||||||
|
inventory.setGoodsName(erpGoods.getName());
|
||||||
|
inventory.setGoodsImg(erpGoods.getImage());
|
||||||
|
inventory.setSkuId(erpGoodsSku.getId());
|
||||||
|
inventory.setSkuCode(erpGoodsSku.getSkuCode());
|
||||||
|
inventory.setSkuName(erpGoodsSku.getSkuName());
|
||||||
|
inventory.setQuantity(0L);
|
||||||
|
inventory.setIsDelete(0);
|
||||||
|
inventory.setCreateTime(new Date());
|
||||||
|
inventory.setCreateBy("同步店铺商品初始化商品 sku 库存");
|
||||||
|
inventoryMapper.insert(inventory);
|
||||||
|
|
||||||
|
//更新ShopGoodsSku
|
||||||
|
DouGoodsSku shopGoodsSkuUpdate = new DouGoodsSku();
|
||||||
|
shopGoodsSkuUpdate.setId(sku.getId());
|
||||||
|
shopGoodsSkuUpdate.setErpGoodsId(erpGoods.getId().toString());
|
||||||
|
shopGoodsSkuUpdate.setErpGoodsSkuId(erpGoodsSku.getId().toString());
|
||||||
|
skuMapper.updateById(shopGoodsSkuUpdate);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return ResultVo.success();
|
return ResultVo.success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,29 @@ package cn.qihangerp.module.open.dou.service.impl;
|
||||||
|
|
||||||
import cn.qihangerp.common.PageQuery;
|
import cn.qihangerp.common.PageQuery;
|
||||||
import cn.qihangerp.common.PageResult;
|
import cn.qihangerp.common.PageResult;
|
||||||
|
import cn.qihangerp.common.ResultVo;
|
||||||
|
import cn.qihangerp.domain.bo.LinkErpGoodsSkuBo;
|
||||||
|
import cn.qihangerp.module.goods.domain.OGoods;
|
||||||
|
import cn.qihangerp.module.goods.domain.OGoodsSku;
|
||||||
|
import cn.qihangerp.module.goods.service.OGoodsService;
|
||||||
|
import cn.qihangerp.module.goods.service.OGoodsSkuService;
|
||||||
|
import cn.qihangerp.module.open.dou.domain.DouGoods;
|
||||||
import cn.qihangerp.module.open.dou.domain.DouGoodsSku;
|
import cn.qihangerp.module.open.dou.domain.DouGoodsSku;
|
||||||
import cn.qihangerp.module.open.dou.domain.bo.DouGoodsBo;
|
import cn.qihangerp.module.open.dou.domain.bo.DouGoodsBo;
|
||||||
import cn.qihangerp.module.open.dou.domain.vo.DouGoodsSkuListVo;
|
import cn.qihangerp.module.open.dou.domain.vo.DouGoodsSkuListVo;
|
||||||
|
import cn.qihangerp.module.open.dou.mapper.DouGoodsMapper;
|
||||||
import cn.qihangerp.module.open.dou.mapper.DouGoodsSkuMapper;
|
import cn.qihangerp.module.open.dou.mapper.DouGoodsSkuMapper;
|
||||||
import cn.qihangerp.module.open.dou.service.DouGoodsSkuService;
|
import cn.qihangerp.module.open.dou.service.DouGoodsSkuService;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author TW
|
* @author TW
|
||||||
* @description 针对表【dou_goods_sku(抖店商品Sku表)】的数据库操作Service实现
|
* @description 针对表【dou_goods_sku(抖店商品Sku表)】的数据库操作Service实现
|
||||||
|
|
@ -23,6 +35,10 @@ import org.springframework.util.StringUtils;
|
||||||
public class DouGoodsSkuServiceImpl extends ServiceImpl<DouGoodsSkuMapper, DouGoodsSku>
|
public class DouGoodsSkuServiceImpl extends ServiceImpl<DouGoodsSkuMapper, DouGoodsSku>
|
||||||
implements DouGoodsSkuService {
|
implements DouGoodsSkuService {
|
||||||
private final DouGoodsSkuMapper mapper;
|
private final DouGoodsSkuMapper mapper;
|
||||||
|
private final DouGoodsMapper douGoodsMapper;
|
||||||
|
private final OGoodsSkuService oGoodsSkuService;
|
||||||
|
private final OGoodsService oGoodsService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<DouGoodsSkuListVo> queryPageList(DouGoodsBo bo, PageQuery pageQuery) {
|
public PageResult<DouGoodsSkuListVo> queryPageList(DouGoodsBo bo, PageQuery pageQuery) {
|
||||||
if(StringUtils.hasText(bo.getCode())){
|
if(StringUtils.hasText(bo.getCode())){
|
||||||
|
|
@ -31,6 +47,40 @@ public class DouGoodsSkuServiceImpl extends ServiceImpl<DouGoodsSkuMapper, DouGo
|
||||||
IPage<DouGoodsSkuListVo> result = mapper.selectSkuPageList(pageQuery.build(), bo.getShopId(),bo.getProductId(),bo.getSkuId(),bo.getCode(),bo.getHasLink());
|
IPage<DouGoodsSkuListVo> result = mapper.selectSkuPageList(pageQuery.build(), bo.getShopId(),bo.getProductId(),bo.getSkuId(),bo.getCode(),bo.getHasLink());
|
||||||
return PageResult.build(result);
|
return PageResult.build(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
@Override
|
||||||
|
public ResultVo linkErpGoodsSku(LinkErpGoodsSkuBo bo) {
|
||||||
|
OGoodsSku oGoodsSku = oGoodsSkuService.getById(bo.getErpGoodsSkuId());
|
||||||
|
if(oGoodsSku == null) return ResultVo.error("未找到系统商品sku");
|
||||||
|
|
||||||
|
OGoods oGoods=oGoodsService.getById(oGoodsSku.getGoodsId());
|
||||||
|
if(oGoods == null){
|
||||||
|
return ResultVo.error("未找到系统商品");
|
||||||
|
}
|
||||||
|
|
||||||
|
DouGoodsSku taoGoodsSku = mapper.selectById(bo.getId());
|
||||||
|
if(taoGoodsSku == null) {
|
||||||
|
return ResultVo.error("DOU商品sku数据不存在");
|
||||||
|
}
|
||||||
|
List<DouGoods> jdGoods = douGoodsMapper.selectList(new LambdaQueryWrapper<DouGoods>().eq(DouGoods::getProductId, taoGoodsSku.getProductId()));
|
||||||
|
if(jdGoods==null||jdGoods.size()==0){
|
||||||
|
return ResultVo.error("DOU商品数据不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
DouGoodsSku sku = new DouGoodsSku();
|
||||||
|
sku.setId(bo.getId());
|
||||||
|
sku.setErpGoodsId(oGoodsSku.getGoodsId().toString());
|
||||||
|
sku.setErpGoodsSkuId(oGoodsSku.getId().toString());
|
||||||
|
mapper.updateById(sku);
|
||||||
|
|
||||||
|
DouGoods goodsUp=new DouGoods();
|
||||||
|
goodsUp.setId(jdGoods.get(0).getId());
|
||||||
|
goodsUp.setErpGoodsId(oGoodsSku.getGoodsId());
|
||||||
|
|
||||||
|
douGoodsMapper.updateById(goodsUp);
|
||||||
|
return ResultVo.success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -145,8 +145,8 @@ public class DouOrderServiceImpl extends ServiceImpl<DouOrderMapper, DouOrder>
|
||||||
// 新增
|
// 新增
|
||||||
DouGoodsSku goodsSku = goodsSkuMapper.selectById(item.getSkuId());
|
DouGoodsSku goodsSku = goodsSkuMapper.selectById(item.getSkuId());
|
||||||
if (goodsSku != null) {
|
if (goodsSku != null) {
|
||||||
item.setOGoodsId(goodsSku.getOGoodsId());
|
item.setOGoodsId(goodsSku.getErpGoodsId());
|
||||||
item.setOGoodsSkuId(goodsSku.getOGoodsSkuId());
|
item.setOGoodsSkuId(goodsSku.getErpGoodsSkuId());
|
||||||
}
|
}
|
||||||
itemMapper.insert(item);
|
itemMapper.insert(item);
|
||||||
}
|
}
|
||||||
|
|
@ -161,8 +161,8 @@ public class DouOrderServiceImpl extends ServiceImpl<DouOrderMapper, DouOrder>
|
||||||
for (var item : order.getItems()) {
|
for (var item : order.getItems()) {
|
||||||
DouGoodsSku goodsSku = goodsSkuMapper.selectById(item.getSkuId());
|
DouGoodsSku goodsSku = goodsSkuMapper.selectById(item.getSkuId());
|
||||||
if (goodsSku != null) {
|
if (goodsSku != null) {
|
||||||
item.setOGoodsId(goodsSku.getOGoodsId());
|
item.setOGoodsId(goodsSku.getErpGoodsId());
|
||||||
item.setOGoodsSkuId(goodsSku.getOGoodsSkuId());
|
item.setOGoodsSkuId(goodsSku.getErpGoodsSkuId());
|
||||||
}
|
}
|
||||||
itemMapper.insert(item);
|
itemMapper.insert(item);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
<result property="categoryDetail" column="category_detail" jdbcType="VARCHAR"/>
|
<result property="categoryDetail" column="category_detail" jdbcType="VARCHAR"/>
|
||||||
<result property="outerProductId" column="outer_product_id" jdbcType="VARCHAR"/>
|
<result property="outerProductId" column="outer_product_id" jdbcType="VARCHAR"/>
|
||||||
<result property="isPackageProduct" column="is_package_product" jdbcType="VARCHAR"/>
|
<result property="isPackageProduct" column="is_package_product" jdbcType="VARCHAR"/>
|
||||||
<result property="oGoodsId" column="o_goods_id" jdbcType="BIGINT"/>
|
<result property="erpGoodsId" column="erp_goods_id" jdbcType="BIGINT"/>
|
||||||
<result property="pullTime" column="pull_time" jdbcType="TIMESTAMP"/>
|
<result property="pullTime" column="pull_time" jdbcType="TIMESTAMP"/>
|
||||||
<result property="modifyTime" column="modify_time" jdbcType="TIMESTAMP"/>
|
<result property="modifyTime" column="modify_time" jdbcType="TIMESTAMP"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
@ -31,6 +31,6 @@
|
||||||
check_status,status,spec_id,
|
check_status,status,spec_id,
|
||||||
create_time,update_time,description,
|
create_time,update_time,description,
|
||||||
category_detail,outer_product_id,is_package_product,
|
category_detail,outer_product_id,is_package_product,
|
||||||
o_goods_id,pull_time,modify_time
|
erp_goods_id,pull_time,modify_time
|
||||||
</sql>
|
</sql>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,13 @@
|
||||||
<result property="normalStockNum" column="normal_stock_num" jdbcType="INTEGER"/>
|
<result property="normalStockNum" column="normal_stock_num" jdbcType="INTEGER"/>
|
||||||
<result property="channelStockNum" column="channel_stock_num" jdbcType="INTEGER"/>
|
<result property="channelStockNum" column="channel_stock_num" jdbcType="INTEGER"/>
|
||||||
<result property="sellProperties" column="sell_properties" jdbcType="VARCHAR"/>
|
<result property="sellProperties" column="sell_properties" jdbcType="VARCHAR"/>
|
||||||
<result property="oGoodsId" column="o_goods_id" jdbcType="BIGINT"/>
|
<result property="erpGoodsId" column="erp_goods_id" jdbcType="BIGINT"/>
|
||||||
<result property="oGoodsSkuId" column="o_goods_sku_id" jdbcType="BIGINT"/>
|
<result property="erpGoodsSkuId" column="erp_goods_sku_id" jdbcType="BIGINT"/>
|
||||||
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>
|
<result property="shopId" column="shop_id" jdbcType="BIGINT"/>
|
||||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||||
<result property="img" column="img" jdbcType="VARCHAR"/>
|
<result property="img" column="img" jdbcType="VARCHAR"/>
|
||||||
|
<result property="pullTime" column="pull_time" jdbcType="TIMESTAMP"/>
|
||||||
|
<result property="modifyTime" column="modify_time" jdbcType="TIMESTAMP"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
|
|
@ -45,14 +47,14 @@
|
||||||
stock_num,prehold_stock_num,prom_stock_num,
|
stock_num,prehold_stock_num,prom_stock_num,
|
||||||
step_stock_num,prehold_step_stock_num,prom_step_stock_num,
|
step_stock_num,prehold_step_stock_num,prom_step_stock_num,
|
||||||
normal_stock_num,channel_stock_num,sell_properties,
|
normal_stock_num,channel_stock_num,sell_properties,
|
||||||
o_goods_id,o_goods_sku_id,shop_id,
|
erp_goods_id,erp_goods_sku_id,shop_id,
|
||||||
name,img
|
name,img,pull_time,modify_time
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectSkuPageList" resultType="cn.qihangerp.module.open.dou.domain.vo.DouGoodsSkuListVo">
|
<select id="selectSkuPageList" resultType="cn.qihangerp.module.open.dou.domain.vo.DouGoodsSkuListVo">
|
||||||
SELECT sku.*,ogs.outer_erp_sku_id FROM oms_dou_goods_sku sku
|
SELECT sku.*,ogs.outer_erp_sku_id FROM oms_dou_goods_sku sku
|
||||||
|
|
||||||
LEFT JOIN o_goods_sku ogs on ogs.id = sku.o_goods_sku_id
|
LEFT JOIN o_goods_sku ogs on ogs.id = sku.erp_goods_sku_id
|
||||||
WHERE 1=1
|
WHERE 1=1
|
||||||
<if test="shopId != null and shopId != ''">
|
<if test="shopId != null and shopId != ''">
|
||||||
AND sku.shop_id = #{shopId}
|
AND sku.shop_id = #{shopId}
|
||||||
|
|
@ -67,10 +69,10 @@
|
||||||
AND sku.code = #{code}
|
AND sku.code = #{code}
|
||||||
</if>
|
</if>
|
||||||
<if test="hasLink != null and hasLink == 0">
|
<if test="hasLink != null and hasLink == 0">
|
||||||
AND (sku.o_goods_sku_id is NULL or sku.o_goods_sku_id = 0)
|
AND (sku.erp_goods_sku_id is NULL or sku.erp_goods_sku_id = 0)
|
||||||
</if>
|
</if>
|
||||||
<if test="hasLink != null and hasLink == 1">
|
<if test="hasLink != null and hasLink == 1">
|
||||||
AND sku.o_goods_sku_id is NOT NULL and sku.o_goods_sku_id != 0
|
AND sku.erp_goods_sku_id is NOT NULL and sku.erp_goods_sku_id != 0
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ public class PddGoodsServiceImpl extends ServiceImpl<PddGoodsMapper, PddGoods>
|
||||||
}
|
}
|
||||||
|
|
||||||
item.setCreateTime(new Date());
|
item.setCreateTime(new Date());
|
||||||
List<PddGoodsSku> pddGoodsSkus = skuMapper.selectList(new LambdaQueryWrapper<PddGoodsSku>().eq(PddGoodsSku::getGoodsId, goods.getGoodsId()));
|
List<PddGoodsSku> pddGoodsSkus = skuMapper.selectList(new LambdaQueryWrapper<PddGoodsSku>().eq(PddGoodsSku::getSkuId, item.getSkuId()));
|
||||||
if(pddGoodsSkus!=null && !pddGoodsSkus.isEmpty()){
|
if(pddGoodsSkus!=null && !pddGoodsSkus.isEmpty()){
|
||||||
// 存在更新
|
// 存在更新
|
||||||
item.setUpdateTime(new Date());
|
item.setUpdateTime(new Date());
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ public class TaoGoodsServiceImpl extends ServiceImpl<TaoGoodsMapper, TaoGoods>
|
||||||
sku.setErpGoodsSkuId(oGoodsSkus.get(0).getId());
|
sku.setErpGoodsSkuId(oGoodsSkus.get(0).getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<TaoGoodsSku> taoGoodsSkus = skuMapper.selectList(new LambdaQueryWrapper<TaoGoodsSku>().eq(TaoGoodsSku::getTaoGoodsId, goods.getId()));
|
List<TaoGoodsSku> taoGoodsSkus = skuMapper.selectList(new LambdaQueryWrapper<TaoGoodsSku>().eq(TaoGoodsSku::getSkuId, sku.getSkuId()));
|
||||||
if(taoGoodsSkus!=null && !taoGoodsSkus.isEmpty()){
|
if(taoGoodsSkus!=null && !taoGoodsSkus.isEmpty()){
|
||||||
// 更新
|
// 更新
|
||||||
sku.setUpdateTime(new Date());
|
sku.setUpdateTime(new Date());
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,17 @@
|
||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
|
||||||
// 查询列表
|
// 查询列表
|
||||||
|
export function listGoods(query) {
|
||||||
|
return request({
|
||||||
|
url: '/api/open-api/dou/goods/list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 查询sku列表
|
||||||
export function listGoodsSku(query) {
|
export function listGoodsSku(query) {
|
||||||
return request({
|
return request({
|
||||||
url: '/api/open-api/dou/goods/skuList',
|
url: '/api/open-api/dou/goods/skuList',
|
||||||
|
|
@ -26,7 +37,7 @@ export function linkErpGoodsSkuId(data) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 接口拉取淘宝商品
|
// 接口拉取商品
|
||||||
export function pullGoodsList(data) {
|
export function pullGoodsList(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/api/open-api/dou/goods/pull_goods',
|
url: '/api/open-api/dou/goods/pull_goods',
|
||||||
|
|
@ -34,3 +45,12 @@ export function pullGoodsList(data) {
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//推送商品到商品库
|
||||||
|
export function pushToOms(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/open-api/dou/goods/push_oms',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,40 +52,43 @@
|
||||||
@click="handlePull"
|
@click="handlePull"
|
||||||
>API拉取商品数据</el-button>
|
>API拉取商品数据</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
:disabled="multiple"
|
||||||
|
icon="el-icon-refresh"
|
||||||
|
size="mini"
|
||||||
|
@click="handlePushOms"
|
||||||
|
>推送到商品库</el-button>
|
||||||
|
</el-col>
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-table v-loading="loading" :data="goodsList" @selection-change="handleSelectionChange">
|
<el-table v-loading="loading" :data="goodsList" @selection-change="handleSelectionChange">
|
||||||
<!-- <el-table-column type="selection" width="55" align="center" /> -->
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
<!-- <el-table-column label="ID" align="center" prop="id" />-->
|
<!-- <el-table-column label="ID" align="center" prop="id" />-->
|
||||||
<el-table-column label="商品ID" align="center" prop="productId" />
|
<el-table-column label="平台商品ID" align="center" prop="productId" />
|
||||||
<el-table-column label="规格Id" align="center" prop="specId" />
|
|
||||||
<el-table-column label="商品名称" align="center" prop="name" />
|
|
||||||
<el-table-column label="图片" align="center" prop="logo" width="100">
|
<el-table-column label="图片" align="center" prop="logo" width="100">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<image-preview :src="scope.row.img" :width="50" :height="50"/>
|
<image-preview :src="scope.row.img" :width="50" :height="50"/>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column label="商品名称" align="center" prop="name" />
|
||||||
<el-table-column label="规格" align="center" prop="specDetailName1" >
|
<el-table-column label="商家编码" align="center" prop="outerProductId" />
|
||||||
|
<el-table-column label="价格" align="center" prop="formattedPrice" >
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="SKU" align="center" >
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
{{scope.row.specDetailName1}}
|
<el-button
|
||||||
{{scope.row.specDetailName2}}
|
size="mini"
|
||||||
{{scope.row.specDetailName3}}
|
type="text"
|
||||||
|
icon="el-icon-info"
|
||||||
|
@click="handleViewSkuList(scope.row)"
|
||||||
|
>{{scope.row.skuList.length +' 个SKU'}}</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<!-- <el-table-column label="店铺" align="center" prop="categoryId" >-->
|
<el-table-column label="ERP商家ID" align="center" prop="erpGoodsId" />
|
||||||
<!-- <template slot-scope="scope">-->
|
|
||||||
<!-- <el-tag size="small">{{categoryList.find(x=>x.id === scope.row.categoryId).name}}</el-tag>-->
|
|
||||||
<!-- </template>-->
|
|
||||||
<!-- </el-table-column>-->
|
|
||||||
<el-table-column label="SKU编码" align="center" prop="code" />
|
|
||||||
<el-table-column label="价格" align="center" prop="price" >
|
|
||||||
<template slot-scope="scope">
|
|
||||||
{{amountFormatter(null,null,scope.row.price/100,0)}}
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="ERP SKU ID" align="center" prop="erpGoodsSkuId" />
|
|
||||||
<!-- <el-table-column label="状态" align="center" prop="skuStatus" >-->
|
<!-- <el-table-column label="状态" align="center" prop="skuStatus" >-->
|
||||||
<!-- <template slot-scope="scope">-->
|
<!-- <template slot-scope="scope">-->
|
||||||
<!-- <el-tag size="small" v-if="scope.row.skuStatus === false">已下架</el-tag>-->
|
<!-- <el-tag size="small" v-if="scope.row.skuStatus === false">已下架</el-tag>-->
|
||||||
|
|
@ -113,6 +116,53 @@
|
||||||
@pagination="getList"
|
@pagination="getList"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<el-dialog title="Sku List" :visible.sync="skuOpen" width="1200px" append-to-body>
|
||||||
|
<el-table v-loading="loading" :data="skuList">
|
||||||
|
<!-- <el-table-column type="selection" width="55" align="center" /> -->
|
||||||
|
<el-table-column label="序号" align="center" prop="index" width="50"/>
|
||||||
|
<el-table-column label="SKU编码" align="left" prop="code" />
|
||||||
|
<el-table-column label="规格Id" align="center" prop="specId" />
|
||||||
|
<el-table-column label="商品名称" align="center" prop="name" />
|
||||||
|
<el-table-column label="图片" align="center" prop="logo" width="100">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<image-preview :src="scope.row.img" :width="50" :height="50"/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column label="规格" align="center" prop="specDetailName1" >
|
||||||
|
<template slot-scope="scope">
|
||||||
|
{{scope.row.specDetailName1}}
|
||||||
|
{{scope.row.specDetailName2}}
|
||||||
|
{{scope.row.specDetailName3}}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column label="价格" align="center" prop="price" >
|
||||||
|
<template slot-scope="scope">
|
||||||
|
{{amountFormatter(null,null,scope.row.price/100,0)}}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column label="库存" align="center" prop="stockNum" />
|
||||||
|
<el-table-column label="ERP SKU ID" align="center" prop="erpGoodsSkuId" />
|
||||||
|
<!-- <el-table-column label="状态" align="center" prop="status" >-->
|
||||||
|
<!-- <template slot-scope="scope">-->
|
||||||
|
<!-- <el-tag size="small" v-if="scope.row.status === 1">销售中</el-tag>-->
|
||||||
|
<!-- <el-tag size="small" v-if="scope.row.status === 2">已下架</el-tag>-->
|
||||||
|
<!-- </template>-->
|
||||||
|
<!-- </el-table-column>-->
|
||||||
|
<!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">-->
|
||||||
|
<!-- <template slot-scope="scope">-->
|
||||||
|
<!-- <el-button-->
|
||||||
|
<!-- size="mini"-->
|
||||||
|
<!-- type="text"-->
|
||||||
|
<!-- icon="el-icon-share"-->
|
||||||
|
<!-- @click="handleLink(scope.row)"-->
|
||||||
|
<!-- >关联ERP</el-button>-->
|
||||||
|
<!-- </template>-->
|
||||||
|
<!-- </el-table-column>-->
|
||||||
|
</el-table>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
<!-- 添加或修改商品管理对话框 -->
|
<!-- 添加或修改商品管理对话框 -->
|
||||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||||
|
|
@ -134,7 +184,7 @@
|
||||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||||
|
|
||||||
import {listShop} from "@/api/shop/shop";
|
import {listShop} from "@/api/shop/shop";
|
||||||
import {pullGoodsList, listGoodsSku, getGoodsSku, linkErpGoodsSkuId} from "@/api/dou/goods";
|
import {pullGoodsList, listGoods, getGoodsSku, linkErpGoodsSkuId,pushToOms} from "@/api/dou/goods";
|
||||||
import {MessageBox} from "element-ui";
|
import {MessageBox} from "element-ui";
|
||||||
import {isRelogin} from "@/utils/request";
|
import {isRelogin} from "@/utils/request";
|
||||||
|
|
||||||
|
|
@ -153,6 +203,8 @@ export default {
|
||||||
// 显示搜索条件
|
// 显示搜索条件
|
||||||
showSearch: true,
|
showSearch: true,
|
||||||
pullLoading: false,
|
pullLoading: false,
|
||||||
|
skuList:[],
|
||||||
|
skuOpen:false,
|
||||||
// 总条数
|
// 总条数
|
||||||
total: 0,
|
total: 0,
|
||||||
// 商品管理表格数据
|
// 商品管理表格数据
|
||||||
|
|
@ -196,13 +248,22 @@ export default {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// 多选框选中数据
|
||||||
|
handleSelectionChange(selection) {
|
||||||
|
this.ids = selection.map(item => item.id)
|
||||||
|
this.single = selection.length!==1
|
||||||
|
this.multiple = !selection.length
|
||||||
|
},
|
||||||
amountFormatter(row, column, cellValue, index) {
|
amountFormatter(row, column, cellValue, index) {
|
||||||
|
if(!cellValue){
|
||||||
|
return "";
|
||||||
|
}
|
||||||
return '¥' + cellValue.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
|
return '¥' + cellValue.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
|
||||||
},
|
},
|
||||||
/** 查询商品管理列表 */
|
/** 查询商品管理列表 */
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
listGoodsSku(this.queryParams).then(response => {
|
listGoods(this.queryParams).then(response => {
|
||||||
this.goodsList = response.rows;
|
this.goodsList = response.rows;
|
||||||
this.total = response.total;
|
this.total = response.total;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
|
@ -282,7 +343,28 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
// this.$modal.msgSuccess("请先配置API");
|
// this.$modal.msgSuccess("请先配置API");
|
||||||
}
|
},
|
||||||
|
/** 查看SKU List*/
|
||||||
|
handleViewSkuList(row){
|
||||||
|
this.skuList = row.skuList
|
||||||
|
this.skuOpen = true;
|
||||||
|
|
||||||
|
},
|
||||||
|
handlePushOms(){
|
||||||
|
this.$confirm('确认同步所有商品到商品库吗?', '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
}).then(() => {
|
||||||
|
this.loading = true
|
||||||
|
pushToOms( this.ids ).then(response => {
|
||||||
|
this.$message.success('商品同步成功')
|
||||||
|
this.getList()
|
||||||
|
}).finally(() => {
|
||||||
|
this.loading = false
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -44,14 +44,23 @@
|
||||||
<el-row :gutter="10" class="mb8">
|
<el-row :gutter="10" class="mb8">
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
:loading="pullLoading"
|
type="primary"
|
||||||
type="success"
|
|
||||||
plain
|
plain
|
||||||
icon="el-icon-download"
|
icon="el-icon-refresh"
|
||||||
size="mini"
|
size="mini"
|
||||||
@click="handlePull"
|
@click="handleLinkOms"
|
||||||
>API拉取商品数据</el-button>
|
>一键关联商品库SKU</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
<!-- <el-col :span="1.5">-->
|
||||||
|
<!-- <el-button-->
|
||||||
|
<!-- :loading="pullLoading"-->
|
||||||
|
<!-- type="success"-->
|
||||||
|
<!-- plain-->
|
||||||
|
<!-- icon="el-icon-download"-->
|
||||||
|
<!-- size="mini"-->
|
||||||
|
<!-- @click="handlePull"-->
|
||||||
|
<!-- >API拉取商品数据</el-button>-->
|
||||||
|
<!-- </el-col>-->
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@
|
||||||
<el-table v-loading="loading" :data="goodsList" @selection-change="handleSelectionChange">
|
<el-table v-loading="loading" :data="goodsList" @selection-change="handleSelectionChange">
|
||||||
<el-table-column type="selection" width="55" align="center" />
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
<!-- <el-table-column label="ID" align="center" prop="id" />-->
|
<!-- <el-table-column label="ID" align="center" prop="id" />-->
|
||||||
<el-table-column label="商品ID" align="center" prop="goodsId" />
|
<el-table-column label="平台商品ID" align="center" prop="goodsId" />
|
||||||
<el-table-column label="图片" align="center" prop="logo" width="100">
|
<el-table-column label="图片" align="center" prop="logo" width="100">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<image-preview :src="scope.row.thumbUrl" :width="50" :height="50"/>
|
<image-preview :src="scope.row.thumbUrl" :width="50" :height="50"/>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue