Thdj.php 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. $this->load->_model("Model_logic_ding","logic_ding");
  15. }
  16. public function searchwaybill(){
  17. if($this->input->method(TRUE) != 'POST'){
  18. $this->_json_error('请求方式错误','500');
  19. }
  20. $json_str = $this->input->raw_input_stream;
  21. $data = json_decode($json_str,true);
  22. $waybill = $data['waybill'];
  23. if(empty($waybill)){
  24. $this->_json_error('快递单号不能为空','500');
  25. }
  26. $waybill = $this->logic_order->getNeedWaybill($waybill);
  27. $info = $this->returns->find("torderinfo = '$waybill'");
  28. if(empty($info)){
  29. $this->_json_error('未查询到此快递单号'.$waybill,'500');
  30. }
  31. $res = $this->aliyunossnew->getOssSignType("shdjfile");
  32. if($res['code'] == -1){
  33. $this->_json_error($res["msg"],'500');
  34. }else{
  35. $this->_json_error('成功',200,[
  36. 'torderinfo'=>$info['torderinfo'],
  37. 'number'=>$info['number'],
  38. 'oss_config'=>$res['data']
  39. ]);
  40. }
  41. $this->_json_error($info,'200');
  42. }
  43. public function thdjwjbc(){
  44. if($this->input->method(TRUE) != 'POST'){
  45. $this->_json_error('请求方式错误','500');
  46. }
  47. $json_str = $this->input->raw_input_stream;
  48. $this->logic_ding->sendToDing(date("Y-m-d")."退货登记传图数据记录".$json_str);
  49. $data = json_decode($json_str,true);
  50. $img = isset($data['img']) ? $data['img'] : '';
  51. $torderinfo = isset($data['torderinfo']) ? $data['torderinfo'] : '';
  52. $number = isset($data['number']) ? $data['number'] : '';
  53. if(empty($img)){
  54. $this->_json_error('图片不能为空','500');
  55. }
  56. if(empty($torderinfo)){
  57. $this->_json_error('快递单号不能为空','500');
  58. }
  59. if(empty($number)){
  60. $this->_json_error('订单号不能为空','500');
  61. }
  62. $info = $this->returns->find("torderinfo = '$torderinfo' and number = '$number'");
  63. if(empty($info)){
  64. $this->_json_error('未查询此快递相关的退货登记信息'.$torderinfo,'500');
  65. }
  66. $img_list = [];
  67. foreach($img as $k=>$v){
  68. if(is_string($v)){
  69. $img_str = str_replace($this->show_url, '', $v);
  70. }else{
  71. $img_str = str_replace($this->show_url, '', $v['url']);
  72. }
  73. $img_list[] = $img_str;
  74. }
  75. $img_str = implode('|', $img_list);
  76. $r = $this->returns->save([
  77. 'img'=>$img_str,
  78. 'edittime'=>time()
  79. ],$info['id']);
  80. if($r){
  81. $this->_json_error('保存成功',200);
  82. }else{
  83. $this->_json_error('保存失败',500);
  84. }
  85. }
  86. }