Search in sources :

Example 6 with Position

use of com.guhanjie.model.Position in project weixin-boot by guhanjie.

the class TestPositionMapper method testSelectByGeo.

@Test
public void testSelectByGeo() {
    String lat = "31.186951";
    String lng = "121.570592";
    Position model = mapper.selectByGeo(lng, lat);
    logger.debug(JSON.toJSONString(model));
    assertNotNull(model);
}
Also used : Position(com.guhanjie.model.Position) Test(org.junit.Test)

Example 7 with Position

use of com.guhanjie.model.Position in project weixin-boot by guhanjie.

the class TestPositionMapper method testGeneratedKey.

@Test
public void testGeneratedKey() {
    logger.debug("Create one record to table[{}]...\n", tableName);
    Position model = new Position();
    model.setAddress("莲泰苑-东南门");
    model.setDetail("4号602室");
    model.setFloor((short) 6);
    model.setGeoLat("31.186951");
    model.setGeoLng("121.570592");
    long insertCount = mapper.insertSelective(model);
    logger.debug(JSON.toJSONString(model));
    assertEquals(insertCount, 1L);
}
Also used : Position(com.guhanjie.model.Position) Test(org.junit.Test)

Example 8 with Position

use of com.guhanjie.model.Position 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);
    }
}
Also used : Order(com.guhanjie.model.Order) Position(com.guhanjie.model.Position)

Aggregations

Position (com.guhanjie.model.Position)8 Date (java.util.Date)3 Test (org.junit.Test)3 Order (com.guhanjie.model.Order)2 User (com.guhanjie.model.User)2 UserService (com.guhanjie.service.UserService)1 BigDecimal (java.math.BigDecimal)1 SimpleDateFormat (java.text.SimpleDateFormat)1