package com.iamberry.wechat.handles.logistics;

import com.iamberry.wechat.core.entity.ResultMsg;
import com.iamberry.wechat.tools.NameUtils;
import com.iamberry.wechat.tools.ResultInfo;
import com.iamberry.wechat.utils.KuaiDi100;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;

/**
 * Created by Administrator on 2017/12/26.
 */
@Controller
@RequestMapping("/logistics")
public class LogisticsHandler {

    @Autowired
    private KuaiDi100 kuaidi100;

    /**
     * 查询快递信息
     * @param com 快递公司代码
     * @param nu 快递单号
     * @return
     */
    @RequestMapping("/getExpressInfo")
    @ResponseBody
    public ResultMsg getExpressInfo(@RequestParam("com") String com, @RequestParam("nu") String nu, HttpServletResponse response){
        ResultMsg msg = new ResultMsg();
        JSONObject rst = null;
        if (com == null || com.equals("") || nu == null || nu.equals("")){
            msg.setResultCode(ResultInfo.ERRORCODE);
            msg.setMessage(NameUtils.getConfig("ERROR"));
            msg.setData(rst);
            msg.setStatus(false);
            return msg;
        }
        rst = kuaidi100.getExpressInfo(com,nu);
        msg.setResultCode(ResultInfo.SUCCESSCODE);
        msg.setMessage(NameUtils.getConfig("SUCCESSINFO"));
        msg.setData(rst);
        msg.setStatus(true);
        return msg;
    }

    /**
     * 手动向特定手机发送短信
     * @param response
     * @param iphone
     * @return
     */
    /*@RequestMapping("/informShipping")
    @ResponseBody
    public String informShipping(HttpServletResponse response,@RequestParam("iphone") String iphone){
        String msg = codeService.informShipping(iphone,INFORM_SHIPPING);
        return msg;
    }*/
}
