//判断该笔订单是否在商户网站中已经做过处理(可参考“集成教程”中“3.4返回数据处理”)
//如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
//如果有做过处理,不执行商户的业务程序
logger.debug("return WAIT_SELLER_SEND_GOODS[orderID:"+order_no+"]");
if(order_no==null)order_no="-1";
Orders o = orderService.queryOrderById(Long.parseLong(order_no.trim()));
if(null!=o){
if(o.getStatus()<Orders.STATUS_PAID){
logger.debug("return WAIT_SELLER_SEND_GOODS[update orderID:"+order_no+"]");
User user = userCardService.findUserById(o.getUser().getId() );
double balance = user.getCard().getScore();
o.setStatus(Orders.STATUS_PAID);
o.setPaytime(new Date());
orderService.updateOrder(o);
user.getCard().setScore(balance-o.getScore());
userCardService.updateUser(user);
}
}
}
if(trade_status.equals("TRADE_FINISHED")){
//判断该笔订单是否在商户网站中已经做过处理(可参考“集成教程”中“3.4返回数据处理”)
//如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
//如果有做过处理,不执行商户的业务程序
if(order_no==null)order_no="-1";
Orders o = orderService.queryOrderById(Long.parseLong(order_no.trim()));
logger.debug("return TRADE_FINISHED[orderID:"+order_no+"]");
if(null!=o){
if(o.getStatus()<Orders.STATUS_CONFIRM){
logger.debug("return TRADE_FINISHED[update orderID:"+order_no+"]");
o.setStatus(Orders.STATUS_CONFIRM);
orderService.updateOrder(o);
}
}
}