|
|
@@ -174,7 +174,16 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
|
|
|
@Override
|
|
|
public Map<String, String> placeGzhOrder(OrderAddBo bo) {
|
|
|
- return null;
|
|
|
+ List<OrderGoodsAddBo> goodsList = bo.getGoodsList();
|
|
|
+ if(goodsList.size()<1){
|
|
|
+ throw new CustomException("商品列表为空");
|
|
|
+ }
|
|
|
+ Order add = BeanUtil.toBean(bo, Order.class);
|
|
|
+ validEntityBeforeSave(add);
|
|
|
+ add.setCreateTime(DateUtils.getNowTime());
|
|
|
+ add.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ Map<String, String> result = dealOrder(add,goodsList,bo.getCouponId(),bo.getActivityId());
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -201,7 +210,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
return this.removeByIds(ids);
|
|
|
}
|
|
|
|
|
|
- private Map<String, String> dealOrder(Order add,List<OrderGoodsAddBo> goodsList,Long couponId,Long activity){
|
|
|
+ public Map<String, String> dealOrder(Order add,List<OrderGoodsAddBo> goodsList,Long couponId,Long activity){
|
|
|
UserVo userVo = iUserService.queryById(add.getUserId());
|
|
|
String body = "中正云课堂消费";
|
|
|
String price = "1";
|
|
|
@@ -318,6 +327,34 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ public Map<String, String> dealGzhOrder(Order add,List<OrderGoodsAddBo> goodsList,Long couponId,Long activity){
|
|
|
+ UserVo userVo = iUserService.queryById(add.getUserId());
|
|
|
+ String body = "中正云课堂充值";
|
|
|
+ String price = "1";
|
|
|
+ String out_trade_no = DateUtils.getDateOrderSn();
|
|
|
+ add.setOderSn(out_trade_no);
|
|
|
+ add.setPayType(1); //微信支付
|
|
|
+ add.setOrderStatus(0);
|
|
|
+ BigDecimal totalPrice = new BigDecimal(0);
|
|
|
+ for (OrderGoodsAddBo g : goodsList) {
|
|
|
+ g.setOrderSn(out_trade_no);
|
|
|
+ if(g.getNum()<1){
|
|
|
+ throw new CustomException("商品数量错误");
|
|
|
+ }
|
|
|
+ g.setGoodsType(4);//充值余额类型
|
|
|
+ totalPrice = totalPrice.add(g.getGoodsPrice());
|
|
|
+ }
|
|
|
+ BigDecimal zero = new BigDecimal("0.01");
|
|
|
+ if(totalPrice.compareTo(zero) < 0){
|
|
|
+ //价格不能小于0.01
|
|
|
+ totalPrice = zero;
|
|
|
+ }
|
|
|
+ add.setOrderPrice(totalPrice);
|
|
|
+ if(!this.save(add)){
|
|
|
+ throw new CustomException("订单数据错误");
|
|
|
+ }
|
|
|
+ Map<String, String> result = iWxPayService.payment(out_trade_no,userVo.getGzhOpenId(),body,price);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
}
|