Commit 49a25d0e by weijiguang

恢复部分代码

parent 3eac39b6
......@@ -217,13 +217,11 @@ public class ShopController extends BaseController {
}
@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)) {
return AjaxResult.error("id列表为空");
}
for (Long id : shopGoodsSkuIds) {
shopGoodsService.updateShopGoodsSkuState(id, state);
}
return AjaxResult.success();
return AjaxResult.success(shopGoodsService.updateShopGoodsSkuState(shopId, goodsId, shopGoodsSkuIds, state));
}
}
......@@ -50,6 +50,8 @@ public interface ShopGoodsSkuMapper {
int updateShopGoodsSkuState(@Param("id") Long shopGoodsSkuId, @Param("state") Integer state);
List<Long> selectSkuIds(@Param("ids") List<Long> ids);
/**
* 删除从店铺到sku关联
*
......
......@@ -61,5 +61,5 @@ public interface IShopGoodsService {
public int deleteShopGoodsById(String id);
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;
import com.soss.system.domain.Machine;
import com.soss.system.domain.ShopGoods;
import com.soss.system.domain.ShopGoodsSku;
import com.soss.system.mapper.*;
import com.soss.system.service.IShopGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 店铺和商品关联Service业务层处理
......@@ -103,11 +107,29 @@ public class ShopGoodsServiceImpl implements IShopGoodsService {
}
@Override
public Boolean updateShopGoodsSkuState(Long shopGoodsSkuId, Integer state) {
int i = shopGoodsSkuMapper.updateShopGoodsSkuState(shopGoodsSkuId, state);
if (i > 0) {
public Boolean updateShopGoodsSkuState(Long shopId, Long goodsId, List<Long> shopGoodsSkuIds, Integer state) {
// int i = shopGoodsSkuMapper.updateShopGoodsSkuState(shopGoodsSkuId, state);
// if (i > 0) {
// 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;
}
return false;
Machine machine = machines.get(0);
Map<Long, List<Long>> map = new HashMap<>();
map.put(goodsId, skuIds);
machineApiService.push(machine, String.valueOf(state), map);
}
return true;
}
}
......@@ -84,6 +84,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateShopGoodsSkuState" >
update shop_goods_sku set `state`= #{state} where id = #{id}
</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 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