|
|
|
@ -528,13 +528,21 @@ public class OrderServiceImpl implements OrderService { |
|
|
|
return orderMapper.addOrder(order); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查找购买流程,并返回订单编号 |
|
|
|
* @param userIsli |
|
|
|
* @param goodsIsli |
|
|
|
* @param userYears |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public String buyFindGoods(String userIsli, String goodsIsli, int userYears) { |
|
|
|
public Map<String,String> buyFindGoods(String userIsli, String goodsIsli, int userYears) { |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
Map<String,String> bretMap = new HashMap<>();// 返回的结果
|
|
|
|
Goods goods = goodsMapper.getGoodsByIsli(goodsIsli); |
|
|
|
if(goods==null){ |
|
|
|
log.error("create order error!"+goodsIsli+""); |
|
|
|
return null; |
|
|
|
log.error("create order error!"+goodsIsli+",不存在"); |
|
|
|
bretMap.put("error","没有该标的"); |
|
|
|
} |
|
|
|
// goods detail
|
|
|
|
GoodsDetail goodsDetail = goodsDetailMapper.getGoodsDetailBygid(goods.getGoodsDetailId()); |
|
|
|
@ -554,11 +562,11 @@ public class OrderServiceImpl implements OrderService { |
|
|
|
// 检查订单支付情况
|
|
|
|
if(orderDetailVo!=null) { |
|
|
|
if (orderDetailVo.getStatus() == 1) { |
|
|
|
throw new ChException("您的待付款订单中有标的:" + goods.getGoodsIslicode() + ",请勿重复下单", 400); |
|
|
|
bretMap.put("error","您的待付款订单中有标的:" + goods.getGoodsIslicode() + ",请勿重复下单"); |
|
|
|
} else if (orderDetailVo.getStatus() == 2) { |
|
|
|
throw new ChException("您的未完成订单中有标的:" + goods.getGoodsIslicode() + ",请勿重复下单", 400); |
|
|
|
bretMap.put("error","您的未完成订单中有标的:" + goods.getGoodsIslicode() + ",请勿重复下单"); |
|
|
|
} else { |
|
|
|
throw new ChException("您的已完成订单中有标的:" + goods.getGoodsIslicode() + ",请勿重复下单", 400); |
|
|
|
bretMap.put("error","您的已完成订单中有标的:" + goods.getGoodsIslicode() + ",请勿重复下单"); |
|
|
|
} |
|
|
|
} |
|
|
|
// 判断当前订单是否存在问题
|
|
|
|
@ -590,8 +598,8 @@ public class OrderServiceImpl implements OrderService { |
|
|
|
payStatus=1; |
|
|
|
}else{ |
|
|
|
// 免费
|
|
|
|
serviceCharge =new BigDecimal(0.00); |
|
|
|
totalMoney = new BigDecimal(0.00); |
|
|
|
serviceCharge =new BigDecimal("0.00"); |
|
|
|
totalMoney = new BigDecimal("0.00"); |
|
|
|
status=2; |
|
|
|
payStatus=2; //已支付
|
|
|
|
} |
|
|
|
@ -615,9 +623,8 @@ public class OrderServiceImpl implements OrderService { |
|
|
|
// 获取远程用户信息
|
|
|
|
JSONObject userjson = SzwhApiUtils.getApiUser(userIsli); |
|
|
|
if(StringUtils.isBlank(userjson.getString("data"))){ |
|
|
|
log.error("未查询到用户信息,下单失败"); |
|
|
|
return null; |
|
|
|
//throw new ChException("未查询到用户信息,下单失败",400);
|
|
|
|
log.error("未查询到用户信息,下单失败"+userIsli); |
|
|
|
bretMap.put("error","未查询到用户信息,下单失败"); |
|
|
|
} |
|
|
|
//添加用户
|
|
|
|
OrderUser odu =SzOrderUtils.mkOrderUser(batchCode,userjson,0); |
|
|
|
@ -663,15 +670,16 @@ public class OrderServiceImpl implements OrderService { |
|
|
|
if(gdret==1){ |
|
|
|
String status_Str=""; |
|
|
|
// 更新goods 状态
|
|
|
|
Map gmap = new HashMap(); |
|
|
|
gmap.put("goods_status", status); |
|
|
|
Map gstmap = new HashMap(); |
|
|
|
int gsstatus=2; |
|
|
|
if(goodsDetail.getGoodsEntrust() ==1){ |
|
|
|
goodsMapper..changeGoodsStatus(5,goods.getId()); |
|
|
|
gsstatus=5; |
|
|
|
status_Str="暂停"; |
|
|
|
}else { |
|
|
|
goodsService.changeGoodsStatus(2,goods.getId()); |
|
|
|
status_Str="下架"; |
|
|
|
} |
|
|
|
gstmap.put("goods_status", gsstatus); |
|
|
|
goodsMapper.updateGoods(gstmap,goods.getId()); |
|
|
|
//更新订单用户状态信息
|
|
|
|
String buyUserName = orderUser.getName(); |
|
|
|
OperationLog oplog =new OperationLog(); |
|
|
|
@ -679,13 +687,14 @@ public class OrderServiceImpl implements OrderService { |
|
|
|
oplog.setLogid(goods.getId()); |
|
|
|
oplog.setMessage(sdf.format(new Date())+"用户"+buyUserName+"下单,"+status_Str+"该委托标的"); |
|
|
|
operationLogMapper.addLog(oplog); |
|
|
|
return batchCode; |
|
|
|
bretMap.put("batchcode",batchCode); |
|
|
|
}else{ |
|
|
|
throw new ChException("标的已卖完",400); |
|
|
|
log.error(goodsIsli+"标的已卖完"); |
|
|
|
bretMap.put("error","标的已卖完"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return batchCode; |
|
|
|
return bretMap; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -786,14 +795,32 @@ public class OrderServiceImpl implements OrderService { |
|
|
|
retmap.put("code","error"); |
|
|
|
retmap.put("msg","用户不存在"); |
|
|
|
} |
|
|
|
if(jsonArray.size()==1){ |
|
|
|
// 该用户的购物车
|
|
|
|
String rkey="car_"+userIsli; |
|
|
|
if(jsonArray.size()==1){ // 下单商品只有一个
|
|
|
|
JSONObject tmpgjson = jsonArray.getJSONObject(0); |
|
|
|
String batchcode = buyFindGoods(userIsli,tmpgjson.getString("goods_islid")) |
|
|
|
String tuseYear = tmpgjson.getString("use_year"); |
|
|
|
//todo check it has null
|
|
|
|
Integer ituseYear = Integer.valueOf(tuseYear); |
|
|
|
String goodsIsli = tmpgjson.getString("goods_isli"); |
|
|
|
Map bmap = buyFindGoods(userIsli,goodsIsli,ituseYear); |
|
|
|
//检查是否有错误信息
|
|
|
|
String berrmsg = (String)bmap.get("error"); |
|
|
|
if(StringUtils.isNotEmpty(berrmsg)){ |
|
|
|
retmap.put("code",400); |
|
|
|
retmap.put("msg",berrmsg); |
|
|
|
} |
|
|
|
//返回订单编号
|
|
|
|
String batchcode = (String)bmap.get("batcha"); |
|
|
|
if(StringUtils.isNotEmpty(batchcode)){ |
|
|
|
// 从购物车中删除该goodsisli
|
|
|
|
SzOrderUtils.delOdGoodsIsliFromCar(rkey,goodsIsli); |
|
|
|
} |
|
|
|
String ureidsKey="car_"+userIsli; |
|
|
|
//查询购物车
|
|
|
|
Object shopCar = RedisUtil.get(ureidsKey); |
|
|
|
return null; |
|
|
|
}else{ |
|
|
|
//
|
|
|
|
} |
|
|
|
|
|
|
|
return retmap; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|