完善京东订单消息

This commit is contained in:
Richie 2024-03-09 21:50:49 +08:00
parent ff32cc2737
commit 3008d26fe3
12 changed files with 1203 additions and 28 deletions

View File

@ -0,0 +1,528 @@
package com.qihang.jd.domain;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 商品规格库存管理
* @TableName o_goods_sku
*/
public class OGoodsSku implements Serializable {
/**
* 主键id
*/
private Long id;
/**
* 商品id
*/
private Long erpGoodsId;
/**
* skuId(唯一)
*/
private Long erpSkuId;
/**
* 规格名
*/
private String skuName;
/**
* 规格编码
*/
private String skuNum;
/**
* 颜色id
*/
private Integer colorId;
/**
* 颜色值
*/
private String colorValue;
/**
* 颜色图片
*/
private String colorImage;
/**
* 尺码id
*/
private Integer sizeId;
/**
* 尺码值
*/
private String sizeValue;
/**
* 款式id
*/
private Integer styleId;
/**
* 款式值
*/
private String styleValue;
/**
* 库存条形码
*/
private String barCode;
/**
* 预计采购价
*/
private BigDecimal purPrice;
/**
* 建议批发价
*/
private BigDecimal wholePrice;
/**
* 建议零售价
*/
private BigDecimal retailPrice;
/**
* 单位成本
*/
private BigDecimal unitCost;
/**
* 备注
*/
private String remark;
/**
* 状态
*/
private Integer status;
/**
* 最低库存预警
*/
private Integer lowQty;
/**
* 最高库存预警
*/
private Integer highQty;
/**
* 0启用 1禁用
*/
private Integer disable;
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
public Long getId() {
return id;
}
/**
* 主键id
*/
public void setId(Long id) {
this.id = id;
}
/**
* 商品id
*/
public Long getErpGoodsId() {
return erpGoodsId;
}
/**
* 商品id
*/
public void setErpGoodsId(Long erpGoodsId) {
this.erpGoodsId = erpGoodsId;
}
/**
* skuId(唯一)
*/
public Long getErpSkuId() {
return erpSkuId;
}
/**
* skuId(唯一)
*/
public void setErpSkuId(Long erpSkuId) {
this.erpSkuId = erpSkuId;
}
/**
* 规格名
*/
public String getSkuName() {
return skuName;
}
/**
* 规格名
*/
public void setSkuName(String skuName) {
this.skuName = skuName;
}
/**
* 规格编码
*/
public String getSkuNum() {
return skuNum;
}
/**
* 规格编码
*/
public void setSkuNum(String skuNum) {
this.skuNum = skuNum;
}
/**
* 颜色id
*/
public Integer getColorId() {
return colorId;
}
/**
* 颜色id
*/
public void setColorId(Integer colorId) {
this.colorId = colorId;
}
/**
* 颜色值
*/
public String getColorValue() {
return colorValue;
}
/**
* 颜色值
*/
public void setColorValue(String colorValue) {
this.colorValue = colorValue;
}
/**
* 颜色图片
*/
public String getColorImage() {
return colorImage;
}
/**
* 颜色图片
*/
public void setColorImage(String colorImage) {
this.colorImage = colorImage;
}
/**
* 尺码id
*/
public Integer getSizeId() {
return sizeId;
}
/**
* 尺码id
*/
public void setSizeId(Integer sizeId) {
this.sizeId = sizeId;
}
/**
* 尺码值
*/
public String getSizeValue() {
return sizeValue;
}
/**
* 尺码值
*/
public void setSizeValue(String sizeValue) {
this.sizeValue = sizeValue;
}
/**
* 款式id
*/
public Integer getStyleId() {
return styleId;
}
/**
* 款式id
*/
public void setStyleId(Integer styleId) {
this.styleId = styleId;
}
/**
* 款式值
*/
public String getStyleValue() {
return styleValue;
}
/**
* 款式值
*/
public void setStyleValue(String styleValue) {
this.styleValue = styleValue;
}
/**
* 库存条形码
*/
public String getBarCode() {
return barCode;
}
/**
* 库存条形码
*/
public void setBarCode(String barCode) {
this.barCode = barCode;
}
/**
* 预计采购价
*/
public BigDecimal getPurPrice() {
return purPrice;
}
/**
* 预计采购价
*/
public void setPurPrice(BigDecimal purPrice) {
this.purPrice = purPrice;
}
/**
* 建议批发价
*/
public BigDecimal getWholePrice() {
return wholePrice;
}
/**
* 建议批发价
*/
public void setWholePrice(BigDecimal wholePrice) {
this.wholePrice = wholePrice;
}
/**
* 建议零售价
*/
public BigDecimal getRetailPrice() {
return retailPrice;
}
/**
* 建议零售价
*/
public void setRetailPrice(BigDecimal retailPrice) {
this.retailPrice = retailPrice;
}
/**
* 单位成本
*/
public BigDecimal getUnitCost() {
return unitCost;
}
/**
* 单位成本
*/
public void setUnitCost(BigDecimal unitCost) {
this.unitCost = unitCost;
}
/**
* 备注
*/
public String getRemark() {
return remark;
}
/**
* 备注
*/
public void setRemark(String remark) {
this.remark = remark;
}
/**
* 状态
*/
public Integer getStatus() {
return status;
}
/**
* 状态
*/
public void setStatus(Integer status) {
this.status = status;
}
/**
* 最低库存预警
*/
public Integer getLowQty() {
return lowQty;
}
/**
* 最低库存预警
*/
public void setLowQty(Integer lowQty) {
this.lowQty = lowQty;
}
/**
* 最高库存预警
*/
public Integer getHighQty() {
return highQty;
}
/**
* 最高库存预警
*/
public void setHighQty(Integer highQty) {
this.highQty = highQty;
}
/**
* 0启用 1禁用
*/
public Integer getDisable() {
return disable;
}
/**
* 0启用 1禁用
*/
public void setDisable(Integer disable) {
this.disable = disable;
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
OGoodsSku other = (OGoodsSku) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getErpGoodsId() == null ? other.getErpGoodsId() == null : this.getErpGoodsId().equals(other.getErpGoodsId()))
&& (this.getErpSkuId() == null ? other.getErpSkuId() == null : this.getErpSkuId().equals(other.getErpSkuId()))
&& (this.getSkuName() == null ? other.getSkuName() == null : this.getSkuName().equals(other.getSkuName()))
&& (this.getSkuNum() == null ? other.getSkuNum() == null : this.getSkuNum().equals(other.getSkuNum()))
&& (this.getColorId() == null ? other.getColorId() == null : this.getColorId().equals(other.getColorId()))
&& (this.getColorValue() == null ? other.getColorValue() == null : this.getColorValue().equals(other.getColorValue()))
&& (this.getColorImage() == null ? other.getColorImage() == null : this.getColorImage().equals(other.getColorImage()))
&& (this.getSizeId() == null ? other.getSizeId() == null : this.getSizeId().equals(other.getSizeId()))
&& (this.getSizeValue() == null ? other.getSizeValue() == null : this.getSizeValue().equals(other.getSizeValue()))
&& (this.getStyleId() == null ? other.getStyleId() == null : this.getStyleId().equals(other.getStyleId()))
&& (this.getStyleValue() == null ? other.getStyleValue() == null : this.getStyleValue().equals(other.getStyleValue()))
&& (this.getBarCode() == null ? other.getBarCode() == null : this.getBarCode().equals(other.getBarCode()))
&& (this.getPurPrice() == null ? other.getPurPrice() == null : this.getPurPrice().equals(other.getPurPrice()))
&& (this.getWholePrice() == null ? other.getWholePrice() == null : this.getWholePrice().equals(other.getWholePrice()))
&& (this.getRetailPrice() == null ? other.getRetailPrice() == null : this.getRetailPrice().equals(other.getRetailPrice()))
&& (this.getUnitCost() == null ? other.getUnitCost() == null : this.getUnitCost().equals(other.getUnitCost()))
&& (this.getRemark() == null ? other.getRemark() == null : this.getRemark().equals(other.getRemark()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getLowQty() == null ? other.getLowQty() == null : this.getLowQty().equals(other.getLowQty()))
&& (this.getHighQty() == null ? other.getHighQty() == null : this.getHighQty().equals(other.getHighQty()))
&& (this.getDisable() == null ? other.getDisable() == null : this.getDisable().equals(other.getDisable()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getErpGoodsId() == null) ? 0 : getErpGoodsId().hashCode());
result = prime * result + ((getErpSkuId() == null) ? 0 : getErpSkuId().hashCode());
result = prime * result + ((getSkuName() == null) ? 0 : getSkuName().hashCode());
result = prime * result + ((getSkuNum() == null) ? 0 : getSkuNum().hashCode());
result = prime * result + ((getColorId() == null) ? 0 : getColorId().hashCode());
result = prime * result + ((getColorValue() == null) ? 0 : getColorValue().hashCode());
result = prime * result + ((getColorImage() == null) ? 0 : getColorImage().hashCode());
result = prime * result + ((getSizeId() == null) ? 0 : getSizeId().hashCode());
result = prime * result + ((getSizeValue() == null) ? 0 : getSizeValue().hashCode());
result = prime * result + ((getStyleId() == null) ? 0 : getStyleId().hashCode());
result = prime * result + ((getStyleValue() == null) ? 0 : getStyleValue().hashCode());
result = prime * result + ((getBarCode() == null) ? 0 : getBarCode().hashCode());
result = prime * result + ((getPurPrice() == null) ? 0 : getPurPrice().hashCode());
result = prime * result + ((getWholePrice() == null) ? 0 : getWholePrice().hashCode());
result = prime * result + ((getRetailPrice() == null) ? 0 : getRetailPrice().hashCode());
result = prime * result + ((getUnitCost() == null) ? 0 : getUnitCost().hashCode());
result = prime * result + ((getRemark() == null) ? 0 : getRemark().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getLowQty() == null) ? 0 : getLowQty().hashCode());
result = prime * result + ((getHighQty() == null) ? 0 : getHighQty().hashCode());
result = prime * result + ((getDisable() == null) ? 0 : getDisable().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", erpGoodsId=").append(erpGoodsId);
sb.append(", erpSkuId=").append(erpSkuId);
sb.append(", skuName=").append(skuName);
sb.append(", skuNum=").append(skuNum);
sb.append(", colorId=").append(colorId);
sb.append(", colorValue=").append(colorValue);
sb.append(", colorImage=").append(colorImage);
sb.append(", sizeId=").append(sizeId);
sb.append(", sizeValue=").append(sizeValue);
sb.append(", styleId=").append(styleId);
sb.append(", styleValue=").append(styleValue);
sb.append(", barCode=").append(barCode);
sb.append(", purPrice=").append(purPrice);
sb.append(", wholePrice=").append(wholePrice);
sb.append(", retailPrice=").append(retailPrice);
sb.append(", unitCost=").append(unitCost);
sb.append(", remark=").append(remark);
sb.append(", status=").append(status);
sb.append(", lowQty=").append(lowQty);
sb.append(", highQty=").append(highQty);
sb.append(", disable=").append(disable);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

View File

@ -0,0 +1,18 @@
package com.qihang.jd.mapper;
import com.qihang.jd.domain.OGoodsSku;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author qilip
* @description 针对表o_goods_sku(商品规格库存管理)的数据库操作Mapper
* @createDate 2024-03-09 21:11:40
* @Entity com.qihang.jd.domain.OGoodsSku
*/
public interface OGoodsSkuMapper extends BaseMapper<OGoodsSku> {
}

View File

@ -0,0 +1,13 @@
package com.qihang.jd.service;
import com.qihang.jd.domain.OGoodsSku;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author qilip
* @description 针对表o_goods_sku(商品规格库存管理)的数据库操作Service
* @createDate 2024-03-09 21:11:40
*/
public interface OGoodsSkuService extends IService<OGoodsSku> {
}

View File

@ -4,9 +4,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qihang.common.common.ResultVo; import com.qihang.common.common.ResultVo;
import com.qihang.common.common.ResultVoEnum; import com.qihang.common.common.ResultVoEnum;
import com.qihang.common.utils.StringUtils;
import com.qihang.jd.domain.JdGoods; import com.qihang.jd.domain.JdGoods;
import com.qihang.jd.domain.JdGoodsSku; import com.qihang.jd.domain.JdGoodsSku;
import com.qihang.jd.domain.OGoodsSku;
import com.qihang.jd.mapper.JdGoodsSkuMapper; import com.qihang.jd.mapper.JdGoodsSkuMapper;
import com.qihang.jd.mapper.OGoodsSkuMapper;
import com.qihang.jd.service.JdGoodsService; import com.qihang.jd.service.JdGoodsService;
import com.qihang.jd.mapper.JdGoodsMapper; import com.qihang.jd.mapper.JdGoodsMapper;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -26,6 +29,7 @@ public class JdGoodsServiceImpl extends ServiceImpl<JdGoodsMapper, JdGoods>
implements JdGoodsService{ implements JdGoodsService{
private final JdGoodsMapper mapper; private final JdGoodsMapper mapper;
private final JdGoodsSkuMapper skuMapper; private final JdGoodsSkuMapper skuMapper;
private final OGoodsSkuMapper goodsSkuMapper;
@Transactional @Transactional
@Override @Override
public ResultVo<Integer> saveGoods(Integer shopId, JdGoods goods) { public ResultVo<Integer> saveGoods(Integer shopId, JdGoods goods) {
@ -34,13 +38,6 @@ public class JdGoodsServiceImpl extends ServiceImpl<JdGoodsMapper, JdGoods>
// 新增 // 新增
goods.setShopId(shopId); goods.setShopId(shopId);
mapper.insert(goods); mapper.insert(goods);
// 添加sku
if(goods.getSkuList()!=null && !goods.getSkuList().isEmpty()){
for (var item : goods.getSkuList()){
item.setGoodsId(goods.getId());
skuMapper.insert(item);
}
}
}else{ }else{
// 修改 // 修改
goods.setId(jdGoods.get(0).getId()); goods.setId(jdGoods.get(0).getId());
@ -48,15 +45,23 @@ public class JdGoodsServiceImpl extends ServiceImpl<JdGoodsMapper, JdGoods>
mapper.updateById(goods); mapper.updateById(goods);
// 删除sku // 删除sku
skuMapper.delete(new LambdaQueryWrapper<JdGoodsSku>().eq(JdGoodsSku::getGoodsId,goods.getId())); skuMapper.delete(new LambdaQueryWrapper<JdGoodsSku>().eq(JdGoodsSku::getGoodsId,goods.getId()));
}
// 添加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()){
item.setGoodsId(goods.getId()); item.setGoodsId(goods.getId());
// 根据OuterId查找ERP系统中的skuid
if(StringUtils.isNotEmpty(item.getOuterId())) {
List<OGoodsSku> oGoodsSkus = goodsSkuMapper.selectList(new LambdaQueryWrapper<OGoodsSku>().eq(OGoodsSku::getSkuNum, item.getOuterId()));
if(oGoodsSkus!=null && !oGoodsSkus.isEmpty()){
item.setErpGoodsId(oGoodsSkus.get(0).getErpGoodsId());
item.setErpSkuId(oGoodsSkus.get(0).getErpSkuId());
}
}
skuMapper.insert(item); skuMapper.insert(item);
} }
} }
}
return new ResultVo<>(ResultVoEnum.SUCCESS); return new ResultVo<>(ResultVoEnum.SUCCESS);
} }
} }

