use of com.guhanjie.model.Order in project weixin-boot by guhanjie.
the class OrderService method updateOrderByPay.
/**
* Method Name: updateOrderByPay<br/>
* Description: [更新订单的支付状态]
* @author GUHANJIE
* @time 2016年10月17日 上午10:30:55
* @param success
* @param orderid
* @param total_fee
* @param time_end
*/
public void updateOrderByPay(boolean success, Integer orderid, String total_fee, String time_end) {
LOGGER.info("Updating order[{}] pay info: sucess=[{}], total_fee=[{}], time_end=[{}]...", orderid, success, total_fee, time_end);
if (orderid == null || total_fee == null || time_end == null) {
LOGGER.warn("error in updating order pay, as pay info not complete: order_id=[{}], total_fee=[{}], time_end=[{}].", orderid, total_fee, time_end);
return;
}
Order order = getOrderById(orderid);
if (order == null) {
LOGGER.warn("order[{}] not exists", orderid);
return;
}
// 一旦订单状态到达“支付成功”,就不再进行后续处理
short oldOrderStatus = order.getStatus();
short oldPayStatus = order.getPayStatus();
if (oldPayStatus == PayStatusEnum.SUCCESS.code()) {
LOGGER.info("order[{}] pay has succeed, no more to handler.", orderid);
return;
}
if (success) {
LOGGER.info("Order[{}] pay complete successfully!!!", orderid);
order.setStatus(OrderStatusEnum.PAYED.code());
order.setPayStatus(PayStatusEnum.SUCCESS.code());
order.setPayType(PayTypeEnum.WEIXIN.code());
order.setPayTime(DateTimeUtil.getDate(time_end, "yyyyMMddHHmmss"));
if (order.getAmount().intValue() != Integer.valueOf(total_fee) / 100) {
LOGGER.warn("Pay amount not matched: topay=[{}], actual payed=[{}]", order.getAmount(), total_fee);
// order.setPayStatus(PayStatusEnum.PAYERROR.code());
}
}
// 更新订单支付状态
LOGGER.info("===updating order[{}] status:[{}]-->[{}], pay status:[{}]-->[{}].", orderid, oldOrderStatus, order.getStatus(), oldPayStatus, order.getPayStatus());
if (1 == orderMapper.updateByPayStatus(order, oldOrderStatus, oldPayStatus)) {
LOGGER.info("Success to update order[{}] pay! status:[{}]-->[{}], pay status:[{}]-->[{}].", orderid, oldOrderStatus, order.getStatus(), oldPayStatus, order.getPayStatus());
// 支付成功,发送微信消息通知客服
StringBuffer sb = new StringBuffer("主人,您有一笔订单已完成支付:\n");
sb.append("订单标识:").append(orderid).append("\n");
sb.append("支付金额:").append(Integer.valueOf(total_fee) / 100).append("元\n");
sb.append("支付时间:").append(DateTimeUtil.formatDate(order.getPayTime())).append("\n");
sb.append("客户名称:").append(order.getContactor()).append("\n");
Position from = positionMapper.selectByPrimaryKey(order.getFromId());
sb.append("起始地:").append(from.getAddress()).append("\n");
Position to = positionMapper.selectByPrimaryKey(order.getToId());
sb.append("目的地:").append(to.getAddress()).append("\n");
sb.append("服务时间:").append(DateTimeUtil.formatDate(order.getStartTime())).append("\n");
MessageKit.sendKFMsg(weixinConstants.KF_OPENIDS, sb.toString());
} else {
LOGGER.warn("Failed to update order[{}] pay, maybe already been updated before", orderid);
}
}
use of com.guhanjie.model.Order in project weixin-boot by guhanjie.
the class OrderService method listOrders.
public PageImpl<Order> listOrders(Date beginTime, Date endTime, Pageable pageable) {
// 查询条件
Map<String, Object> param = new HashMap<String, Object>();
if (beginTime != null) {
param.put("beginTime", beginTime);
}
if (endTime != null) {
param.put("endTime", endTime);
}
param.put("offset", pageable.getOffset());
param.put("pagesize", pageable.getPageSize());
int total = orderMapper.countSelective(param);
List<Order> list = orderMapper.selectByQualifiedPage(param);
if (list != null) {
for (Order order : list) {
if (StringUtils.isNotBlank(order.getWaypointsIds())) {
setWayPoints(order);
}
}
}
PageImpl<Order> page = new PageImpl<Order>(list, pageable, total);
return page;
}
Aggregations