浏览代码

提交代码

6 月之前
父节点
当前提交
f453bcfc8c

+ 27 - 2
08.src/Xingxi/xingxi-admin/src/main/java/com/xingxi/web/controller/master/merchant/controller/MerchantProdController.java

@@ -6,6 +6,10 @@ import com.xingxi.common.core.domain.AjaxResult;
 import com.xingxi.common.core.page.TableDataInfo;
 import com.xingxi.common.core.text.Convert;
 import com.xingxi.common.enums.BusinessType;
+import com.xingxi.common.utils.DateUtils;
+import com.xingxi.common.utils.ShiroUtils;
+import com.xingxi.master.merchant.domain.MerchantProd;
+import com.xingxi.master.merchant.service.IMerchantProdService;
 import com.xingxi.web.controller.master.merchant.domain.MerchantProdVo;
 import com.xingxi.web.controller.master.merchant.service.IMerchantProdVoService;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
@@ -14,6 +18,7 @@ import org.springframework.ui.ModelMap;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -28,6 +33,8 @@ public class MerchantProdController extends BaseController {
     private final String prefix = "master/merchant/prod";
 
     @Resource
+    private IMerchantProdService merchantProdService;
+    @Resource
     private IMerchantProdVoService merchantProdVoService;
 
     @RequiresPermissions("master:merchant:prod:view")
@@ -81,12 +88,30 @@ public class MerchantProdController extends BaseController {
     @ResponseBody
     public AjaxResult remove(String ids) {
         if (ids.indexOf(",") > 0) {
-            return toAjax(merchantProdVoService.logicDeleteMerchantProdByMercProdIds(Convert.toStrArray(ids)));
+            return toAjax(merchantProdService.logicDeleteMerchantProdByMercProdIds(Convert.toStrArray(ids)));
         } else {
-            return toAjax(merchantProdVoService.logicDeleteMerchantProdByMercProdId(Long.parseLong(ids)));
+            return toAjax(merchantProdService.logicDeleteMerchantProdByMercProdId(Long.parseLong(ids)));
         }
     }
 
+    /**
+     * 上架店铺商品
+     */
+    @RequiresPermissions("master:merchant:prod:shelf")
+    @Log(title = "店铺商品", businessType = BusinessType.UPDATE)
+    @PostMapping("/shelf")
+    @ResponseBody
+    public AjaxResult shelf(Long mercProdId, String shelfFlag) {
+        Date nowDate = DateUtils.getNowDate();
+        MerchantProd merchantProd = new MerchantProd();
+        merchantProd.setMercProdId(mercProdId);
+        merchantProd.setShelfFlag(shelfFlag);
+        merchantProd.setShelfTime(nowDate);
+        merchantProd.setUpdateUser(ShiroUtils.getLoginName());
+        merchantProd.setUpdateTime(nowDate);
+        return toAjax(merchantProdService.updateMerchantProd(merchantProd));
+    }
+
     @RequiresPermissions("master:merchant:prod:view")
     @GetMapping("/checkMercProd")
     @ResponseBody

+ 1 - 3
08.src/Xingxi/xingxi-admin/src/main/java/com/xingxi/web/controller/master/merchant/service/IMerchantProdVoService.java

@@ -1,7 +1,5 @@
 package com.xingxi.web.controller.master.merchant.service;
 
-import com.xingxi.master.merchant.domain.MerchantProd;
-import com.xingxi.master.merchant.service.IMerchantProdService;
 import com.xingxi.web.controller.master.merchant.domain.MerchantProdVo;
 
 import java.util.List;
@@ -12,7 +10,7 @@ import java.util.List;
  * @author xingxi
  * @date 2025-03-06
  */
-public interface IMerchantProdVoService extends IMerchantProdService {
+public interface IMerchantProdVoService {
     /**
      * 查询店铺商品列表
      *

+ 3 - 4
08.src/Xingxi/xingxi-admin/src/main/java/com/xingxi/web/controller/master/merchant/service/impl/MerchantProdVoServiceImpl.java

@@ -2,16 +2,14 @@ package com.xingxi.web.controller.master.merchant.service.impl;
 
 import com.xingxi.common.core.text.Convert;
 import com.xingxi.common.enums.EDelFlag;
+import com.xingxi.common.enums.EShelfFlag;
 import com.xingxi.common.exception.BusinessException;
 import com.xingxi.common.utils.DateUtils;
 import com.xingxi.common.utils.ShiroUtils;
 import com.xingxi.master.merchant.domain.MerchantProd;
-import com.xingxi.master.merchant.service.impl.MerchantProdServiceImpl;
 import com.xingxi.web.controller.master.merchant.domain.MerchantProdVo;
 import com.xingxi.web.controller.master.merchant.mapper.MerchantProdVoMapper;
 import com.xingxi.web.controller.master.merchant.service.IMerchantProdVoService;
-import com.xingxi.web.controller.master.product.domain.ProdVo;
-import com.xingxi.web.controller.master.product.mapper.ProdVoMapper;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -25,7 +23,7 @@ import java.util.List;
  * @date 2025-03-06
  */
 @Service
-public class MerchantProdVoServiceImpl extends MerchantProdServiceImpl implements IMerchantProdVoService {
+public class MerchantProdVoServiceImpl implements IMerchantProdVoService {
     @Resource
     private MerchantProdVoMapper merchantProdVoMapper;
 
@@ -76,6 +74,7 @@ public class MerchantProdVoServiceImpl extends MerchantProdServiceImpl implement
             MerchantProd merchantProd = new MerchantProd();
             merchantProd.setMercId(merchantProdVo.getMercId());
             merchantProd.setProdAttrId(Long.parseLong(prodAttrId));
+            merchantProd.setShelfFlag(EShelfFlag.NO.getVal());
             merchantProd.setDelFlag(EDelFlag.NO.getVal());
             merchantProd.setCreateUser(ShiroUtils.getLoginName());
             merchantProd.setCreateTime(DateUtils.getNowDate());

+ 71 - 0
08.src/Xingxi/xingxi-admin/src/main/java/com/xingxi/web/controller/master/product/controller/ProdPicController.java

@@ -0,0 +1,71 @@
+package com.xingxi.web.controller.master.product.controller;
+
+import com.xingxi.common.annotation.Log;
+import com.xingxi.common.core.controller.BaseController;
+import com.xingxi.common.core.domain.AjaxResult;
+import com.xingxi.common.enums.BusinessType;
+import com.xingxi.web.controller.master.product.domain.ProdPicVo;
+import com.xingxi.web.controller.master.product.service.IProdPicVoService;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 商品图片Controller
+ *
+ * @author ruoyi
+ * @date 2025-03-09
+ */
+@Controller
+@RequestMapping("/master/product/prodPic")
+public class ProdPicController extends BaseController {
+    private final String prefix = "master/product/prodPic";
+
+    @Resource
+    private IProdPicVoService prodPicVoService;
+
+    /**
+     * 修改商品图片
+     */
+    @RequiresPermissions("master:product:editPic")
+    @GetMapping("/editPic/{id}")
+    public String editPic(@PathVariable("id") Long id, ModelMap mMap) {
+        ProdPicVo cond = new ProdPicVo();
+        cond.setProdId(id);
+        List<ProdPicVo> prodPicVoList = new ArrayList<>();
+        List<ProdPicVo> resultList = prodPicVoService.selectProdPicVoList(cond);
+        if (resultList != null && resultList.size() > 0) {
+            prodPicVoList = resultList;
+        }
+        mMap.put("prodId", id);
+        mMap.put("prodPicVoList", prodPicVoList);
+        return prefix + "/editPic";
+    }
+
+    /**
+     * 添加商品图片
+     */
+    @RequiresPermissions("master:product:addPic")
+    @Log(title = "商品图片", businessType = BusinessType.INSERT)
+    @PostMapping("/addProdPic")
+    @ResponseBody
+    public AjaxResult addProdPic(ProdPicVo prodPicVo) {
+        return AjaxResult.success(prodPicVoService.addProdPic(prodPicVo));
+    }
+
+    /**
+     * 删除商品图片
+     */
+    @RequiresPermissions("master:product:Pic:remove")
+    @Log(title = "商品图片", businessType = BusinessType.DELETE)
+    @PostMapping("/remove")
+    @ResponseBody
+    public AjaxResult remove(ProdPicVo prodPicVo) {
+        return toAjax(prodPicVoService.logicDeleteProdPicByCondition(prodPicVo));
+    }
+}

+ 115 - 0
08.src/Xingxi/xingxi-admin/src/main/java/com/xingxi/web/controller/master/product/controller/ProdVendorController.java

@@ -0,0 +1,115 @@
+package com.xingxi.web.controller.master.product.controller;
+
+import com.xingxi.common.annotation.Log;
+import com.xingxi.common.core.controller.BaseController;
+import com.xingxi.common.core.domain.AjaxResult;
+import com.xingxi.common.core.page.TableDataInfo;
+import com.xingxi.common.enums.BusinessType;
+import com.xingxi.common.utils.poi.ExcelUtil;
+import com.xingxi.master.product.domain.ProdVendor;
+import com.xingxi.master.product.service.IProdVendorService;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * 商品供应商Controller
+ *
+ * @author ruoyi
+ * @date 2025-03-09
+ */
+@Controller
+@RequestMapping("/system/product/vendor")
+public class ProdVendorController extends BaseController {
+    private final String prefix = "system/product/vendor";
+
+    @Resource
+    private IProdVendorService prodVendorService;
+
+    @RequiresPermissions("system:product:vendor:view")
+    @GetMapping()
+    public String vendor() {
+        return prefix + "/vendor";
+    }
+
+    /**
+     * 查询商品供应商列表
+     */
+    @RequiresPermissions("system:product:vendor:list")
+    @PostMapping("/list")
+    @ResponseBody
+    public TableDataInfo list(ProdVendor prodVendor) {
+        startPage();
+        List<ProdVendor> list = prodVendorService.selectProdVendorList(prodVendor);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出商品供应商列表
+     */
+    @RequiresPermissions("system:product:vendor:export")
+    @Log(title = "商品供应商", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    @ResponseBody
+    public AjaxResult export(ProdVendor prodVendor) {
+        List<ProdVendor> list = prodVendorService.selectProdVendorList(prodVendor);
+        ExcelUtil<ProdVendor> util = new ExcelUtil<>(ProdVendor.class);
+        return util.exportExcel(list, "商品供应商数据");
+    }
+
+    /**
+     * 新增商品供应商
+     */
+    @GetMapping("/add")
+    public String add() {
+        return prefix + "/add";
+    }
+
+    /**
+     * 新增保存商品供应商
+     */
+    @RequiresPermissions("system:product:vendor:add")
+    @Log(title = "商品供应商", businessType = BusinessType.INSERT)
+    @PostMapping("/add")
+    @ResponseBody
+    public AjaxResult addSave(ProdVendor prodVendor) {
+        return toAjax(prodVendorService.insertProdVendor(prodVendor));
+    }
+
+    /**
+     * 修改商品供应商
+     */
+    @RequiresPermissions("system:product:vendor:edit")
+    @GetMapping("/edit/{prodVendorId}")
+    public String edit(@PathVariable("prodVendorId") Long prodVendorId, ModelMap mMap) {
+        ProdVendor prodVendor = prodVendorService.selectProdVendorByProdVendorId(prodVendorId);
+        mMap.put("prodVendor", prodVendor);
+        return prefix + "/edit";
+    }
+
+    /**
+     * 修改保存商品供应商
+     */
+    @RequiresPermissions("system:product:vendor:edit")
+    @Log(title = "商品供应商", businessType = BusinessType.UPDATE)
+    @PostMapping("/edit")
+    @ResponseBody
+    public AjaxResult editSave(ProdVendor prodVendor) {
+        return toAjax(prodVendorService.updateProdVendor(prodVendor));
+    }
+
+    /**
+     * 删除商品供应商
+     */
+    @RequiresPermissions("system:product:vendor:remove")
+    @Log(title = "商品供应商", businessType = BusinessType.DELETE)
+    @PostMapping("/remove")
+    @ResponseBody
+    public AjaxResult remove(String ids) {
+        return toAjax(prodVendorService.deleteProdVendorByProdVendorIds(ids));
+    }
+}

+ 12 - 0
08.src/Xingxi/xingxi-admin/src/main/resources/templates/master/merchant/prod/merchantProd.html

@@ -97,6 +97,11 @@
                         align: 'center',
                         formatter: function(value, row, index) {
                             var actions = [];
+                            if (row.shelfFlag !== "1") {
+                                actions.push('<a class="btn btn-success btn-xs ' + shelfFlags + '" href="javascript:void(0)" onclick="shelf(\'' + row.mercProdId + '\', \'1\')"><i class="fa fa-uplevel"></i>上架</a> ');
+                            } else {
+                                actions.push('<a class="btn btn-success btn-xs ' + shelfFlags + '" href="javascript:void(0)" onclick="shelf(\'' + row.mercProdId + '\', \'0\')"><i class="fa fa-uplevel"></i>下架</a> ');
+                            }
                             actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.mercProdId + '\')"><i class="fa fa-remove"></i>删除</a> ');
                             return actions.join('');
                         }
@@ -109,6 +114,13 @@
         function addProduct() {
             $.modal.open("添加商品", prefix + "/edit/" + $("#mercId").val());
         }
+
+        function shelf(mercProdId, shelfFlag) {
+            var shelfString = shelfFlag==="1"?"上架":"下架"
+            $.modal.confirm("确认" + shelfString + "?", function() {
+                $.operate.post(prefix + "/shelf", {"mercProdId": mercProdId, "shelfFlag": shelfFlag});
+            });
+        }
     </script>
 </body>
 </html>

+ 30 - 0
08.src/Xingxi/xingxi-common/src/main/java/com/xingxi/common/enums/EShelfFlag.java

@@ -0,0 +1,30 @@
+package com.xingxi.common.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @program: gululuq
+ * @description: 删除标志
+ * @author: 金
+ * @create: 2025-03-16
+ */
+@AllArgsConstructor
+@Getter
+public enum EShelfFlag {
+    YES("1", "已上架"),
+    NO("0", "未上架");
+
+    private String val;
+    private String desc;
+
+    // 解析
+    public static EShelfFlag parseByVal(String val) {
+        for (EShelfFlag type : EShelfFlag.values()) {
+            if (type.getVal().equalsIgnoreCase(val)) {
+                return type;
+            }
+        }
+        return EShelfFlag.NO;
+    }
+}