View File

@ -0,0 +1,22 @@
package com.qihang.jd.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qihang.jd.domain.OGoodsSku;
import com.qihang.jd.service.OGoodsSkuService;
import com.qihang.jd.mapper.OGoodsSkuMapper;
import org.springframework.stereotype.Service;
/**
* @author qilip
* @description 针对表o_goods_sku(商品规格库存管理)的数据库操作Service实现
* @createDate 2024-03-09 21:11:40
*/
@Service
public class OGoodsSkuServiceImpl extends ServiceImpl<OGoodsSkuMapper, OGoodsSku>
implements OGoodsSkuService{
}

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qihang.jd.mapper.OGoodsSkuMapper">
<resultMap id="BaseResultMap" type="com.qihang.jd.domain.OGoodsSku">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="erpGoodsId" column="erp_goods_id" jdbcType="BIGINT"/>
<result property="erpSkuId" column="erp_sku_id" jdbcType="BIGINT"/>
<result property="skuName" column="sku_name" jdbcType="VARCHAR"/>
<result property="skuNum" column="sku_num" jdbcType="VARCHAR"/>
<result property="colorId" column="color_id" jdbcType="INTEGER"/>
<result property="colorValue" column="color_value" jdbcType="VARCHAR"/>
<result property="colorImage" column="color_image" jdbcType="VARCHAR"/>
<result property="sizeId" column="size_id" jdbcType="INTEGER"/>
<result property="sizeValue" column="size_value" jdbcType="VARCHAR"/>
<result property="styleId" column="style_id" jdbcType="INTEGER"/>
<result property="styleValue" column="style_value" jdbcType="VARCHAR"/>
<result property="barCode" column="bar_code" jdbcType="VARCHAR"/>
<result property="purPrice" column="pur_price" jdbcType="DECIMAL"/>
<result property="wholePrice" column="whole_price" jdbcType="DECIMAL"/>
<result property="retailPrice" column="retail_price" jdbcType="DECIMAL"/>
<result property="unitCost" column="unit_cost" jdbcType="DECIMAL"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="TINYINT"/>
<result property="lowQty" column="low_qty" jdbcType="INTEGER"/>
<result property="highQty" column="high_qty" jdbcType="INTEGER"/>
<result property="disable" column="disable" jdbcType="TINYINT"/>
</resultMap>
<sql id="Base_Column_List">
id,erp_goods_id,erp_sku_id,
sku_name,sku_num,color_id,
color_value,color_image,size_id,
size_value,style_id,style_value,
bar_code,pur_price,whole_price,
retail_price,unit_cost,remark,
status,low_qty,high_qty,
disable
</sql>
</mapper>

