11 changed files with 333 additions and 8 deletions
@ -0,0 +1,29 @@ |
|||||
|
package com.qs.serve.modules.goods.controller; |
||||
|
|
||||
|
import com.qs.serve.common.model.dto.R; |
||||
|
import com.qs.serve.modules.goods.service.GoodsApplicationService; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/11/22 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@AllArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("goods/sync") |
||||
|
public class GoodsSyncController { |
||||
|
|
||||
|
private GoodsApplicationService goodsApplicationService; |
||||
|
|
||||
|
@GetMapping("/stand") |
||||
|
public R<?> toStandList(Integer fullUpdate){ |
||||
|
goodsApplicationService.syncStandGoods(fullUpdate!=null&&fullUpdate==1); |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,34 @@ |
|||||
|
package com.qs.serve.modules.goods.entity.dto; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/11/21 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class StandInventory { |
||||
|
|
||||
|
private String id; |
||||
|
private String invCode; |
||||
|
private String invName; |
||||
|
private String invSku; |
||||
|
private String invSkuCode; |
||||
|
private String invSeries; |
||||
|
private String invCategory; |
||||
|
private String invBrand; |
||||
|
private String invOrderStatus; |
||||
|
private String invCostStatus; |
||||
|
private String chestCasing; |
||||
|
private String invUnitWeight; |
||||
|
private String invUnit; |
||||
|
private String invVolume; |
||||
|
private String invWeight; |
||||
|
private String invGrossWeight; |
||||
|
private String invPlace; |
||||
|
private String invTaste; |
||||
|
private String invStartDate; |
||||
|
private String invEndDate; |
||||
|
private String rowCreateTime; |
||||
|
|
||||
|
} |
@ -0,0 +1,100 @@ |
|||||
|
package com.qs.serve.modules.goods.mapper; |
||||
|
|
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
import org.apache.ibatis.annotations.Update; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/11/21 |
||||
|
*/ |
||||
|
public interface GoodsCrmSkuMapper { |
||||
|
|
||||
|
/** |
||||
|
* 上架商品 |
||||
|
* @param codes |
||||
|
* @return |
||||
|
*/ |
||||
|
@Update("<script>" + |
||||
|
"update goods_sku set `enable` = 1 where sku_code in " + |
||||
|
" <foreach collection='invCodes' item='invCode' open='(' separator=',' close=')'> "+ |
||||
|
" #{invCode} "+ |
||||
|
" </foreach> " + |
||||
|
"</script>") |
||||
|
int updateShelfOnInCodes(@Param("invCodes")List<String> codes); |
||||
|
|
||||
|
/** |
||||
|
* 下架商品 |
||||
|
* @param codes |
||||
|
* @return |
||||
|
*/ |
||||
|
@Update("<script>" + |
||||
|
"update goods_sku set `enable` = 0 where sku_code not in " + |
||||
|
" <foreach collection='invCodes' item='invCode' open='(' separator=',' close=')'> "+ |
||||
|
" #{invCode} "+ |
||||
|
" </foreach> " + |
||||
|
"</script>") |
||||
|
int updateShelfOffNotInCodes(@Param("invCodes")List<String> codes); |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 设置非特殊品 |
||||
|
* @param codes |
||||
|
* @return |
||||
|
*/ |
||||
|
@Update("<script>" + |
||||
|
"update goods_sku set `special_flag` = 0 where sku_code not in " + |
||||
|
" <foreach collection='invCodes' item='invCode' open='(' separator=',' close=')'> "+ |
||||
|
" #{invCode} "+ |
||||
|
" </foreach> " + |
||||
|
"</script>") |
||||
|
int updateSpecialNotInCodes(@Param("invCodes")List<String> codes); |
||||
|
|
||||
|
/** |
||||
|
* 设置特殊品 |
||||
|
* @param codes |
||||
|
* @return |
||||
|
*/ |
||||
|
@Update("<script>" + |
||||
|
"update goods_sku set `special_flag` = 1 where sku_code in " + |
||||
|
" <foreach collection='invCodes' item='invCode' open='(' separator=',' close=')'> "+ |
||||
|
" #{invCode} "+ |
||||
|
" </foreach> " + |
||||
|
"</script>") |
||||
|
int updateSpecialInCodes(@Param("invCodes")List<String> codes); |
||||
|
|
||||
|
/** |
||||
|
* 根据sku修改spu非特殊品 |
||||
|
* @return |
||||
|
*/ |
||||
|
@Update("update goods_spu set goods_spu.special_sku_id = 0 " + |
||||
|
"where goods_spu.id not in ( " + |
||||
|
" select spu_id from goods_sku where goods_spu.special_sku_id is not null and goods_spu.special_sku_id !=0 )") |
||||
|
int updateSpuSpecialIdBySku(); |
||||
|
|
||||
|
/** |
||||
|
* 根据sku状态,更新spu上架状态 |
||||
|
* @return |
||||
|
*/ |
||||
|
@Update("update goods_spu set shelf = 0 where goods_spu.id not in ( " + |
||||
|
" select goods_sku.spu_id from goods_sku where goods_sku.`enable` = 1 " + |
||||
|
") ") |
||||
|
int updateSpuShelfBySku(); |
||||
|
|
||||
|
//设置错误的产地,下架
|
||||
|
//select concat(spu_id,'_',belong) tmp,count(1) from goods_sku where `enable` = 1 and special_flag = 0 group by tmp HAVING count(1)>1
|
||||
|
|
||||
|
/** |
||||
|
* 根据sku是否特殊商品更新spu特殊商品标识 |
||||
|
* @return |
||||
|
*/ |
||||
|
@Update("update goods_spu " + |
||||
|
" left join " + |
||||
|
" (select goods_sku.spu_id,goods_sku.id as sku_id from goods_sku where goods_sku.`enable` = 1 and special_flag = 1) sku_tmp" + |
||||
|
" on sku_tmp.spu_id = goods_spu.id" + |
||||
|
" set goods_spu.special_sku_id = sku_tmp.sku_id " + |
||||
|
" where sku_tmp.sku_id is not null ") |
||||
|
int updateSpuSpecSkuId(); |
||||
|
|
||||
|
} |
Loading…
Reference in new issue