Commit 4041c454 authored by 张永's avatar 张永

需求 #15246

parent f4665f09
......@@ -79,7 +79,7 @@ public class CartController {
@ApiOperation("加入购物车(JSON格式)")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "orgNo", dataType = "String", required = true),
@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\"}]}"),
@ApiImplicitParam(paramType = "query", name = "data", dataType = "String", required = false, value = "JSON格式", defaultValue = "{\"shopNO\": \"00029975\",\"cartList\": [{\"goodsID\": \"30771\",\"goodsTypeID\": 0,\"saleQty\": \"24\",\"saleUnit\": \"单位\", \"setPrice\": \"10.5\",\"agentContractNO\": \"600327002\",\"promoGroupNO\":\"\",\"promoPaperNO\":\"00001810100007\"}]}"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
......@@ -120,7 +120,7 @@ public class CartController {
@ApiOperation("修改数量(JSON格式)")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "orgNo", dataType = "String", required = true),
@ApiImplicitParam(paramType = "query", name = "data", dataType = "String", required = false, value = "JSON格式", defaultValue = "{\"shopNO\": \"00029975\", \"idx\": 2,\"saleQty\": \"23\"}"),
@ApiImplicitParam(paramType = "query", name = "data", dataType = "String", required = false, value = "JSON格式", defaultValue = "{\"shopNO\": \"00029975\", \"idx\": 2,\"saleQty\": \"23\",\"saleUnit\": \"单位\"}"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
......
......@@ -64,6 +64,7 @@ public class CartServiceImpl implements CartService {
String sAgentContractNO = Util.objTo(cartObj.get("agentContractNO"), String.class);
String sPromoPaperNO = Util.objTo(cartObj.get("promoPaperNO"), String.class, null);
String sPromoGroupNO = Util.objTo(cartObj.get("promoGroupNO"), String.class, null);
String sSaleUnit = Util.objTo(cartObj.get("saleUnit"),String.class,null);
if(StringUtil.isNotBlank(sPromoPaperNO)) {
jdbcTemplate.executeUpdate("update tCart set sPromoPaperNO = ?, sPromoGroupNO = ? where sOrgNO = ? and sShopNO = ? and sAgentContractNO = ? and nGoodsID = ? and nTag = ? and (sPromoPaperNO is null or sPromoPaperNO = '')",sPromoPaperNO, sPromoGroupNO, orgNo, shopNO, sAgentContractNO, nGoodsID, nGoodsTypeID);
}
......@@ -85,8 +86,8 @@ public class CartServiceImpl implements CartService {
}
List<Map<String, Object>> list = jdbcTemplate.queryForList("select nIdx, nSaleQty, sPromoPaperNO from tCart" + StringUtil.join(" and ", " where ", "", strs));
if(list.size() == 0) {
Object[] args = new Object[]{shopNO, orgNo, ++nMaxIdx, nGoodsTypeID, sAgentContractNO, nGoodsID, nSaleQty, nSetPrice, sPromoPaperNO, sPromoGroupNO};
jdbcTemplate.executeUpdate("insert into tCart (sShopNO, sOrgNO, nIdx, nTag, sAgentContractNO, nGoodsID, nSaleQty, nSetPrice, dLastUpdateTime, sPromoPaperNO, sPromoGroupNO) values (?, ?, ?, ?, ?, ?, ?, ?, getdate(), ?, ?)", args);
Object[] args = new Object[]{shopNO, orgNo, ++nMaxIdx, nGoodsTypeID, sAgentContractNO, nGoodsID, nSaleQty, nSetPrice, sPromoPaperNO, sPromoGroupNO,sSaleUnit};
jdbcTemplate.executeUpdate("insert into tCart (sShopNO, sOrgNO, nIdx, nTag, sAgentContractNO, nGoodsID, nSaleQty, nSetPrice, dLastUpdateTime, sPromoPaperNO, sPromoGroupNO,sSaleUnit) values (?, ?, ?, ?, ?, ?, ?, ?, getdate(), ?, ?,?)", args);
} else {
Integer nIdx = Util.objTo(list.get(0).get("nIdx"), Integer.class);
Double nQty = Util.objTo(list.get(0).get("nSaleQty"), Double.class);
......@@ -164,7 +165,7 @@ public class CartServiceImpl implements CartService {
* @param: @return
* @return: String
* @throws
* {"shopNO": "00029975","terminal": "wechat","langID": "936", "idx": 2,"saleQty": "23" }
* {"shopNO": "00029975","terminal": "wechat","langID": "936", "idx": 2,"saleQty": "23","saleUnit":"单位" }
*/
public String updateQty (JSONObject obj,String terminal) {
String orgNo = obj.getString("orgNo");
......@@ -172,6 +173,7 @@ public class CartServiceImpl implements CartService {
Integer idx = obj.getInteger("idx");
BigDecimal saleQty = obj.getBigDecimal("saleQty");
String langID = obj.getString("langID");
String saleUnit = obj.getString("saleUnit");
if(saleQty.compareTo(BigDecimal.ZERO) == 0) {
JSONObject removeObj = new JSONObject();
removeObj.put("shopNO", shopNO);
......@@ -183,8 +185,8 @@ public class CartServiceImpl implements CartService {
System.out.println(removeObj);
this.remove(removeObj,terminal);
} else {
String sql = "update tCart set nSaleQty = ? where sOrgNO = ? and sShopNO = ? and nIdx = ?";
jdbcTemplate.executeUpdate(sql, saleQty, orgNo, shopNO, idx);
String sql = "update tCart set nSaleQty = ?,sSaleUnit = ? where sOrgNO = ? and sShopNO = ? and nIdx = ?";
jdbcTemplate.executeUpdate(sql, saleQty,saleUnit, orgNo, shopNO, idx);
}
this.CartToCartTempItem(shopNO);
return Rjx.jsonOk().set("count", count(orgNo, shopNO)).toJson();
......
......@@ -165,6 +165,22 @@ public class GoodsServiceImpl implements GoodsService {
boolean isCheckAgentID = StringUtil.isNotBlank(agentID)?true:false;
//检查是不是不多单位 需求 #15246
int IsGoodsUnit = 0 ; //1为多单位,0 为否
try {
String mSql = "select count(1) from tAgentGoodsUnit a " +
" where a.sUnitTypeID in('SaleMid','SaleBig') " +
" and a.nAgentID = ? " +
" and a.nGoodsID = ?";
int mCount = jdbcTemplate.queryForInt(mSql,agentID,goodsId);
if(mCount >0 ) {
IsGoodsUnit = 1;
}
} catch (Exception e1) {
e1.printStackTrace();
}
String gSql = "select t.*, ap.nRealSalePrice nApSalePrice from V_OrgGoods t left join tAgentCustTypePrice ap on ap.sCustTypeID = ? and ap.sAgentContractNO = t.sAgentContractNO and ap.nGoodsID = t.nGoodsID where t.sOrgNO = ? and t.sAgentContractNO = ? and t.nGoodsID = ? ";
Map<String, Object> detail = null;
......@@ -181,6 +197,7 @@ public class GoodsServiceImpl implements GoodsService {
if(nApSalePrice != null) {
detail.put("nRealSalePrice", nApSalePrice);
}
detail.put("IsGoodsUnit", IsGoodsUnit);
} catch (EmptyResultDataAccessException e) {
throw new XException("商品已下架");
}
......@@ -246,6 +263,19 @@ public class GoodsServiceImpl implements GoodsService {
detail.put("promoList", promoList);
//商品详情再增加一个集合输出多单位信息 需求 #15246
if(IsGoodsUnit == 1) {
String GoodsUnitSql = " select gu.sUnitTypeID, gu.sUnitType, gu.nConvertRate, gu.sUnit, nRealSalePrice = gu.nSalePrice, sShowUnit = convert(varchar,gu.nSalePrice) + '元/' + gu.sUnit + ' (' + dbo.fn_GetConvertDec(gu.nConvertRate) + t.sUnit + ')' "
+ " from V_OrgGoods t join tAgentGoodsUnit gu on gu.nAgentID = t.nAgentID and gu.nGoodsID = t.nGoodsID "
+ " where t.sOrgNO = ? and t.sAgentContractNO = ? and t.nGoodsID = ? and t.nAgentID = ? order by nConvertRate ";
List<Map<String,Object>> goodsUnitList = jdbcTemplate.queryForList(GoodsUnitSql,orgNo,contractNo,goodsId,agentID);
rjx.set("goodsUnitList", goodsUnitList);
}else {
rjx.set("goodsUnitList", null);
}
rjx.set("goodsDetail", detail);
rjx.putAll(picList);
return rjx.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