|
|
|
@ -81,6 +81,7 @@ public class OrderServiceImpl implements OrderService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 组合查询订单信息 |
|
|
|
* |
|
|
|
* @param qumap |
|
|
|
* @param page |
|
|
|
* @param limit |
|
|
|
@ -244,6 +245,7 @@ public class OrderServiceImpl implements OrderService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 订单详情,方法2 |
|
|
|
* |
|
|
|
* @param batchcode |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ -344,6 +346,7 @@ public class OrderServiceImpl implements OrderService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 订单信息细化 |
|
|
|
* |
|
|
|
* @param bathcode |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ -480,6 +483,7 @@ public class OrderServiceImpl implements OrderService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 关闭时间为当前 |
|
|
|
* |
|
|
|
* @param batchcode |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ -516,6 +520,7 @@ public class OrderServiceImpl implements OrderService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 统计所有订单总数 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@ -531,6 +536,7 @@ public class OrderServiceImpl implements OrderService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 查找购买流程,并返回订单编号 |
|
|
|
* |
|
|
|
* @param userIsli |
|
|
|
* @param goodsIsli |
|
|
|
* @param userYears |
|
|
|
@ -625,17 +631,18 @@ public class OrderServiceImpl implements OrderService { |
|
|
|
if (orderUser != null) { |
|
|
|
userId = orderUser.getId(); |
|
|
|
} else { |
|
|
|
// 获取远程用户信息
|
|
|
|
JSONObject userjson = SzwhApiUtils.getApiUser(userIsli); |
|
|
|
if(StringUtils.isBlank(userjson.getString("data"))){ |
|
|
|
Map adumap = addOrderUserByBatchacode(batchCode,userIsli); |
|
|
|
if(adumap!=null){ |
|
|
|
String errmsg = (String)adumap.get("error"); |
|
|
|
if(StringUtils.isNotEmpty(errmsg)){ |
|
|
|
log.error("未查询到用户信息,下单失败" + userIsli); |
|
|
|
bretMap.put("error","未查询到用户信息,下单失败"); |
|
|
|
return bretMap; |
|
|
|
bretMap.put("msg",errmsg); |
|
|
|
} |
|
|
|
String oduid =(String)adumap.get("oduid"); |
|
|
|
if(StringUtils.isNotEmpty(oduid)){ |
|
|
|
userId = Integer.valueOf(oduid); |
|
|
|
} |
|
|
|
} |
|
|
|
//添加用户
|
|
|
|
OrderUser odu =SzOrderUtils.mkOrderUser(batchCode,userjson,0); |
|
|
|
orderUserMapper.addOrderUser(odu); |
|
|
|
userId = odu.getId(); |
|
|
|
} |
|
|
|
|
|
|
|
// 订单实体
|
|
|
|
@ -705,6 +712,7 @@ public class OrderServiceImpl implements OrderService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 输出条件查询订单 |
|
|
|
* |
|
|
|
* @param qmap |
|
|
|
* @param page |
|
|
|
* @param limit |
|
|
|
@ -789,6 +797,7 @@ public class OrderServiceImpl implements OrderService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 创建订单实现方法 |
|
|
|
* |
|
|
|
* @param userIsli |
|
|
|
* @param goodsJsonArray post过来的json参数 |
|
|
|
* @return |
|
|
|
@ -802,6 +811,7 @@ public class OrderServiceImpl implements OrderService { |
|
|
|
retmap.put("msg", "用户不存在"); |
|
|
|
return retmap; |
|
|
|
} |
|
|
|
Map bmap = new HashMap();// 执行返回map
|
|
|
|
// 该用户的购物车
|
|
|
|
String rkey = "car_" + userIsli; |
|
|
|
String batchcode = "";//订单编号,一次一个
|
|
|
|
@ -811,7 +821,7 @@ public class OrderServiceImpl implements OrderService { |
|
|
|
//todo check it has null
|
|
|
|
Integer ituseYear = Integer.valueOf(tuseYear); |
|
|
|
String goodsIsli = tmpgjson.getString("goods_isli"); |
|
|
|
Map bmap = buyFindGoods(userIsli,goodsIsli,ituseYear); |
|
|
|
bmap = buyFindGoods(userIsli, goodsIsli, ituseYear); |
|
|
|
//检查是否有错误信息
|
|
|
|
String berrmsg = (String) bmap.get("error"); |
|
|
|
if (StringUtils.isNotEmpty(berrmsg)) { |
|
|
|
@ -820,23 +830,37 @@ public class OrderServiceImpl implements OrderService { |
|
|
|
return retmap; |
|
|
|
} |
|
|
|
//返回订单编号
|
|
|
|
batchcode = (String)bmap.get("batcha"); |
|
|
|
if(StringUtils.isNotEmpty(batchcode)){ |
|
|
|
// 从购物车中删除该goodsisli
|
|
|
|
SzOrderUtils.delOdGoodsIsliFromCar(rkey,goodsIsli); |
|
|
|
batchcode = (String) bmap.get("batchcode"); |
|
|
|
|
|
|
|
// 检查购物车中是否有该商品,有则删除
|
|
|
|
Map ucar = SzCarUtils.getCar(rkey); |
|
|
|
if (ucar.get(goodsIsli) != null) { |
|
|
|
SzCarUtils.delCart(userIsli, goodsIsli); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 多个商品同时结算
|
|
|
|
// 应用场景:购物车中勾选多个产品进行结算
|
|
|
|
//$batchcode = $this->buyCarGoods($user_isli, $goods);
|
|
|
|
bmap = buyCarGoods(userIsli, goodsJsonArray); |
|
|
|
} |
|
|
|
//1、订单号一个 2、用户一个 3、订单商品(一)多个 4、操作购物车
|
|
|
|
// export order map
|
|
|
|
// order basic \order goods |order user
|
|
|
|
retmap = getOrderMapByBatch(batchcode,userIsli); |
|
|
|
// 检查是否有执行过程中的错误
|
|
|
|
String errmsg = (String) bmap.get("error"); |
|
|
|
if (StringUtils.isNotEmpty(errmsg)) { |
|
|
|
retmap.put("msg", errmsg); |
|
|
|
retmap.put("rdata", ""); |
|
|
|
} else { |
|
|
|
retmap.put("msg", "成功"); |
|
|
|
retmap.put("rdata", getOrderMapByBatch(batchcode, userIsli)); |
|
|
|
} |
|
|
|
return retmap; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据订单号列举出所有相关 |
|
|
|
* |
|
|
|
* @param batchcode 订单号 |
|
|
|
* @param userIsli 用户编号 |
|
|
|
* @return |
|
|
|
@ -858,8 +882,65 @@ public class OrderServiceImpl implements OrderService { |
|
|
|
return otmap; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 购物车订单商品结算 |
|
|
|
* |
|
|
|
* @param userIsli |
|
|
|
* @param gJsonArray |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public Map<String, Object> buyCarGoods(String userIsli, JSONArray gJsonArray) { |
|
|
|
Map outmap = new HashMap(); |
|
|
|
//服务费 订单中费用
|
|
|
|
BigDecimal serviceCharge = new BigDecimal("0.00"); |
|
|
|
BigDecimal totalMoney = new BigDecimal("0.00"); |
|
|
|
//
|
|
|
|
String batchacode = SzOrderUtils.createOrderBatchcode(); |
|
|
|
// ratio setting
|
|
|
|
AccountRatioSetting accountRatioSetting = accountRatioSettingMapper.getUsingAccRatioSetting(); |
|
|
|
AccountRatioDetail accountRatioDetail = accountRatioDetailMapper.getAccRatioDetailByIdRole(accountRatioSetting.getId(), 2); |
|
|
|
//add order user
|
|
|
|
Map odumap = addOrderUserByBatchacode(batchacode,userIsli); |
|
|
|
Integer buyUid=0; |
|
|
|
if(odumap!=null){ |
|
|
|
String oduid= (String)odumap.get("oduid"); |
|
|
|
if(StringUtils.isNotEmpty(oduid)){ |
|
|
|
buyUid =Integer.valueOf(oduid); |
|
|
|
} |
|
|
|
} |
|
|
|
// get username
|
|
|
|
String buyUserName = orderUserMapper.getOrderUserById(buyUid).getName(); |
|
|
|
// 检查购物车中是否有该商品,有则删除
|
|
|
|
String rkey = "car_" + userIsli; |
|
|
|
Map ucar = SzCarUtils.getCar(rkey); |
|
|
|
|
|
|
|
for(int i=0;i<gJsonArray.size();i++){ |
|
|
|
JSONObject tgjson = gJsonArray.getJSONObject(i); |
|
|
|
String gisli = tgjson.getString("goods_isli"); |
|
|
|
// 是否在购物车里面
|
|
|
|
if (ucar.get(gisli) != null) { |
|
|
|
Goods goods = goodsMapper.getGoodsFuelByIsLi(gisli); |
|
|
|
if(goods==null){ |
|
|
|
log.error(gisli+",标的不存在"); |
|
|
|
outmap.put("error","标的不存在"); |
|
|
|
return outmap; |
|
|
|
} |
|
|
|
GoodsDetail goodsDetail = goodsDetailMapper.getGoodsDetailBygid(goods.getGoodsDetailId()); |
|
|
|
//校验订单信息合法
|
|
|
|
SzOrderUtils.checkOrder(goods, goodsDetail, userIsli); |
|
|
|
// 检查商品库存等
|
|
|
|
//todo
|
|
|
|
// 完成下单后,从购物车移除
|
|
|
|
SzCarUtils.delCart(userIsli, gisli); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return outmap; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 结算 |
|
|
|
* |
|
|
|
* @param order |
|
|
|
* @param orderGoodsDetailList |
|
|
|
* @return |
|
|
|
@ -936,4 +1017,29 @@ public class OrderServiceImpl implements OrderService { |
|
|
|
rtlist.add(ptmap); |
|
|
|
return rtlist; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 插入订单用户表 |
|
|
|
* |
|
|
|
* @param batchCode 订单号 |
|
|
|
* @param userIsli 用户号 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private Map<String, Object> addOrderUserByBatchacode(String batchCode, String userIsli) { |
|
|
|
Map rmap = new HashMap(); |
|
|
|
int userId = 0; |
|
|
|
// 获取远程用户信息
|
|
|
|
JSONObject userjson = SzwhApiUtils.getApiUser(userIsli); |
|
|
|
if (StringUtils.isBlank(userjson.getString("data"))) { |
|
|
|
rmap.put("error", "未查询到用户信息,下单失败"); |
|
|
|
return rmap; |
|
|
|
} |
|
|
|
//添加用户
|
|
|
|
OrderUser odu = SzOrderUtils.mkOrderUser(batchCode, userjson, 1); |
|
|
|
orderUserMapper.addOrderUser(odu); |
|
|
|
userId = odu.getId(); |
|
|
|
|
|
|
|
rmap.put("oduid", userId); |
|
|
|
return rmap; |
|
|
|
} |
|
|
|
} |
|
|
|
|