Outwarehouse.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. class Outwarehouse extends Lyapi_Controller{
  4. // 注意:登录接口不能受基础控制器的登录校验,可以覆盖构造方法或单独处理
  5. public function __construct() {
  6. // 这里不执行登录校验,只加载缓存驱动
  7. parent::__construct(); // 暂时注释,或者使用一个新的不校验的基类
  8. // 简便做法:复制 Lyapi_Controller 的部分代码但不调用 _check_api_auth
  9. // $this->load->driver('cache'); // 加载缓存驱动
  10. $this->load->_model("Model_logic_order","logic_order");
  11. }
  12. public function ckct() {
  13. $this->_json_error("获取成功",200,[]);
  14. }
  15. public function savescan(){
  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. if(empty($data['number'])){
  22. $this->_json_error('参数错误','500');
  23. }
  24. $imglist = $data['imglist'];
  25. if(empty($imglist)){
  26. $this->_json_error('未上传出库图片','500');
  27. }
  28. $orderinfo = $this->logic_order->getInfo("number = '".$data['number']."'");
  29. if(empty($orderinfo)){
  30. $this->_json_error('订单不存在','500');
  31. }
  32. if($orderinfo['waybill'] != $data['waybill']){
  33. $this->_json_error('运单号和数据库存储不一致','500');
  34. }
  35. $query = $this->db->get_where('scanimgs', ['number' => $data['number']]);
  36. if($query->num_rows() > 0){
  37. }else{
  38. $time = time();
  39. $img_list = [
  40. [
  41. "imgurl"=>[],
  42. "addtime"=>$time
  43. ]
  44. ];
  45. $this->db->from('scanimgs')->insert(
  46. [
  47. 'number' => $orderinfo['number'],
  48. 'shop'=>$orderinfo['shop'],
  49. 'plat'=>$orderinfo['lv_platform'],
  50. 'addtime'=>$time,
  51. "imgs"=>json_encode($img_list),
  52. 'updatetime'=>$time,
  53. ]
  54. );
  55. }
  56. }
  57. }