baolei 3 ماه پیش
والد
کامیت
30c60f8387

+ 16 - 0
08.src/Xingxi/xingxi-admin/src/main/java/com/xingxi/web/controller/business/banner/controller/BannerController.java

@@ -7,6 +7,9 @@ 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.enums.EBannerType;
+import com.xingxi.common.enums.EDelFlag;
+import com.xingxi.common.utils.DateUtils;
 import com.xingxi.common.utils.poi.ExcelUtil;
 import com.xingxi.web.controller.business.banner.domain.BannerVo;
 import com.xingxi.web.controller.business.banner.service.IBannerVoService;
@@ -16,6 +19,7 @@ import org.springframework.ui.ModelMap;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -81,6 +85,15 @@ public class BannerController extends BaseController {
     @PostMapping("/add")
     @ResponseBody
     public AjaxResult addSave(Banner banner) {
+
+        Date nowDate = DateUtils.getNowDate();
+        banner.setBannerType(EBannerType.IMAGE.getVal());
+        banner.setSort(999L);
+        banner.setDelFlag(EDelFlag.NO.getVal());
+        banner.setCreateUser(getLoginName());
+        banner.setCreateTime(nowDate);
+        banner.setUpdateUser(getLoginName());
+        banner.setUpdateTime(nowDate);
         return toAjax(bannerService.insertBanner(banner));
     }
 
@@ -103,6 +116,9 @@ public class BannerController extends BaseController {
     @PostMapping("/edit")
     @ResponseBody
     public AjaxResult editSave(Banner banner) {
+        Date nowDate = DateUtils.getNowDate();
+        banner.setUpdateUser(getLoginName());
+        banner.setUpdateTime(nowDate);
         return toAjax(bannerService.updateBanner(banner));
     }
 

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

@@ -16,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional;
 import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 店铺商品Service业务层处理
@@ -74,24 +75,31 @@ public class MerchantProdVoServiceImpl implements IMerchantProdVoService {
         String[] prodAttrIds = Convert.toStrArray(merchantProdVo.getProdAttrIds());
         MerchantProd cond = new MerchantProd();
         cond.setMercId(merchantProdVo.getMercId());
-        List<MerchantProdVo> checkResult = merchantProdVoMapper.selectMerchantProdVoByMercId(merchantProdVo.getMercId());
-        if (checkResult.size() > 0) {
-            int effectRows = merchantProdVoMapper.logicDeleteMerchantProdByCondition(cond);
-            if (effectRows == 0) {
-                throw new BusinessException("删除失败,请重试!");
-            }
-        }
+//        List<MerchantProdVo> checkResult = merchantProdVoMapper.selectMerchantProdVoByMercId(merchantProdVo.getMercId());
+//        if (checkResult.size() > 0) {
+//            int effectRows = merchantProdVoMapper.logicDeleteMerchantProdByCondition(cond);
+//            if (effectRows == 0) {
+//                throw new BusinessException("删除失败,请重试!");
+//            }
+//        }
         int effectRows = 0;
         List<MerchantProd> batchInsertList = new ArrayList<>();
+
+        List<MerchantProdVo> checkResult = merchantProdVoMapper.selectMerchantProdVoByMercId(merchantProdVo.getMercId());
+
+        List<Long> mercProdAttrIds = checkResult.stream().map(MerchantProdVo::getProdAttrId).collect(Collectors.toList());
+
         for (String prodAttrId : prodAttrIds) {
-            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());
-            batchInsertList.add(merchantProd);
+            if (!mercProdAttrIds.contains(Long.parseLong(prodAttrId))) {
+                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());
+                batchInsertList.add(merchantProd);
+            }
         }
         effectRows += merchantProdVoMapper.batchInsertMerchantProd(batchInsertList);
         return effectRows;

+ 1 - 0
08.src/Xingxi/xingxi-admin/src/main/resources/mapper/BannerVoMapper.xml

@@ -48,5 +48,6 @@
             <if test="updateTime != null "> and t_banner.updateTime = #{updateTime}</if>
             <if test="prodName != null  and prodName != ''"> and m_prod.prodName like concat('%', #{prodName}, '%')</if>
         </where>
+        order by t_banner.sort
     </select>
 </mapper>

+ 1 - 1
08.src/Xingxi/xingxi-admin/src/main/resources/templates/business/banner/edit.html

@@ -54,7 +54,7 @@
     </div>
     <th:block th:include="include :: footer" />
     <script th:inline="javascript">
-        var prefix = ctx + "system/banner";
+        var prefix = ctx + "business/banner"
 
         $('#bannerImgUrl').change(function () {
             var fileSize = this.files[0].size;

+ 1 - 1
08.src/Xingxi/xingxi-admin/src/main/resources/templates/master/product/prodPic/editPic.html

@@ -139,7 +139,7 @@
                 "picUrl": $("#picUrl").val(),
                 "sort": picIdx,
             };
-            $.operate.post(prefix + "/addProdPic", data, setIdToImg);
+            $.operate.post(prefix + "/addProdPic", data, refreshTab);
         }
 
         function refreshTab() {

+ 1 - 2
08.src/Xingxi/xingxi-system/src/main/resources/mapper/business/BannerMapper.xml

@@ -49,6 +49,7 @@
             <if test="updateUser != null  and updateUser != ''"> and updateUser = #{updateUser}</if>
             <if test="updateTime != null "> and updateTime = #{updateTime}</if>
         </where>
+        order by sort
     </select>
 
     <select id="selectBannerByBannerId" parameterType="Long" resultMap="BannerResult">
@@ -100,8 +101,6 @@
             <if test="newsId != null">newsId = #{newsId},</if>
             <if test="sort != null">sort = #{sort},</if>
             <if test="delFlag != null">delFlag = #{delFlag},</if>
-            <if test="createUser != null">createUser = #{createUser},</if>
-            <if test="createTime != null">createTime = #{createTime},</if>
             <if test="updateUser != null">updateUser = #{updateUser},</if>
             <if test="updateTime != null">updateTime = #{updateTime},</if>
         </trim>