Authored by yangchangjiang

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

... ... @@ -97,4 +97,6 @@ public interface ProductMapper {
@Param("product") Product product,
@Param("start") int start,
@Param("rows") int rows);
int syncOrderGoodsInfo(@Param("productCode") String productCode);
}
\ No newline at end of file
... ...
... ... @@ -347,5 +347,22 @@
limit #{start}, #{rows}
</select>
<update id="syncOrderGoodsInfo" parameterType="string">
UPDATE
ufo_product.goods g,
ufo_product.`storage` s,
ufo_order.seller_order_goods sog,
ufo_product.product p
SET
sog.image_url = g.color_image,
sog.product_name = p.product_name
WHERE
sog.storage_id = s.id
AND s.goods_id = g.id
AND p.id = g.product_id
AND sog.attributes NOT IN (5,6)
AND (g.color_image != sog.image_url OR p.product_name != sog.product_name)
AND p.product_code IN ( #{productCode} )
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -193,4 +193,15 @@ public class ProductController {
Map<Integer, Integer> countInfo = productService.queryBatchProductStorageCount(productIdList);
return new com.yoho.ufo.service.model.ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(countInfo).build();
}
/**
* 同步订单商品信息
* @param productCode 商品编码
* @return 影响行数
*/
@RequestMapping(value = "/syncOrderGoodsInfo",method = RequestMethod.POST)
public ApiResponse syncOrderGoodsInfo(String productCode){
return productService.syncOrderGoodsInfo(productCode);
}
}
... ...
... ... @@ -49,4 +49,6 @@ public interface IProductService {
List<String> queryProductImageList(Integer skup);
Map<Integer, Integer> queryBatchProductStorageCount(List<Integer> productIdList);
ApiResponse<Integer> syncOrderGoodsInfo(String productCode);
}
... ...
... ... @@ -1461,6 +1461,15 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw
return CollectionUtil.extractMap(storages, Storage::getProductId, Storage::getStorageNum);
}
@Override
public ApiResponse<Integer> syncOrderGoodsInfo(String productCode) {
if(StringUtils.isEmpty(productCode)){
return new ApiResponse<>(400,"商品编号不能为空");
}
productMapper.syncOrderGoodsInfo(productCode);
return new ApiResponse<>(200,"同步成功");
}
private String getMaxLen(String str, int len) {
if (str == null) {
return "";
... ...
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Yoho!Buy运营平台</title>
<script src="/ufoPlatform/js/include.js"></script>
</head>
<body class="easyui-layout" fit="true">
<div region="north" style="height: 230px">
<script>
document.write(addHead('辅助工具', ''));
</script>
<style>
.div_search input {
margin-top: 20px;
}
.div_search .textbox {
margin-top: 20px;
}
.div_search .easyui-linkbutton {
margin-top: 20px;
}
</style>
<div style="margin-left: 30px;" class="div_search">
<input id="productCode" type="text"/>
<a id="syncButton" class="easyui-linkbutton btn-info" data-options="iconCls:'icon-search'">同步订单商品信息</a>
</div>
</div>
<script type="text/javascript">
var productPoolId;
$(function () {
$("#productCode").textbox({
prompt: "商品编号"
});
// 同步
$("#syncButton").linkbutton({
onClick: function () {
var param = getParams();
syncOrderGoodsInfo(param);
}
});
//同步订单商品的图片地址和商品名称
function syncOrderGoodsInfo(param) {
$.ajax({
type: 'POST',
url: contextPath + '/product/syncOrderGoodsInfo',
data: param,
success: function (result) {
if(result.code == 200){
window.self.$.messager.show({
title : "提示",
msg : result.message
});
$("#productCode").val('');
}else {
window.self.$.messager.alert("失败", result.message, "error");
}
}
});
}
/**
* 提取参数
*/
function getParams() {
var productCode = $('#productCode').textbox('getValue');
var param = {};
if (undefined !== productCode && null !== productCode && "" !== productCode) {
param.productCode = productCode;
}
return param;
}
});
</script>
</body>
</html>
\ No newline at end of file
... ...