Commit 97320b74 authored by Quxl's avatar Quxl

x

parent 6203a9d3
package com.egolm.shop.api.service.impl; package com.egolm.shop.api.service.impl;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.egolm.common.DateUtil; import com.egolm.common.DateUtil;
import com.egolm.common.StringUtil; import com.egolm.common.StringUtil;
import com.egolm.common.Util; import com.egolm.common.Util;
import com.egolm.common.bean.Rjx; import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.JdbcTemplate; import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page; import com.egolm.common.jdbc.Page;
import com.egolm.common.jdbc.dialect.SqlServerDialect; import com.egolm.common.jdbc.dialect.SqlServerDialect;
import com.egolm.shop.api.service.GoodsService; import com.egolm.shop.api.service.GoodsService;
import com.egolm.shop.common.XException; import com.egolm.shop.common.XException;
import com.egolm.shop.common.utils.I18NUtils; import com.egolm.shop.common.utils.I18NUtils;
@Service @Service
public class GoodsServiceImpl implements GoodsService { public class GoodsServiceImpl implements GoodsService {
@Autowired @Autowired
private JdbcTemplate jdbcTemplate; private JdbcTemplate jdbcTemplate;
/** /**
* 获取当前用户历史购买的商品同分类(三级)下的三个月内购买数量最多的商品Top 20, * 获取当前用户历史购买的商品同分类(三级)下的三个月内购买数量最多的商品Top 20,
* 未登录时获取当前区域三个月内购买数量最多的商品Top 20 * 未登录时获取当前区域三个月内购买数量最多的商品Top 20
*/ */
@Override @Override
public List<Map<String,Object>> listThinkLike(Map<String,Object> params, Page page){ public List<Map<String,Object>> listThinkLike(Map<String,Object> params, Page page){
String userNO = params.get("userNO")+""; String userNO = params.get("userNO")+"";
String orgNO = params.get("orgNO")+""; String orgNO = params.get("orgNO")+"";
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.setTime(new Date()); cal.setTime(new Date());
cal.add(Calendar.DATE, -90); cal.add(Calendar.DATE, -90);
Date date = new Date(cal.getTime().getTime()); Date date = new Date(cal.getTime().getTime());
String beginDate = DateUtil.format(date); String beginDate = DateUtil.format(date);
String endDate = DateUtil.format(new Date()); String endDate = DateUtil.format(new Date());
String sql = "select a.nGoodsID GoodsID, g.sGoodsNO GoodsNO, g.sGoodsDesc GoodsName, acg.nSalePrice Price, acg.sSpec Spec, acg.sUnit Unit, acg.nMinSaleQty MinQty, " String sql = "select a.nGoodsID GoodsID, g.sGoodsNO GoodsNO, g.sGoodsDesc GoodsName, acg.nSalePrice Price, acg.sSpec Spec, acg.sUnit Unit, acg.nMinSaleQty MinQty, "
+ " acg.nSaleUnits SaleUnit, acg.nMarketPrice MarketPrice, sum(a.nSaleQty) SaleQty from tAgentGoodsDailyOnline a join tGoods g on a.nGoodsID = g.nGoodsID " + " acg.nSaleUnits SaleUnit, acg.nMarketPrice MarketPrice, sum(a.nSaleQty) SaleQty from tAgentGoodsDailyOnline a join tGoods g on a.nGoodsID = g.nGoodsID "
+ " join tAgentContractGoods acg on a.sAgentContractNO = acg.sAgentContractNO and a.nGoodsID = acg.nGoodsID "; + " join tAgentContractGoods acg on a.sAgentContractNO = acg.sAgentContractNO and a.nGoodsID = acg.nGoodsID ";
if(!userNO.equals("nouserNO")&&!StringUtil.isEmpty(userNO)) { if(!userNO.equals("nouserNO")&&!StringUtil.isEmpty(userNO)) {
sql += " ,tUserOrg tu, tUserAgent ua where acg.sOrgNO = '" + orgNO + "' and acg.sOrgNO = tu.sOrgNO and tu.sUserNO = '" + userNO + "' and tu.nTag&1 = 0" sql += " ,tUserOrg tu, tUserAgent ua where acg.sOrgNO = '" + orgNO + "' and acg.sOrgNO = tu.sOrgNO and tu.sUserNO = '" + userNO + "' and tu.nTag&1 = 0"
+ " and acg.nAgentID = ua.nAgentID and ua.sUserNO = '" + userNO + "' and ua.nTag&1 = 0 and a.dTradeDate >= '" + beginDate + "' and a.dTradeDate < '" + endDate + "' "; + " and acg.nAgentID = ua.nAgentID and ua.sUserNO = '" + userNO + "' and ua.nTag&1 = 0 and a.dTradeDate >= '" + beginDate + "' and a.dTradeDate < '" + endDate + "' ";
}else { }else {
sql += " where acg.sOrgNO = '" + orgNO + "' and a.dTradeDate >= '" + beginDate + "' and a.dTradeDate < '" + endDate +"'"; sql += " where acg.sOrgNO = '" + orgNO + "' and a.dTradeDate >= '" + beginDate + "' and a.dTradeDate < '" + endDate +"'";
} }
sql += " group by a.nGoodsID, g.sGoodsNO, g.sGoodsDesc, acg.nSalePrice, acg.sSpec, acg.sUnit, acg.nMinSaleQty, acg.nSaleUnits, acg.nMarketPrice, acg.sMarketUnit"; sql += " group by a.nGoodsID, g.sGoodsNO, g.sGoodsDesc, acg.nSalePrice, acg.sSpec, acg.sUnit, acg.nMinSaleQty, acg.nSaleUnits, acg.nMarketPrice, acg.sMarketUnit";
jdbcTemplate.setDialect(new SqlServerDialect()); jdbcTemplate.setDialect(new SqlServerDialect());
return jdbcTemplate.limit(sql, page); return jdbcTemplate.limit(sql, page);
} }
@Override @Override
public List<Map<String, Object>> getHotSaleGoods(Map<String, Object> map, Page page) { public List<Map<String, Object>> getHotSaleGoods(Map<String, Object> map, Page page) {
String sql="SELECT GoodsID = agd.nGoodsID,ContractNO = agd.sAgentContractNO ,SaleQty = sum(agd.nSaleQty), ImageUrl = isnull(g.sURL ,'') " String sql="SELECT GoodsID = agd.nGoodsID,ContractNO = agd.sAgentContractNO ,SaleQty = sum(agd.nSaleQty), ImageUrl = isnull(g.sURL ,'') "
+ " FROM tAgentGoodsDailyOnline agd JOIN tAgentContractGoods acg ON agd.sAgentContractNO = acg.sAgentContractNO " + " FROM tAgentGoodsDailyOnline agd JOIN tAgentContractGoods acg ON agd.sAgentContractNO = acg.sAgentContractNO "
+ " LEFT JOIN tGoodsPic g ON agd.nGoodsID = g.nGoodsID AND g.sPicTypeID = '1' AND g.nItem = 1 AND g.nTag&1=0 " + " LEFT JOIN tGoodsPic g ON agd.nGoodsID = g.nGoodsID AND g.sPicTypeID = '1' AND g.nItem = 1 AND g.nTag&1=0 "
+ " WHERE acg.nTag&1=0 AND acg.sOrgNO = ? " + " WHERE acg.nTag&1=0 AND acg.sOrgNO = ? "
+ " GROUP BY agd.nGoodsID,agd.sAgentContractNO,g.sURL "; + " GROUP BY agd.nGoodsID,agd.sAgentContractNO,g.sURL ";
String OrgNO=(String) map.get("OrgNO"); String OrgNO=(String) map.get("OrgNO");
jdbcTemplate.setDialect(new SqlServerDialect()); jdbcTemplate.setDialect(new SqlServerDialect());
return jdbcTemplate.limit(sql, page,OrgNO); return jdbcTemplate.limit(sql, page,OrgNO);
} }
@Override @Override
public List<Map<String, Object>> GetCategoryGoods(Map<String, Object> map, Page page) { public List<Map<String, Object>> GetCategoryGoods(Map<String, Object> map, Page page) {
String OrgNO=(String) map.get("OrgNO"); String OrgNO=(String) map.get("OrgNO");
String ShopNO=(String) map.get("ShopNO"); String ShopNO=(String) map.get("ShopNO");
String CategoryNOA=(String) map.get("CategoryNOA"); String CategoryNOA=(String) map.get("CategoryNOA");
String CategoryNOB=(String) map.get("CategoryNOB"); String CategoryNOB=(String) map.get("CategoryNOB");
String DistrictID; String DistrictID;
String sql_0="SELECT DistrictID=sDistrictID FROM tShop WHERE sOrgNO =? AND sShopNO = ?"; String sql_0="SELECT DistrictID=sDistrictID FROM tShop WHERE sOrgNO =? AND sShopNO = ?";
try { try {
DistrictID=jdbcTemplate.queryForString(sql_0, OrgNO,ShopNO); DistrictID=jdbcTemplate.queryForString(sql_0, OrgNO,ShopNO);
} catch (EmptyResultDataAccessException e) { } catch (EmptyResultDataAccessException e) {
DistrictID=""; DistrictID="";
} }
String sql=" SELECT GoodsID = acg.nGoodsID,"+ String sql=" SELECT GoodsID = acg.nGoodsID,"+
" GoodsNO = acg.sGoodsNO, " + " GoodsNO = acg.sGoodsNO, " +
" GoodsName = acg.sGoodsDesc, " + " GoodsName = acg.sGoodsDesc, " +
" Price = acg.nSalePrice, " + " Price = acg.nSalePrice, " +
" Unit = acg.sUnit, " + " Unit = acg.sUnit, " +
" Spec = acg.sSpec, " + " Spec = acg.sSpec, " +
" MinQty = acg.nMinSaleQty, " + " MinQty = acg.nMinSaleQty, " +
" SaleUnit = acg.nSaleUnits, " + " SaleUnit = acg.nSaleUnits, " +
" MarketPrice = acg.nMarketPrice, " + " MarketPrice = acg.nMarketPrice, " +
" MarketUnit = acg.sMarketUnit, " + " MarketUnit = acg.sMarketUnit, " +
" ImagePath = ISNULL(g.sURL,'')," + " ImagePath = ISNULL(g.sURL,'')," +
" PopImagePath = '' " + " PopImagePath = '' " +
" FROM tAgentContractWarehouse acw, tAgentContractGoods acg " " FROM tAgentContractWarehouse acw, tAgentContractGoods acg "
+ "LEFT JOIN tGoodsPic g ON acg.nGoodsID = g.nGoodsID " + + "LEFT JOIN tGoodsPic g ON acg.nGoodsID = g.nGoodsID " +
" AND g.sPicTypeID = '1' " + " AND g.sPicTypeID = '1' " +
" AND g.nItem = 1, " + " AND g.nItem = 1, " +
"(SELECT a.sWarehouseNO FROM tWarehouseDistrict a, (SELECT sDistrictID, nDCPriority = max(nDCPriority) FROM tWarehouseDistrict " + "(SELECT a.sWarehouseNO FROM tWarehouseDistrict a, (SELECT sDistrictID, nDCPriority = max(nDCPriority) FROM tWarehouseDistrict " +
" GROUP BY sDistrictID) b WHERE a.sDistrictID = b.sDistrictID AND a.nDCPriority = b.nDCPriority AND (a.sDistrictID = ? OR ? = '') " + " GROUP BY sDistrictID) b WHERE a.sDistrictID = b.sDistrictID AND a.nDCPriority = b.nDCPriority AND (a.sDistrictID = ? OR ? = '') " +
" ) d, tCategory c " + " ) d, tCategory c " +
" WHERE acw.sAgentContractNO = acg.sAgentContractNO " + " WHERE acw.sAgentContractNO = acg.sAgentContractNO " +
" AND acw.sWarehouseNO = d.sWarehouseNO " + " AND acw.sWarehouseNO = d.sWarehouseNO " +
" AND acg.sCategoryNO = c.sCategoryNO " + " AND acg.sCategoryNO = c.sCategoryNO " +
" AND acg.nTag&1=0 " + " AND acg.nTag&1=0 " +
" AND acg.sOrgNO = '"+OrgNO+"' " + " AND acg.sOrgNO = '"+OrgNO+"' " +
" AND (c.sPath LIKE ISNULL((SELECT sPath FROM tCategory WHERE sCategoryNO = ?),'') + '%') " + " AND (c.sPath LIKE ISNULL((SELECT sPath FROM tCategory WHERE sCategoryNO = ?),'') + '%') " +
" AND (c.sPath LIKE ISNULL((SELECT sPath FROM tCategory WHERE sCategoryNO = ?),'') + '%') " ; " AND (c.sPath LIKE ISNULL((SELECT sPath FROM tCategory WHERE sCategoryNO = ?),'') + '%') " ;
jdbcTemplate.setDialect(new SqlServerDialect()); jdbcTemplate.setDialect(new SqlServerDialect());
return jdbcTemplate.limit(sql,page, DistrictID,DistrictID,CategoryNOA,CategoryNOB); return jdbcTemplate.limit(sql,page, DistrictID,DistrictID,CategoryNOA,CategoryNOB);
} }
/** /**
* 热搜词 * 热搜词
* <p>Title: hotSearchKey</p> * <p>Title: hotSearchKey</p>
* <p>Description: </p> * <p>Description: </p>
* @param map * @param map
* @param page * @param page
* @return * @return
* @see com.egolm.shop.api.service.GoodsService#hotSearchKey(java.util.Map, com.egolm.common.jdbc.Page) * @see com.egolm.shop.api.service.GoodsService#hotSearchKey(java.util.Map, com.egolm.common.jdbc.Page)
*/ */
@Override @Override
public List<Map<String, Object>> hotSearchKey(Map<String, Object> map, Page page) { public List<Map<String, Object>> hotSearchKey(Map<String, Object> map, Page page) {
String orgNO=(String) map.get("orgNO"); String orgNO=(String) map.get("orgNO");
String sql="SELECT " String sql="SELECT "
+ " searchCount = COUNT (sKeyword), " + " searchCount = COUNT (sKeyword), "
+ " keyword = sKeyword " + " keyword = sKeyword "
+ "FROM " + "FROM "
+ " tShopSearchLog slog LEFT JOIN tShop s on(s.sShopNO=slog.sShopNO) " + " tShopSearchLog slog LEFT JOIN tShop s on(s.sShopNO=slog.sShopNO) "
+ "WHERE " + "WHERE "
+ " s.sShopNO=slog.sShopNO " + " s.sShopNO=slog.sShopNO "
+ " AND s.sOrgNO='"+orgNO+"' " + " AND s.sOrgNO='"+orgNO+"' "
+ " GROUP BY " + " GROUP BY "
+ " s.sOrgNO, " + " s.sOrgNO, "
+ " sKeyword "; + " sKeyword ";
jdbcTemplate.setDialect(new SqlServerDialect()); jdbcTemplate.setDialect(new SqlServerDialect());
return jdbcTemplate.limit(sql,page); return jdbcTemplate.limit(sql,page);
} }
/** /**
* 商品详情 * 商品详情
* <p>Title: goodsDetail</p> * <p>Title: goodsDetail</p>
* <p>Description: </p> * <p>Description: </p>
* @param map * @param map
* @param page * @param page
* @return * @return
* @see com.egolm.shop.api.service.GoodsService#goodsDetail(java.util.Map, com.egolm.common.jdbc.Page) * @see com.egolm.shop.api.service.GoodsService#goodsDetail(java.util.Map, com.egolm.common.jdbc.Page)
*/ */
@Override @Override
public String goodsDetail(Map<String, Object> map) { public String goodsDetail(Map<String, Object> map) {
String orgNo = (String)map.get("orgNo"); String orgNo = (String)map.get("orgNo");
String goodsId=(String) map.get("goodsId"); String goodsId=(String) map.get("goodsId");
String contractNo=(String) map.get("contractNo"); String contractNo=(String) map.get("contractNo");
String custTypeId=(String) map.get("custTypeId"); String custTypeId=(String) map.get("custTypeId");
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 = ?"; 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; Map<String, Object> detail = null;
try { try {
detail = jdbcTemplate.queryForMap(gSql, custTypeId, orgNo, contractNo, goodsId); detail = jdbcTemplate.queryForMap(gSql, custTypeId, orgNo, contractNo, goodsId);
BigDecimal nApSalePrice = (BigDecimal) detail.get("nApSalePrice"); BigDecimal nApSalePrice = (BigDecimal) detail.get("nApSalePrice");
if(nApSalePrice != null) { if(nApSalePrice != null) {
detail.put("nRealSalePrice", nApSalePrice); detail.put("nRealSalePrice", nApSalePrice);
} }
} catch (EmptyResultDataAccessException e) { } catch (EmptyResultDataAccessException e) {
throw new XException("商品已下架"); throw new XException("商品已下架");
} }
String sql = "select t.nGoodsID, t.sSubCode, t.nParentID, t.sSpecName, t.sSpec, isnull(ap.nRealSalePrice, og.nRealSalePrice) nRealSalePrice, og.nStockQty, og.nLockedQty from tGoodsSubCode t left join V_OrgGoods og on og.sOrgNO = ? and og.sAgentContractNO = ? and og.nGoodsID = t.nGoodsID left join tAgentCustTypePrice ap on ap.sCustTypeID = ? and ap.sAgentContractNO = og.sAgentContractNO and ap.nGoodsID = og.nGoodsID where t.nParentID = ? and t.nTag&1 = 0"; String sql = "select t.nGoodsID, t.sSubCode, t.nParentID, t.sSpecName, t.sSpec, isnull(ap.nRealSalePrice, og.nRealSalePrice) nRealSalePrice, og.nStockQty, og.nLockedQty from tGoodsSubCode t left join V_OrgGoods og on og.sOrgNO = ? and og.sAgentContractNO = ? and og.nGoodsID = t.nGoodsID left join tAgentCustTypePrice ap on ap.sCustTypeID = ? and ap.sAgentContractNO = og.sAgentContractNO and ap.nGoodsID = og.nGoodsID where t.nParentID = ? and t.nTag&1 = 0";
List<Map<String, Object>> specList = jdbcTemplate.queryForList(sql, orgNo, contractNo, custTypeId, goodsId); List<Map<String, Object>> specList = jdbcTemplate.queryForList(sql, orgNo, contractNo, custTypeId, goodsId);
Map<String, Map<String, Object>> specMap = Util.listToMM(specList, ";", "sSpecName", "sSpec"); Map<String, Map<String, Object>> specMap = Util.listToMM(specList, ";", "sSpecName", "sSpec");
Set<String> specNames = specList.stream().map(o -> (String)o.get("sSpecName")).collect(Collectors.toSet()); Set<String> specNames = specList.stream().map(o -> (String)o.get("sSpecName")).collect(Collectors.toSet());
Set<String> specs = specList.stream().map(o -> (String)o.get("sSpec")).collect(Collectors.toSet()); Set<String> specs = specList.stream().map(o -> (String)o.get("sSpec")).collect(Collectors.toSet());
BigDecimal nMarketPrice = (BigDecimal)detail.get("nMarketPrice"); BigDecimal nMarketPrice = (BigDecimal)detail.get("nMarketPrice");
BigDecimal nRealSalePrice = (BigDecimal)detail.get("nRealSalePrice"); BigDecimal nRealSalePrice = (BigDecimal)detail.get("nRealSalePrice");
BigDecimal nProfitMargin = BigDecimal.ZERO; BigDecimal nProfitMargin = BigDecimal.ZERO;
if(nRealSalePrice != null && nRealSalePrice.compareTo(BigDecimal.ZERO) != 0) { if(nRealSalePrice != null && nRealSalePrice.compareTo(BigDecimal.ZERO) != 0) {
nProfitMargin = nMarketPrice.subtract(nRealSalePrice).multiply(new BigDecimal(100)).divide(nRealSalePrice, 2, BigDecimal.ROUND_HALF_UP); nProfitMargin = nMarketPrice.subtract(nRealSalePrice).multiply(new BigDecimal(100)).divide(nRealSalePrice, 2, BigDecimal.ROUND_HALF_UP);
} }
detail.put("nProfitMargin", nProfitMargin); detail.put("nProfitMargin", nProfitMargin);
Map<String, List<Map<String, Object>>> picList = goodsPicList(goodsId, contractNo); Map<String, List<Map<String, Object>>> picList = goodsPicList(goodsId, contractNo);
String promoSql = "select pm.* from tYWPromoMain pm, tYWPromoDtl pd, tPromoCustBWList bw where pm.sPromoPaperNO = bw.sPromoPaperNO and bw.sShopNO = ? and pm.sPromoActionTypeID != '3' and pm.sOrgNO = ? and pm.sPromoPaperNO = pd.sPromoPaperNO and pm.nTag&3 = 2 and (pd.sAgentContractNO = ?) and (pd.nGoodsID = ?)"; String promoSql = "select pm.* from tYWPromoMain pm, tYWPromoDtl pd, tPromoCustBWList bw where pm.sPromoPaperNO = bw.sPromoPaperNO and bw.sShopNO = ? and pm.sPromoActionTypeID != '3' and pm.sOrgNO = ? and pm.sPromoPaperNO = pd.sPromoPaperNO and pm.nTag&3 = 2 and (pd.sAgentContractNO = ?) and (pd.nGoodsID = ?)";
Object[] args = new Object[] {custTypeId, orgNo, contractNo, goodsId}; Object[] args = new Object[] {custTypeId, orgNo, contractNo, goodsId};
List<Map<String, Object>> promoList = jdbcTemplate.queryForList(promoSql, args); List<Map<String, Object>> promoList = jdbcTemplate.queryForList(promoSql, args);
detail.put("promoList", promoList); detail.put("promoList", promoList);
Rjx rjx = Rjx.jsonOk().set("goodsDetail", detail).set("specList", specList).set("specMap", specMap).set("specNames", specNames).set("specs", specs); Rjx rjx = Rjx.jsonOk().set("goodsDetail", detail).set("specList", specList).set("specMap", specMap).set("specNames", specNames).set("specs", specs);
rjx.putAll(picList); rjx.putAll(picList);
return rjx.toJson(); return rjx.toJson();
} }
/** /**
* 查询商品图片 * 查询商品图片
* @Title: goodsPicList * @Title: goodsPicList
* @Description: TODO(这里用一句话描述这个方法的作用) * @Description: TODO(这里用一句话描述这个方法的作用)
* @param: @param goodsID * @param: @param goodsID
* @param: @param agentContractNO * @param: @param agentContractNO
* @param: @return * @param: @return
* @return: List<Map<String,Object>> * @return: List<Map<String,Object>>
* @throws * @throws
*/ */
public Map<String, List<Map<String, Object>>> goodsPicList(String goodsID,String agentContractNO ){ public Map<String, List<Map<String, Object>>> goodsPicList(String goodsID,String agentContractNO ){
String sql1 = "select agp.sURL, agp.nLength, agp.sPicTypeID from tAgentGoodsPic agp, tAgentContractGoods acg where agp.nAgentID = acg.nAgentID and agp.nGoodsID = acg.nGoodsID and acg.sAgentContractNO = ? and acg.nGoodsID = ? and agp.nTag&1 = 0 order by agp.nIdx"; String sql1 = "select agp.sURL, agp.nLength, agp.sPicTypeID from tAgentGoodsPic agp, tAgentContractGoods acg where agp.nAgentID = acg.nAgentID and agp.nGoodsID = acg.nGoodsID and acg.sAgentContractNO = ? and acg.nGoodsID = ? and agp.nTag&1 = 0 order by agp.nIdx";
List<Map<String, Object>> picList1 = jdbcTemplate.queryForList(sql1, agentContractNO, goodsID); List<Map<String, Object>> picList1 = jdbcTemplate.queryForList(sql1, agentContractNO, goodsID);
Map<String, List<Map<String,Object>>> picML1 = Util.listToML(picList1, "sPicTypeID"); Map<String, List<Map<String,Object>>> picML1 = Util.listToML(picList1, "sPicTypeID");
Map<String, List<Map<String, Object>>> pics = new HashMap<String, List<Map<String, Object>>>(); Map<String, List<Map<String, Object>>> pics = new HashMap<String, List<Map<String, Object>>>();
for(String sPicTypeID : new String[] {"1", "2", "3", "4"}) { for(String sPicTypeID : new String[] {"1", "2", "3", "4"}) {
List<Map<String, Object>> picList = picML1.get(sPicTypeID); List<Map<String, Object>> picList = picML1.get(sPicTypeID);
pics.put("ImgGroup_" + sPicTypeID, picList); pics.put("ImgGroup_" + sPicTypeID, picList);
} }
return pics; return pics;
} }
/** /**
* 收藏及取消收藏 * 收藏及取消收藏
* @Title: updateFlavor * @Title: updateFlavor
* @Description: TODO(这里用一句话描述这个方法的作用) * @Description: TODO(这里用一句话描述这个方法的作用)
* @param: @param params * @param: @param params
* @param: @return * @param: @return
* @return: String * @return: String
* @throws * @throws
*/ */
public String updateFlavor(Map<String,Object> params){ public String updateFlavor(Map<String,Object> params){
String goodsID=(String)params.get("goodsID"); String goodsID=(String)params.get("goodsID");
String shopNO=(String)params.get("shopNO"); String shopNO=(String)params.get("shopNO");
String override=(String)params.get("override"); String override=(String)params.get("override");
String langID=(String) params.get("langID"); String langID=(String) params.get("langID");
String sqlD="delete from tFlavorGoods where sShopNO =? and nGoodsID = ?"; String sqlD="delete from tFlavorGoods where sShopNO =? and nGoodsID = ?";
String sqlIn=" if not exists (select 1 from tFlavorGoods where sShopNO = ? and nGoodsID = ?)" String sqlIn=" if not exists (select 1 from tFlavorGoods where sShopNO = ? and nGoodsID = ?)"
+" insert into tFlavorGoods (sShopNO, nGoodsID, dLastUpdateTime) " +" insert into tFlavorGoods (sShopNO, nGoodsID, dLastUpdateTime) "
+" values (?,?,getdate())"; +" values (?,?,getdate())";
jdbcTemplate.setDialect(new SqlServerDialect()); jdbcTemplate.setDialect(new SqlServerDialect());
if("0".equals(override)) { if("0".equals(override)) {
try { try {
jdbcTemplate.executeUpdate(sqlD, shopNO,goodsID); jdbcTemplate.executeUpdate(sqlD, shopNO,goodsID);
return Rjx.jsonOk().setMessage(I18NUtils.getMessage(langID, "Msg_CancelCollect_success")).toJson(); return Rjx.jsonOk().setMessage(I18NUtils.getMessage(langID, "Msg_CancelCollect_success")).toJson();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return Rjx.jsonErr().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_CancelCollect_failure")).toJson(); return Rjx.jsonErr().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_CancelCollect_failure")).toJson();
} }
}else if("1".equals(override)) { }else if("1".equals(override)) {
try { try {
jdbcTemplate.executeUpdate(sqlIn, shopNO,goodsID, shopNO,goodsID); jdbcTemplate.executeUpdate(sqlIn, shopNO,goodsID, shopNO,goodsID);
return Rjx.jsonOk().setMessage(I18NUtils.getMessage(langID, "Msg_Collection_success")).toJson(); return Rjx.jsonOk().setMessage(I18NUtils.getMessage(langID, "Msg_Collection_success")).toJson();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return Rjx.jsonErr().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_Collection_failure")).toJson(); return Rjx.jsonErr().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_Collection_failure")).toJson();
} }
} }
return Rjx.jsonErr().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_Operate_failure")).toJson(); return Rjx.jsonErr().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_Operate_failure")).toJson();
} }
@Override @Override
public Map<String, Map<String, Object>> queryStockPrice(String orgNo, String shopNo, String[] uidAry) { public Map<String, Map<String, Object>> queryStockPrice(String orgNo, String shopNo, String[] uidAry) {
List<String> args = new ArrayList<String>(); List<String> args = new ArrayList<String>();
for(String uid : uidAry) { for(String uid : uidAry) {
if(StringUtil.isBlank(uid)) { if(StringUtil.isBlank(uid)) {
continue; continue;
} }
String[] kv = uid.split(":", 2); String[] kv = uid.split(":", 2);
args.add("(t.sAgentContractNO = '" + kv[0] + "' and t.nGoodsID = " + kv[1] + ")"); args.add("(t.sAgentContractNO = '" + kv[0] + "' and t.nGoodsID = " + kv[1] + ")");
} }
String sCustTypeID = "99999999999999"; String sCustTypeID = "99999999999999";
try { try {
sCustTypeID = jdbcTemplate.queryForString("select c.sCustTypeID from tCustomer c, tShop s where c.sCustNO = s.sCustNO and s.sShopNO = ?", shopNo); sCustTypeID = jdbcTemplate.queryForString("select c.sCustTypeID from tCustomer c, tShop s where c.sCustNO = s.sCustNO and s.sShopNO = ?", shopNo);
} catch (Exception e) { } catch (Exception e) {
//shopNo为空,没有登陆 //shopNo为空,没有登陆
} }
String sql = "select t.sAgentContractNO, t.nGoodsID, t.nStockQty, t.nDefaultPrice, isnull(ap.nRealSalePrice, t.nRealSalePrice) nRealSalePrice from V_OrgGoods t left join tAgentCustTypePrice ap on ap.sCustTypeID = '" + sCustTypeID + "' and t.sAgentContractNO = ap.sAgentContractNO and t.nGoodsID = ap.nGoodsID where t.sOrgNO = '" + orgNo + "' " + StringUtil.join(" OR ", " and (", ")", " and (1 = 0) ", args); String sql = "select t.sAgentContractNO, t.nGoodsID, t.nStockQty, t.nRealStockQty, t.nDefaultPrice, isnull(ap.nRealSalePrice, t.nRealSalePrice) nRealSalePrice from V_OrgGoods t left join tAgentCustTypePrice ap on ap.sCustTypeID = '" + sCustTypeID + "' and t.sAgentContractNO = ap.sAgentContractNO and t.nGoodsID = ap.nGoodsID where t.sOrgNO = '" + orgNo + "' " + StringUtil.join(" OR ", " and (", ")", " and (1 = 0) ", args);
List<Map<String, Object>> datas = jdbcTemplate.queryForList(sql); List<Map<String, Object>> datas = jdbcTemplate.queryForList(sql);
Map<String, Map<String, Object>> mm = Util.listToMM(datas, ":", "sAgentContractNO", "nGoodsID"); Map<String, Map<String, Object>> mm = Util.listToMM(datas, ":", "sAgentContractNO", "nGoodsID");
String sql1 = "select t.sAgentContractNO, t.nGoodsID, p.sPromoTheme, p.sPromoName, p.sPromoPaperNO, p.sPromoActionTypeID, t.sGroupNO sPromoGroupNO from tYWPromoDtl t, tYWPromoMain p where p.sPromoActionTypeID != '3' and t.sPromoPaperNO = p.sPromoPaperNO and p.nTag&3 = 2 and p.sOrgNO = '" + orgNo + "' " + StringUtil.join(" OR ", " and (", ")", " and (1 = 0) ", args) + " group by t.sAgentContractNO, t.nGoodsID, p.sPromoTheme, p.sPromoName, p.sPromoPaperNO, p.sPromoActionTypeID, t.sGroupNO"; String sql1 = "select t.sAgentContractNO, t.nGoodsID, p.sPromoTheme, p.sPromoName, p.sPromoPaperNO, p.sPromoActionTypeID, t.sGroupNO sPromoGroupNO from tYWPromoDtl t, tYWPromoMain p where p.sPromoActionTypeID != '3' and t.sPromoPaperNO = p.sPromoPaperNO and p.nTag&3 = 2 and p.sOrgNO = '" + orgNo + "' " + StringUtil.join(" OR ", " and (", ")", " and (1 = 0) ", args) + " group by t.sAgentContractNO, t.nGoodsID, p.sPromoTheme, p.sPromoName, p.sPromoPaperNO, p.sPromoActionTypeID, t.sGroupNO";
List<Map<String, Object>> plist = jdbcTemplate.queryForList(sql1); List<Map<String, Object>> plist = jdbcTemplate.queryForList(sql1);
Map<String, List<Map<String, Object>>> pmm = Util.listToML(plist, ":", "sAgentContractNO", "nGoodsID"); Map<String, List<Map<String, Object>>> pmm = Util.listToML(plist, ":", "sAgentContractNO", "nGoodsID");
for(String key : mm.keySet()) { for(String key : mm.keySet()) {
mm.get(key).put("promoList", pmm.get(key)); mm.get(key).put("promoList", pmm.get(key));
} }
return mm; return mm;
} }
} }
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