Browse Source

调整代码

master
xyiege 3 years ago
parent
commit
732a8bee56
  1. 6
      src/main/java/cn/chjyj/szwh/controller/api/GoodsController.java
  2. 2
      src/main/java/cn/chjyj/szwh/service/GoodsService.java
  3. 28
      src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java

6
src/main/java/cn/chjyj/szwh/controller/api/GoodsController.java

@ -60,12 +60,12 @@ public class GoodsController extends BaseController {
String appkey = request.getParameter("appkey"); String appkey = request.getParameter("appkey");
String timestamp = request.getParameter("timestamp"); String timestamp = request.getParameter("timestamp");
// //
Map<String, Object> retmap =goodsService.getShoppingCar(userIsli); List retlist =goodsService.getShoppingCar(userIsli);
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
long howUse = (end-start)/1000l; long howUse = (end-start)/1000l;
jsonObject.put("code",200); jsonObject.put("code","success");
jsonObject.put("msg","成功"); jsonObject.put("msg","成功");
jsonObject.put("data",retmap); jsonObject.put("data",retlist);
jsonObject.put("useTime",howUse); jsonObject.put("useTime",howUse);
return jsonObject; return jsonObject;
} }

2
src/main/java/cn/chjyj/szwh/service/GoodsService.java

@ -127,7 +127,7 @@ public interface GoodsService {
* @param userIsli * @param userIsli
* @return * @return
*/ */
Map<String,Object> getShoppingCar(String userIsli); List getShoppingCar(String userIsli);
/** /**
* del from use goods shop car * del from use goods shop car

28
src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java

@ -533,6 +533,7 @@ public class GoodsServiceImpl implements GoodsService {
@Override @Override
public List getTypeGoods(String type, String createtime, String goods_type) { public List getTypeGoods(String type, String createtime, String goods_type) {
// 商品列表
List<Goods> glist = new ArrayList<>(); List<Goods> glist = new ArrayList<>();
String where = "";//查询条件 String where = "";//查询条件
if ("1".equals(type)) { if ("1".equals(type)) {
@ -725,18 +726,20 @@ public class GoodsServiceImpl implements GoodsService {
} }
@Override @Override
public Map<String, Object> getShoppingCar(String userIsli) { public List getShoppingCar(String userIsli) {
Map<String, Object> retmap = new HashMap<>(); // wait for result
List retlist =new ArrayList();
String shopRedisKey = "car_" + userIsli; String shopRedisKey = "car_" + userIsli;
// get shopping car from redis
Object shopCar = RedisUtil.get(shopRedisKey); Object shopCar = RedisUtil.get(shopRedisKey);
JSONObject shopCarJson = JSONObject.parseObject(shopCar.toString()); JSONObject shopCarJson = JSONObject.parseObject(shopCar.toString());
JSONArray jsonArray = shopCarJson.getJSONArray("data"); JSONArray jsonArray = shopCarJson.getJSONArray("data");
//JSONObject carjson =JSONObject.parseObject(shopCar.toString());
if (shopCar == null) { if (shopCar == null) {
//null //null
return retmap; return null;
} }
//fenpei //分配比例
Map acrmap = new HashMap(); Map acrmap = new HashMap();
acrmap.put("is_deleted", 0); acrmap.put("is_deleted", 0);
acrmap.put("status", 1); acrmap.put("status", 1);
@ -744,15 +747,18 @@ public class GoodsServiceImpl implements GoodsService {
AccountRatioSetting accountRatioSetting = acrlist.get(0); AccountRatioSetting accountRatioSetting = acrlist.get(0);
AccountRatioDetail accountRatioDetail = accountRatioDetailMapper.getAccRatioDetailByIdRole(accountRatioSetting.getId(), 2); AccountRatioDetail accountRatioDetail = accountRatioDetailMapper.getAccRatioDetailByIdRole(accountRatioSetting.getId(), 2);
//循环枚举
if (jsonArray.size() > 0) { if (jsonArray.size() > 0) {
//goods information //goods information
for (int x = 0; x < jsonArray.size(); x++) { for (int x =0; x<jsonArray.size(); x++) {
Map<String, Object> retmap = new HashMap<>();
JSONObject jsonObject = jsonArray.getJSONObject(x); JSONObject jsonObject = jsonArray.getJSONObject(x);
String goodsIsli = jsonObject.getString("goods_isli"); String goodsIsli = jsonObject.getString("goods_isli");
Goods goods = goodsMapper.getGoodsFuelByIsLi(goodsIsli); //goods
// Goods goods = goodsMapper.getGoodsByIsli(goodsIsli);
//goods detail
GoodsDetail goodsDetail = goodsDetailMapper.getGoodsDetailBygid(goods.getGoodsDetailId()); GoodsDetail goodsDetail = goodsDetailMapper.getGoodsDetailBygid(goods.getGoodsDetailId());
retmap.put("detial", goodsDetail); retmap.put("detail", goodsDetail);
// 计算服务费 // 计算服务费
Integer count = jsonObject.getInteger("use_years"); Integer count = jsonObject.getInteger("use_years");
if (goodsDetail.getGoodsEntrust() == 1) { if (goodsDetail.getGoodsEntrust() == 1) {
@ -792,9 +798,11 @@ public class GoodsServiceImpl implements GoodsService {
retmap.put("user", umap); retmap.put("user", umap);
// //
retmap.put("goods", goods); retmap.put("goods", goods);
// add retlist
retlist.add(retmap);
} }
} }
return retmap; return retlist;
} }
@Override @Override

Loading…
Cancel
Save