feat(商城): 订单模块

添加用户订单各状态查询
master
wayn 4 years ago
parent 84d0a4ac8a
commit ae01f50b73

@ -26,6 +26,12 @@ public class OrderController extends BaseController {
return iOrderService.selectListPage(page, showType);
}
@PostMapping("statusCount")
public R statusCount() {
return iOrderService.statusCount();
}
@PostMapping("submit")
public R submit(@RequestBody OrderVO orderVO) {
return iOrderService.submit(orderVO);

@ -64,4 +64,10 @@ public interface IOrderService extends IService<Order> {
* @return r
*/
R payNotify(HttpServletRequest request, HttpServletResponse response);
/**
*
* @return r
*/
R statusCount();
}

@ -130,6 +130,36 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
return R.success().add("data", orderVoList).add("pages", orderIPage.getPages()).add("page", orderIPage.getCurrent());
}
@Override
public R statusCount() {
R success = R.success();
Long userId = SecurityUtils.getUserId();
List<Order> orderList = list(new QueryWrapper<Order>().select("order_status", "comments").eq("user_id", userId));
int unpaid = 0;
int unship = 0;
int unrecv = 0;
int uncomment = 0;
for (Order order : orderList) {
if (OrderUtil.isCreateStatus(order)) {
unpaid++;
} else if (OrderUtil.isPayStatus(order)) {
unship++;
} else if (OrderUtil.isShipStatus(order)) {
unrecv++;
} else if (OrderUtil.isConfirmStatus(order) || OrderUtil.isAutoConfirmStatus(order)) {
uncomment += order.getComments();
} else {
// todo
}
}
success.add("unpaid", unpaid);
success.add("unship", unship);
success.add("unrecv", unrecv);
success.add("uncomment", uncomment);
return success;
}
@Override
@Transactional(rollbackFor = Exception.class)
public R submit(OrderVO orderVO) {
@ -158,28 +188,28 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
}
// 商品费用
BigDecimal checkedGoodsPrice = new BigDecimal(0.00);
BigDecimal checkedGoodsPrice = new BigDecimal("0.00");
for (Cart checkGoods : checkedGoodsList) {
checkedGoodsPrice = checkedGoodsPrice.add(checkGoods.getPrice().multiply(new BigDecimal(checkGoods.getNumber())));
}
// 根据订单商品总价计算运费满足条件例如88元则免运费否则需要支付运费例如8元
BigDecimal freightPrice = new BigDecimal(0.00);
BigDecimal freightPrice = new BigDecimal("0.00");
/*if (checkedGoodsPrice.compareTo(SystemConfig.getFreightLimit()) < 0) {
freightPrice = SystemConfig.getFreight();
}*/
// 可以使用的其他钱,例如用户积分
BigDecimal integralPrice = new BigDecimal(0.00);
BigDecimal integralPrice = new BigDecimal("0.00");
// 优惠卷抵扣费用
BigDecimal couponPrice = new BigDecimal(0.00);
BigDecimal couponPrice = new BigDecimal("0.00");
// 团购抵扣费用
BigDecimal grouponPrice = new BigDecimal(0.00);
BigDecimal grouponPrice = new BigDecimal("0.00");
// 订单费用
BigDecimal orderTotalPrice = checkedGoodsPrice.add(freightPrice).subtract(couponPrice).max(new BigDecimal(0.00));
BigDecimal orderTotalPrice = checkedGoodsPrice.add(freightPrice).subtract(couponPrice).max(new BigDecimal("0.00"));
// 最终支付费用
BigDecimal actualPrice = orderTotalPrice.subtract(integralPrice);
@ -394,5 +424,4 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
return R.error(WxPayNotifyResponse.success("处理成功!"));
}
}

Loading…
Cancel
Save