Commit 49a25d0e by weijiguang

恢复部分代码

parent 3eac39b6
...@@ -217,13 +217,11 @@ public class ShopController extends BaseController { ...@@ -217,13 +217,11 @@ public class ShopController extends BaseController {
} }
@GetMapping("/updateShopGoodsSkuState") @GetMapping("/updateShopGoodsSkuState")
public AjaxResult updateShopGoodsSkuState(@RequestParam("ids") List<Long> shopGoodsSkuIds, @RequestParam("state") Integer state) { public AjaxResult updateShopGoodsSkuState(@RequestParam("shopId") Long shopId, @RequestParam("goodsId") Long goodsId,
@RequestParam("ids") List<Long> shopGoodsSkuIds, @RequestParam("state") Integer state) {
if (CollectionUtils.isEmpty(shopGoodsSkuIds)) { if (CollectionUtils.isEmpty(shopGoodsSkuIds)) {
return AjaxResult.error("id列表为空"); return AjaxResult.error("id列表为空");
} }
for (Long id : shopGoodsSkuIds) { return AjaxResult.success(shopGoodsService.updateShopGoodsSkuState(shopId, goodsId, shopGoodsSkuIds, state));
shopGoodsService.updateShopGoodsSkuState(id, state);
}
return AjaxResult.success();
} }
} }
...@@ -50,6 +50,8 @@ public interface ShopGoodsSkuMapper { ...@@ -50,6 +50,8 @@ public interface ShopGoodsSkuMapper {
int updateShopGoodsSkuState(@Param("id") Long shopGoodsSkuId, @Param("state") Integer state); int updateShopGoodsSkuState(@Param("id") Long shopGoodsSkuId, @Param("state") Integer state);
List<Long> selectSkuIds(@Param("ids") List<Long> ids);
/** /**
* 删除从店铺到sku关联 * 删除从店铺到sku关联
* *
......
...@@ -61,5 +61,5 @@ public interface IShopGoodsService { ...@@ -61,5 +61,5 @@ public interface IShopGoodsService {
public int deleteShopGoodsById(String id); public int deleteShopGoodsById(String id);
List<ShopGoodsSku> selectSkuByShopGoods(Long shopId, Long goodsId); List<ShopGoodsSku> selectSkuByShopGoods(Long shopId, Long goodsId);
Boolean updateShopGoodsSkuState(Long shopGoodsSkuId, Integer state); Boolean updateShopGoodsSkuState(Long shopId, Long goodsId, List<Long> shopGoodsSkuId, Integer state);
} }
package com.soss.system.service.impl; package com.soss.system.service.impl;
import com.soss.system.domain.Machine;
import com.soss.system.domain.ShopGoods; import com.soss.system.domain.ShopGoods;
import com.soss.system.domain.ShopGoodsSku; import com.soss.system.domain.ShopGoodsSku;
import com.soss.system.mapper.*; import com.soss.system.mapper.*;
import com.soss.system.service.IShopGoodsService; import com.soss.system.service.IShopGoodsService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 店铺和商品关联Service业务层处理 * 店铺和商品关联Service业务层处理
...@@ -103,11 +107,29 @@ public class ShopGoodsServiceImpl implements IShopGoodsService { ...@@ -103,11 +107,29 @@ public class ShopGoodsServiceImpl implements IShopGoodsService {
} }
@Override @Override
public Boolean updateShopGoodsSkuState(Long shopGoodsSkuId, Integer state) { public Boolean updateShopGoodsSkuState(Long shopId, Long goodsId, List<Long> shopGoodsSkuIds, Integer state) {
int i = shopGoodsSkuMapper.updateShopGoodsSkuState(shopGoodsSkuId, state); // int i = shopGoodsSkuMapper.updateShopGoodsSkuState(shopGoodsSkuId, state);
if (i > 0) { // if (i > 0) {
return true; // return true;
// }
for (Long id : shopGoodsSkuIds) {
shopGoodsSkuMapper.updateShopGoodsSkuState(id, state);
}
List<Long> skuIds = shopGoodsSkuMapper.selectSkuIds(shopGoodsSkuIds);
if(!CollectionUtils.isEmpty(skuIds)) {
//推送给极光
List<Machine> machines = machineMapper.selectMachineByShopId(shopId);
if (CollectionUtils.isEmpty(machines)) {
return true;
}
Machine machine = machines.get(0);
Map<Long, List<Long>> map = new HashMap<>();
map.put(goodsId, skuIds);
machineApiService.push(machine, String.valueOf(state), map);
} }
return false; return true;
} }
} }
...@@ -84,6 +84,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -84,6 +84,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateShopGoodsSkuState" > <update id="updateShopGoodsSkuState" >
update shop_goods_sku set `state`= #{state} where id = #{id} update shop_goods_sku set `state`= #{state} where id = #{id}
</update> </update>
<select id="selectSkuIds" >
select sku_id from shop_goods_sku
<if test="ids!=null">
where id in
<foreach collection="ids" index="index" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
</select>
<delete id="deleteShopGoodsSkuById" parameterType="String"> <delete id="deleteShopGoodsSkuById" parameterType="String">
delete from shop_goods_sku where id = #{id} delete from shop_goods_sku where id = #{id}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment