Commit daa14e7d authored by 张永's avatar 张永

1

parent d067b57b
package com.egolm.shop.api; package com.egolm.shop.api;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.egolm.common.bean.Rjx; import com.egolm.common.StringUtil;
import com.egolm.shop.api.service.CartService; import com.egolm.common.bean.Rjx;
import com.egolm.shop.api.service.CartService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@Api(tags={"购物车相关接口"})
@RestController @Api(tags={"购物车相关接口"})
@RequestMapping("cart") @RestController
public class CartController { @RequestMapping("cart")
public class CartController {
@Autowired
private CartService cartService; @Autowired
private CartService cartService;
@ApiOperation("购物车商品种类数量")
@ApiImplicitParams({ @ApiOperation("购物车商品种类数量")
@ApiImplicitParam(paramType = "query", name = "orgNo", dataType = "String", required = true), @ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name="shopNo", dataType = "String", required = true, value = "店铺编号", defaultValue = ""), @ApiImplicitParam(paramType = "query", name = "orgNo", dataType = "String", required = true),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = false, value = "终端标识", defaultValue = "wechat"), @ApiImplicitParam(paramType = "query", name="shopNo", dataType = "String", required = true, value = "店铺编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"), @ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = false, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""), @ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "") @ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
}) @ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/getCartCount",method=RequestMethod.GET)
public String cartQuery(String orgNo, String shopNo) { @RequestMapping(value = "/getCartCount",method=RequestMethod.GET)
Map<String, Object> map = cartService.count(orgNo, shopNo); public String cartQuery(String orgNo, String shopNo) {
return Rjx.jsonOk().set("count", map.get("totalCount")).set("qty", map.get("totalSaleQty")).toJson(); Map<String, Object> map = cartService.count(orgNo, shopNo);
} return Rjx.jsonOk().set("count", map.get("totalCount")).set("qty", map.get("totalSaleQty")).toJson();
}
@ApiOperation("购物车信息")
@ApiImplicitParams({ @ApiOperation("购物车信息")
@ApiImplicitParam(paramType = "query", name = "orgNo", dataType = "String", required = true), @ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name="shopNO", dataType = "String", required = true, value = "店铺编号", defaultValue = ""), @ApiImplicitParam(paramType = "query", name = "orgNo", dataType = "String", required = true),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = false, value = "终端标识", defaultValue = "wechat"), @ApiImplicitParam(paramType = "query", name="shopNO", dataType = "String", required = true, value = "店铺编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"), @ApiImplicitParam(paramType = "query", name="isCalcPromo", dataType = "String", required = true, value = "是否计算汇总 0为不计算,1为计算", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""), @ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = false, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "") @ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
}) @ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
@RequestMapping(value = "/cartQuery",method=RequestMethod.GET) })
public String cartQuery(String orgNo, HttpServletRequest request, HttpServletResponse response) {
Map<String,Object> params = new HashMap<String,Object>(); @RequestMapping(value = "/cartQuery",method=RequestMethod.GET)
params.put("orgNo", orgNo); public String cartQuery(String orgNo, HttpServletRequest request, HttpServletResponse response) {
params.put("shopNO",request.getParameter("shopNO")); String isCaclPromo = request.getParameter("isCalcPromo");
params.put("terminal",request.getParameter("terminal")); if(StringUtil.isNotUndefinedAndNull(isCaclPromo) && StringUtil.isNotEmpty(isCaclPromo)) {
params.put("langID",request.getParameter("langID")); }else {
isCaclPromo = "1"; //
return cartService.query(params); }
}
Map<String,Object> params = new HashMap<String,Object>();
params.put("orgNo", orgNo);
@ApiOperation("加入购物车(JSON格式)") params.put("shopNO",request.getParameter("shopNO"));
@ApiImplicitParams({ params.put("terminal",request.getParameter("terminal"));
@ApiImplicitParam(paramType = "query", name = "orgNo", dataType = "String", required = true), params.put("langID",request.getParameter("langID"));
@ApiImplicitParam(paramType = "query", name = "data", dataType = "String", required = false, value = "JSON格式", defaultValue = "{\"shopNO\": \"00029975\",\"cartList\": [{\"goodsID\": \"30771\",\"goodsTypeID\": 0,\"saleQty\": \"24\", \"setPrice\": \"10.5\",\"agentContractNO\": \"600327002\",\"promoGroupNO\":\"\",\"promoPaperNO\":\"00001810100007\"}]}"), params.put("isCalcPromo",isCaclPromo);
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"), return cartService.query(params);
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""), }
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@ApiOperation("加入购物车(JSON格式)")
@RequestMapping(value = "/appendCart",method=RequestMethod.POST,produces = "application/json") @ApiImplicitParams({
public String appendCart(String orgNo, HttpServletRequest request, HttpServletResponse response) { @ApiImplicitParam(paramType = "query", name = "orgNo", dataType = "String", required = true),
String reqJson =request.getParameter("data"); @ApiImplicitParam(paramType = "query", name = "data", dataType = "String", required = false, value = "JSON格式", defaultValue = "{\"shopNO\": \"00029975\",\"cartList\": [{\"goodsID\": \"30771\",\"goodsTypeID\": 0,\"saleQty\": \"24\", \"setPrice\": \"10.5\",\"agentContractNO\": \"600327002\",\"promoGroupNO\":\"\",\"promoPaperNO\":\"00001810100007\"}]}"),
JSONObject jsonObj = JSONObject.parseObject(reqJson); @ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
jsonObj.put("orgNo", orgNo); @ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
System.out.println("appendCart-------"+reqJson); @ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
String terminal = request.getParameter("terminal"); @ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
return cartService.append(jsonObj,terminal); })
}
@RequestMapping(value = "/appendCart",method=RequestMethod.POST,produces = "application/json")
public String appendCart(String orgNo, HttpServletRequest request, HttpServletResponse response) {
@ApiOperation("删除购物车(JSON格式)") String reqJson =request.getParameter("data");
@ApiImplicitParams({ JSONObject jsonObj = JSONObject.parseObject(reqJson);
@ApiImplicitParam(paramType = "query", name = "orgNo", dataType = "String", required = true), jsonObj.put("orgNo", orgNo);
@ApiImplicitParam(paramType = "query", name = "data", dataType = "String", required = false, value = "JSON格式", defaultValue = "{\"shopNO\": \"00029975\",\"idxs\": [1,2,3]}"), System.out.println("appendCart-------"+reqJson);
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"), String terminal = request.getParameter("terminal");
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"), return cartService.append(jsonObj,terminal);
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""), }
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@ApiOperation("删除购物车(JSON格式)")
@RequestMapping(value = "/remove",method=RequestMethod.POST) @ApiImplicitParams({
public String remove(String orgNo, HttpServletRequest request, HttpServletResponse response) { @ApiImplicitParam(paramType = "query", name = "orgNo", dataType = "String", required = true),
String reqJson = request.getParameter("data"); @ApiImplicitParam(paramType = "query", name = "data", dataType = "String", required = false, value = "JSON格式", defaultValue = "{\"shopNO\": \"00029975\",\"idxs\": [1,2,3]}"),
JSONObject jsonObj = JSONObject.parseObject(reqJson); @ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
jsonObj.put("orgNo", orgNo); @ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
System.out.println("remove-------"+reqJson); @ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
String terminal = request.getParameter("terminal"); @ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
return cartService.remove(jsonObj,terminal); })
}
@RequestMapping(value = "/remove",method=RequestMethod.POST)
@ApiOperation("修改数量(JSON格式)") public String remove(String orgNo, HttpServletRequest request, HttpServletResponse response) {
@ApiImplicitParams({ String reqJson = request.getParameter("data");
@ApiImplicitParam(paramType = "query", name = "orgNo", dataType = "String", required = true), JSONObject jsonObj = JSONObject.parseObject(reqJson);
@ApiImplicitParam(paramType = "query", name = "data", dataType = "String", required = false, value = "JSON格式", defaultValue = "{\"shopNO\": \"00029975\", \"idx\": 2,\"saleQty\": \"23\"}"), jsonObj.put("orgNo", orgNo);
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""), System.out.println("remove-------"+reqJson);
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "") String terminal = request.getParameter("terminal");
}) return cartService.remove(jsonObj,terminal);
}
@RequestMapping(value = "/updateQty",method=RequestMethod.POST)
public String updateQty(String orgNo, HttpServletRequest request, HttpServletResponse response) { @ApiOperation("修改数量(JSON格式)")
String reqJson = request.getParameter("data"); @ApiImplicitParams({
JSONObject jsonObj = JSONObject.parseObject(reqJson); @ApiImplicitParam(paramType = "query", name = "orgNo", dataType = "String", required = true),
jsonObj.put("orgNo", orgNo); @ApiImplicitParam(paramType = "query", name = "data", dataType = "String", required = false, value = "JSON格式", defaultValue = "{\"shopNO\": \"00029975\", \"idx\": 2,\"saleQty\": \"23\"}"),
System.out.println("updateQty-------"+reqJson); @ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
String terminal = request.getParameter("terminal"); @ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
return cartService.updateQty(jsonObj,terminal); })
}
@RequestMapping(value = "/updateQty",method=RequestMethod.POST)
@ApiOperation("修改价格(JSON格式)") public String updateQty(String orgNo, HttpServletRequest request, HttpServletResponse response) {
@ApiImplicitParams({ String reqJson = request.getParameter("data");
@ApiImplicitParam(paramType = "query", name = "orgNo", dataType = "String", required = true), JSONObject jsonObj = JSONObject.parseObject(reqJson);
@ApiImplicitParam(paramType = "query", name = "data", dataType = "String", required = false, value = "JSON格式", defaultValue = "{\"shopNO\": \"00029975\", \"idx\": 2,\"setPrice\": \"2.3\"}"), jsonObj.put("orgNo", orgNo);
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""), System.out.println("updateQty-------"+reqJson);
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "") String terminal = request.getParameter("terminal");
}) return cartService.updateQty(jsonObj,terminal);
}
@RequestMapping(value = "/setPrice",method=RequestMethod.POST)
public String setPrice(String orgNo, HttpServletRequest request, HttpServletResponse response) { @ApiOperation("修改价格(JSON格式)")
String reqJson = request.getParameter("data"); @ApiImplicitParams({
JSONObject jsonObj = JSONObject.parseObject(reqJson); @ApiImplicitParam(paramType = "query", name = "orgNo", dataType = "String", required = true),
jsonObj.put("orgNo", orgNo); @ApiImplicitParam(paramType = "query", name = "data", dataType = "String", required = false, value = "JSON格式", defaultValue = "{\"shopNO\": \"00029975\", \"idx\": 2,\"setPrice\": \"2.3\"}"),
System.out.println("setPrice-------"+reqJson); @ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
String terminal = request.getParameter("terminal"); @ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
return cartService.setPrice(jsonObj,terminal); })
}
@RequestMapping(value = "/setPrice",method=RequestMethod.POST)
public String setPrice(String orgNo, HttpServletRequest request, HttpServletResponse response) {
@ApiOperation("清空购物车") String reqJson = request.getParameter("data");
@ApiImplicitParams({ JSONObject jsonObj = JSONObject.parseObject(reqJson);
@ApiImplicitParam(paramType = "query", name = "orgNo", dataType = "String", required = true), jsonObj.put("orgNo", orgNo);
@ApiImplicitParam(paramType = "query", name="shopNo", dataType = "String", required = true, value = "店铺编号", defaultValue = ""), System.out.println("setPrice-------"+reqJson);
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = false, value = "终端标识", defaultValue = "wechat"), String terminal = request.getParameter("terminal");
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"), return cartService.setPrice(jsonObj,terminal);
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""), }
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@ApiOperation("清空购物车")
@RequestMapping(value = "/clear",method=RequestMethod.GET) @ApiImplicitParams({
public String clear(String orgNo, String shopNo) { @ApiImplicitParam(paramType = "query", name = "orgNo", dataType = "String", required = true),
cartService.clear(orgNo, shopNo); @ApiImplicitParam(paramType = "query", name="shopNo", dataType = "String", required = true, value = "店铺编号", defaultValue = ""),
return Rjx.jsonOk().toJson(); @ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = false, value = "终端标识", defaultValue = "wechat"),
} @ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
} @ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/clear",method=RequestMethod.GET)
public String clear(String orgNo, String shopNo) {
cartService.clear(orgNo, shopNo);
return Rjx.jsonOk().toJson();
}
}
package com.egolm.shop.api.service; package com.egolm.shop.api.service;
import java.util.Map; import java.util.Map;
public interface CartQueryService { public interface CartQueryService {
public Map<String, Object> query(String orgNo, String shopNo, String terminal) ; public Map<String, Object> query(String orgNo, String shopNo, String terminal,String isCalcPromo) ;
} }
...@@ -43,7 +43,7 @@ public class CartQueryServiceImpl implements CartQueryService { ...@@ -43,7 +43,7 @@ public class CartQueryServiceImpl implements CartQueryService {
@Autowired @Autowired
private JdbcTemplate jdbcTemplate; private JdbcTemplate jdbcTemplate;
public Map<String, Object> query(String orgNo, String shopNo, String terminal) { public Map<String, Object> query(String orgNo, String shopNo, String terminal,String isCalcPromo) {
Rjx rjx = Rjx.json().set("IsValid", true); Rjx rjx = Rjx.json().set("IsValid", true);
if (!StringUtil.isNotUndefinedAndNull(shopNo, terminal)) { if (!StringUtil.isNotUndefinedAndNull(shopNo, terminal)) {
throw new ReflectException("Query the shopping cart parameter error:" throw new ReflectException("Query the shopping cart parameter error:"
...@@ -71,7 +71,13 @@ public class CartQueryServiceImpl implements CartQueryService { ...@@ -71,7 +71,13 @@ public class CartQueryServiceImpl implements CartQueryService {
} catch (Exception e1) { } catch (Exception e1) {
e1.printStackTrace(); e1.printStackTrace();
} }
try {
String sql1 = "exec up_B2BCartToCartTempItem '" + shopNo + "', '"+isCalcPromo+"' "; //是否计算促销
jdbcTemplate.executeUpdate(sql1);
} catch (Exception e1) {
e1.printStackTrace();
}
List<Map<String, Object>> datas = this.getGoodsList(orgNo, shopNo, terminal); List<Map<String, Object>> datas = this.getGoodsList(orgNo, shopNo, terminal);
......
...@@ -216,7 +216,8 @@ public class CartServiceImpl implements CartService { ...@@ -216,7 +216,8 @@ public class CartServiceImpl implements CartService {
String orgNo = (String)params.get("orgNo"); String orgNo = (String)params.get("orgNo");
String shopNO = params.get("shopNO")+""; String shopNO = params.get("shopNO")+"";
String terminal = params.get("terminal")+""; String terminal = params.get("terminal")+"";
Map<String, Object> queryMap = cartRedisService.query(orgNo, shopNO, terminal); String isCalcPromo = params.get("isCalcPromo")+""; //"是否计算汇总 0为不计算,1为计算"
Map<String, Object> queryMap = cartRedisService.query(orgNo, shopNO, terminal,isCalcPromo);
/*Map<String, Object> countMap = this.count(orgNo, shopNO); /*Map<String, Object> countMap = this.count(orgNo, shopNO);
queryMap.putAll(countMap);*/ queryMap.putAll(countMap);*/
return Rjx.jsonOk().setData(queryMap).toJson(); return Rjx.jsonOk().setData(queryMap).toJson();
......
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