Yyys.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. //用友YS的执行
  4. class Yyys extends Lyapi_Controller{
  5. // 注意:登录接口不能受基础控制器的登录校验,可以覆盖构造方法或单独处理
  6. public function __construct() {
  7. // 这里不执行登录校验,只加载缓存驱动
  8. parent::__construct(); // 暂时注释,或者使用一个新的不校验的基类
  9. $this->load->_model("Model_ysrecords","ysrecords");
  10. }
  11. public function lyysmsghz() {
  12. $ip = $this->input->ip_address();
  13. $json_str = $this->input->raw_input_stream;
  14. $data = json_decode($json_str,true);
  15. $jiami_str = hash_hmac('sha256', 'LYERP_'.$data['timestamp'], 'ys&ly202608261549');
  16. //$jiami_str.="&";
  17. // if($gsmc != $jiami_str){
  18. // echo "ERROR!-".$jiami_str;
  19. // }
  20. $ys_no = "";
  21. if(!empty($data['content'])){
  22. //调拨单审核
  23. if($data['type'] == "st_transferapply_bill_audit"){
  24. if(!empty($data['content']['code'])){
  25. $ys_no = $data['content']['code'];
  26. }
  27. }elseif($data['type'] == "SALE_AUDITORDER_NOTIFY_SENT"){
  28. //销售单
  29. if(!empty($data['content']['BILL_INFO'])){
  30. if(!empty($data['content']['BILL_INFO']['billCode'])){
  31. $ys_no = $data['content']['BILL_INFO']['billCode'];
  32. }
  33. }
  34. }else{
  35. }
  36. }
  37. if(empty($data['gsmc'])){
  38. $this->db->insert("ysnorecords",[
  39. 'ys_no'=>"",
  40. 'recept_cont'=>$json_str,
  41. 'addtime'=>time(),
  42. ]);
  43. echo "SUCCESS";
  44. exit;
  45. }
  46. if($jiami_str != $data['gsmc']){
  47. $this->db->insert("ysnorecords",[
  48. 'ys_no'=>$ys_no,
  49. 'recept_cont'=>$json_str,
  50. 'addtime'=>time(),
  51. ]);
  52. }else{
  53. $time = time();
  54. $info = $this->ysrecords->find("ys_no = '{$ys_no}'");
  55. if(empty($info)){
  56. $this->db->insert("ysnorecords",[
  57. 'ys_no'=>$ys_no,
  58. 'recept_cont'=>$json_str,
  59. 'addtime'=>time(),
  60. ]);
  61. echo "ERROR";
  62. exit;
  63. }
  64. //调拨订单审核
  65. if($data['type'] == 'st_transferapply_bill_audit'){
  66. $this->ysrecords->save(
  67. [
  68. 'recept_cont'=>$json_str,
  69. 'recepttime'=>$time,
  70. 'status'=>0,
  71. 'dotime'=>0
  72. ],$info['id']);
  73. }
  74. //调拨订单弃审
  75. if($data['type'] == 'SALE_AUDITORDER_NOTIFY_SENT'){
  76. $this->ysrecords->save(
  77. [
  78. 'recept_cont'=>$json_str,
  79. 'unaudit_time'=>$time,
  80. 'status'=>0,
  81. 'dotime'=>0
  82. ],$info['id']);
  83. }
  84. echo "SUCCESS";
  85. exit;
  86. }
  87. }
  88. }