package com.qckj.amz.controller;
import com.alibaba.fastjson.JSONArray;
import com.qckj.amz.dao.ProductTempBasicDao;
import com.qckj.amz.dao.ProductTempDescDao;
import com.qckj.amz.dao.ProductTempRlatDao;
import com.qckj.amz.domain.ProductTempBasic;
import com.qckj.amz.domain.ProductTempDesc;
import com.qckj.amz.domain.ProductTempRlat;
import com.qckj.amz.domain.temp.GoodsExportExcelEntity;
import com.qckj.amz.utils.constants.AmzConstants;
import com.qckj.amz.utils.enums.EnumAmzDictCode;
import com.qckj.common.core.domain.AjaxResult;
import com.qckj.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @author luchuan
* @version v1.0
* @date 2022/12/23 0023
**/
@RestController
@RequestMapping("/amz/restfulapi")
public class ProductImportController {
@Autowired
private ProductTempBasicDao productTempBasicDao;
@Autowired
private ProductTempRlatDao productTempRlatDao;
@Autowired
private ProductTempDescDao productTempDescDao;
/*
@RequestMapping(value = "/import", method = RequestMethod.POST)
public AjaxResult export(@RequestParam(name = "goodsExcelsList") String goodsExcelsList
,@RequestParam(name = "createBy") String createBy
,@RequestParam(name = "database") String database) {
*/
@RequestMapping(value = "/import", method = RequestMethod.POST)
public AjaxResult export(@RequestBody String goodsExcelsList) {
String database = "HO";
String createBy = "QC001";
//公共属性
String batchNo = database+"-"+ DateUtils.dateTimeNow();//批次号
Date createTime = new Date();
//开始数据处理
List<GoodsExportExcelEntity> goodsList = JSONArray.parseArray(goodsExcelsList, GoodsExportExcelEntity.class);
if (goodsList!=null && goodsList.size()>0){
ArrayList<ProductTempBasic> basicList = new ArrayList<>();
ArrayList<ProductTempRlat> rlatList = new ArrayList<>();
ArrayList<ProductTempDesc> descList = new ArrayList<>();
for (GoodsExportExcelEntity goods: goodsList) {
System.out.println("new_sku=="+database+"-"+goods.getSku());
//校验是否已经存在
ProductTempBasic basicReq = new ProductTempBasic();
basicReq.setProductCode(database+"-"+goods.getSku());//可能会重复-后期可追加字符
Example<ProductTempBasic> basicExample = Example.of(basicReq);
ProductTempBasic productTempBasic = productTempBasicDao.findOne(basicExample).orElse(null);
if (productTempBasic!=null){
continue;//当前产品已经存在,直接跳过
}
//有变体:parentChild:parent-child
//无变体:parentChild:null
if (goods.getParentChild()==null || goods.getParentChild().equals("Parent")){
//基本信息
ProductTempBasic basic = new ProductTempBasic();
basic.setProductCode(database+"-"+goods.getSku());//可能会重复-后期可追加字符
basic.setBatchNo(batchNo);
basic.setProductCategory("unknown");//产品分类
basic.setStandardPriceCoefficient(new BigDecimal(0.95));//销售价格系数
basic.setProductSourceType(database);//产品来源:HO
basic.setBuyingLink("");//采购链接
basic.setBuyingPrice(new BigDecimal(0));//采购价格
basic.setProductSharingType("1");//共享类型:1不共享
basic.setIsCommissionType("");//是否佣金
basic.setCommissionRate(null);//佣金率
basic.setProductStatus("01111");
basic.setMainImageUrl(goods.getMainPic());
basic.setCreateBy(createBy);
basic.setCreateTime(createTime);
basicList.add(basic);
//变体
ProductTempRlat rlat = new ProductTempRlat();
rlat.setProductCode(database+"-"+goods.getSku());
rlat.setItemSku(database+"-"+goods.getSku());
rlat.setParentSku(null);//父体sku为null
rlat.setExternalProductId("");//EAN值/父体为null
rlat.setExternalProductIdType("");//EAN/父体为null
if (goods.getParentChild()==null){
rlat.setParentChild(null);
}else {
rlat.setParentChild(AmzConstants.PARENTAGE_PARENT);
}
rlat.setRelationshipType(null);//关系类型/父体为null
rlat.setVariationTheme(goods.getVariantTheme());
rlat.setColorName(goods.getColor());
rlat.setSizeName(goods.getSize());
rlat.setItemWeight(Double.parseDouble(goods.getWeight()));
rlat.setStandardPrice(new BigDecimal(goods.getPrice()));
rlat.setQuantity(Integer.parseInt(goods.getStock()));
rlat.setMainImageUrl(goods.getMainPic());
rlat.setOtherImageUrl1(goods.getPic1());
rlat.setOtherImageUrl2(goods.getPic2());
rlat.setOtherImageUrl3(goods.getPic3());
rlat.setOtherImageUrl4(goods.getPic4());
rlat.setOtherImageUrl5(goods.getPic5());
rlat.setOtherImageUrl6(goods.getPic6());
rlat.setOtherImageUrl7(goods.getPic7());
rlat.setOtherImageUrl8(goods.getPic8());
rlat.setCreateBy(createBy);
rlat.setCreateTime(createTime);
rlatList.add(rlat);
//描述
//英国-英语
ProductTempDesc descUK = new ProductTempDesc();
descUK.setProductCode(database+"-"+goods.getSku());
descUK.setCountryCode(EnumAmzDictCode.COUNTRYCODE_UK.getCode());//英国
descUK.setLanguageCode(EnumAmzDictCode.COUNTRYCODE_UK.getDesc());
descUK.setMarketspacePriceCoefficient(new BigDecimal(1));
descUK.setItemName(goods.getEnTitle());
descUK.setGenericKeywords(goods.getEnKey());
descUK.setBulletPoint1(goods.getEnKeyPoints1());
descUK.setBulletPoint2(goods.getEnKeyPoints2());
descUK.setBulletPoint3(goods.getEnKeyPoints3());
descUK.setBulletPoint4(goods.getEnKeyPoints4());
descUK.setBulletPoint5(goods.getEnKeyPoints5());
String productDescriptionUK = "";
productDescriptionUK += goods.getEnDescr1() == null ? "" : goods.getEnDescr1()+"\n";
productDescriptionUK += goods.getEnDescr2() == null ? "" : goods.getEnDescr2()+"\n";
productDescriptionUK += goods.getEnDescr3() == null ? "" : goods.getEnDescr3()+"\n";
productDescriptionUK += goods.getEnDescr4() == null ? "" : goods.getEnDescr4()+"\n";
productDescriptionUK += goods.getEnDescr5() == null ? "" : goods.getEnDescr5()+"\n";
productDescriptionUK += goods.getEnDescr6() == null ? "" : goods.getEnDescr6()+"\n";
productDescriptionUK += goods.getEnDescr7() == null ? "" : goods.getEnDescr7()+"\n";
productDescriptionUK += goods.getEnDescr8() == null ? "" : goods.getEnDescr8()+"\n";
productDescriptionUK += goods.getEnDescr9() == nu
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Amazon为了更好地管理日常运营活动,提高工作效率,侨川ERP系统实现了SpApi接口对接、商品制作、商品库存、订单处理、财务管理、供应链等方面的业务。
资源推荐
资源详情
资源评论
收起资源包目录
侨川科技QCKJ-ERP系统主要实现用户产品共享,可自己设置佣金抽成,供所有用户实现快速铺货模式,当然也可以不共享,专业做精品 (757个子文件)
run.bat 218B
package.bat 153B
package.bat 141B
build.bat 109B
run-web.bat 99B
clean.bat 92B
.env.development 161B
dockerfile 518B
dockerfile 242B
.editorconfig 514B
.eslintignore 298B
401.gif 160KB
.gitignore 638B
.gitignore 256B
index.html 5KB
favicon.ico 6KB
ProductImportController.java 52KB
ExcelUtil.java 32KB
GoodsExportExcelEntity.java 28KB
Convert.java 24KB
HTMLFilter.java 19KB
UploadFeedsServiceImpl.java 19KB
GenTableServiceImpl.java 17KB
SysUserServiceImpl.java 15KB
UUID.java 15KB
ReflectUtils.java 14KB
StringUtils.java 14KB
SysMenuServiceImpl.java 14KB
SysMenuDaoCustomImpl.java 14KB
SysRoleServiceImpl.java 12KB
ProductTempBasicController.java 11KB
VelocityUtils.java 10KB
SysJobServiceImpl.java 10KB
SysUser.java 9KB
SysDeptServiceImpl.java 9KB
SysConfigServiceImpl.java 9KB
Base64.java 9KB
GenTableColumn.java 9KB
HttpUtils.java 9KB
CreateProductImageFeedXml.java 9KB
SysDictTypeServiceImpl.java 9KB
PinYin4jUtils.java 9KB
GenTable.java 8KB
TestCreateXml.java 8KB
ProductTempExport.java 8KB
ProductFmlBasicController.java 8KB
GenUtils.java 7KB
SysRole.java 7KB
ProductFmlRlatController.java 7KB
FileUploadUtils.java 7KB
ConfigProductTittle.java 7KB
SysUserController.java 7KB
GenController.java 7KB
SysPostServiceImpl.java 7KB
LogAspect.java 7KB
ProductTempRlatController.java 7KB
RowMapperUtils.java 7KB
VerifyCodeUtils.java 7KB
CreateProductFeedXml.java 7KB
ProductTempDescController.java 6KB
ProductFmlDescController.java 6KB
Server.java 6KB
AmzHttpUtils.java 6KB
SecurityConfig.java 6KB
SysRoleController.java 6KB
TokenService.java 6KB
SysUserDaoCustomImpl.java 6KB
IpUtils.java 6KB
SysMenuController.java 6KB
SysDeptController.java 5KB
JobInvokeUtil.java 5KB
SysDictDataServiceImpl.java 5KB
RedisCache.java 5KB
FileUtils.java 5KB
SysOperLogServiceImpl.java 5KB
ProductAmzUploadTask.java 5KB
SysJobLogServiceImpl.java 5KB
ShopAuthController.java 5KB
GenTableDaoCustomImpl.java 5KB
DataScopeAspect.java 5KB
CommonController.java 5KB
ProductTempImport.java 5KB
ProductTempRlat.java 5KB
ProductFmlRlat.java 5KB
DictUtils.java 5KB
SysNoticeServiceImpl.java 5KB
DruidConfig.java 5KB
PermissionService.java 5KB
SysJobController.java 5KB
SysProfileController.java 5KB
SysLogininforServiceImpl.java 5KB
TestController.java 5KB
CreatePricingFeedXml.java 5KB
HttpGet.java 4KB
SwaggerConfig.java 4KB
SysDictTypeController.java 4KB
SysPostController.java 4KB
DateUtils.java 4KB
CaptchaConfig.java 4KB
SysConfigController.java 4KB
共 757 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
Java程序员-张凯
- 粉丝: 1w+
- 资源: 7353
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功