Thdj.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. class Thdj extends Lyapi_Controller{
  4. private $show_url = "https://lyerposs.wepolicy.cn";
  5. // 注意:登录接口不能受基础控制器的登录校验,可以覆盖构造方法或单独处理
  6. public function __construct() {
  7. // 这里不执行登录校验,只加载缓存驱动
  8. parent::__construct(); // 暂时注释,或者使用一个新的不校验的基类
  9. // 简便做法:复制 Lyapi_Controller 的部分代码但不调用 _check_api_auth
  10. // $this->load->driver('cache'); // 加载缓存驱动
  11. $this->load->_model("Model_logic_order","logic_order");
  12. $this->load->_model("Model_returns","returns");
  13. $this->load->_model("Model_aliyunossnew","aliyunossnew");
  14. }
  15. public function searchwaybill(){
  16. if($this->input->method(TRUE) != 'POST'){
  17. $this->_json_error('请求方式错误','500');
  18. }
  19. $json_str = $this->input->raw_input_stream;
  20. $data = json_decode($json_str,true);
  21. $waybill = $data['waybill'];
  22. if(empty($waybill)){
  23. $this->_json_error('快递单号不能为空','500');
  24. }
  25. $waybill = $this->logic_order->getNeedWaybill($waybill);
  26. $info = $this->returns->find("torderinfo = '$waybill'");
  27. if(empty($info)){
  28. $this->_json_error('未查询到此快递单号'.$waybill,'500');
  29. }
  30. $res = $this->aliyunossnew->getOssSignType("shdjfile");
  31. if($res['code'] == -1){
  32. $this->_json_error($res["msg"],'500');
  33. }else{
  34. $this->_json_error('成功',200,[
  35. 'torderinfo'=>$info['torderinfo'],
  36. 'number'=>$info['number'],
  37. 'oss_config'=>$res['data']
  38. ]);
  39. }
  40. $this->_json_error($info,'200');
  41. }
  42. public function thdjwjbc(){
  43. if($this->input->method(TRUE) != 'POST'){
  44. $this->_json_error('请求方式错误','500');
  45. }
  46. $json_str = $this->input->raw_input_stream;
  47. $data = json_decode($json_str,true);
  48. $img = isset($data['img']) ? $data['img'] : '';
  49. $torderinfo = isset($data['torderinfo']) ? $data['torderinfo'] : '';
  50. $number = isset($data['number']) ? $data['number'] : '';
  51. if(empty($img)){
  52. $this->_json_error('图片不能为空','500');
  53. }
  54. if(empty($torderinfo)){
  55. $this->_json_error('快递单号不能为空','500');
  56. }
  57. if(empty($number)){
  58. $this->_json_error('订单号不能为空','500');
  59. }
  60. $info = $this->returns->find("torderinfo = '$torderinfo' and number = '$number'");
  61. if(empty($info)){
  62. $this->_json_error('未查询此快递相关的退货登记信息'.$torderinfo,'500');
  63. }
  64. $img_str = implode('|', $img);
  65. $r = $this->returns->save([
  66. 'img'=>$img_str,
  67. ],$info['id']);
  68. if($r){
  69. $this->_json_error('保存成功',200);
  70. }else{
  71. $this->_json_error('保存失败',500);
  72. }
  73. }
  74. }