mirror of https://github.com/jeecgboot/jeecg-boot
feat : tempSkuBuilder
parent
da932802d7
commit
3030a527c2
|
@ -40,6 +40,8 @@ import javax.servlet.ServletRequest;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -56,6 +58,8 @@ import static org.jeecg.common.util.SqlInjectionUtil.specialFilterContentForDict
|
||||||
@RequestMapping("/sku")
|
@RequestMapping("/sku")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SkuController {
|
public class SkuController {
|
||||||
|
@Autowired
|
||||||
|
private IShopService shopService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISkuService skuService;
|
private ISkuService skuService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -447,9 +451,88 @@ public class SkuController {
|
||||||
|
|
||||||
@PostMapping("/createMabangSku")
|
@PostMapping("/createMabangSku")
|
||||||
public Result<?> createMabangSku(@RequestBody List<SkuOrderPage> skuList) {
|
public Result<?> createMabangSku(@RequestBody List<SkuOrderPage> skuList) {
|
||||||
skuList.forEach(sku -> sku.setStatus(3));
|
log.info("Request to create {} new skus in Mabang", skuList.size());
|
||||||
|
skuList.forEach(sku -> {
|
||||||
|
if(sku.getId() != null && !sku.getId().isEmpty()) {
|
||||||
|
log.info("Request to pair sku [{}] with old sku [{}]", sku.getErpCode(), sku.getId());
|
||||||
|
}
|
||||||
|
if(sku.getShippingDiscount() == null) {
|
||||||
|
sku.setShippingDiscount(BigDecimal.ZERO);
|
||||||
|
} else {
|
||||||
|
BigDecimal oldValue = sku.getShippingDiscount().divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);
|
||||||
|
sku.setShippingDiscount(BigDecimal.ONE.subtract(oldValue));
|
||||||
|
}
|
||||||
|
sku.setStatus(3);
|
||||||
|
});
|
||||||
return Result.OK(skuListMabangService.publishSkuToMabang(skuList));
|
return Result.OK(skuListMabangService.publishSkuToMabang(skuList));
|
||||||
}
|
}
|
||||||
|
@RequestMapping(value = "/exportNewMabangSkusXls")
|
||||||
|
public ModelAndView exportXls(@RequestParam Map<String, String> params) {
|
||||||
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||||
|
List<NewSkuPage> skuList = parseSkuList(params);
|
||||||
|
log.info("Request to create {} new skus in Mabang", skuList.size());
|
||||||
|
skuList.forEach(sku -> {
|
||||||
|
if(sku.getShippingDiscount() == null) {
|
||||||
|
sku.setShippingDiscount(BigDecimal.ONE);
|
||||||
|
} else {
|
||||||
|
BigDecimal oldValue = sku.getShippingDiscount().divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP);
|
||||||
|
sku.setShippingDiscount(BigDecimal.ONE.subtract(oldValue));
|
||||||
|
}
|
||||||
|
sku.setStatus(3);
|
||||||
|
});
|
||||||
|
|
||||||
|
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||||
|
mv.addObject(NormalExcelConstants.FILE_NAME, "新增库存SKU表");
|
||||||
|
mv.addObject(NormalExcelConstants.CLASS, NewSkuPage.class);
|
||||||
|
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("新增库存SKU表数据", "导出人:" + sysUser.getRealname(), "新增库存SKU表"));
|
||||||
|
mv.addObject(NormalExcelConstants.DATA_LIST, skuList);
|
||||||
|
return mv;
|
||||||
|
}
|
||||||
|
private List<NewSkuPage> parseSkuList(Map<String, String> params) {
|
||||||
|
// Group parameters by "selections[index]"
|
||||||
|
Map<Integer, Map<String, String>> grouped = new HashMap<>();
|
||||||
|
for (Map.Entry<String, String> entry : params.entrySet()) {
|
||||||
|
String key = entry.getKey();
|
||||||
|
String value = entry.getValue();
|
||||||
|
|
||||||
|
if (key.startsWith("selections[")) {
|
||||||
|
int indexStart = key.indexOf("[") + 1;
|
||||||
|
int indexEnd = key.indexOf("]");
|
||||||
|
int index = Integer.parseInt(key.substring(indexStart, indexEnd));
|
||||||
|
|
||||||
|
String field = key.substring(key.indexOf("][") + 2, key.length() - 1);
|
||||||
|
grouped.computeIfAbsent(index, k -> new HashMap<>()).put(field, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert maps to SkuOrderPage objects
|
||||||
|
return grouped.values().stream()
|
||||||
|
.map(this::mapToSkuOrderPage)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private NewSkuPage mapToSkuOrderPage(Map<String, String> map) {
|
||||||
|
NewSkuPage sku = new NewSkuPage();
|
||||||
|
sku.setMabangSku(map.get("id"));
|
||||||
|
sku.setZhName(map.get("zhName"));
|
||||||
|
sku.setEnName(map.get("enName"));
|
||||||
|
sku.setDeclareEname(map.get("declareEname"));
|
||||||
|
sku.setDeclareName(map.get("declareName"));
|
||||||
|
sku.setErpCode(map.get("erpCode"));
|
||||||
|
sku.setWeight(map.get("weight") != null ? Integer.parseInt(map.get("weight")) : null);
|
||||||
|
sku.setStatus(map.get("status") != null ? Integer.parseInt(map.get("status")) : 3);
|
||||||
|
sku.setSensitiveAttribute(map.get("sensitiveAttribute"));
|
||||||
|
sku.setIsGift(map.get("isGift") != null ? Integer.parseInt(map.get("isGift")) : 2);
|
||||||
|
sku.setSkuPrice(map.get("skuPrice") != null ? new BigDecimal(map.get("skuPrice")) : BigDecimal.ZERO);
|
||||||
|
sku.setDeclaredValue(map.get("declaredValue") != null ? new BigDecimal(map.get("declaredValue")) : null);
|
||||||
|
sku.setShippingDiscount(map.get("shippingDiscount") != null ? new BigDecimal(map.get("shippingDiscount")) : BigDecimal.ZERO);
|
||||||
|
sku.setServiceFee(map.get("serviceFee") != null ? new BigDecimal(map.get("serviceFee")) : BigDecimal.ZERO);
|
||||||
|
sku.setWarehouse(map.get("warehouse"));
|
||||||
|
sku.setSupplier(map.get("supplier"));
|
||||||
|
sku.setSupplierLink(map.get("supplierLink"));
|
||||||
|
sku.setImageSource(map.get("imageSource"));
|
||||||
|
return sku;
|
||||||
|
}
|
||||||
@PostMapping("syncSkus")
|
@PostMapping("syncSkus")
|
||||||
public Result<?> syncSkus(@RequestBody List<String> erpCodes) {
|
public Result<?> syncSkus(@RequestBody List<String> erpCodes) {
|
||||||
Map<Sku, String> newSkusNeedTreatmentMap;
|
Map<Sku, String> newSkusNeedTreatmentMap;
|
||||||
|
@ -496,4 +579,34 @@ public class SkuController {
|
||||||
skuListMabangService.mabangSkuStockUpdate(erpCodes);
|
skuListMabangService.mabangSkuStockUpdate(erpCodes);
|
||||||
return Result.OK();
|
return Result.OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/unpairedSkus")
|
||||||
|
public Result<?> unpairedSkus(@RequestParam(name = "shop") String shopCode,
|
||||||
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||||
|
@RequestParam(name = "pageSize", defaultValue = "50") Integer pageSize,
|
||||||
|
@RequestParam(name = "column", defaultValue = "erp_code") String column,
|
||||||
|
@RequestParam(name = "order", defaultValue = "ASC") String order
|
||||||
|
) {
|
||||||
|
String parsedColumn = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, column.replace("_dictText", ""));
|
||||||
|
String parsedOrder = order.toUpperCase();
|
||||||
|
if(!parsedOrder.equals("ASC") && !parsedOrder.equals("DESC")) {
|
||||||
|
return Result.error("Error 400 Bad Request");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
specialFilterContentForDictSql(parsedColumn);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
return Result.error("Error 400 Bad Request");
|
||||||
|
}
|
||||||
|
String shopId = shopService.getIdByCode(shopCode);
|
||||||
|
if (shopId == null) return Result.error(404, "Shop not found");
|
||||||
|
int total = skuListMabangService.countUnpairedSkus(shopId);
|
||||||
|
List<SkuOrderPage> unpairedSkus = skuListMabangService.unpairedSkus(shopId, pageNo, pageSize, parsedColumn, parsedOrder);
|
||||||
|
|
||||||
|
IPage<SkuOrderPage> page = new Page<>();
|
||||||
|
page.setRecords(unpairedSkus);
|
||||||
|
page.setCurrent(pageNo);
|
||||||
|
page.setSize(pageSize);
|
||||||
|
page.setTotal(total);
|
||||||
|
return Result.OK(page);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import org.jeecg.common.system.base.controller.JeecgController;
|
import org.jeecg.common.system.base.controller.JeecgController;
|
||||||
import org.jeecg.modules.business.vo.Responses;
|
import org.jeecg.modules.business.vo.ResponsesWithMsg;
|
||||||
import org.jeecg.modules.business.vo.SkuWeightPage;
|
import org.jeecg.modules.business.vo.SkuWeightPage;
|
||||||
import org.jeecg.modules.business.vo.SkuWeightParam;
|
import org.jeecg.modules.business.vo.SkuWeightParam;
|
||||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||||
|
@ -192,7 +192,7 @@ public class SkuWeightController extends JeecgController<SkuWeight, ISkuWeightSe
|
||||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||||
|
|
||||||
Responses responses = new Responses();
|
ResponsesWithMsg responses = new ResponsesWithMsg();
|
||||||
List<SkuWeight> skuWeights = new ArrayList<>();
|
List<SkuWeight> skuWeights = new ArrayList<>();
|
||||||
Map<String, SkuWeight> skuWeightMappedByErpCode = new HashMap<>();
|
Map<String, SkuWeight> skuWeightMappedByErpCode = new HashMap<>();
|
||||||
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||||
|
@ -242,16 +242,16 @@ public class SkuWeightController extends JeecgController<SkuWeight, ISkuWeightSe
|
||||||
skuWeightMappedByErpCode.put(erpCode, skuWeight);
|
skuWeightMappedByErpCode.put(erpCode, skuWeight);
|
||||||
}
|
}
|
||||||
log.info("Import weights for skus: {}", skuWeightMappedByErpCode.keySet());
|
log.info("Import weights for skus: {}", skuWeightMappedByErpCode.keySet());
|
||||||
Responses mabangResponses = skuListMabangService.mabangSkuWeightUpdate(skuWeights);
|
ResponsesWithMsg mabangResponses = skuListMabangService.mabangSkuWeightUpdate(skuWeights);
|
||||||
List<SkuWeight> skuWeightSuccesses = new ArrayList<>();
|
List<SkuWeight> skuWeightSuccesses = new ArrayList<>();
|
||||||
mabangResponses.getSuccesses().forEach(skuErpCode -> {
|
mabangResponses.getSuccesses().forEach((skuErpCode, messages) -> {
|
||||||
String erpCode = skuErpCode.split(":")[0].trim();
|
skuWeightSuccesses.add(skuWeightMappedByErpCode.get(skuErpCode));
|
||||||
skuWeightSuccesses.add(skuWeightMappedByErpCode.get(erpCode));
|
|
||||||
});
|
});
|
||||||
skuWeightSuccesses.forEach(skuWeight -> skuMongoService.upsertSkuWeight(skuWeight));
|
skuWeightSuccesses.forEach(skuWeight -> skuMongoService.upsertSkuWeight(skuWeight));
|
||||||
skuWeightService.saveBatch(skuWeights);
|
skuWeightService.saveBatch(skuWeights);
|
||||||
responses.getSuccesses().addAll(mabangResponses.getSuccesses());
|
|
||||||
responses.getFailures().addAll(mabangResponses.getFailures());
|
mabangResponses.getSuccesses().forEach(responses::addSuccess);
|
||||||
|
mabangResponses.getFailures().forEach(responses::addFailure);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
String msg = e.getMessage();
|
String msg = e.getMessage();
|
||||||
|
@ -324,11 +324,10 @@ public class SkuWeightController extends JeecgController<SkuWeight, ISkuWeightSe
|
||||||
skuWeightsMap.put(sku.getErpCode(), skuWeight);
|
skuWeightsMap.put(sku.getErpCode(), skuWeight);
|
||||||
}
|
}
|
||||||
List<SkuWeight> skuWeights = new ArrayList<>(skuWeightsMap.values());
|
List<SkuWeight> skuWeights = new ArrayList<>(skuWeightsMap.values());
|
||||||
Responses responses = skuListMabangService.mabangSkuWeightUpdate(skuWeights);
|
ResponsesWithMsg responses = skuListMabangService.mabangSkuWeightUpdate(skuWeights);
|
||||||
List<SkuWeight> skuWeightSuccesses = new ArrayList<>();
|
List<SkuWeight> skuWeightSuccesses = new ArrayList<>();
|
||||||
responses.getSuccesses().forEach(skuErpCode -> {
|
responses.getSuccesses().forEach((skuErpCode, messages) -> {
|
||||||
String erpCode = skuErpCode.split(":")[0].trim();
|
skuWeightSuccesses.add(skuWeightsMap.get(skuErpCode));
|
||||||
skuWeightSuccesses.add(skuWeightsMap.get(erpCode));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
skuWeightSuccesses.forEach(skuWeight -> skuMongoService.upsertSkuWeight(skuWeight));
|
skuWeightSuccesses.forEach(skuWeight -> skuMongoService.upsertSkuWeight(skuWeight));
|
||||||
|
|
|
@ -40,6 +40,11 @@ public class SkuData {
|
||||||
private Integer status;
|
private Integer status;
|
||||||
@JSONField(name="originalSku")
|
@JSONField(name="originalSku")
|
||||||
private String originalSku;
|
private String originalSku;
|
||||||
|
/**
|
||||||
|
* if multiple virtual skus, they need to be separated by ";"
|
||||||
|
*/
|
||||||
|
@JSONField(name="virtualSkus")
|
||||||
|
private String virtualSkus;
|
||||||
@JSONField(name="salePrice")
|
@JSONField(name="salePrice")
|
||||||
private BigDecimal salePrice;
|
private BigDecimal salePrice;
|
||||||
@JSONField(name="declareValue")
|
@JSONField(name="declareValue")
|
||||||
|
@ -54,7 +59,10 @@ public class SkuData {
|
||||||
private BigDecimal purchasePrice;
|
private BigDecimal purchasePrice;
|
||||||
/**默认供应商名称,接口参数传showProvider才返回*/
|
/**默认供应商名称,接口参数传showProvider才返回*/
|
||||||
@JSONField(name="warehouse")
|
@JSONField(name="warehouse")
|
||||||
private String warehouse;
|
private Warehouse[] warehouse;
|
||||||
|
|
||||||
|
@JSONField(name="warehouseName")
|
||||||
|
private String warehouseName;
|
||||||
/**
|
/**
|
||||||
* if stockPicture is empty, we use it
|
* if stockPicture is empty, we use it
|
||||||
*/
|
*/
|
||||||
|
@ -109,7 +117,7 @@ public class SkuData {
|
||||||
/**
|
/**
|
||||||
* 是否为易燃品 1: 是 2:不是,默认为2
|
* 是否为易燃品 1: 是 2:不是,默认为2
|
||||||
*/
|
*/
|
||||||
@JSONField(name="is_flammable")
|
@JSONField(name="is_flammables")
|
||||||
private Integer isFlammable;
|
private Integer isFlammable;
|
||||||
/**
|
/**
|
||||||
* 是否为刀具 1:是 2:不是,默认为2
|
* 是否为刀具 1:是 2:不是,默认为2
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class SkuListRawStream implements NetworkDataStream<SkuListResponse> {
|
||||||
public SkuListResponse attempt() {
|
public SkuListResponse attempt() {
|
||||||
log.info("Begin the first request");
|
log.info("Begin the first request");
|
||||||
this.currentResponse = new SkuListRequest(toSend).send();
|
this.currentResponse = new SkuListRequest(toSend).send();
|
||||||
if (currentResponse.getData().isEmpty()) {
|
if (currentResponse.getData() == null || currentResponse.getData().isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
began = true;
|
began = true;
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class SkuListRequestBody implements RequestBody {
|
||||||
putNonNull(json, "maxRows", maxRows);
|
putNonNull(json, "maxRows", maxRows);
|
||||||
putNonNull(json, "showVirtualSku", showVirtualSku);
|
putNonNull(json, "showVirtualSku", showVirtualSku);
|
||||||
putNonNull(json, "showProvider", showProvider);
|
putNonNull(json, "showProvider", showProvider);
|
||||||
putNonNull(json, "showWarehouse", showWarehouse);
|
putNonNull(json, "showWarehouse", String.valueOf(showWarehouse));
|
||||||
putNonNull(json, "showLabel", showLabel);
|
putNonNull(json, "showLabel", showLabel);
|
||||||
putNonNull(json, "showAttributes", showAttributes);
|
putNonNull(json, "showAttributes", showAttributes);
|
||||||
return json;
|
return json;
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
package org.jeecg.modules.business.domain.api.mabang.doSearchSkuListNew;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
// 仓库信息,接口参数传showWarehouse才返回
|
||||||
|
public class Warehouse {
|
||||||
|
/**仓库编号*/
|
||||||
|
@JSONField(name = "warehouseId")
|
||||||
|
private long warehouseId;
|
||||||
|
/**仓位**/
|
||||||
|
@JSONField(name = "gridCode")
|
||||||
|
private String gridCode;
|
||||||
|
/**库存警戒天数*/
|
||||||
|
@JSONField(name = "stockWarningDays")
|
||||||
|
private int stockWarningDays;
|
||||||
|
/**商品预警天数*/
|
||||||
|
@JSONField(name="product_warning_days")
|
||||||
|
private int productWarningDays;
|
||||||
|
/**仓库名称*/
|
||||||
|
@JSONField(name = "warehouseName")
|
||||||
|
private String warehouseName;
|
||||||
|
/**仓库状态:1启用;2停用*/
|
||||||
|
@JSONField(name = "status")
|
||||||
|
private int status;
|
||||||
|
/**仓库成本价*/
|
||||||
|
@JSONField(name = "stockCost")
|
||||||
|
private String stockCost;
|
||||||
|
/**是否是默认仓库1是;2否*/
|
||||||
|
@JSONField(name = "isDefault")
|
||||||
|
private int isDefault;
|
||||||
|
/**警戒库存*/
|
||||||
|
@JSONField(name = "stockWarningQuantity")
|
||||||
|
private int stockWarningQuantity;
|
||||||
|
/**采购天数*/
|
||||||
|
@JSONField(name = "purchaseDays")
|
||||||
|
private int purchaseDays;
|
||||||
|
@JSONField(name = "minPurchaseQuantity")
|
||||||
|
private int minPurchaseQuantity;
|
||||||
|
@JSONField(name = "maxPurchaseQuantity")
|
||||||
|
private int maxPurchaseQuantity;
|
||||||
|
}
|
|
@ -85,7 +85,7 @@ public class SkuAddRequestBody implements RequestBody {
|
||||||
this.declareValue = data.getDeclareValue();
|
this.declareValue = data.getDeclareValue();
|
||||||
this.declareName = data.getDeclareNameZh();
|
this.declareName = data.getDeclareNameZh();
|
||||||
this.declareEname = data.getDeclareNameEn();
|
this.declareEname = data.getDeclareNameEn();
|
||||||
this.warehouse = data.getWarehouse();
|
this.warehouse = data.getWarehouseName();
|
||||||
this.remark = data.getSaleRemark();
|
this.remark = data.getSaleRemark();
|
||||||
this.hasBattery = data.getHasBattery();
|
this.hasBattery = data.getHasBattery();
|
||||||
this.magnetic = data.getMagnetic();
|
this.magnetic = data.getMagnetic();
|
||||||
|
|
|
@ -20,12 +20,21 @@ public class SkuAddResponse extends Response {
|
||||||
|
|
||||||
private final String stockSku;
|
private final String stockSku;
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
|
||||||
public SkuAddResponse(Code code, JSONObject data, String stockId, String stockSku) {
|
public SkuAddResponse(Code code, JSONObject data, String stockId, String stockSku) {
|
||||||
super(code);
|
super(code);
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.stockId = stockId;
|
this.stockId = stockId;
|
||||||
this.stockSku = stockSku;
|
this.stockSku = stockSku;
|
||||||
}
|
}
|
||||||
|
public SkuAddResponse(Code code, JSONObject data, String stockId, String stockSku, String message) {
|
||||||
|
super(code);
|
||||||
|
this.data = data;
|
||||||
|
this.stockId = stockId;
|
||||||
|
this.stockSku = stockSku;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make an instance by parsing json, it only checks validity of code.
|
* Make an instance by parsing json, it only checks validity of code.
|
||||||
|
|
|
@ -4,19 +4,23 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.codehaus.jettison.json.JSONException;
|
import org.codehaus.jettison.json.JSONException;
|
||||||
import org.codehaus.jettison.json.JSONObject;
|
import org.codehaus.jettison.json.JSONObject;
|
||||||
import org.jeecg.modules.business.domain.api.mabang.doSearchSkuListNew.*;
|
import org.jeecg.modules.business.domain.api.mabang.doSearchSkuListNew.*;
|
||||||
|
import org.jeecg.modules.business.service.ISkuListMabangService;
|
||||||
import org.quartz.Job;
|
import org.quartz.Job;
|
||||||
import org.quartz.JobDataMap;
|
import org.quartz.JobDataMap;
|
||||||
import org.quartz.JobExecutionContext;
|
import org.quartz.JobExecutionContext;
|
||||||
import org.quartz.JobExecutionException;
|
import org.quartz.JobExecutionException;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class MabangUnpairedSkuJob implements Job {
|
public class MabangUnpairedSkuJob implements Job {
|
||||||
|
@Autowired
|
||||||
|
private ISkuListMabangService skuListMabangService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||||
JobDataMap jobDataMap = context.getMergedJobDataMap();
|
JobDataMap jobDataMap = context.getMergedJobDataMap();
|
||||||
|
@ -40,11 +44,7 @@ public class MabangUnpairedSkuJob implements Job {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkuListRequestBody body = new SkuListRequestBody();
|
List<SkuData> skuDatas = skuListMabangService.fetchUnpairedSkus(skuList);
|
||||||
body.setStockSkuList(String.join(",", skuList));
|
|
||||||
SkuListRawStream rawStream = new SkuListRawStream(body);
|
|
||||||
UnpairedSkuListStream stream = new UnpairedSkuListStream(rawStream);
|
|
||||||
List<SkuData> skusFromMabang = stream.all();
|
|
||||||
// System.out.println("skus from mabang : " + skusFromMabang);
|
// System.out.println("skus from mabang : " + skusFromMabang);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,4 +19,8 @@ public interface SensitiveAttributeMapper extends BaseMapper<SensitiveAttribute>
|
||||||
String getHighestPriorityAttributeId(@Param("orderId") String orderId);
|
String getHighestPriorityAttributeId(@Param("orderId") String orderId);
|
||||||
|
|
||||||
List<SensitiveAttribute> listIdAndPriority();
|
List<SensitiveAttribute> listIdAndPriority();
|
||||||
|
|
||||||
|
String getNameByAttributes(@Param("attribute") SensitiveAttribute sensitiveAttribute);
|
||||||
|
|
||||||
|
SensitiveAttribute getByZhName(@Param("zhName") String zhName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,4 +80,8 @@ public interface SkuMapper extends BaseMapper<Sku> {
|
||||||
List<Sku> listImgUrls();
|
List<Sku> listImgUrls();
|
||||||
|
|
||||||
List<String> fetchAllClientSkuCodes(@Param("clientCode") String clientCode);
|
List<String> fetchAllClientSkuCodes(@Param("clientCode") String clientCode);
|
||||||
|
|
||||||
|
List<String> fetchUnpairedSkus(@Param("shopId") String shopId, @Param("offset") Integer offset, @Param("size") Integer pageSize, @Param("column") String column, @Param("order") String order);
|
||||||
|
|
||||||
|
int countUnpairedSkus(@Param("shopId") String shopId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,24 @@
|
||||||
WHERE po.id = #{orderId}
|
WHERE po.id = #{orderId}
|
||||||
ORDER BY sa.priority DESC LIMIT 1;
|
ORDER BY sa.priority DESC LIMIT 1;
|
||||||
</select>
|
</select>
|
||||||
<select id="listIdAndPriority" resultType="org.jeecg.modules.business.entity.SensitiveAttribute">
|
<select id="listIdAndPriority" resultType="org.jeecg.modules.business.entity.SensitiveAttribute">
|
||||||
SELECT id, priority, zh_name
|
SELECT id, priority, zh_name
|
||||||
FROM wia_app.sensitive_attribute
|
FROM wia_app.sensitive_attribute
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getNameByAttributes" resultType="java.lang.String">
|
||||||
|
SELECT zh_name
|
||||||
|
FROM sensitive_attribute sa
|
||||||
|
WHERE sa.is_paste = #{attribute.isPaste}
|
||||||
|
AND sa.is_knife = #{attribute.isKnife}
|
||||||
|
AND sa.is_flammable = #{attribute.isFlammable}
|
||||||
|
AND sa.powder = #{attribute.powder}
|
||||||
|
AND sa.has_battery = #{attribute.hasBattery}
|
||||||
|
AND sa.magnetic = #{attribute.magnetic}
|
||||||
|
AND sa.no_liquid_cosmetic = #{attribute.noLiquidCosmetic}
|
||||||
|
</select>
|
||||||
|
<select id="getByZhName" resultType="org.jeecg.modules.business.entity.SensitiveAttribute">
|
||||||
|
SELECT *
|
||||||
|
FROM sensitive_attribute sa
|
||||||
|
WHERE sa.zh_name = #{zhName};
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
|
@ -790,4 +790,30 @@
|
||||||
JOIN client c ON client_sku.client_id = c.id
|
JOIN client c ON client_sku.client_id = c.id
|
||||||
WHERE c.internal_code = #{clientCode};
|
WHERE c.internal_code = #{clientCode};
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="fetchUnpairedSkus" resultType="java.lang.String">
|
||||||
|
SELECT poc.sku_id as erp_code
|
||||||
|
FROM platform_order po
|
||||||
|
JOIN shop s ON po.shop_id = s.id
|
||||||
|
JOIN platform_order_content poc ON po.id = poc.platform_order_id
|
||||||
|
LEFT JOIN sku ON poc.sku_id = sku.id
|
||||||
|
WHERE sku.id IS NULL
|
||||||
|
AND po.erp_status IN (1, 2)
|
||||||
|
AND poc.erp_status <> 5
|
||||||
|
AND s.id = #{shopId}
|
||||||
|
GROUP BY poc.sku_id
|
||||||
|
ORDER BY ${column} ${order}
|
||||||
|
LIMIT #{offset}, #{size};
|
||||||
|
</select>
|
||||||
|
<select id="countUnpairedSkus" resultType="java.lang.Integer">
|
||||||
|
SELECT COUNT(DISTINCT poc.sku_id)
|
||||||
|
FROM platform_order_content poc
|
||||||
|
JOIN platform_order po ON poc.platform_order_id = po.id
|
||||||
|
JOIN shop s ON po.shop_id = s.id
|
||||||
|
LEFT JOIN sku ON poc.sku_id = sku.id
|
||||||
|
WHERE sku.id IS NULL
|
||||||
|
AND po.erp_status IN (1, 2)
|
||||||
|
AND poc.erp_status <> 5
|
||||||
|
AND s.id = #{shopId};
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -17,4 +17,8 @@ public interface ISensitiveAttributeService extends IService<SensitiveAttribute>
|
||||||
String getHighestPriorityAttributeId(String orderId);
|
String getHighestPriorityAttributeId(String orderId);
|
||||||
|
|
||||||
List<SensitiveAttribute> listIdAndPriority();
|
List<SensitiveAttribute> listIdAndPriority();
|
||||||
|
|
||||||
|
String getNameByAttributes(SensitiveAttribute sensitiveAttribute);
|
||||||
|
|
||||||
|
SensitiveAttribute getByZhName(String zhName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import org.jeecg.modules.business.domain.api.mabang.doSearchSkuListNew.SkuData;
|
import org.jeecg.modules.business.domain.api.mabang.doSearchSkuListNew.SkuData;
|
||||||
import org.jeecg.modules.business.entity.Sku;
|
import org.jeecg.modules.business.entity.Sku;
|
||||||
import org.jeecg.modules.business.entity.SkuWeight;
|
import org.jeecg.modules.business.entity.SkuWeight;
|
||||||
import org.jeecg.modules.business.vo.Responses;
|
import org.jeecg.modules.business.vo.ResponsesWithMsg;
|
||||||
import org.jeecg.modules.business.vo.SkuOrderPage;
|
import org.jeecg.modules.business.vo.SkuOrderPage;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -33,12 +33,18 @@ public interface ISkuListMabangService extends IService<SkuData> {
|
||||||
List<String> parseSkuListToProductCodeList(List<SkuData> erpCodeList) throws Exception;
|
List<String> parseSkuListToProductCodeList(List<SkuData> erpCodeList) throws Exception;
|
||||||
Map<Sku, String> createSkus(List<SkuData> skuDataList);
|
Map<Sku, String> createSkus(List<SkuData> skuDataList);
|
||||||
|
|
||||||
Responses publishSkuToMabang(List<SkuOrderPage> skuList);
|
ResponsesWithMsg publishSkuToMabang(List<SkuOrderPage> skuList);
|
||||||
|
|
||||||
Map<Sku, String> skuSyncUpsert(List<String> erpCodes);
|
Map<Sku, String> skuSyncUpsert(List<String> erpCodes);
|
||||||
void updateSkuId();
|
void updateSkuId();
|
||||||
|
|
||||||
void mabangSkuStockUpdate(List<String> erpCodes);
|
void mabangSkuStockUpdate(List<String> erpCodes);
|
||||||
|
|
||||||
Responses mabangSkuWeightUpdate(List<SkuWeight> skuWeights);
|
ResponsesWithMsg mabangSkuWeightUpdate(List<SkuWeight> skuWeights);
|
||||||
|
|
||||||
|
List<SkuData> fetchUnpairedSkus(List<String> stockSkuList);
|
||||||
|
|
||||||
|
List<SkuOrderPage> unpairedSkus(String shopId, Integer pageNo, Integer pageSize, String column, String order);
|
||||||
|
|
||||||
|
int countUnpairedSkus(String shopId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,4 +124,8 @@ public interface ISkuService extends IService<Sku> {
|
||||||
List<Sku> listImgUrls();
|
List<Sku> listImgUrls();
|
||||||
|
|
||||||
List<String> fetchAllClientSkuCodes(String clientCode);
|
List<String> fetchAllClientSkuCodes(String clientCode);
|
||||||
|
|
||||||
|
List<String> fetchUnpairedSkus(String shopId, int offset, Integer pageSize, String column, String order);
|
||||||
|
|
||||||
|
int countUnpairedSkus(String shopId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,4 +35,14 @@ public class SensitiveAttributeServiceImpl extends ServiceImpl<SensitiveAttribut
|
||||||
public List<SensitiveAttribute> listIdAndPriority() {
|
public List<SensitiveAttribute> listIdAndPriority() {
|
||||||
return sensitiveAttributeMapper.listIdAndPriority();
|
return sensitiveAttributeMapper.listIdAndPriority();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNameByAttributes(SensitiveAttribute sensitiveAttribute) {
|
||||||
|
return sensitiveAttributeMapper.getNameByAttributes(sensitiveAttribute);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SensitiveAttribute getByZhName(String zhName) {
|
||||||
|
return sensitiveAttributeMapper.getByZhName(zhName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.jeecg.modules.business.entity.*;
|
||||||
import org.jeecg.modules.business.mapper.SkuListMabangMapper;
|
import org.jeecg.modules.business.mapper.SkuListMabangMapper;
|
||||||
import org.jeecg.modules.business.mongoService.SkuMongoService;
|
import org.jeecg.modules.business.mongoService.SkuMongoService;
|
||||||
import org.jeecg.modules.business.service.*;
|
import org.jeecg.modules.business.service.*;
|
||||||
import org.jeecg.modules.business.vo.Responses;
|
import org.jeecg.modules.business.vo.ResponsesWithMsg;
|
||||||
import org.jeecg.modules.business.vo.SkuOrderPage;
|
import org.jeecg.modules.business.vo.SkuOrderPage;
|
||||||
import org.jeecg.modules.online.cgform.mapper.OnlCgformFieldMapper;
|
import org.jeecg.modules.online.cgform.mapper.OnlCgformFieldMapper;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -466,7 +466,8 @@ public class SkuListMabangServiceImpl extends ServiceImpl<SkuListMabangMapper, S
|
||||||
}
|
}
|
||||||
return remark;
|
return remark;
|
||||||
}
|
}
|
||||||
public Responses publishSkuToMabang(List<SkuOrderPage> skuList) {
|
public ResponsesWithMsg publishSkuToMabang(List<SkuOrderPage> skuList) {
|
||||||
|
ResponsesWithMsg responses = new ResponsesWithMsg();
|
||||||
List<SkuData> skuDataList = skuList.stream()
|
List<SkuData> skuDataList = skuList.stream()
|
||||||
.map(this::SkuOrderPageToSkuData)
|
.map(this::SkuOrderPageToSkuData)
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
|
@ -483,7 +484,7 @@ public class SkuListMabangServiceImpl extends ServiceImpl<SkuListMabangMapper, S
|
||||||
return request.send();
|
return request.send();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error publishing sku {} to mabang : {}", requestBody.getStockSku(), e.getMessage());
|
log.error("Error publishing sku {} to mabang : {}", requestBody.getStockSku(), e.getMessage());
|
||||||
return new SkuAddResponse(Response.Code.ERROR, null, null, requestBody.getStockSku());
|
return new SkuAddResponse(Response.Code.ERROR, null, null, requestBody.getStockSku(), e.getMessage());
|
||||||
}
|
}
|
||||||
}, executor))
|
}, executor))
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
|
@ -494,13 +495,13 @@ public class SkuListMabangServiceImpl extends ServiceImpl<SkuListMabangMapper, S
|
||||||
.filter(SkuAddResponse::success)
|
.filter(SkuAddResponse::success)
|
||||||
.map(SkuAddResponse::getStockSku)
|
.map(SkuAddResponse::getStockSku)
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
List<String> failures = results.stream()
|
results.forEach(response -> {
|
||||||
.filter(response -> !response.success())
|
if(response.success()) {
|
||||||
.map(SkuAddResponse::getStockSku)
|
responses.addSuccess(response.getStockSku());
|
||||||
.collect(toList());
|
} else {
|
||||||
Responses responses = new Responses();
|
responses.addFailure(response.getStockSku(), response.getMessage());
|
||||||
responses.setSuccesses(successes);
|
}
|
||||||
responses.setFailures(failures);
|
});
|
||||||
return responses;
|
return responses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -544,7 +545,12 @@ public class SkuListMabangServiceImpl extends ServiceImpl<SkuListMabangMapper, S
|
||||||
|
|
||||||
public SkuData SkuOrderPageToSkuData(SkuOrderPage skuOrderPage) {
|
public SkuData SkuOrderPageToSkuData(SkuOrderPage skuOrderPage) {
|
||||||
SensitiveAttribute sensitiveAttribute = sensitiveAttributeService.getById(skuOrderPage.getSensitiveAttribute());
|
SensitiveAttribute sensitiveAttribute = sensitiveAttributeService.getById(skuOrderPage.getSensitiveAttribute());
|
||||||
|
if(sensitiveAttribute == null) {
|
||||||
|
sensitiveAttribute = sensitiveAttributeService.getByZhName(skuOrderPage.getSensitiveAttribute());
|
||||||
|
}
|
||||||
SkuData skuData = new SkuData();
|
SkuData skuData = new SkuData();
|
||||||
|
if(skuOrderPage.getId() != null)
|
||||||
|
skuData.setVirtualSkus(skuOrderPage.getId());
|
||||||
skuData.setErpCode(skuOrderPage.getErpCode());
|
skuData.setErpCode(skuOrderPage.getErpCode());
|
||||||
skuData.setNameCN(skuOrderPage.getZhName());
|
skuData.setNameCN(skuOrderPage.getZhName());
|
||||||
skuData.setNameEN(skuOrderPage.getEnName());
|
skuData.setNameEN(skuOrderPage.getEnName());
|
||||||
|
@ -552,7 +558,7 @@ public class SkuListMabangServiceImpl extends ServiceImpl<SkuListMabangMapper, S
|
||||||
skuData.setDeclareNameEn(skuOrderPage.getDeclareEname());
|
skuData.setDeclareNameEn(skuOrderPage.getDeclareEname());
|
||||||
skuData.setSalePrice(skuOrderPage.getSkuPrice());
|
skuData.setSalePrice(skuOrderPage.getSkuPrice());
|
||||||
skuData.setDeclareValue(skuOrderPage.getDeclaredValue());
|
skuData.setDeclareValue(skuOrderPage.getDeclaredValue());
|
||||||
skuData.setWarehouse(DEFAULT_WAREHOUSE_NAME);
|
skuData.setWarehouseName(DEFAULT_WAREHOUSE_NAME);
|
||||||
if(skuOrderPage.getWeight() != null)
|
if(skuOrderPage.getWeight() != null)
|
||||||
skuData.setSaleRemark(skuOrderPage.getWeight().toString());
|
skuData.setSaleRemark(skuOrderPage.getWeight().toString());
|
||||||
skuData.setHasBattery(sensitiveAttribute.getHasBattery());
|
skuData.setHasBattery(sensitiveAttribute.getHasBattery());
|
||||||
|
@ -568,6 +574,33 @@ public class SkuListMabangServiceImpl extends ServiceImpl<SkuListMabangMapper, S
|
||||||
return skuData;
|
return skuData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SkuOrderPage SkuDataToSkuOrderPage(SkuData skuData) {
|
||||||
|
SkuOrderPage sop = new SkuOrderPage();
|
||||||
|
SensitiveAttribute sensitiveAttribute = new SensitiveAttribute();
|
||||||
|
sensitiveAttribute.setHasBattery(skuData.getHasBattery());
|
||||||
|
sensitiveAttribute.setPowder(skuData.getPowder());
|
||||||
|
sensitiveAttribute.setIsFlammable(skuData.getIsFlammable());
|
||||||
|
sensitiveAttribute.setIsKnife(skuData.getIsKnife());
|
||||||
|
sensitiveAttribute.setIsPaste(skuData.getIsPaste());
|
||||||
|
sensitiveAttribute.setMagnetic(skuData.getMagnetic());
|
||||||
|
sensitiveAttribute.setNoLiquidCosmetic(skuData.getNoLiquidCosmetic());
|
||||||
|
String sensitiveAttributeName = sensitiveAttributeService.getNameByAttributes(sensitiveAttribute);
|
||||||
|
sop.setSensitiveAttribute(sensitiveAttributeName);
|
||||||
|
sop.setId(String.valueOf(skuData.getStockSkuId()));
|
||||||
|
sop.setErpCode(skuData.getErpCode());
|
||||||
|
sop.setZhName(skuData.getNameCN());
|
||||||
|
sop.setEnName(skuData.getNameEN());
|
||||||
|
sop.setDeclaredValue(skuData.getDeclareValue());
|
||||||
|
sop.setSkuPrice(skuData.getSalePrice());
|
||||||
|
if(skuData.getWarehouse() != null)
|
||||||
|
sop.setWarehouse(skuData.getWarehouse()[0].getWarehouseName());
|
||||||
|
sop.setImageSource(skuData.getSalePicture());
|
||||||
|
sop.setIsGift(skuData.getIsGift());
|
||||||
|
sop.setSupplier(skuData.getSupplier());
|
||||||
|
sop.setSupplierLink(skuData.getSupplierLink());
|
||||||
|
sop.setStatus(skuData.getStatusValue());
|
||||||
|
return sop;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call a routine to replace SKU codes (from MabangAPI)
|
* Call a routine to replace SKU codes (from MabangAPI)
|
||||||
|
@ -635,9 +668,8 @@ public class SkuListMabangServiceImpl extends ServiceImpl<SkuListMabangMapper, S
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Responses mabangSkuWeightUpdate(List<SkuWeight> skuWeights) {
|
public ResponsesWithMsg mabangSkuWeightUpdate(List<SkuWeight> skuWeights) {
|
||||||
Responses responses = new Responses();
|
ResponsesWithMsg responses = new ResponsesWithMsg();
|
||||||
List<String> failures = new ArrayList<>();
|
|
||||||
List<String> skuIds = skuWeights.stream()
|
List<String> skuIds = skuWeights.stream()
|
||||||
.map(SkuWeight::getSkuId)
|
.map(SkuWeight::getSkuId)
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
|
@ -701,7 +733,7 @@ public class SkuListMabangServiceImpl extends ServiceImpl<SkuListMabangMapper, S
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
if(null == skuInDb) {
|
if(null == skuInDb) {
|
||||||
log.error("Sku not found : {}", skuWeight.getSkuId());
|
log.error("Sku not found : {}", skuWeight.getSkuId());
|
||||||
failures.add(skuWeight.getSkuId());
|
responses.addFailure(skuWeight.getSkuId(), "Sku not found");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if(null == sku) {
|
if(null == sku) {
|
||||||
|
@ -745,17 +777,47 @@ public class SkuListMabangServiceImpl extends ServiceImpl<SkuListMabangMapper, S
|
||||||
List<SkuChangeResponse> results = futures.stream().map(CompletableFuture::join).collect(toList());
|
List<SkuChangeResponse> results = futures.stream().map(CompletableFuture::join).collect(toList());
|
||||||
long successCount = results.stream().filter(SkuChangeResponse::success).count();
|
long successCount = results.stream().filter(SkuChangeResponse::success).count();
|
||||||
log.info("{}/{} skus updated successfully.", successCount, skuDataList.size());
|
log.info("{}/{} skus updated successfully.", successCount, skuDataList.size());
|
||||||
List<String> successes = results.stream()
|
results.forEach(response -> {
|
||||||
.filter(SkuChangeResponse::success)
|
if(response.success()) {
|
||||||
.map(response -> response.getStockSku() + " : Mabang OK")
|
responses.addSuccess(response.getStockSku(), "Mabang");
|
||||||
.collect(toList());
|
}
|
||||||
failures.addAll(results.stream()
|
else {
|
||||||
.filter(response -> !response.success())
|
responses.addFailure(response.getStockSku(), "Mabang");
|
||||||
.map(response -> response.getStockSku() + " | Mabang")
|
}
|
||||||
.collect(toList()));
|
});
|
||||||
|
|
||||||
responses.getSuccesses().addAll(successes);
|
|
||||||
responses.setFailures(failures);
|
|
||||||
return responses;
|
return responses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SkuData> fetchUnpairedSkus(List<String> stockSkuList) {
|
||||||
|
List<List<String>> skusPartition = Lists.partition(new ArrayList<>(stockSkuList), 50);
|
||||||
|
List<SkuData> skuDataList = new ArrayList<>();
|
||||||
|
for(List<String> skuPartition : skusPartition) {
|
||||||
|
SkuListRequestBody body = new SkuListRequestBody();
|
||||||
|
body.setShowWarehouse(1);
|
||||||
|
body.setStockSkuList(String.join(",", skuPartition));
|
||||||
|
SkuListRawStream rawStream = new SkuListRawStream(body);
|
||||||
|
UnpairedSkuListStream stream = new UnpairedSkuListStream(rawStream);
|
||||||
|
skuDataList.addAll(stream.all());
|
||||||
|
}
|
||||||
|
return skuDataList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SkuOrderPage> unpairedSkus(String shopId, Integer pageNo, Integer pageSize, String column, String order) {
|
||||||
|
int offset = (pageNo - 1) * pageSize;
|
||||||
|
List<String> stockSkuList = skuService.fetchUnpairedSkus(shopId, offset, pageSize, column, order);
|
||||||
|
if(stockSkuList.isEmpty()){
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
List<SkuData> skuDataList = fetchUnpairedSkus(stockSkuList);
|
||||||
|
return skuDataList.stream()
|
||||||
|
.map(this::SkuDataToSkuOrderPage)
|
||||||
|
.collect(toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int countUnpairedSkus(String shopId) {
|
||||||
|
return skuService.countUnpairedSkus(shopId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,8 +59,6 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS
|
||||||
@Autowired
|
@Autowired
|
||||||
private ILogisticChannelPriceService logisticChannelPriceService;
|
private ILogisticChannelPriceService logisticChannelPriceService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private CountryService countryService;
|
|
||||||
@Autowired
|
|
||||||
private IPlatformOrderContentService platformOrderContentService;
|
private IPlatformOrderContentService platformOrderContentService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISkuLogisticChoiceService skuLogisticChoiceService;
|
private ISkuLogisticChoiceService skuLogisticChoiceService;
|
||||||
|
@ -619,4 +617,13 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS
|
||||||
return skuMapper.fetchAllClientSkuCodes(clientCode);
|
return skuMapper.fetchAllClientSkuCodes(clientCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> fetchUnpairedSkus(String shopId, int offset, Integer pageSize, String column, String order) {
|
||||||
|
return skuMapper.fetchUnpairedSkus(shopId, offset, pageSize, column, order);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int countUnpairedSkus(String shopId) {
|
||||||
|
return skuMapper.countUnpairedSkus(shopId);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,128 @@
|
||||||
|
package org.jeecg.modules.business.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: SKU采购表
|
||||||
|
* @Author: jeecg-boot
|
||||||
|
* @Date: 2024-03-25
|
||||||
|
* @Version: V1.1
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "skuOrderPage对象", description = "SKU表")
|
||||||
|
public class NewSkuPage {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
@Excel(name = "马帮动创建Sku", width = 15)
|
||||||
|
@ApiModelProperty(value = "马帮动创建Sku")
|
||||||
|
private String mabangSku;
|
||||||
|
/**
|
||||||
|
* 商品ID
|
||||||
|
*/
|
||||||
|
@Excel(name = "商品", width = 15)
|
||||||
|
@ApiModelProperty(value = "商品")
|
||||||
|
private String zhName;
|
||||||
|
/**
|
||||||
|
* 商品ID
|
||||||
|
*/
|
||||||
|
@Excel(name = "商品英文", width = 15)
|
||||||
|
@ApiModelProperty(value = "商品英文")
|
||||||
|
private String enName;
|
||||||
|
/**
|
||||||
|
* ERP中商品代码
|
||||||
|
*/
|
||||||
|
@Excel(name = "ERP中商品代码", width = 15)
|
||||||
|
@ApiModelProperty(value = "ERP中商品代码")
|
||||||
|
private String erpCode;
|
||||||
|
/**
|
||||||
|
* 重量
|
||||||
|
*/
|
||||||
|
@Excel(name = "重量", width = 15)
|
||||||
|
@ApiModelProperty(value = "重量")
|
||||||
|
private Integer weight;
|
||||||
|
/**
|
||||||
|
* 图片链接
|
||||||
|
*/
|
||||||
|
@Excel(name = "图片链接", width = 15)
|
||||||
|
@ApiModelProperty(value = "图片链接")
|
||||||
|
private String imageSource;
|
||||||
|
/**
|
||||||
|
* 运费折扣
|
||||||
|
*/
|
||||||
|
@Excel(name = "运费折扣", width = 15)
|
||||||
|
@ApiModelProperty(value = "运费折扣")
|
||||||
|
private BigDecimal shippingDiscount;
|
||||||
|
/**
|
||||||
|
* 服务费
|
||||||
|
*/
|
||||||
|
@Excel(name = "服务费", width = 15)
|
||||||
|
@ApiModelProperty(value = "服务费")
|
||||||
|
private BigDecimal serviceFee;
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
* 1:自动创建;2:待开发;3:正常;4:清仓;5:停止销售"
|
||||||
|
* default : 3
|
||||||
|
*/
|
||||||
|
@Excel(name = "状态", width = 15)
|
||||||
|
@ApiModelProperty(value = "状态")
|
||||||
|
private Integer status;
|
||||||
|
/**
|
||||||
|
* 敏感属性
|
||||||
|
*/
|
||||||
|
@Excel(name = "敏感属性", width = 15)
|
||||||
|
@ApiModelProperty(value = "敏感属性")
|
||||||
|
private String sensitiveAttribute;
|
||||||
|
/**
|
||||||
|
* 是否赠品
|
||||||
|
* 1是 2否
|
||||||
|
*/
|
||||||
|
@Excel(name = "是否赠品", width = 15)
|
||||||
|
@ApiModelProperty(value = "是否赠品")
|
||||||
|
private Integer isGift;
|
||||||
|
/**
|
||||||
|
* SKU价格
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "SKU价格")
|
||||||
|
private BigDecimal skuPrice;
|
||||||
|
/**
|
||||||
|
* 申报价格
|
||||||
|
*/
|
||||||
|
@Excel(name = "申报价格", width = 15)
|
||||||
|
@ApiModelProperty(value = "申报价格")
|
||||||
|
private BigDecimal declaredValue;
|
||||||
|
/**
|
||||||
|
* 申报中文名称
|
||||||
|
*/
|
||||||
|
@Excel(name = "申报中文名称", width = 15)
|
||||||
|
@ApiModelProperty(value = "申报中文名称")
|
||||||
|
private String declareName;
|
||||||
|
/**
|
||||||
|
* 申报英文名称
|
||||||
|
*/
|
||||||
|
@Excel(name = "申报英文名称", width = 15)
|
||||||
|
@ApiModelProperty(value = "申报英文名称")
|
||||||
|
private String declareEname;
|
||||||
|
/**
|
||||||
|
* 供应商
|
||||||
|
*/
|
||||||
|
@Excel(name = "供应商", width = 15)
|
||||||
|
@ApiModelProperty(value = "供应商")
|
||||||
|
private String supplier;
|
||||||
|
/**
|
||||||
|
* 供应商商品网址
|
||||||
|
*/
|
||||||
|
@Excel(name = "供应商商品网址", width = 15)
|
||||||
|
@ApiModelProperty(value = "供应商商品网址")
|
||||||
|
private String supplierLink;
|
||||||
|
|
||||||
|
@Excel(name = "仓库", width = 15)
|
||||||
|
@ApiModelProperty(value = "仓库")
|
||||||
|
private String warehouse;
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
package org.jeecg.modules.business.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ResponsesWithMsg {
|
||||||
|
private Map<String, List<String>> successes = new HashMap<>();
|
||||||
|
private Map<String, List<String>> failures = new HashMap<>();
|
||||||
|
|
||||||
|
public void addSuccess(String message) {
|
||||||
|
successes.putIfAbsent(message, new ArrayList<>());
|
||||||
|
}
|
||||||
|
public void addSuccess(String key, String message) {
|
||||||
|
if (!successes.containsKey(key)) {
|
||||||
|
successes.put(key, new ArrayList<>());
|
||||||
|
}
|
||||||
|
successes.get(key).add(message);
|
||||||
|
}
|
||||||
|
public void addSuccess(String key, List<String> messages) {
|
||||||
|
if (!successes.containsKey(key)) {
|
||||||
|
successes.put(key, new ArrayList<>());
|
||||||
|
}
|
||||||
|
successes.get(key).addAll(messages);
|
||||||
|
}
|
||||||
|
public void addFailure(String message) {
|
||||||
|
failures.putIfAbsent(message, new ArrayList<>());
|
||||||
|
}
|
||||||
|
public void addFailure(String key, String message) {
|
||||||
|
if (!failures.containsKey(key)) {
|
||||||
|
failures.put(key, new ArrayList<>());
|
||||||
|
}
|
||||||
|
failures.get(key).add(message);
|
||||||
|
}
|
||||||
|
public void addFailure(String key, List<String> messages) {
|
||||||
|
if (!failures.containsKey(key)) {
|
||||||
|
failures.put(key, new ArrayList<>());
|
||||||
|
}
|
||||||
|
failures.get(key).addAll(messages);
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,6 @@ import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
import org.jeecgframework.poi.excel.annotation.ExcelCollection;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@ -131,7 +130,6 @@ public class SkuOrderPage {
|
||||||
/**
|
/**
|
||||||
* SKU价格
|
* SKU价格
|
||||||
*/
|
*/
|
||||||
@ExcelCollection(name = "SKU价格")
|
|
||||||
@ApiModelProperty(value = "SKU价格")
|
@ApiModelProperty(value = "SKU价格")
|
||||||
private java.math.BigDecimal skuPrice;
|
private java.math.BigDecimal skuPrice;
|
||||||
/**
|
/**
|
||||||
|
@ -206,4 +204,8 @@ public class SkuOrderPage {
|
||||||
@Excel(name = "供应商商品网址", width = 15)
|
@Excel(name = "供应商商品网址", width = 15)
|
||||||
@ApiModelProperty(value = "供应商商品网址")
|
@ApiModelProperty(value = "供应商商品网址")
|
||||||
private String supplierLink;
|
private String supplierLink;
|
||||||
|
|
||||||
|
@Excel(name = "仓库", width = 15)
|
||||||
|
@ApiModelProperty(value = "仓库")
|
||||||
|
private String warehouse;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue