标签:
js:
var useData = [];
$.ajax({
url: "/dealer/dealerShoper/synShopers",
method: "post",
data: JSON.stringify(useData),
contentType: ‘application/json‘,
dataType: "json",
success: function(data){
console.log(data);
callback && callback();
__d.hide();
}
})
controller:
@ResponseBody
@RequestMapping("/synShopers")
public JsonMessage synShopersForClear(@RequestBody List<JSONObject> jsonList) throws BusinessException {
UserPrincipal userPrincipal = OnLineUserUtils.getPrincipal();
if(null != jsonList && null != userPrincipal && userPrincipal.getUserType().equals(DealerConstant.userType.DEALER_TYPE))
{
List<Map<String,Object>> dealerShoperList = Lists.newArrayList();
for (JSONObject jsonObject : jsonList) {
ProductSku productSku = productSkuService.findProductSku((String)jsonObject.get("skuId"));
Map<String,Object> map = Maps.newHashMap();
map.put("skuId", (String) jsonObject.get("skuId"));
if(null != productSku)
{
Boolean isChange = false ;
short productType = (short)jsonObject.get("productType");
BigDecimal productSkuPrice = (BigDecimal)jsonObject.get("productSkuPrice");
Integer quantity = jsonObject.getInteger("quantity");
map.put("productSkuPrice",productSkuPrice);
map.put("quantity", productSku.getQuantity());
map.put("isValid", true);
if(productType == DealerConstant.DealerShoper.PRODUCTTYPE_CASH)
{
if(productSku.getProductSkuPrice().getDirectPrice().compareTo(productSkuPrice) != 0)
{
map.put("productSkuPrice",productSku.getProductSkuPrice().getDirectPrice());
isChange= true;
}
}
else if(productType == DealerConstant.DealerShoper.PRODUCTTYPE_CREDIT)
{
if(productSku.getProductSkuPrice().getCreditPrice().compareTo(productSkuPrice) != 0)
{
map.put("productSkuPrice",productSku.getProductSkuPrice().getCreditPrice());
isChange= true;
}
}
else if(productType == DealerConstant.DealerShoper.PRODUCTTYPE_SAM)
{
if(productSku.getProductSkuPrice().getSamplePrice().compareTo(productSkuPrice) != 0)
{
map.put("productSkuPrice",productSku.getProductSkuPrice().getSamplePrice());
isChange= true;
}
}
if(productSku.getQuantity()-quantity < 0)
{
map.put("quantity", productSku.getQuantity());
isChange = true;
}
if(isChange)
{
dealerShoperList.add(map);
}
}else{
map.put("isValid",false);
dealerShoperList.add(map);
}
}
return this.getJsonMessage(CommonConst.SUCCESS,dealerShoperList);
}
return this.getJsonMessage(CommonConst.FAIL);
}
com.alibaba.fastjson
标签:
原文地址:http://www.cnblogs.com/yiyongyao/p/4832625.html