View File

@ -0,0 +1,419 @@
package com.qihang.sys.api.domain;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
*
* @TableName jd_goods_sku
*/
public class JdGoodsSku implements Serializable {
/**
*
*/
private Long id;
/**
* 外键jd_goods表id
*/
private Long goodsId;
/**
*
*/
private Long wareId;
/**
*
*/
private Long skuId;
/**
*
*/
private Integer status;
/**
*
*/
private BigDecimal jdPrice;
/**
*
*/
private String outerId;
/**
*
*/
private String barCode;
/**
*
*/
private String logo;
/**
*
*/
private String saleAttrs;
/**
*
*/
private String skuName;
/**
*
*/
private Integer stockNum;
/**
*
*/
private Date modified;
/**
*
*/
private Date created;
/**
*
*/
private String currencySpuId;
/**
* erp商品id
*/
private Long erpGoodsId;
/**
* erp商品sku id
*/
private Long erpSkuId;
private static final long serialVersionUID = 1L;
/**
*
*/
public Long getId() {
return id;
}
/**
*
*/
public void setId(Long id) {
this.id = id;
}
/**
* 外键jd_goods表id
*/
public Long getGoodsId() {
return goodsId;
}
/**
* 外键jd_goods表id
*/
public void setGoodsId(Long goodsId) {
this.goodsId = goodsId;
}
/**
*
*/
public Long getWareId() {
return wareId;
}
/**
*
*/
public void setWareId(Long wareId) {
this.wareId = wareId;
}
/**
*
*/
public Long getSkuId() {
return skuId;
}
/**
*
*/
public void setSkuId(Long skuId) {
this.skuId = skuId;
}
/**
*
*/
public Integer getStatus() {
return status;
}
/**
*
*/
public void setStatus(Integer status) {
this.status = status;
}
/**
*
*/
public BigDecimal getJdPrice() {
return jdPrice;
}
/**
*
*/
public void setJdPrice(BigDecimal jdPrice) {
this.jdPrice = jdPrice;
}
/**
*
*/
public String getOuterId() {
return outerId;
}
/**
*
*/
public void setOuterId(String outerId) {
this.outerId = outerId;
}
/**
*
*/
public String getBarCode() {
return barCode;
}
/**
*
*/
public void setBarCode(String barCode) {
this.barCode = barCode;
}
/**
*
*/
public String getLogo() {
return logo;
}
/**
*
*/
public void setLogo(String logo) {
this.logo = logo;
}
/**
*
*/
public String getSaleAttrs() {
return saleAttrs;
}
/**
*
*/
public void setSaleAttrs(String saleAttrs) {
this.saleAttrs = saleAttrs;
}
/**
*
*/
public String getSkuName() {
return skuName;
}
/**
*
*/
public void setSkuName(String skuName) {
this.skuName = skuName;
}
/**
*
*/
public Integer getStockNum() {
return stockNum;
}
/**
*
*/
public void setStockNum(Integer stockNum) {
this.stockNum = stockNum;
}
/**
*
*/
public Date getModified() {
return modified;
}
/**
*
*/
public void setModified(Date modified) {
this.modified = modified;
}
/**
*
*/
public Date getCreated() {
return created;
}
/**
*
*/
public void setCreated(Date created) {
this.created = created;
}
/**
*
*/
public String getCurrencySpuId() {
return currencySpuId;
}
/**
*
*/
public void setCurrencySpuId(String currencySpuId) {
this.currencySpuId = currencySpuId;
}
/**
* erp商品id
*/
public Long getErpGoodsId() {
return erpGoodsId;
}
/**
* erp商品id
*/
public void setErpGoodsId(Long erpGoodsId) {
this.erpGoodsId = erpGoodsId;
}
/**
* erp商品sku id
*/
public Long getErpSkuId() {
return erpSkuId;
}
/**
* erp商品sku id
*/
public void setErpSkuId(Long erpSkuId) {
this.erpSkuId = erpSkuId;
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
JdGoodsSku other = (JdGoodsSku) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getGoodsId() == null ? other.getGoodsId() == null : this.getGoodsId().equals(other.getGoodsId()))
&& (this.getWareId() == null ? other.getWareId() == null : this.getWareId().equals(other.getWareId()))
&& (this.getSkuId() == null ? other.getSkuId() == null : this.getSkuId().equals(other.getSkuId()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getJdPrice() == null ? other.getJdPrice() == null : this.getJdPrice().equals(other.getJdPrice()))
&& (this.getOuterId() == null ? other.getOuterId() == null : this.getOuterId().equals(other.getOuterId()))
&& (this.getBarCode() == null ? other.getBarCode() == null : this.getBarCode().equals(other.getBarCode()))
&& (this.getLogo() == null ? other.getLogo() == null : this.getLogo().equals(other.getLogo()))
&& (this.getSaleAttrs() == null ? other.getSaleAttrs() == null : this.getSaleAttrs().equals(other.getSaleAttrs()))
&& (this.getSkuName() == null ? other.getSkuName() == null : this.getSkuName().equals(other.getSkuName()))
&& (this.getStockNum() == null ? other.getStockNum() == null : this.getStockNum().equals(other.getStockNum()))
&& (this.getModified() == null ? other.getModified() == null : this.getModified().equals(other.getModified()))
&& (this.getCreated() == null ? other.getCreated() == null : this.getCreated().equals(other.getCreated()))
&& (this.getCurrencySpuId() == null ? other.getCurrencySpuId() == null : this.getCurrencySpuId().equals(other.getCurrencySpuId()))
&& (this.getErpGoodsId() == null ? other.getErpGoodsId() == null : this.getErpGoodsId().equals(other.getErpGoodsId()))
&& (this.getErpSkuId() == null ? other.getErpSkuId() == null : this.getErpSkuId().equals(other.getErpSkuId()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getGoodsId() == null) ? 0 : getGoodsId().hashCode());
result = prime * result + ((getWareId() == null) ? 0 : getWareId().hashCode());
result = prime * result + ((getSkuId() == null) ? 0 : getSkuId().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getJdPrice() == null) ? 0 : getJdPrice().hashCode());
result = prime * result + ((getOuterId() == null) ? 0 : getOuterId().hashCode());
result = prime * result + ((getBarCode() == null) ? 0 : getBarCode().hashCode());
result = prime * result + ((getLogo() == null) ? 0 : getLogo().hashCode());
result = prime * result + ((getSaleAttrs() == null) ? 0 : getSaleAttrs().hashCode());
result = prime * result + ((getSkuName() == null) ? 0 : getSkuName().hashCode());
result = prime * result + ((getStockNum() == null) ? 0 : getStockNum().hashCode());
result = prime * result + ((getModified() == null) ? 0 : getModified().hashCode());
result = prime * result + ((getCreated() == null) ? 0 : getCreated().hashCode());
result = prime * result + ((getCurrencySpuId() == null) ? 0 : getCurrencySpuId().hashCode());
result = prime * result + ((getErpGoodsId() == null) ? 0 : getErpGoodsId().hashCode());
result = prime * result + ((getErpSkuId() == null) ? 0 : getErpSkuId().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", goodsId=").append(goodsId);
sb.append(", wareId=").append(wareId);
sb.append(", skuId=").append(skuId);
sb.append(", status=").append(status);
sb.append(", jdPrice=").append(jdPrice);
sb.append(", outerId=").append(outerId);
sb.append(", barCode=").append(barCode);
sb.append(", logo=").append(logo);
sb.append(", saleAttrs=").append(saleAttrs);
sb.append(", skuName=").append(skuName);
sb.append(", stockNum=").append(stockNum);
sb.append(", modified=").append(modified);
sb.append(", created=").append(created);
sb.append(", currencySpuId=").append(currencySpuId);
sb.append(", erpGoodsId=").append(erpGoodsId);
sb.append(", erpSkuId=").append(erpSkuId);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

View File

@ -0,0 +1,18 @@
package com.qihang.sys.api.mapper;
import com.qihang.sys.api.domain.JdGoodsSku;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author qilip
* @description 针对表jd_goods_sku的数据库操作Mapper
* @createDate 2024-03-09 21:19:02
* @Entity com.qihang.sys.api.domain.JdGoodsSku
*/
public interface JdGoodsSkuMapper extends BaseMapper<JdGoodsSku> {
}

View File

@ -0,0 +1,13 @@
package com.qihang.sys.api.service;
import com.qihang.sys.api.domain.JdGoodsSku;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author qilip
* @description 针对表jd_goods_sku的数据库操作Service
* @createDate 2024-03-09 21:19:02
*/
public interface JdGoodsSkuService extends IService<JdGoodsSku> {
}

View File

@ -0,0 +1,22 @@
package com.qihang.sys.api.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qihang.sys.api.domain.JdGoodsSku;
import com.qihang.sys.api.service.JdGoodsSkuService;
import com.qihang.sys.api.mapper.JdGoodsSkuMapper;
import org.springframework.stereotype.Service;
/**
* @author qilip
* @description 针对表jd_goods_sku的数据库操作Service实现
* @createDate 2024-03-09 21:19:02
*/
@Service
public class JdGoodsSkuServiceImpl extends ServiceImpl<JdGoodsSkuMapper, JdGoodsSku>
implements JdGoodsSkuService{
}

View File

@ -9,18 +9,13 @@ import com.qihang.common.enums.EnumShopType;
import com.qihang.common.enums.JdOrderStateEnum; import com.qihang.common.enums.JdOrderStateEnum;
import com.qihang.common.utils.DateUtils; import com.qihang.common.utils.DateUtils;
import com.qihang.common.utils.StringUtils; import com.qihang.common.utils.StringUtils;
import com.qihang.sys.api.domain.JdOrder; import com.qihang.sys.api.domain.*;
import com.qihang.sys.api.domain.JdOrderItem; import com.qihang.sys.api.mapper.*;
import com.qihang.sys.api.domain.OOrder;
import com.qihang.sys.api.domain.OOrderItem;
import com.qihang.sys.api.mapper.JdOrderItemMapper;
import com.qihang.sys.api.mapper.JdOrderMapper;
import com.qihang.sys.api.mapper.OOrderItemMapper;
import com.qihang.sys.api.service.OOrderService; import com.qihang.sys.api.service.OOrderService;
import com.qihang.sys.api.mapper.OOrderMapper;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.java.Log; import lombok.extern.java.Log;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -40,9 +35,10 @@ public class OOrderServiceImpl extends ServiceImpl<OOrderMapper, OOrder>
private final OOrderItemMapper orderItemMapper; private final OOrderItemMapper orderItemMapper;
private final JdOrderMapper jdOrderMapper; private final JdOrderMapper jdOrderMapper;
private final JdOrderItemMapper jdOrderItemMapper; private final JdOrderItemMapper jdOrderItemMapper;
private final JdGoodsSkuMapper jdGoodsSkuMapper;
@Transactional
@Override @Override
public ResultVo<Integer> jdOrderMessage(String orderId) { public ResultVo<Integer> jdOrderMessage(String orderId) {
System.out.println("京东订单消息处理");
log.info("京东订单消息处理"+orderId); log.info("京东订单消息处理"+orderId);
List<JdOrder> jdOrders = jdOrderMapper.selectList(new LambdaQueryWrapper<JdOrder>().eq(JdOrder::getOrderId, orderId)); List<JdOrder> jdOrders = jdOrderMapper.selectList(new LambdaQueryWrapper<JdOrder>().eq(JdOrder::getOrderId, orderId));
if(jdOrders == null || jdOrders.size() == 0) { if(jdOrders == null || jdOrders.size() == 0) {
@ -52,9 +48,8 @@ public class OOrderServiceImpl extends ServiceImpl<OOrderMapper, OOrder>
JdOrder jdOrder = jdOrders.get(0); JdOrder jdOrder = jdOrders.get(0);
List<OOrder> oOrders = orderMapper.selectList(new LambdaQueryWrapper<OOrder>().eq(OOrder::getOrderNum, orderId)); List<OOrder> oOrders = orderMapper.selectList(new LambdaQueryWrapper<OOrder>().eq(OOrder::getOrderNum, orderId));
if(oOrders == null || oOrders.size() == 0) { if(oOrders == null || oOrders.isEmpty()) {
// 新增订单 // 新增订单
OOrder insert = new OOrder(); OOrder insert = new OOrder();
insert.setOrderNum(orderId); insert.setOrderNum(orderId);
insert.setShopType(EnumShopType.JD.getIndex()); insert.setShopType(EnumShopType.JD.getIndex());
@ -85,18 +80,63 @@ public class OOrderServiceImpl extends ServiceImpl<OOrderMapper, OOrder>
insert.setShipType(0); insert.setShipType(0);
insert.setCreateTime(new Date()); insert.setCreateTime(new Date());
insert.setCreateBy("ORDER_MESSAGE"); insert.setCreateBy("ORDER_MESSAGE");
// orderMapper.insert(insert); orderMapper.insert(insert);
List<JdOrderItem> jdOrderItems = jdOrderItemMapper.selectList(new LambdaQueryWrapper<JdOrderItem>().eq(JdOrderItem::getOrderId, jdOrder.getId())); List<JdOrderItem> jdOrderItems = jdOrderItemMapper.selectList(new LambdaQueryWrapper<JdOrderItem>().eq(JdOrderItem::getOrderId, jdOrder.getId()));
if(jdOrderItems!=null && jdOrderItems.size()>0) { if(jdOrderItems!=null && jdOrderItems.size()>0) {
for (var item : jdOrderItems){ for (var item : jdOrderItems) {
OOrderItem orderItem = new OOrderItem(); OOrderItem orderItem = new OOrderItem();
orderItem.setOrderId(insert.getId()); orderItem.setOrderId(insert.getId());
// TODO这里将订单商品skuid转换成erp系统的skuid // TODO这里将订单商品skuid转换成erp系统的skuid
Long erpGoodsId = 0L;
Long erpSkuId = 0L;
List<JdGoodsSku> jdGoodsSkus = jdGoodsSkuMapper.selectList(new LambdaQueryWrapper<JdGoodsSku>().eq(JdGoodsSku::getSkuId, item.getSkuId()));
if (jdGoodsSkus != null && !jdGoodsSkus.isEmpty()) {
erpGoodsId = jdGoodsSkus.get(0).getErpGoodsId();
erpSkuId = jdGoodsSkus.get(0).getErpSkuId();
orderItem.setGoodsImg(jdGoodsSkus.get(0).getLogo());
orderItem.setGoodsSpec(jdGoodsSkus.get(0).getSkuName());
orderItem.setSkuNum(jdGoodsSkus.get(0).getOuterId());
}
orderItem.setGoodsId(erpGoodsId);
orderItem.setSkuId(erpSkuId);
orderItem.setGoodsTitle(item.getSkuName());
orderItem.setGoodsPrice(StringUtils.isEmpty(item.getJdPrice())?0.0:Double.parseDouble(item.getJdPrice()));
Integer quantity = StringUtils.isEmpty(item.getItemTotal())?0: Integer.parseInt(item.getItemTotal());
orderItem.setItemAmount(orderItem.getGoodsPrice() *quantity);
orderItem.setQuantity(quantity);
if(orderStatus == 11){
orderItem.setRefundStatus(2);
orderItem.setRefundCount(quantity);
}else if (orderStatus == -1) {
}else{
orderItem.setRefundStatus(1);
orderItem.setRefundCount(0);
}
orderItem.setCreateTime(new Date());
orderItem.setCreateBy("ORDER_MESSAGE");
orderItemMapper.insert(orderItem);
} }
} }
}else{ }else{
// 修改订单 // 修改订单 (修改)
OOrder update = new OOrder();
update.setId(oOrders.get(0).getId());
// 状态
int orderStatus = JdOrderStateEnum.getIndex(jdOrder.getOrderState());
if (orderStatus == 11) {
update.setRefundStatus(2);
} else if (orderStatus == -1) {
update.setRefundStatus(-1);
} else {
update.setRefundStatus(1);
}
update.setOrderStatus(orderStatus);
update.setUpdateTime(new Date());
update.setUpdateBy("ORDER_MESSAGE");
orderMapper.updateById(update);
} }
return null; return null;
} }

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qihang.sys.api.mapper.JdGoodsSkuMapper">
<resultMap id="BaseResultMap" type="com.qihang.sys.api.domain.JdGoodsSku">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="goodsId" column="goods_id" jdbcType="BIGINT"/>
<result property="wareId" column="ware_id" jdbcType="BIGINT"/>
<result property="skuId" column="sku_id" jdbcType="BIGINT"/>
<result property="status" column="status" jdbcType="INTEGER"/>
<result property="jdPrice" column="jd_price" jdbcType="DECIMAL"/>
<result property="outerId" column="outer_id" jdbcType="VARCHAR"/>
<result property="barCode" column="bar_code" jdbcType="VARCHAR"/>
<result property="logo" column="logo" jdbcType="VARCHAR"/>
<result property="saleAttrs" column="sale_attrs" jdbcType="VARCHAR"/>
<result property="skuName" column="sku_name" jdbcType="VARCHAR"/>
<result property="stockNum" column="stock_num" jdbcType="INTEGER"/>
<result property="modified" column="modified" jdbcType="TIMESTAMP"/>
<result property="created" column="created" jdbcType="TIMESTAMP"/>
<result property="currencySpuId" column="currency_spu_id" jdbcType="VARCHAR"/>
<result property="erpGoodsId" column="erp_goods_id" jdbcType="BIGINT"/>
<result property="erpSkuId" column="erp_sku_id" jdbcType="BIGINT"/>
</resultMap>
<sql id="Base_Column_List">
id,goods_id,ware_id,
sku_id,status,jd_price,
outer_id,bar_code,logo,
sale_attrs,sku_name,stock_num,
modified,created,currency_spu_id,
erp_goods_id,erp_sku_id
</sql>
</mapper>