mirror of https://github.com/jeecgboot/jeecg-boot
commit
78d5d457e2
|
@ -0,0 +1,163 @@
|
|||
package org.jeecg.modules.business.controller.admin;
|
||||
|
||||
import java.util.Arrays;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.modules.business.entity.LabelData;
|
||||
import org.jeecg.modules.business.service.ILabelDataService;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
|
||||
/**
|
||||
* @Description: 自定义分类
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-02-06
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Api(tags="自定义分类")
|
||||
@RestController
|
||||
@RequestMapping("/labelData")
|
||||
@Slf4j
|
||||
public class LabelDataController extends JeecgController<LabelData, ILabelDataService> {
|
||||
@Autowired
|
||||
private ILabelDataService labelDataService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param labelData
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "自定义分类-分页列表查询")
|
||||
@ApiOperation(value="自定义分类-分页列表查询", notes="自定义分类-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<LabelData>> queryPageList(LabelData labelData,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<LabelData> queryWrapper = QueryGenerator.initQueryWrapper(labelData, req.getParameterMap());
|
||||
Page<LabelData> page = new Page<LabelData>(pageNo, pageSize);
|
||||
IPage<LabelData> pageList = labelDataService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param labelData
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "自定义分类-添加")
|
||||
@ApiOperation(value="自定义分类-添加", notes="自定义分类-添加")
|
||||
@RequiresPermissions("business:label_data:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody LabelData labelData) {
|
||||
labelDataService.save(labelData);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param labelData
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "自定义分类-编辑")
|
||||
@ApiOperation(value="自定义分类-编辑", notes="自定义分类-编辑")
|
||||
@RequiresPermissions("business:label_data:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody LabelData labelData) {
|
||||
labelDataService.updateById(labelData);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "自定义分类-通过id删除")
|
||||
@ApiOperation(value="自定义分类-通过id删除", notes="自定义分类-通过id删除")
|
||||
@RequiresPermissions("business:label_data:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
||||
labelDataService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "自定义分类-批量删除")
|
||||
@ApiOperation(value="自定义分类-批量删除", notes="自定义分类-批量删除")
|
||||
@RequiresPermissions("business:label_data:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
this.labelDataService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "自定义分类-通过id查询")
|
||||
@ApiOperation(value="自定义分类-通过id查询", notes="自定义分类-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<LabelData> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
LabelData labelData = labelDataService.getById(id);
|
||||
if(labelData==null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(labelData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param labelData
|
||||
*/
|
||||
@RequiresPermissions("business:label_data:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, LabelData labelData) {
|
||||
return super.exportXls(request, labelData, LabelData.class, "自定义分类");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("business:label_data:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, LabelData.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -40,6 +40,8 @@ import javax.servlet.ServletRequest;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -56,6 +58,8 @@ import static org.jeecg.common.util.SqlInjectionUtil.specialFilterContentForDict
|
|||
@RequestMapping("/sku")
|
||||
@Slf4j
|
||||
public class SkuController {
|
||||
@Autowired
|
||||
private IShopService shopService;
|
||||
@Autowired
|
||||
private ISkuService skuService;
|
||||
@Autowired
|
||||
|
@ -447,9 +451,86 @@ public class SkuController {
|
|||
|
||||
@PostMapping("/createMabangSku")
|
||||
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.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));
|
||||
}
|
||||
@RequestMapping(value = "/exportNewMabangSkusXls")
|
||||
public ModelAndView exportXls(@RequestParam Map<String, String> params) {
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
List<NewSkuPage> skuList = parseSkuList(params);
|
||||
log.info("Exporting new skus to excel ...");
|
||||
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"));
|
||||
sku.setLabelData(map.get("labelData"));
|
||||
return sku;
|
||||
}
|
||||
@PostMapping("syncSkus")
|
||||
public Result<?> syncSkus(@RequestBody List<String> erpCodes) {
|
||||
Map<Sku, String> newSkusNeedTreatmentMap;
|
||||
|
@ -496,4 +577,34 @@ public class SkuController {
|
|||
skuListMabangService.mabangSkuStockUpdate(erpCodes);
|
||||
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(400, "Bad Request");
|
||||
}
|
||||
try {
|
||||
specialFilterContentForDictSql(parsedColumn);
|
||||
} catch (RuntimeException e) {
|
||||
return Result.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 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.SkuWeightParam;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
|
@ -192,7 +192,7 @@ public class SkuWeightController extends JeecgController<SkuWeight, ISkuWeightSe
|
|||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||
|
||||
Responses responses = new Responses();
|
||||
ResponsesWithMsg responses = new ResponsesWithMsg();
|
||||
List<SkuWeight> skuWeights = new ArrayList<>();
|
||||
Map<String, SkuWeight> skuWeightMappedByErpCode = new HashMap<>();
|
||||
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||
|
@ -242,16 +242,16 @@ public class SkuWeightController extends JeecgController<SkuWeight, ISkuWeightSe
|
|||
skuWeightMappedByErpCode.put(erpCode, skuWeight);
|
||||
}
|
||||
log.info("Import weights for skus: {}", skuWeightMappedByErpCode.keySet());
|
||||
Responses mabangResponses = skuListMabangService.mabangSkuWeightUpdate(skuWeights);
|
||||
ResponsesWithMsg mabangResponses = skuListMabangService.mabangSkuWeightUpdate(skuWeights);
|
||||
List<SkuWeight> skuWeightSuccesses = new ArrayList<>();
|
||||
mabangResponses.getSuccesses().forEach(skuErpCode -> {
|
||||
String erpCode = skuErpCode.split(":")[0].trim();
|
||||
skuWeightSuccesses.add(skuWeightMappedByErpCode.get(erpCode));
|
||||
mabangResponses.getSuccesses().forEach((skuErpCode, messages) -> {
|
||||
skuWeightSuccesses.add(skuWeightMappedByErpCode.get(skuErpCode));
|
||||
});
|
||||
skuWeightSuccesses.forEach(skuWeight -> skuMongoService.upsertSkuWeight(skuWeight));
|
||||
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) {
|
||||
e.printStackTrace();
|
||||
String msg = e.getMessage();
|
||||
|
@ -324,11 +324,10 @@ public class SkuWeightController extends JeecgController<SkuWeight, ISkuWeightSe
|
|||
skuWeightsMap.put(sku.getErpCode(), skuWeight);
|
||||
}
|
||||
List<SkuWeight> skuWeights = new ArrayList<>(skuWeightsMap.values());
|
||||
Responses responses = skuListMabangService.mabangSkuWeightUpdate(skuWeights);
|
||||
ResponsesWithMsg responses = skuListMabangService.mabangSkuWeightUpdate(skuWeights);
|
||||
List<SkuWeight> skuWeightSuccesses = new ArrayList<>();
|
||||
responses.getSuccesses().forEach(skuErpCode -> {
|
||||
String erpCode = skuErpCode.split(":")[0].trim();
|
||||
skuWeightSuccesses.add(skuWeightsMap.get(erpCode));
|
||||
responses.getSuccesses().forEach((skuErpCode, messages) -> {
|
||||
skuWeightSuccesses.add(skuWeightsMap.get(skuErpCode));
|
||||
});
|
||||
|
||||
skuWeightSuccesses.forEach(skuWeight -> skuMongoService.upsertSkuWeight(skuWeight));
|
||||
|
|
|
@ -557,7 +557,7 @@ public class InvoiceController {
|
|||
|
||||
List<PlatformOrderFront> orders = platformOrderService.fetchUninvoicedOrdersByShopForClientFullSQL(shopIdList, Collections.singletonList(1), parsedColumn, parsedOrder, pageNo, pageSize,
|
||||
productStatuses, shippingAvailable, purchaseAvailable);
|
||||
int total = orders.get(0).getTotalCount();
|
||||
int total = !order.isEmpty() ? orders.get(0).getTotalCount() : 0;
|
||||
|
||||
IPage<PlatformOrderFront> page = new Page<>();
|
||||
page.setRecords(orders);
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package org.jeecg.modules.business.domain.api.mabang.doSearchSkuListNew;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
// 仓库信息,接口参数传showWarehouse才返回
|
||||
public class Label {
|
||||
/**自定义分类ID*/
|
||||
@JSONField(name = "id")
|
||||
private long id;
|
||||
/**自定义分类名称**/
|
||||
@JSONField(name = "name")
|
||||
private String name;
|
||||
}
|
|
@ -40,6 +40,11 @@ public class SkuData {
|
|||
private Integer status;
|
||||
@JSONField(name="originalSku")
|
||||
private String originalSku;
|
||||
/**
|
||||
* if multiple virtual skus, they need to be separated by ";"
|
||||
*/
|
||||
@JSONField(name="virtualSkus")
|
||||
private String virtualSkus;
|
||||
@JSONField(name="salePrice")
|
||||
private BigDecimal salePrice;
|
||||
@JSONField(name="declareValue")
|
||||
|
@ -54,7 +59,12 @@ public class SkuData {
|
|||
private BigDecimal purchasePrice;
|
||||
/**默认供应商名称,接口参数传showProvider才返回*/
|
||||
@JSONField(name="warehouse")
|
||||
private String warehouse;
|
||||
private Warehouse[] warehouse;
|
||||
/** 自定义分类,接口参数传showLabel才返回*/
|
||||
@JSONField(name="label")
|
||||
private Label[] label;
|
||||
@JSONField(name="warehouseName")
|
||||
private String warehouseName;
|
||||
/**
|
||||
* if stockPicture is empty, we use it
|
||||
*/
|
||||
|
@ -81,6 +91,11 @@ public class SkuData {
|
|||
*/
|
||||
@JSONField(name="saleRemark")
|
||||
private String saleRemark;
|
||||
/**
|
||||
* 自定义分类json格式
|
||||
*/
|
||||
@JSONField(name="labelData")
|
||||
private Label[] labelData;
|
||||
/**
|
||||
* 是否含电池:1是;2否
|
||||
*/
|
||||
|
@ -109,7 +124,7 @@ public class SkuData {
|
|||
/**
|
||||
* 是否为易燃品 1: 是 2:不是,默认为2
|
||||
*/
|
||||
@JSONField(name="is_flammable")
|
||||
@JSONField(name="is_flammables")
|
||||
private Integer isFlammable;
|
||||
/**
|
||||
* 是否为刀具 1:是 2:不是,默认为2
|
||||
|
|
|
@ -31,7 +31,7 @@ public class SkuListRawStream implements NetworkDataStream<SkuListResponse> {
|
|||
public SkuListResponse attempt() {
|
||||
log.info("Begin the first request");
|
||||
this.currentResponse = new SkuListRequest(toSend).send();
|
||||
if (currentResponse.getData().isEmpty()) {
|
||||
if (currentResponse.getData() == null || currentResponse.getData().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
began = true;
|
||||
|
|
|
@ -48,8 +48,8 @@ public class SkuListRequestBody implements RequestBody {
|
|||
putNonNull(json, "maxRows", maxRows);
|
||||
putNonNull(json, "showVirtualSku", showVirtualSku);
|
||||
putNonNull(json, "showProvider", showProvider);
|
||||
putNonNull(json, "showWarehouse", showWarehouse);
|
||||
putNonNull(json, "showLabel", showLabel);
|
||||
putNonNull(json, "showWarehouse", String.valueOf(showWarehouse));
|
||||
putNonNull(json, "showLabel", String.valueOf(showLabel));
|
||||
putNonNull(json, "showAttributes", showAttributes);
|
||||
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;
|
||||
}
|
|
@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
|||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.jeecg.modules.business.domain.api.mabang.RequestBody;
|
||||
import org.jeecg.modules.business.domain.api.mabang.doSearchSkuListNew.Label;
|
||||
import org.jeecg.modules.business.domain.api.mabang.doSearchSkuListNew.SkuData;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
@ -24,6 +25,7 @@ public class SkuAddRequestBody implements RequestBody {
|
|||
private String declareEname;
|
||||
private String warehouse;
|
||||
private String remark;
|
||||
private Label[] labelData;
|
||||
private Integer hasBattery;
|
||||
private Integer magnetic;
|
||||
private Integer powder;
|
||||
|
@ -34,6 +36,7 @@ public class SkuAddRequestBody implements RequestBody {
|
|||
private Integer isGift;
|
||||
private String supplier;
|
||||
private String supplierLink;
|
||||
private String picture;
|
||||
|
||||
@Override
|
||||
public String api() {
|
||||
|
@ -51,6 +54,15 @@ public class SkuAddRequestBody implements RequestBody {
|
|||
putNonNull(json, "declareValue", declareValue);
|
||||
putNonNull(json, "declareName", declareName);
|
||||
putNonNull(json, "declareEname", declareEname);
|
||||
if(labelData != null) {
|
||||
JSONArray labelDataArray = new JSONArray();
|
||||
for(Label label : labelData) {
|
||||
JSONObject labelJson = new JSONObject();
|
||||
labelJson.put("name", label.getName());
|
||||
labelDataArray.add(labelJson);
|
||||
}
|
||||
json.put("labelData", labelDataArray.toJSONString());
|
||||
}
|
||||
JSONArray warehouseData = new JSONArray();
|
||||
JSONObject warehouse = new JSONObject();
|
||||
warehouse.put("name", this.warehouse);
|
||||
|
@ -74,6 +86,7 @@ public class SkuAddRequestBody implements RequestBody {
|
|||
supplier.put("flag", 1);
|
||||
supplierData.add(supplier);
|
||||
json.put("suppliersData", supplierData.toJSONString());
|
||||
putNonNull(json, "picture", picture);
|
||||
return json;
|
||||
}
|
||||
|
||||
|
@ -85,8 +98,9 @@ public class SkuAddRequestBody implements RequestBody {
|
|||
this.declareValue = data.getDeclareValue();
|
||||
this.declareName = data.getDeclareNameZh();
|
||||
this.declareEname = data.getDeclareNameEn();
|
||||
this.warehouse = data.getWarehouse();
|
||||
this.warehouse = data.getWarehouseName();
|
||||
this.remark = data.getSaleRemark();
|
||||
this.labelData = data.getLabelData();
|
||||
this.hasBattery = data.getHasBattery();
|
||||
this.magnetic = data.getMagnetic();
|
||||
this.powder = data.getPowder();
|
||||
|
@ -97,6 +111,7 @@ public class SkuAddRequestBody implements RequestBody {
|
|||
this.isGift = data.getIsGift();
|
||||
this.supplier = data.getSupplier();
|
||||
this.supplierLink = data.getSupplierLink();
|
||||
this.picture = data.getSalePicture();
|
||||
}
|
||||
|
||||
private <E> void putNonNull(JSONObject json, String key, E value) {
|
||||
|
|
|
@ -20,12 +20,21 @@ public class SkuAddResponse extends Response {
|
|||
|
||||
private final String stockSku;
|
||||
|
||||
private String message;
|
||||
|
||||
public SkuAddResponse(Code code, JSONObject data, String stockId, String stockSku) {
|
||||
super(code);
|
||||
this.data = data;
|
||||
this.stockId = stockId;
|
||||
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.
|
||||
|
|
|
@ -4,19 +4,23 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.codehaus.jettison.json.JSONException;
|
||||
import org.codehaus.jettison.json.JSONObject;
|
||||
import org.jeecg.modules.business.domain.api.mabang.doSearchSkuListNew.*;
|
||||
import org.jeecg.modules.business.service.ISkuListMabangService;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MabangUnpairedSkuJob implements Job {
|
||||
@Autowired
|
||||
private ISkuListMabangService skuListMabangService;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
JobDataMap jobDataMap = context.getMergedJobDataMap();
|
||||
|
@ -40,11 +44,7 @@ public class MabangUnpairedSkuJob implements Job {
|
|||
return;
|
||||
}
|
||||
|
||||
SkuListRequestBody body = new SkuListRequestBody();
|
||||
body.setStockSkuList(String.join(",", skuList));
|
||||
SkuListRawStream rawStream = new SkuListRawStream(body);
|
||||
UnpairedSkuListStream stream = new UnpairedSkuListStream(rawStream);
|
||||
List<SkuData> skusFromMabang = stream.all();
|
||||
List<SkuData> skuDatas = skuListMabangService.fetchUnpairedSkus(skuList);
|
||||
// System.out.println("skus from mabang : " + skusFromMabang);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
package org.jeecg.modules.business.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Description: 自定义分类
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-02-06
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("label_data")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="label_data对象", description="自定义分类")
|
||||
public class LabelData implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**主键*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "主键")
|
||||
private java.lang.String id;
|
||||
/**创建人*/
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private java.lang.String createBy;
|
||||
/**创建日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "创建日期")
|
||||
private java.util.Date createTime;
|
||||
/**更新人*/
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private java.lang.String updateBy;
|
||||
/**更新日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "更新日期")
|
||||
private java.util.Date updateTime;
|
||||
/**自定义分类名称*/
|
||||
@Excel(name = "自定义分类名称", width = 15)
|
||||
@ApiModelProperty(value = "自定义分类名称")
|
||||
private java.lang.String name;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package org.jeecg.modules.business.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.business.entity.LabelData;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @Description: 自定义分类
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-02-06
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Repository
|
||||
public interface LabelDataMapper extends BaseMapper<LabelData> {
|
||||
|
||||
}
|
|
@ -19,4 +19,8 @@ public interface SensitiveAttributeMapper extends BaseMapper<SensitiveAttribute>
|
|||
String getHighestPriorityAttributeId(@Param("orderId") String orderId);
|
||||
|
||||
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<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);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<?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="org.jeecg.modules.business.mapper.LabelDataMapper">
|
||||
|
||||
</mapper>
|
|
@ -29,4 +29,20 @@
|
|||
SELECT id, priority, zh_name
|
||||
FROM wia_app.sensitive_attribute
|
||||
</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>
|
|
@ -790,4 +790,30 @@
|
|||
JOIN client c ON client_sku.client_id = c.id
|
||||
WHERE c.internal_code = #{clientCode};
|
||||
</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>
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package org.jeecg.modules.business.service;
|
||||
|
||||
import org.jeecg.modules.business.entity.LabelData;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @Description: 自定义分类
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-02-06
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ILabelDataService extends IService<LabelData> {
|
||||
|
||||
}
|
|
@ -17,4 +17,8 @@ public interface ISensitiveAttributeService extends IService<SensitiveAttribute>
|
|||
String getHighestPriorityAttributeId(String orderId);
|
||||
|
||||
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.entity.Sku;
|
||||
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 java.util.List;
|
||||
|
@ -33,12 +33,18 @@ public interface ISkuListMabangService extends IService<SkuData> {
|
|||
List<String> parseSkuListToProductCodeList(List<SkuData> erpCodeList) throws Exception;
|
||||
Map<Sku, String> createSkus(List<SkuData> skuDataList);
|
||||
|
||||
Responses publishSkuToMabang(List<SkuOrderPage> skuList);
|
||||
ResponsesWithMsg publishSkuToMabang(List<SkuOrderPage> skuList);
|
||||
|
||||
Map<Sku, String> skuSyncUpsert(List<String> erpCodes);
|
||||
void updateSkuId();
|
||||
|
||||
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<String> fetchAllClientSkuCodes(String clientCode);
|
||||
|
||||
List<String> fetchUnpairedSkus(String shopId, int offset, Integer pageSize, String column, String order);
|
||||
|
||||
int countUnpairedSkus(String shopId);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package org.jeecg.modules.business.service.impl;
|
||||
|
||||
import org.jeecg.modules.business.entity.LabelData;
|
||||
import org.jeecg.modules.business.mapper.LabelDataMapper;
|
||||
import org.jeecg.modules.business.service.ILabelDataService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
/**
|
||||
* @Description: 自定义分类
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-02-06
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class LabelDataServiceImpl extends ServiceImpl<LabelDataMapper, LabelData> implements ILabelDataService {
|
||||
|
||||
}
|
|
@ -35,4 +35,14 @@ public class SensitiveAttributeServiceImpl extends ServiceImpl<SensitiveAttribut
|
|||
public List<SensitiveAttribute> 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.mongoService.SkuMongoService;
|
||||
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.online.cgform.mapper.OnlCgformFieldMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -466,7 +466,8 @@ public class SkuListMabangServiceImpl extends ServiceImpl<SkuListMabangMapper, S
|
|||
}
|
||||
return remark;
|
||||
}
|
||||
public Responses publishSkuToMabang(List<SkuOrderPage> skuList) {
|
||||
public ResponsesWithMsg publishSkuToMabang(List<SkuOrderPage> skuList) {
|
||||
ResponsesWithMsg responses = new ResponsesWithMsg();
|
||||
List<SkuData> skuDataList = skuList.stream()
|
||||
.map(this::SkuOrderPageToSkuData)
|
||||
.collect(toList());
|
||||
|
@ -483,24 +484,20 @@ public class SkuListMabangServiceImpl extends ServiceImpl<SkuListMabangMapper, S
|
|||
return request.send();
|
||||
} catch (Exception e) {
|
||||
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))
|
||||
.collect(toList());
|
||||
List<SkuAddResponse> results = futures.stream().map(CompletableFuture::join).collect(toList());
|
||||
long successCount = results.stream().filter(SkuAddResponse::success).count();
|
||||
log.info("{}/{} skus published successfully.", successCount, skuDataList.size());
|
||||
List<String> successes = results.stream()
|
||||
.filter(SkuAddResponse::success)
|
||||
.map(SkuAddResponse::getStockSku)
|
||||
.collect(toList());
|
||||
List<String> failures = results.stream()
|
||||
.filter(response -> !response.success())
|
||||
.map(SkuAddResponse::getStockSku)
|
||||
.collect(toList());
|
||||
Responses responses = new Responses();
|
||||
responses.setSuccesses(successes);
|
||||
responses.setFailures(failures);
|
||||
results.forEach(response -> {
|
||||
if(response.success()) {
|
||||
responses.addSuccess(response.getStockSku());
|
||||
} else {
|
||||
responses.addFailure(response.getStockSku(), response.getMessage());
|
||||
}
|
||||
});
|
||||
return responses;
|
||||
}
|
||||
|
||||
|
@ -544,7 +541,12 @@ public class SkuListMabangServiceImpl extends ServiceImpl<SkuListMabangMapper, S
|
|||
|
||||
public SkuData SkuOrderPageToSkuData(SkuOrderPage skuOrderPage) {
|
||||
SensitiveAttribute sensitiveAttribute = sensitiveAttributeService.getById(skuOrderPage.getSensitiveAttribute());
|
||||
if(sensitiveAttribute == null) {
|
||||
sensitiveAttribute = sensitiveAttributeService.getByZhName(skuOrderPage.getSensitiveAttribute());
|
||||
}
|
||||
SkuData skuData = new SkuData();
|
||||
if(skuOrderPage.getId() != null)
|
||||
skuData.setVirtualSkus(skuOrderPage.getId());
|
||||
skuData.setErpCode(skuOrderPage.getErpCode());
|
||||
skuData.setNameCN(skuOrderPage.getZhName());
|
||||
skuData.setNameEN(skuOrderPage.getEnName());
|
||||
|
@ -552,7 +554,14 @@ public class SkuListMabangServiceImpl extends ServiceImpl<SkuListMabangMapper, S
|
|||
skuData.setDeclareNameEn(skuOrderPage.getDeclareEname());
|
||||
skuData.setSalePrice(skuOrderPage.getSkuPrice());
|
||||
skuData.setDeclareValue(skuOrderPage.getDeclaredValue());
|
||||
skuData.setWarehouse(DEFAULT_WAREHOUSE_NAME);
|
||||
skuData.setWarehouseName(DEFAULT_WAREHOUSE_NAME);
|
||||
List<Label> labels = new ArrayList<>();
|
||||
for(String labelName : skuOrderPage.getLabelData().split(",")) {
|
||||
Label label = new Label();
|
||||
label.setName(labelName);
|
||||
labels.add(label);
|
||||
}
|
||||
skuData.setLabelData(labels.toArray(new Label[0]));
|
||||
if(skuOrderPage.getWeight() != null)
|
||||
skuData.setSaleRemark(skuOrderPage.getWeight().toString());
|
||||
skuData.setHasBattery(sensitiveAttribute.getHasBattery());
|
||||
|
@ -565,9 +574,44 @@ public class SkuListMabangServiceImpl extends ServiceImpl<SkuListMabangMapper, S
|
|||
skuData.setIsGift(skuOrderPage.getIsGift());
|
||||
skuData.setSupplier(skuOrderPage.getSupplier());
|
||||
skuData.setSupplierLink(skuOrderPage.getSupplierLink());
|
||||
skuData.setSalePicture(skuOrderPage.getImageSource());
|
||||
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());
|
||||
if(skuData.getLabelData() != null) {
|
||||
StringBuilder labelDataString = new StringBuilder();
|
||||
for(Label labelData : skuData.getLabelData()) {
|
||||
labelDataString.append(labelData.getName()).append(",");
|
||||
}
|
||||
sop.setLabelData(labelDataString.toString());
|
||||
}
|
||||
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)
|
||||
|
@ -635,9 +679,8 @@ public class SkuListMabangServiceImpl extends ServiceImpl<SkuListMabangMapper, S
|
|||
}
|
||||
|
||||
@Override
|
||||
public Responses mabangSkuWeightUpdate(List<SkuWeight> skuWeights) {
|
||||
Responses responses = new Responses();
|
||||
List<String> failures = new ArrayList<>();
|
||||
public ResponsesWithMsg mabangSkuWeightUpdate(List<SkuWeight> skuWeights) {
|
||||
ResponsesWithMsg responses = new ResponsesWithMsg();
|
||||
List<String> skuIds = skuWeights.stream()
|
||||
.map(SkuWeight::getSkuId)
|
||||
.collect(toList());
|
||||
|
@ -701,7 +744,7 @@ public class SkuListMabangServiceImpl extends ServiceImpl<SkuListMabangMapper, S
|
|||
.orElse(null);
|
||||
if(null == skuInDb) {
|
||||
log.error("Sku not found : {}", skuWeight.getSkuId());
|
||||
failures.add(skuWeight.getSkuId());
|
||||
responses.addFailure(skuWeight.getSkuId(), "Sku not found");
|
||||
return null;
|
||||
}
|
||||
if(null == sku) {
|
||||
|
@ -745,17 +788,48 @@ public class SkuListMabangServiceImpl extends ServiceImpl<SkuListMabangMapper, S
|
|||
List<SkuChangeResponse> results = futures.stream().map(CompletableFuture::join).collect(toList());
|
||||
long successCount = results.stream().filter(SkuChangeResponse::success).count();
|
||||
log.info("{}/{} skus updated successfully.", successCount, skuDataList.size());
|
||||
List<String> successes = results.stream()
|
||||
.filter(SkuChangeResponse::success)
|
||||
.map(response -> response.getStockSku() + " : Mabang OK")
|
||||
.collect(toList());
|
||||
failures.addAll(results.stream()
|
||||
.filter(response -> !response.success())
|
||||
.map(response -> response.getStockSku() + " | Mabang")
|
||||
.collect(toList()));
|
||||
|
||||
responses.getSuccesses().addAll(successes);
|
||||
responses.setFailures(failures);
|
||||
results.forEach(response -> {
|
||||
if(response.success()) {
|
||||
responses.addSuccess(response.getStockSku(), "Mabang");
|
||||
}
|
||||
else {
|
||||
responses.addFailure(response.getStockSku(), "Mabang");
|
||||
}
|
||||
});
|
||||
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.setShowLabel(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
|
||||
private ILogisticChannelPriceService logisticChannelPriceService;
|
||||
@Autowired
|
||||
private CountryService countryService;
|
||||
@Autowired
|
||||
private IPlatformOrderContentService platformOrderContentService;
|
||||
@Autowired
|
||||
private ISkuLogisticChoiceService skuLogisticChoiceService;
|
||||
|
@ -619,4 +617,13 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS
|
|||
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,132 @@
|
|||
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;
|
||||
|
||||
@Excel(name = "自定义分类", width = 15)
|
||||
@ApiModelProperty(value = "自定义分类")
|
||||
private String labelData;
|
||||
}
|
|
@ -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 lombok.Data;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.jeecgframework.poi.excel.annotation.ExcelCollection;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
@ -131,7 +130,6 @@ public class SkuOrderPage {
|
|||
/**
|
||||
* SKU价格
|
||||
*/
|
||||
@ExcelCollection(name = "SKU价格")
|
||||
@ApiModelProperty(value = "SKU价格")
|
||||
private java.math.BigDecimal skuPrice;
|
||||
/**
|
||||
|
@ -206,4 +204,12 @@ public class SkuOrderPage {
|
|||
@Excel(name = "供应商商品网址", width = 15)
|
||||
@ApiModelProperty(value = "供应商商品网址")
|
||||
private String supplierLink;
|
||||
|
||||
@Excel(name = "仓库", width = 15)
|
||||
@ApiModelProperty(value = "仓库")
|
||||
private String warehouse;
|
||||
|
||||
@Excel(name ="自定义分类", width = 15)
|
||||
@ApiModelProperty(value = "自定义分类")
|
||||
private String labelData;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue