Authored by yangchangjiang

--task=null --user=杨长江 根据商品编号同步订单商品的图片地址和名称

@@ -97,4 +97,6 @@ public interface ProductMapper { @@ -97,4 +97,6 @@ public interface ProductMapper {
97 @Param("product") Product product, 97 @Param("product") Product product,
98 @Param("start") int start, 98 @Param("start") int start,
99 @Param("rows") int rows); 99 @Param("rows") int rows);
  100 +
  101 + int syncOrderGoodsInfo(@Param("productCode") String productCode);
100 } 102 }
@@ -347,5 +347,22 @@ @@ -347,5 +347,22 @@
347 limit #{start}, #{rows} 347 limit #{start}, #{rows}
348 </select> 348 </select>
349 349
  350 + <update id="syncOrderGoodsInfo" parameterType="string">
  351 + UPDATE
  352 + ufo_product.goods g,
  353 + ufo_product.`storage` s,
  354 + ufo_order.seller_order_goods sog,
  355 + ufo_product.product p
  356 + SET
  357 + sog.image_url = g.color_image,
  358 + sog.product_name = p.product_name
  359 + WHERE
  360 + sog.storage_id = s.id
  361 + AND s.goods_id = g.id
  362 + AND p.id = g.product_id
  363 + AND sog.attributes NOT IN (5,6)
  364 + AND (g.color_image != sog.image_url OR p.product_name != sog.product_name)
  365 + AND p.product_code IN ( #{productCode} )
  366 + </update>
350 367
351 </mapper> 368 </mapper>
@@ -193,4 +193,15 @@ public class ProductController { @@ -193,4 +193,15 @@ public class ProductController {
193 Map<Integer, Integer> countInfo = productService.queryBatchProductStorageCount(productIdList); 193 Map<Integer, Integer> countInfo = productService.queryBatchProductStorageCount(productIdList);
194 return new com.yoho.ufo.service.model.ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(countInfo).build(); 194 return new com.yoho.ufo.service.model.ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(countInfo).build();
195 } 195 }
  196 +
  197 +
  198 + /**
  199 + * 同步订单商品信息
  200 + * @param productCode 商品编码
  201 + * @return 影响行数
  202 + */
  203 + @RequestMapping(value = "/syncOrderGoodsInfo",method = RequestMethod.POST)
  204 + public ApiResponse syncOrderGoodsInfo(String productCode){
  205 + return productService.syncOrderGoodsInfo(productCode);
  206 + }
196 } 207 }
@@ -49,4 +49,6 @@ public interface IProductService { @@ -49,4 +49,6 @@ public interface IProductService {
49 List<String> queryProductImageList(Integer skup); 49 List<String> queryProductImageList(Integer skup);
50 50
51 Map<Integer, Integer> queryBatchProductStorageCount(List<Integer> productIdList); 51 Map<Integer, Integer> queryBatchProductStorageCount(List<Integer> productIdList);
  52 +
  53 + ApiResponse<Integer> syncOrderGoodsInfo(String productCode);
52 } 54 }
@@ -1461,6 +1461,15 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw @@ -1461,6 +1461,15 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw
1461 return CollectionUtil.extractMap(storages, Storage::getProductId, Storage::getStorageNum); 1461 return CollectionUtil.extractMap(storages, Storage::getProductId, Storage::getStorageNum);
1462 } 1462 }
1463 1463
  1464 + @Override
  1465 + public ApiResponse<Integer> syncOrderGoodsInfo(String productCode) {
  1466 + if(StringUtils.isEmpty(productCode)){
  1467 + return new ApiResponse<>(400,"商品编号不能为空");
  1468 + }
  1469 + productMapper.syncOrderGoodsInfo(productCode);
  1470 + return new ApiResponse<>(200,"同步成功");
  1471 + }
  1472 +
1464 private String getMaxLen(String str, int len) { 1473 private String getMaxLen(String str, int len) {
1465 if (str == null) { 1474 if (str == null) {
1466 return ""; 1475 return "";
  1 +<!DOCTYPE html>
  2 +<html>
  3 +<head>
  4 + <meta charset="UTF-8"/>
  5 + <title>Yoho!Buy运营平台</title>
  6 + <script src="/ufoPlatform/js/include.js"></script>
  7 +</head>
  8 +<body class="easyui-layout" fit="true">
  9 +<div region="north" style="height: 230px">
  10 + <script>
  11 + document.write(addHead('辅助工具', ''));
  12 + </script>
  13 + <style>
  14 + .div_search input {
  15 + margin-top: 20px;
  16 + }
  17 +
  18 + .div_search .textbox {
  19 + margin-top: 20px;
  20 + }
  21 +
  22 + .div_search .easyui-linkbutton {
  23 + margin-top: 20px;
  24 + }
  25 + </style>
  26 + <div style="margin-left: 30px;" class="div_search">
  27 + <input id="productCode" type="text"/>
  28 +
  29 + <a id="syncButton" class="easyui-linkbutton btn-info" data-options="iconCls:'icon-search'">同步订单商品信息</a>
  30 + </div>
  31 +</div>
  32 +
  33 +<script type="text/javascript">
  34 +
  35 + var productPoolId;
  36 + $(function () {
  37 +
  38 + $("#productCode").textbox({
  39 + prompt: "商品编号"
  40 + });
  41 +
  42 + // 同步
  43 + $("#syncButton").linkbutton({
  44 + onClick: function () {
  45 + var param = getParams();
  46 + syncOrderGoodsInfo(param);
  47 + }
  48 + });
  49 +
  50 + //同步订单商品的图片地址和商品名称
  51 + function syncOrderGoodsInfo(param) {
  52 + $.ajax({
  53 + type: 'POST',
  54 + url: contextPath + '/product/syncOrderGoodsInfo',
  55 + data: param,
  56 + success: function (result) {
  57 + if(result.code == 200){
  58 + window.self.$.messager.show({
  59 + title : "提示",
  60 + msg : result.message
  61 + });
  62 + $("#productCode").val('');
  63 + }else {
  64 + window.self.$.messager.alert("失败", result.message, "error");
  65 + }
  66 + }
  67 + });
  68 + }
  69 + /**
  70 + * 提取参数
  71 + */
  72 + function getParams() {
  73 + var productCode = $('#productCode').textbox('getValue');
  74 + var param = {};
  75 + if (undefined !== productCode && null !== productCode && "" !== productCode) {
  76 + param.productCode = productCode;
  77 + }
  78 + return param;
  79 + }
  80 + });
  81 +
  82 +</script>
  83 +
  84 +</body>
  85 +</html>