|
@@ -60,10 +60,15 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public ResponseJson<Map<String, Object>> orderConfirm(String productIds, Integer userId) {
|
|
|
+ public ResponseJson<Map<String, Object>> orderConfirm(String productIds, Integer organizeId, Integer storeId) {
|
|
|
Map<String, Object> confirmData = new HashMap<>(5);
|
|
|
- if (userId != null) {
|
|
|
+ if (organizeId != null) {
|
|
|
log.info("<<<<< 结算订单 >>>>>");
|
|
|
+ //获取组织对应的用户
|
|
|
+ Integer userId = userMapper.getUserIdByOrganizeId(organizeId);
|
|
|
+ if (null == userId) {
|
|
|
+ return ResponseJson.error("用户不存在", null);
|
|
|
+ }
|
|
|
//商品总金额
|
|
|
AtomicReference<BigDecimal> totalPrice = new AtomicReference<>(BigDecimal.ZERO);
|
|
|
//促销满减
|
|
@@ -75,7 +80,7 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
|
|
|
shopList.forEach(shop -> {
|
|
|
shopIds.add(shop.getShopId());
|
|
|
//购物车购买
|
|
|
- List<CartProductVo> products = orderSubmitMapper.findProductListByCart(shop.getShopId(), productId, userId);
|
|
|
+ List<CartProductVo> products = orderSubmitMapper.findProductListByCart(shop.getShopId(), productId, storeId);
|
|
|
BigDecimal fullReduction = BigDecimal.ZERO;
|
|
|
BigDecimal shopTotalPrice = BigDecimal.ZERO;
|
|
|
for (CartProductVo product : products) {
|
|
@@ -115,6 +120,9 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
|
|
|
confirmData.put("shopList", shopList);
|
|
|
// 发票信息
|
|
|
CmUserInvoiceInfoPo invoice = orderSubmitMapper.findUserInvoice(userId);
|
|
|
+ // 可用余额
|
|
|
+ BigDecimal availableMoney = orderSubmitMapper.findAbleUserMoney(userId);
|
|
|
+ confirmData.put("userMoney", availableMoney);
|
|
|
confirmData.put("invoice", invoice);
|
|
|
return ResponseJson.success(confirmData);
|
|
|
} else {
|
|
@@ -124,13 +132,18 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public ResponseJson<Map<String, String>> orderSubmit(Integer clubUserId, Integer addressId, List<Map<String, Object>> orderInfo, Map<String, Object> payInfo, Map<String, Object> orderInvoice) {
|
|
|
+ public ResponseJson<Map<String, String>> orderSubmit(Integer organizeId, Integer storeId, Integer addressId, List<Map<String, Object>> orderInfo, Map<String, Object> payInfo, Map<String, Object> orderInvoice) {
|
|
|
/*
|
|
|
* 逻辑处理 start
|
|
|
*/
|
|
|
log.info("******************** 提交订单逻辑处理 start *******************");
|
|
|
+ //获取组织对应的用户id
|
|
|
+ Integer userId = userMapper.getUserIdByOrganizeId(organizeId);
|
|
|
+ if (null == userId) {
|
|
|
+ return ResponseJson.error("用户不存在", null);
|
|
|
+ }
|
|
|
//机构用户
|
|
|
- UserPo user = orderSubmitMapper.findUser(clubUserId);
|
|
|
+ UserPo user = orderSubmitMapper.findUser(userId);
|
|
|
if (null == user) {
|
|
|
return ResponseJson.error("用户信息异常", null);
|
|
|
}
|
|
@@ -141,7 +154,7 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
|
|
|
if (1 == balancePayFlag && null != ableUserMoney) {
|
|
|
// 使用余额
|
|
|
if (MathUtil.compare(ableUserMoney, BigDecimal.ZERO) == 0) {
|
|
|
- return ResponseJson.error("用户可用余额为0",null);
|
|
|
+ return ResponseJson.error("用户可用余额为0", null);
|
|
|
}
|
|
|
}
|
|
|
// 商品总数量
|
|
@@ -204,6 +217,8 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
|
|
|
order.setUserID(user.getUserID().longValue());
|
|
|
// 机构ID
|
|
|
order.setClubID(user.getClubID().longValue());
|
|
|
+ // 门店Id
|
|
|
+ order.setOrganizeStoreId(storeId);
|
|
|
// 订单来源
|
|
|
order.setOrderSource("6");
|
|
|
order.setOrganizeID(user.getUserOrganizeID());
|
|
@@ -353,7 +368,7 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
|
|
|
// 加入订单商品列表
|
|
|
orderProductList.add(orderProduct);
|
|
|
|
|
|
- shoppingCartMapper.deleteCartByProductId(user.getUserID(), product.getId());
|
|
|
+ shoppingCartMapper.deleteCartByProductId(storeId, product.getId());
|
|
|
log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>删除用户购物车数据productId:" + product.getId());
|
|
|
|
|
|
}
|
|
@@ -1244,4 +1259,42 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
|
|
|
payOrderMapper.insertOrderRelation(relation);
|
|
|
log.info(">>>>>>>>>>>>>>>>>>>>>>>保存余额到收款记录," + balancePayFee);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseJson<Map<String,Object>> paymentValidation(Integer orderId) {
|
|
|
+ Map<String, Object> map = new HashMap<>(3);
|
|
|
+ map.put("orderId", orderId);
|
|
|
+ OrderVo order = orderMapper.findOrder(orderId);
|
|
|
+ Integer count = orderSubmitMapper.findRefundNum(orderId);
|
|
|
+ if (count != null && count > 0) {
|
|
|
+ map.put("code", -1);
|
|
|
+ map.put("msg", "订单已申请全部退款,无需再付款!");
|
|
|
+ return ResponseJson.success(map);
|
|
|
+ }
|
|
|
+ orderService.getDiscernReceipt(order);
|
|
|
+ map.put("pendingPayments", order.getPendingPayments());
|
|
|
+ map.put("onlinePayFlag", order.getOnlinePayFlag());
|
|
|
+ List<OrderProductVo> orderProductList = orderMapper.findAllOrderProduct(orderId);
|
|
|
+ for (OrderProductVo orderProduct : orderProductList) {
|
|
|
+ //是否包含充值商品
|
|
|
+ boolean rechargeGoods = OrderNoUtils.getRechargeProduct(orderProduct.getProductId());
|
|
|
+ if (rechargeGoods) {
|
|
|
+ return ResponseJson.success(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ UserPo user = orderSubmitMapper.findUser(order.getUserId().intValue());
|
|
|
+ if (MathUtil.compare(user.getAbleUserMoney(), 0) > 0) {
|
|
|
+ if (MathUtil.compare(user.getAbleUserMoney(), order.getPendingPayments()) < 0) {
|
|
|
+ map.put("code", 1);
|
|
|
+ map.put("msg", "余额不为0且小于待付金额");
|
|
|
+ map.put("ableUserMoney", user.getAbleUserMoney());
|
|
|
+ map.put("pendingPayments", MathUtil.sub(order.getPendingPayments(), user.getAbleUserMoney()));
|
|
|
+ } else {
|
|
|
+ map.put("code", 2);
|
|
|
+ map.put("msg", "余额大于或等于待付金额");
|
|
|
+ map.put("ableUserMoney", user.getAbleUserMoney());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResponseJson.success(map);
|
|
|
+ }
|
|
|
}
|