Authored by caoyan

订单管理

... ... @@ -54,11 +54,11 @@ public class BuyerOrderController {
@RequestMapping(value = "/updateOrderStatus")
public ApiResponse updateOrderStatus(BuyerOrderReq req) {
LOGGER.info("updateOrderStatus in. req is {}", req);
int result = buyerOrderService.updateOrderStatus(req);
if(result > 0) {
JSONObject result = buyerOrderService.updateOrderStatus(req);
if(result.getIntValue("code") == 200) {
return new ApiResponse.ApiResponseBuilder().code(200).message("更新成功").build();
}else {
return new ApiResponse.ApiResponseBuilder().code(500).message("更新失败").build();
return new ApiResponse.ApiResponseBuilder().code(500).message(result.getString("message")).build();
}
}
... ...
... ... @@ -21,7 +21,7 @@ public interface IBuyerOrderService {
PageResponseBO<BuyerOrderResp> queryOrderList(BuyerOrderReq req);
int updateOrderStatus(BuyerOrderReq req);
JSONObject updateOrderStatus(BuyerOrderReq req);
BuyerOrderResp getReceiveInfoByOrderCode(BuyerOrderReq req);
... ...
... ... @@ -225,66 +225,56 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
return result;
}
public int updateOrderStatus(BuyerOrderReq req) {
public JSONObject updateOrderStatus(BuyerOrderReq req) {
if(null == req.getId() || null == req.getStatus()) {
return 0;
return null;
}
BuyerOrder buyerOrder = buyerOrderMapper.selectById(req.getId());
if(null == buyerOrder) {
return 0;
return null;
}
//调用前台接口
String args = "";
int resultCode = 200;
JSONObject jsonObject = new JSONObject();
if(req.getStatus().byteValue() == Constant.BUYER_ORDER_STATUS_TO_BE_RECEIVED.getByteVal()) {//鉴定通过
args = "orderAppraise.appraiseSuccess";
resultCode = asyncCallAppraise(args, buyerOrder.getOrderCode(), req);
jsonObject = asyncCallAppraise(args, buyerOrder.getOrderCode(), req);
}else if(req.getStatus().byteValue() == Constant.BUYER_ORDER_STATUS_JUDGE_NOT_PASS.getByteVal()) {//鉴定不通过
args = "orderAppraise.appraiseFail";
resultCode = asyncCallAppraise(args, buyerOrder.getOrderCode(), req);
jsonObject = asyncCallAppraise(args, buyerOrder.getOrderCode(), req);
}else if(req.getStatus().byteValue() == Constant.BUYER_ORDER_STATUS_JUDGING.getByteVal()) {//确认收货
args = "ufo-gateway.confirmReceive";
resultCode = asyncCallConfirmReceive(args, buyerOrder.getOrderCode());
jsonObject = asyncCallConfirmReceive(args, buyerOrder.getOrderCode());
}
if(resultCode != 200) {
return 0;
if(resultCode == 200) {
buyerOrderMapper.updateStatusById(req.getId(), req.getStatus());
}
return buyerOrderMapper.updateStatusById(req.getId(), req.getStatus());
return jsonObject;
}
private int asyncCallConfirmReceive(String args, String orderCode) {
private JSONObject asyncCallConfirmReceive(String args, String orderCode) {
OrderRequest request = new OrderRequest();
request.setOrderCode(Long.valueOf(orderCode));
JSONObject jsonObject = serviceCaller.asyncCall(args, request, JSONObject.class).get(5);
LOGGER.info("call ufo-gateway interface is {},result is {}", args, jsonObject.toJSONString());
return jsonObject.getIntValue("code");
return jsonObject;
}
private int asyncCallAppraise(String args, String orderCode, BuyerOrderReq req) {
private JSONObject asyncCallAppraise(String args, String orderCode, BuyerOrderReq req) {
AppraiseExpressInfoBo bo = new AppraiseExpressInfoBo();
bo.setOrderCode(Long.valueOf(orderCode));
bo.setExpressCompanyId(req.getExpressCompanyId());
bo.setWayBillCode(req.getWaybillCode());
bo.setDepotNum(req.getDepotNo());
JSONObject jsonObject = null;
LOGGER.info("appraise orderCode is {},startTime is {}", orderCode, DateUtil.getCurrentTimeSecond());
try {
jsonObject = serviceCaller.asyncCall(args, bo, JSONObject.class).get(5);
} catch (Exception e) {
LOGGER.error("appraise fail!!! orderCode is {}, error is {}", orderCode,e.getMessage());
}finally {
LOGGER.info("appraise orderCode is {}, endTime is {}", orderCode, DateUtil.getCurrentTimeSecond());
}
JSONObject jsonObject = serviceCaller.asyncCall(args, bo, JSONObject.class).get(5);
LOGGER.info("call ufo-gateway interface is {},result is {}", args, jsonObject.toJSONString());
if(null == jsonObject) {
return 0;
}
LOGGER.info("call ufo-gateway interface is {}, result is {}", args, jsonObject.toJSONString());
return jsonObject.getIntValue("code");
return jsonObject;
}
public BuyerOrderResp getReceiveInfoByOrderCode(BuyerOrderReq req) {
... ...
... ... @@ -592,7 +592,7 @@ function deliverGoods(id){
msg : "鉴定通过操作成功!"
});
}else {
window.self.$.messager.alert("失败", "失败!", "error");
window.self.$.messager.alert("失败", data.message, "error");
}
});
... ... @@ -626,7 +626,7 @@ function sendBackGoods(id){
msg : "鉴定不通过操作成功!"
});
}else {
window.self.$.messager.alert("失败", "失败!", "error");
window.self.$.messager.alert("失败", data.message, "error");
}
});
... ...