1
This commit is contained in:
@@ -5,6 +5,11 @@ import com.alibaba.fastjson2.JSONObject;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.erp.domain.*;
|
||||
import com.ruoyi.jarvis.service.IOuterIdGeneratorService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.ruoyi.erp.request.ERPAccount;
|
||||
import com.ruoyi.erp.request.ProductCreateRequest;
|
||||
import com.ruoyi.erp.request.ProductCategoryListQueryRequest;
|
||||
@@ -27,6 +32,11 @@ import java.util.List;
|
||||
@Validated
|
||||
public class ProductController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IOuterIdGeneratorService outerIdGeneratorService;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ProductController.class);
|
||||
|
||||
@PostMapping("/createByPromotion")
|
||||
public R<?> createByPromotion(@RequestBody @Validated CreateProductFromPromotionRequest req) {
|
||||
try {
|
||||
@@ -39,7 +49,16 @@ public class ProductController extends BaseController {
|
||||
erpShop.setPrice(req.getPrice());
|
||||
erpShop.setExpressFee(req.getExpressFee());
|
||||
erpShop.setStock(req.getStock());
|
||||
erpShop.setOuterid(req.getOuterId());
|
||||
|
||||
// 处理商家编码:如果为空则自动生成
|
||||
String outerId = req.getOuterId();
|
||||
if (StringUtils.isEmpty(outerId) && StringUtils.isNotEmpty(req.getSkuid())) {
|
||||
outerId = outerIdGeneratorService.generateOuterId(req.getSkuid());
|
||||
if (StringUtils.isNotEmpty(outerId)) {
|
||||
log.info("自动生成商家编码: skuid={}, outerId={}", req.getSkuid(), outerId);
|
||||
}
|
||||
}
|
||||
erpShop.setOuterid(outerId);
|
||||
erpShop.setStuffStatus(req.getStuffStatus());
|
||||
|
||||
// 发布店铺(必填)
|
||||
@@ -90,7 +109,27 @@ public class ProductController extends BaseController {
|
||||
JSONObject body = JSONObject.parseObject(JSON.toJSONString(erpShop));
|
||||
createRequest.setRequestBody(body);
|
||||
String resp = createRequest.getResponseBody();
|
||||
return R.ok(JSONObject.parse(resp));
|
||||
|
||||
// 解析响应并添加生成的outerId
|
||||
JSONObject responseData = JSONObject.parseObject(resp);
|
||||
if (responseData != null && responseData.getInteger("code") == 0) {
|
||||
// 如果发品成功,在响应中添加生成的outerId
|
||||
if (StringUtils.isNotEmpty(outerId)) {
|
||||
if (responseData.get("data") instanceof JSONObject) {
|
||||
JSONObject data = responseData.getJSONObject("data");
|
||||
data.put("outer_id", outerId);
|
||||
data.put("outerId", outerId);
|
||||
} else {
|
||||
// 如果没有data字段,创建一个
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("outer_id", outerId);
|
||||
data.put("outerId", outerId);
|
||||
responseData.put("data", data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return R.ok(responseData);
|
||||
} catch (Exception e) {
|
||||
return R.fail("创建失败: " + e.getMessage());
|
||||
}
|
||||
@@ -374,6 +413,7 @@ public class ProductController extends BaseController {
|
||||
private String whiteImages;
|
||||
private String serviceSupport; // 多个用逗号分隔
|
||||
private String outerId;
|
||||
private String skuid; // SKUID,用于自动生成商家编码
|
||||
private Integer stuffStatus;
|
||||
|
||||
private List<SkuItemDto> skuItems;
|
||||
@@ -412,6 +452,8 @@ public class ProductController extends BaseController {
|
||||
public void setServiceSupport(String serviceSupport) { this.serviceSupport = serviceSupport; }
|
||||
public String getOuterId() { return outerId; }
|
||||
public void setOuterId(String outerId) { this.outerId = outerId; }
|
||||
public String getSkuid() { return skuid; }
|
||||
public void setSkuid(String skuid) { this.skuid = skuid; }
|
||||
public Integer getStuffStatus() { return stuffStatus; }
|
||||
public void setStuffStatus(Integer stuffStatus) { this.stuffStatus = stuffStatus; }
|
||||
public List<SkuItemDto> getSkuItems() { return skuItems; }
|
||||
|
||||
@@ -185,4 +185,14 @@ public class FavoriteProductController extends BaseController
|
||||
{
|
||||
return toAjax(favoriteProductService.updateUseCountAndTime(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新发品信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('jarvis:favoriteProduct:edit')")
|
||||
@PutMapping("/updateProductInfo")
|
||||
public AjaxResult updateProductInfo(@RequestBody FavoriteProduct favoriteProduct)
|
||||
{
|
||||
return toAjax(favoriteProductService.updateProductInfo(favoriteProduct));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.ruoyi.web.controller.jarvis;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.jarvis.domain.PrdErrorTip;
|
||||
import com.ruoyi.jarvis.service.IPrdErrorTipService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 商品错误提示Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-01-01
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/jarvis/prdErrorTip")
|
||||
public class PrdErrorTipController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IPrdErrorTipService prdErrorTipService;
|
||||
|
||||
/**
|
||||
* 查询商品错误提示列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(PrdErrorTip prdErrorTip)
|
||||
{
|
||||
startPage();
|
||||
List<PrdErrorTip> list = prdErrorTipService.selectPrdErrorTipList(prdErrorTip);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出商品错误提示列表
|
||||
*/
|
||||
@Log(title = "商品错误提示", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(PrdErrorTip prdErrorTip)
|
||||
{
|
||||
List<PrdErrorTip> list = prdErrorTipService.selectPrdErrorTipList(prdErrorTip);
|
||||
ExcelUtil<PrdErrorTip> util = new ExcelUtil<PrdErrorTip>(PrdErrorTip.class);
|
||||
return util.exportExcel(list, "商品错误提示数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品错误提示详细信息
|
||||
*/
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(prdErrorTipService.selectPrdErrorTipById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增商品错误提示
|
||||
*/
|
||||
@Log(title = "商品错误提示", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody PrdErrorTip prdErrorTip)
|
||||
{
|
||||
return toAjax(prdErrorTipService.insertPrdErrorTip(prdErrorTip));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改商品错误提示
|
||||
*/
|
||||
@Log(title = "商品错误提示", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody PrdErrorTip prdErrorTip)
|
||||
{
|
||||
return toAjax(prdErrorTipService.updatePrdErrorTip(prdErrorTip));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品错误提示
|
||||
*/
|
||||
@Log(title = "商品错误提示", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(prdErrorTipService.deletePrdErrorTipByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据错误代码和子代码查询错误提示
|
||||
*/
|
||||
@GetMapping("/getByCode/{errCode}/{errSubCode}")
|
||||
public AjaxResult getByCode(@PathVariable String errCode, @PathVariable String errSubCode)
|
||||
{
|
||||
return success(prdErrorTipService.selectPrdErrorTipByCode(errCode, errSubCode));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user