|
|
|
@ -187,13 +187,13 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
orderkey = "g.click_count"; |
|
|
|
break; |
|
|
|
case "createtime": |
|
|
|
orderkey="g.createtime"; |
|
|
|
orderkey = "g.createtime"; |
|
|
|
break; |
|
|
|
case "price": |
|
|
|
orderkey="gd.price"; |
|
|
|
orderkey = "gd.price"; |
|
|
|
break; |
|
|
|
} |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
gmap.remove("orderway"); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -216,22 +216,22 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
glmap.put("goods_detail_id", gl.getGoods_detail_id()); |
|
|
|
glmap.put("is_recommend", gl.getIsRecommend()); |
|
|
|
glmap.put("entrust_status", gl.getEntrust_status()); |
|
|
|
glmap.put("charges_type",gl.getCharges_type()); |
|
|
|
glmap.put("price",gl.getPrice()); |
|
|
|
glmap.put("goods_ownership_str",gl.getGoods_ownership_str()); |
|
|
|
glmap.put("createtime",gl.getCreatetime()); |
|
|
|
glmap.put("goods_entrust",gl.getGoods_entrust()); |
|
|
|
glmap.put("cnceltime",gl.getCanceltime()); |
|
|
|
glmap.put("goods_image",gl.getGoods_image()); |
|
|
|
glmap.put("stock",gl.getStock()); |
|
|
|
glmap.put("sale_count",gl.getSale_count()); |
|
|
|
glmap.put("click_count",gl.getClick_count()); |
|
|
|
glmap.put("charges_type", gl.getCharges_type()); |
|
|
|
glmap.put("price", gl.getPrice()); |
|
|
|
glmap.put("goods_ownership_str", gl.getGoods_ownership_str()); |
|
|
|
glmap.put("createtime", gl.getCreatetime()); |
|
|
|
glmap.put("goods_entrust", gl.getGoods_entrust()); |
|
|
|
glmap.put("cnceltime", gl.getCanceltime()); |
|
|
|
glmap.put("goods_image", gl.getGoods_image()); |
|
|
|
glmap.put("stock", gl.getStock()); |
|
|
|
glmap.put("sale_count", gl.getSale_count()); |
|
|
|
glmap.put("click_count", gl.getClick_count()); |
|
|
|
JSONObject userjson = SzwhApiUtils.getApiUser(gl.getUser_islicode()); |
|
|
|
Map umap = JSONObject.parseObject(userjson.getString("data")); |
|
|
|
glmap.put("user",umap); |
|
|
|
glmap.put("user", umap); |
|
|
|
// 商品资源
|
|
|
|
List<GoodsSource> gslist = goodsSourceMapper.getGoodsSourceByIsli(gl.getGoods_islicode()); |
|
|
|
glmap.put("source",gslist); |
|
|
|
glmap.put("source", gslist); |
|
|
|
//处理其他操作
|
|
|
|
glmap.put("key", gl.getGoods_islicode()); |
|
|
|
nglist.add(glmap); |
|
|
|
@ -546,64 +546,64 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
glist = goodsMapper.getGoodsByCondition(where, 8, "recommend_sort", "DESC"); |
|
|
|
} |
|
|
|
//填充信息
|
|
|
|
List retlist =new ArrayList(); |
|
|
|
for(Goods g:glist){ |
|
|
|
List retlist = new ArrayList(); |
|
|
|
for (Goods g : glist) { |
|
|
|
//goods detail
|
|
|
|
GoodsDetail gd =goodsDetailMapper.getGoodsDetailBygid(g.getGoodsDetailId()); |
|
|
|
GoodsDetail gd = goodsDetailMapper.getGoodsDetailBygid(g.getGoodsDetailId()); |
|
|
|
// goods source
|
|
|
|
List<GoodsSource> gslist = goodsSourceMapper.getGoodsSourceByIsli(g.getGoodsIslicode()); |
|
|
|
|
|
|
|
Map tgmap = new HashMap(); |
|
|
|
tgmap.put("goods_islicode",g.getGoodsIslicode()); |
|
|
|
tgmap.put("goods_name",gd.getGoodsName()); |
|
|
|
tgmap.put("goods_status",g.getGoodsStatus()); |
|
|
|
tgmap.put("createtime",g.getCreateTime()); |
|
|
|
tgmap.put("canceltime",g.getCancelTime()); |
|
|
|
tgmap.put("goods_type",gd.getGoodsType()); |
|
|
|
tgmap.put("contractual_period",gd.getContractualPeriod()); |
|
|
|
tgmap.put("contract",gd.getContract()); |
|
|
|
tgmap.put("transaction_class",gd.getTransactionClass()); |
|
|
|
tgmap.put("goods_entrust",gd.getGoodsEntrust()); |
|
|
|
tgmap.put("charges_type",gd.getChargesType()); |
|
|
|
tgmap.put("price",gd.getPrice()); |
|
|
|
tgmap.put("goods_ownership",gd.getGoodsOwnership()); |
|
|
|
tgmap.put("otherIdentifiers",gd.getOtherIdentifiers()); |
|
|
|
tgmap.put("classification",gd.getClassification()); |
|
|
|
|
|
|
|
if(glist!=null){ |
|
|
|
List tmpgs=new ArrayList(); |
|
|
|
for(GoodsSource gs:gslist){ |
|
|
|
tgmap.put("servicecode",gs.getServicecode()); |
|
|
|
tgmap.put("linkcode",gs.getLinkcode()); |
|
|
|
tgmap.put("publisherId",gs.getPublisherid()); |
|
|
|
tgmap.put("registrant",gs.getRegistrant()); |
|
|
|
tgmap.put("resolution_url",gs.getResolutionUrl()); |
|
|
|
tgmap.put("source_type",gs.getSourceType()); |
|
|
|
tgmap.put("source_name_type",gs.getSourceNameType()); |
|
|
|
tgmap.put("source_name",gs.getSourceName()); |
|
|
|
tgmap.put("sourceIdentify",gs.getSourceIdentify()); |
|
|
|
tgmap.put("source_fragment",gs.getSourceFragment()); |
|
|
|
tgmap.put("target_name",gs.getTargetName()); |
|
|
|
tgmap.put("target_name_type",gs.getTargetNameType()); |
|
|
|
tgmap.put("targetIdentify",gs.getTargetIdentify()); |
|
|
|
tgmap.put("target_fragment",gs.getTargetFragment()); |
|
|
|
tgmap.put("targetFormat",gs.getTargetFormat()); |
|
|
|
tgmap.put("source_data",gs.getSourceData()); |
|
|
|
tgmap.put("target_data",gs.getTargetData()); |
|
|
|
tgmap.put("metadataXml",gs.getMetadataXml()); |
|
|
|
tgmap.put("allocationtime",gs.getAllocationtime()); |
|
|
|
tgmap.put("cancellation_reason",gs.getCancellationReason()); |
|
|
|
tgmap.put("goods_islicode", g.getGoodsIslicode()); |
|
|
|
tgmap.put("goods_name", gd.getGoodsName()); |
|
|
|
tgmap.put("goods_status", g.getGoodsStatus()); |
|
|
|
tgmap.put("createtime", g.getCreateTime()); |
|
|
|
tgmap.put("canceltime", g.getCancelTime()); |
|
|
|
tgmap.put("goods_type", gd.getGoodsType()); |
|
|
|
tgmap.put("contractual_period", gd.getContractualPeriod()); |
|
|
|
tgmap.put("contract", gd.getContract()); |
|
|
|
tgmap.put("transaction_class", gd.getTransactionClass()); |
|
|
|
tgmap.put("goods_entrust", gd.getGoodsEntrust()); |
|
|
|
tgmap.put("charges_type", gd.getChargesType()); |
|
|
|
tgmap.put("price", gd.getPrice()); |
|
|
|
tgmap.put("goods_ownership", gd.getGoodsOwnership()); |
|
|
|
tgmap.put("otherIdentifiers", gd.getOtherIdentifiers()); |
|
|
|
tgmap.put("classification", gd.getClassification()); |
|
|
|
|
|
|
|
if (glist != null) { |
|
|
|
List tmpgs = new ArrayList(); |
|
|
|
for (GoodsSource gs : gslist) { |
|
|
|
tgmap.put("servicecode", gs.getServicecode()); |
|
|
|
tgmap.put("linkcode", gs.getLinkcode()); |
|
|
|
tgmap.put("publisherId", gs.getPublisherid()); |
|
|
|
tgmap.put("registrant", gs.getRegistrant()); |
|
|
|
tgmap.put("resolution_url", gs.getResolutionUrl()); |
|
|
|
tgmap.put("source_type", gs.getSourceType()); |
|
|
|
tgmap.put("source_name_type", gs.getSourceNameType()); |
|
|
|
tgmap.put("source_name", gs.getSourceName()); |
|
|
|
tgmap.put("sourceIdentify", gs.getSourceIdentify()); |
|
|
|
tgmap.put("source_fragment", gs.getSourceFragment()); |
|
|
|
tgmap.put("target_name", gs.getTargetName()); |
|
|
|
tgmap.put("target_name_type", gs.getTargetNameType()); |
|
|
|
tgmap.put("targetIdentify", gs.getTargetIdentify()); |
|
|
|
tgmap.put("target_fragment", gs.getTargetFragment()); |
|
|
|
tgmap.put("targetFormat", gs.getTargetFormat()); |
|
|
|
tgmap.put("source_data", gs.getSourceData()); |
|
|
|
tgmap.put("target_data", gs.getTargetData()); |
|
|
|
tgmap.put("metadataXml", gs.getMetadataXml()); |
|
|
|
tgmap.put("allocationtime", gs.getAllocationtime()); |
|
|
|
tgmap.put("cancellation_reason", gs.getCancellationReason()); |
|
|
|
} |
|
|
|
tgmap.put("source",tmpgs); |
|
|
|
tgmap.put("source", tmpgs); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tgmap.put("cancellationtime",g.getCancelTime()); |
|
|
|
tgmap.put("cancellationtime", g.getCancelTime()); |
|
|
|
|
|
|
|
tgmap.put("sale_count",g.getSaleCount()); |
|
|
|
tgmap.put("click_count",g.getClickCount()); |
|
|
|
tgmap.put("stock",gd.getStock()); |
|
|
|
tgmap.put("goods_image",gd.getGoodsImage()); |
|
|
|
tgmap.put("sale_count", g.getSaleCount()); |
|
|
|
tgmap.put("click_count", g.getClickCount()); |
|
|
|
tgmap.put("stock", gd.getStock()); |
|
|
|
tgmap.put("goods_image", gd.getGoodsImage()); |
|
|
|
|
|
|
|
retlist.add(tgmap); |
|
|
|
} |
|
|
|
@ -614,21 +614,21 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public int changeGoodsStatus(int status, int gid) { |
|
|
|
Map gmap =new HashMap(); |
|
|
|
gmap.put("goods_status",status); |
|
|
|
return goodsMapper.updateGoods(gmap,gid); |
|
|
|
Map gmap = new HashMap(); |
|
|
|
gmap.put("goods_status", status); |
|
|
|
return goodsMapper.updateGoods(gmap, gid); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Map<String, Object> addShopCar(String userIsli, String goodsIsli, Integer userYears) { |
|
|
|
Map<String,Object> retmap =new HashMap<>(); |
|
|
|
Map<String, Object> retmap = new HashMap<>(); |
|
|
|
User user = userMapper.getUserByIsli(userIsli); |
|
|
|
// get current goods
|
|
|
|
Goods goods = goodsMapper.getGoodsFuelByIsLi(goodsIsli); |
|
|
|
if(goods==null){ |
|
|
|
retmap.put("code",400); |
|
|
|
retmap.put("msg","没有该标的"); |
|
|
|
}else { |
|
|
|
if (goods == null) { |
|
|
|
retmap.put("code", 400); |
|
|
|
retmap.put("msg", "没有该标的"); |
|
|
|
} else { |
|
|
|
if (goods.getGoodsStatus() != 1) { |
|
|
|
retmap.put("code", 400); |
|
|
|
retmap.put("msg", "该标的现不在上架中"); |
|
|
|
@ -644,165 +644,183 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
} |
|
|
|
//
|
|
|
|
Map ordmap = new HashMap(); |
|
|
|
ordmap.put("o.buy_islicode",userIsli); |
|
|
|
ordmap.put("od.goods_islicode",goodsIsli); |
|
|
|
ordmap.put("od.is_deleted",0); |
|
|
|
ordmap.put("ostatus_not",5); |
|
|
|
OrderDetailVo orderDetailVo= orderMapper.getOrderDetailVOByMap(ordmap); |
|
|
|
if(orderDetailVo!=null){ |
|
|
|
retmap.put("code",400); |
|
|
|
retmap.put("msg","该标的已有订单,添加购物车失败"); |
|
|
|
ordmap.put("o.buy_islicode", userIsli); |
|
|
|
ordmap.put("od.goods_islicode", goodsIsli); |
|
|
|
ordmap.put("od.is_deleted", 0); |
|
|
|
ordmap.put("ostatus_not", 5); |
|
|
|
OrderDetailVo orderDetailVo = orderMapper.getOrderDetailVOByMap(ordmap); |
|
|
|
if (orderDetailVo != null) { |
|
|
|
retmap.put("code", 400); |
|
|
|
retmap.put("msg", "该标的已有订单,添加购物车失败"); |
|
|
|
} |
|
|
|
// goods detail
|
|
|
|
GoodsDetail goodsDetail = goodsDetailMapper.getGoodsDetailBygid(goods.getGoodsDetailId()); |
|
|
|
if(goodsDetail.getStock()<=0 && goodsDetail.getGoodsEntrust() ==1){ |
|
|
|
retmap.put("code",400); |
|
|
|
retmap.put("msg","该标的已有订单,添加购物车失败"); |
|
|
|
if (goodsDetail.getStock() <= 0 && goodsDetail.getGoodsEntrust() == 1) { |
|
|
|
retmap.put("code", 400); |
|
|
|
retmap.put("msg", "该标的已有订单,添加购物车失败"); |
|
|
|
} |
|
|
|
Date now=new Date(); |
|
|
|
if(goodsDetail.getContractualPeriod()==3){ |
|
|
|
if(goods.getContractualStartTime().compareTo(now)>0 |
|
|
|
|| goods.getContractualtimeEndTime().compareTo(now)<0 |
|
|
|
){ |
|
|
|
retmap.put("code",400); |
|
|
|
retmap.put("msg","标的委托已结束"); |
|
|
|
Date now = new Date(); |
|
|
|
if (goodsDetail.getContractualPeriod() == 3) { |
|
|
|
if (goods.getContractualStartTime().compareTo(now) > 0 |
|
|
|
|| goods.getContractualtimeEndTime().compareTo(now) < 0 |
|
|
|
) { |
|
|
|
retmap.put("code", 400); |
|
|
|
retmap.put("msg", "标的委托已结束"); |
|
|
|
} |
|
|
|
} |
|
|
|
//shop car infomation
|
|
|
|
String shopRedisKey="car_"+userIsli; |
|
|
|
JSONObject carjson =new JSONObject(); |
|
|
|
String shopRedisKey = "car_" + userIsli; |
|
|
|
JSONObject carjson = new JSONObject(); |
|
|
|
// 购物车列表
|
|
|
|
List carList = new ArrayList(); |
|
|
|
// car item
|
|
|
|
Map cimap = new HashMap(); |
|
|
|
// {"user_isli":"ssss",data:["sss","sss","sss"]}
|
|
|
|
//object
|
|
|
|
Object shopCar = RedisUtil.get(shopRedisKey); |
|
|
|
if(shopCar!=null){ |
|
|
|
JSONArray jsonArray =carjson.getJSONArray("data"); |
|
|
|
// 检查goods_isli
|
|
|
|
List goodsIsliList =new ArrayList(); |
|
|
|
for(int x=0;x<jsonArray.size();x++){ |
|
|
|
JSONObject tmpjson =(JSONObject) jsonArray.get(x); |
|
|
|
String tgoodsisli = tmpjson.getString("goods_islid"); |
|
|
|
goodsIsliList.add(tgoodsisli); |
|
|
|
} |
|
|
|
//检查是否在列表中
|
|
|
|
if(goodsIsliList.contains(goodsIsli)){ |
|
|
|
retmap.put("code",400); |
|
|
|
retmap.put("msg","该标的已添加到购物车"); |
|
|
|
|
|
|
|
// 购物车中有记录的
|
|
|
|
if (shopCar != null) { |
|
|
|
JSONArray jsonArray = carjson.getJSONArray("data"); |
|
|
|
if (jsonArray == null) { //为空需要添新的元素
|
|
|
|
cimap.put("goods_isli", goodsIsli); |
|
|
|
cimap.put("use_years", userYears); |
|
|
|
carList.add(cimap); |
|
|
|
} else { |
|
|
|
//抽取出goods_isli
|
|
|
|
List cgilist = new ArrayList(); |
|
|
|
for (int x = 0; x < jsonArray.size(); x++) { |
|
|
|
JSONObject tmpjson = (JSONObject) jsonArray.get(x); |
|
|
|
cgilist.add(tmpjson.getString("goods_isli")); |
|
|
|
} |
|
|
|
// goods_isli has been exist in car?
|
|
|
|
if(cgilist.contains(goodsIsli)){ |
|
|
|
retmap.put("code", 400); |
|
|
|
retmap.put("msg", "该标的已添加到购物车"); |
|
|
|
}else { |
|
|
|
cimap.put("goods_isli", goodsIsli); |
|
|
|
cimap.put("use_years", userYears); |
|
|
|
carList.add(cimap); |
|
|
|
} |
|
|
|
} |
|
|
|
List tmpCarItem = new ArrayList(); |
|
|
|
Map tmpcar = new HashMap(); |
|
|
|
tmpcar.put("goods_isli",goodsIsli); |
|
|
|
tmpcar.put("use_years",userYears); |
|
|
|
tmpCarItem.add(tmpcar); |
|
|
|
carjson.put("data",tmpCarItem); |
|
|
|
RedisUtil.set(shopRedisKey,carjson.toJSONString()); |
|
|
|
}else{ |
|
|
|
Map tmpCar = new HashMap(); |
|
|
|
tmpCar.put("goods_islicode",goodsIsli); |
|
|
|
tmpCar.put("use_years",userYears); |
|
|
|
List carItem = new ArrayList(); |
|
|
|
carItem.add(tmpCar); |
|
|
|
carjson.put("data",carItem); |
|
|
|
|
|
|
|
RedisUtil.set(shopRedisKey,carjson.toJSONString()); |
|
|
|
// 添加到购物车json
|
|
|
|
carjson.put("user_isli",userIsli); |
|
|
|
carjson.put("data",carList); |
|
|
|
RedisUtil.set(shopRedisKey, carjson.toJSONString()); |
|
|
|
} else { |
|
|
|
//first biuld car item
|
|
|
|
cimap.put("user_isli",goodsIsli); |
|
|
|
cimap.put("use_years",userYears); |
|
|
|
// second add to carlist
|
|
|
|
carList.add(cimap); |
|
|
|
//third add new wraper
|
|
|
|
carjson.put("user_isli",userIsli); |
|
|
|
carjson.put("data",carList); |
|
|
|
RedisUtil.set(shopRedisKey, carjson.toJSONString()); |
|
|
|
} |
|
|
|
//购物车添加成功
|
|
|
|
retmap.put("code", 200); |
|
|
|
retmap.put("msg", "成功"); |
|
|
|
return retmap; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Map<String, Object> getShoppingCar(String userIsli) { |
|
|
|
Map<String,Object> retmap =new HashMap<>(); |
|
|
|
String shopRedisKey="car_"+userIsli; |
|
|
|
Object shopCar =RedisUtil.get(shopRedisKey); |
|
|
|
JSONObject shopCarJson =JSONObject.parseObject(shopCar.toString()); |
|
|
|
Map<String, Object> retmap = new HashMap<>(); |
|
|
|
String shopRedisKey = "car_" + userIsli; |
|
|
|
Object shopCar = RedisUtil.get(shopRedisKey); |
|
|
|
JSONObject shopCarJson = JSONObject.parseObject(shopCar.toString()); |
|
|
|
JSONArray jsonArray = shopCarJson.getJSONArray("data"); |
|
|
|
//JSONObject carjson =JSONObject.parseObject(shopCar.toString());
|
|
|
|
if(shopCar==null){ |
|
|
|
if (shopCar == null) { |
|
|
|
//null
|
|
|
|
return retmap; |
|
|
|
} |
|
|
|
//fenpei
|
|
|
|
Map acrmap = new HashMap(); |
|
|
|
acrmap.put("is_deleted",0); |
|
|
|
acrmap.put("status",1); |
|
|
|
List<AccountRatioSetting> acrlist = accountRatioSettingMapper.getRatioSettingList(acrmap,0,1); |
|
|
|
acrmap.put("is_deleted", 0); |
|
|
|
acrmap.put("status", 1); |
|
|
|
List<AccountRatioSetting> acrlist = accountRatioSettingMapper.getRatioSettingList(acrmap, 0, 1); |
|
|
|
AccountRatioSetting accountRatioSetting = acrlist.get(0); |
|
|
|
AccountRatioDetail accountRatioDetail =accountRatioDetailMapper.getAccRatioDetailByIdRole(accountRatioSetting.getId(),2); |
|
|
|
|
|
|
|
//goods information
|
|
|
|
for(int x=0;x<jsonArray.size();x++){ |
|
|
|
JSONObject jsonObject = jsonArray.getJSONObject(x); |
|
|
|
String goodsIsli= jsonObject.getString("goods_isli"); |
|
|
|
Goods goods = goodsMapper.getGoodsFuelByIsLi(goodsIsli); |
|
|
|
//
|
|
|
|
GoodsDetail goodsDetail = goodsDetailMapper.getGoodsDetailBygid(goods.getGoodsDetailId()); |
|
|
|
retmap.put("detial",goodsDetail); |
|
|
|
// 计算服务费
|
|
|
|
Integer count = jsonObject.getInteger("use_years"); |
|
|
|
if(goodsDetail.getGoodsEntrust()==1){ |
|
|
|
count=1; |
|
|
|
} |
|
|
|
BigDecimal serviceCharge=new BigDecimal(0); |
|
|
|
BigDecimal totalMoney =new BigDecimal(0); |
|
|
|
if(goodsDetail.getChargesType()==2){ |
|
|
|
if(accountRatioDetail.getCalculate()==1){ |
|
|
|
BigDecimal rate =accountRatioDetail.getRatio().divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP); |
|
|
|
serviceCharge = new BigDecimal(count).multiply(goodsDetail.getPrice()) |
|
|
|
.multiply(rate); |
|
|
|
}else{ |
|
|
|
serviceCharge = new BigDecimal(count).multiply(goodsDetail.getPrice()) |
|
|
|
.add(accountRatioDetail.getAmount()); |
|
|
|
AccountRatioDetail accountRatioDetail = accountRatioDetailMapper.getAccRatioDetailByIdRole(accountRatioSetting.getId(), 2); |
|
|
|
|
|
|
|
if (jsonArray.size() > 0) { |
|
|
|
//goods information
|
|
|
|
for (int x = 0; x < jsonArray.size(); x++) { |
|
|
|
JSONObject jsonObject = jsonArray.getJSONObject(x); |
|
|
|
String goodsIsli = jsonObject.getString("goods_isli"); |
|
|
|
Goods goods = goodsMapper.getGoodsFuelByIsLi(goodsIsli); |
|
|
|
//
|
|
|
|
GoodsDetail goodsDetail = goodsDetailMapper.getGoodsDetailBygid(goods.getGoodsDetailId()); |
|
|
|
retmap.put("detial", goodsDetail); |
|
|
|
// 计算服务费
|
|
|
|
Integer count = jsonObject.getInteger("use_years"); |
|
|
|
if (goodsDetail.getGoodsEntrust() == 1) { |
|
|
|
count = 1; |
|
|
|
} |
|
|
|
totalMoney = new BigDecimal(count).multiply(goodsDetail.getPrice()) |
|
|
|
.add(serviceCharge) |
|
|
|
.add(goodsDetail.getEarnestMoney()); |
|
|
|
} |
|
|
|
BigDecimal goodsPrice = new BigDecimal(count).multiply(goodsDetail.getPrice()).setScale(2); |
|
|
|
retmap.put("service_charge",serviceCharge); |
|
|
|
retmap.put("total_money",totalMoney); |
|
|
|
retmap.put("goods_price",goodsPrice); |
|
|
|
//
|
|
|
|
if(goodsDetail.getGoodsEntrust()==1 || (goodsDetail.getChargesType()==1 && goodsDetail.getGoodsEntrust()==2)){ |
|
|
|
retmap.put("transaction_count","-"); |
|
|
|
}else{ |
|
|
|
retmap.put("transaction_count",count); |
|
|
|
BigDecimal serviceCharge = new BigDecimal(0); |
|
|
|
BigDecimal totalMoney = new BigDecimal(0); |
|
|
|
if (goodsDetail.getChargesType() == 2) { |
|
|
|
if (accountRatioDetail.getCalculate() == 1) { |
|
|
|
BigDecimal rate = accountRatioDetail.getRatio().divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP); |
|
|
|
serviceCharge = new BigDecimal(count).multiply(goodsDetail.getPrice()) |
|
|
|
.multiply(rate); |
|
|
|
} else { |
|
|
|
serviceCharge = new BigDecimal(count).multiply(goodsDetail.getPrice()) |
|
|
|
.add(accountRatioDetail.getAmount()); |
|
|
|
} |
|
|
|
totalMoney = new BigDecimal(count).multiply(goodsDetail.getPrice()) |
|
|
|
.add(serviceCharge) |
|
|
|
.add(goodsDetail.getEarnestMoney()); |
|
|
|
} |
|
|
|
BigDecimal goodsPrice = new BigDecimal(count).multiply(goodsDetail.getPrice()).setScale(2); |
|
|
|
retmap.put("service_charge", serviceCharge); |
|
|
|
retmap.put("total_money", totalMoney); |
|
|
|
retmap.put("goods_price", goodsPrice); |
|
|
|
//
|
|
|
|
if (goodsDetail.getGoodsEntrust() == 1 || (goodsDetail.getChargesType() == 1 && goodsDetail.getGoodsEntrust() == 2)) { |
|
|
|
retmap.put("transaction_count", "-"); |
|
|
|
} else { |
|
|
|
retmap.put("transaction_count", count); |
|
|
|
} |
|
|
|
//GOODS SOURCE
|
|
|
|
List<GoodsSource> goodsSource = goodsSourceMapper.getGoodsSourceByIsli(goods.getGoodsIslicode()); |
|
|
|
retmap.put("source", goodsSource); |
|
|
|
//
|
|
|
|
JSONObject userjson = SzwhApiUtils.getApiUser(userIsli); |
|
|
|
Map umap = JSONObject.parseObject(userjson.getString("data")); |
|
|
|
retmap.put("user", umap); |
|
|
|
//
|
|
|
|
retmap.put("goods", goods); |
|
|
|
} |
|
|
|
//GOODS SOURCE
|
|
|
|
List<GoodsSource> goodsSource = goodsSourceMapper.getGoodsSourceByIsli(goods.getGoodsIslicode()); |
|
|
|
retmap.put("source",goodsSource); |
|
|
|
//
|
|
|
|
JSONObject userjson = SzwhApiUtils.getApiUser(userIsli); |
|
|
|
Map umap = JSONObject.parseObject(userjson.getString("data")); |
|
|
|
retmap.put("user",umap); |
|
|
|
//
|
|
|
|
retmap.put("goods",goods); |
|
|
|
} |
|
|
|
|
|
|
|
return retmap; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void delShoppingCar(String userIsli, String goodsIsli) { |
|
|
|
String shopRedisKey ="car_"+userIsli; |
|
|
|
Object shopCar =RedisUtil.get(shopRedisKey); |
|
|
|
if(shopCar!=null){ |
|
|
|
JSONObject shopCarJson =JSONObject.parseObject(shopCar.toString()); |
|
|
|
String shopRedisKey = "car_" + userIsli; |
|
|
|
Object shopCar = RedisUtil.get(shopRedisKey); |
|
|
|
if (shopCar != null) { |
|
|
|
JSONObject shopCarJson = JSONObject.parseObject(shopCar.toString()); |
|
|
|
JSONArray jsonArray = shopCarJson.getJSONArray("data"); |
|
|
|
//
|
|
|
|
JSONObject carjson = new JSONObject(); |
|
|
|
List carlist = new ArrayList(); |
|
|
|
//
|
|
|
|
if(jsonArray.size()>0){ |
|
|
|
for(int x=0;x<jsonArray.size();x++) { |
|
|
|
if (jsonArray.size() > 0) { |
|
|
|
for (int x = 0; x < jsonArray.size(); x++) { |
|
|
|
JSONObject tmpJson = (JSONObject) jsonArray.get(x); |
|
|
|
String tmpgoodsisli = tmpJson.getString("goods_isli"); |
|
|
|
// not equal save into list
|
|
|
|
if(!goodsIsli.equals(tmpgoodsisli)){ |
|
|
|
if (!goodsIsli.equals(tmpgoodsisli)) { |
|
|
|
carlist.add(jsonArray.get(x)); |
|
|
|
} |
|
|
|
} |
|
|
|
// save into new car
|
|
|
|
carjson.put("data",carlist); |
|
|
|
RedisUtil.set(shopRedisKey,carjson); |
|
|
|
} else{ |
|
|
|
carjson.put("data", carlist); |
|
|
|
RedisUtil.set(shopRedisKey, carjson); |
|
|
|
} else { |
|
|
|
RedisUtil.del(shopRedisKey); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -912,7 +930,7 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
cend = "2099-12-31"; |
|
|
|
} |
|
|
|
// 加上时间
|
|
|
|
cend=cend+" 23:59:59"; |
|
|
|
cend = cend + " 23:59:59"; |
|
|
|
//委托开始时间,取当前时间
|
|
|
|
Timestamp ncst = new Timestamp(System.currentTimeMillis()); |
|
|
|
//委托结束时间 default value 2099-12-31 23:59:59
|
|
|
|
@ -937,7 +955,7 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
} |
|
|
|
// 周期性托管,判断开始时间是否结束
|
|
|
|
if (iperiod == 3) { |
|
|
|
try{ |
|
|
|
try { |
|
|
|
// 委托开始时间 匹配时间格式,防止转码出错
|
|
|
|
Date wtStart = sdf.parse(ncstart); |
|
|
|
// 委托开始时间戳
|
|
|
|
@ -948,8 +966,8 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
cend = ysdf.format(wtEnd) + " 23:59:59"; |
|
|
|
// 委托终止时间时间戳
|
|
|
|
ncet = new Timestamp(sdf.parse(cend).getTime()); |
|
|
|
}catch (Exception ex){ |
|
|
|
log.error("周期性委托日期转码错误:"+ex.getLocalizedMessage()); |
|
|
|
} catch (Exception ex) { |
|
|
|
log.error("周期性委托日期转码错误:" + ex.getLocalizedMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
//绑定商品属性
|
|
|
|
|