TestController.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Service\qyWechatService;
  4. use App\Service\TestService;
  5. use Illuminate\Http\Request;
  6. use Illuminate\Support\Str;
  7. class TestController extends BaseController
  8. {
  9. public function testdwy(Request $request){
  10. list($bool, $data) = (new TestService())->testdwy($request->all());
  11. if($bool){
  12. return $this->json_return(200,'',$data);
  13. }else{
  14. return $this->json_return(201,$data);
  15. }
  16. }
  17. public function testdwyget(Request $request){
  18. list($bool, $data) = (new TestService())->testdwyget($request->all());
  19. if($bool){
  20. return $this->json_return(200,'',$data);
  21. }else{
  22. return $this->json_return(201,$data);
  23. }
  24. }
  25. public function testdwyput(Request $request){
  26. list($bool, $data) = (new TestService())->testdwyput($request->all());
  27. if($bool){
  28. return $this->json_return(200,'',$data);
  29. }else{
  30. return $this->json_return(201,$data);
  31. }
  32. }
  33. public function test(){
  34. dd(env("maycur_appcode"),env("maycur_appsercet"),getenv("maycur_appcode"),getenv("maycur_appsercet"));
  35. }
  36. public function salesOrderGet(Request $request){
  37. $common_array = $request->common_param;
  38. list($bool, $data) = (new TestService())->salesOrderGet($request->all(),$common_array);
  39. if($bool){
  40. return $this->json_return(200,'',$data);
  41. }else{
  42. return $this->json_return(201,$data);
  43. }
  44. }
  45. public function materialAddU8(Request $request){
  46. $common_array = $request->common_param;
  47. list($bool, $data) = (new TestService())->materialAddU8($request->all(), $common_array);
  48. if($bool){
  49. return $this->json_return(200,'',$data);
  50. }else{
  51. return $this->json_return(201,$data);
  52. }
  53. }
  54. public function productInAddU8(Request $request){
  55. $common_array = $request->common_param;
  56. list($bool, $data) = (new TestService())->ProductInAddU8($request->all(), $common_array);
  57. if($bool){
  58. return $this->json_return(200,'',$data);
  59. }else{
  60. return $this->json_return(201,$data);
  61. }
  62. }
  63. public function dispatchAddU8(Request $request){
  64. $common_array = $request->common_param;
  65. list($bool, $data) = (new TestService())->DispatchAddU8($request->all(), $common_array);
  66. if($bool){
  67. return $this->json_return(200,'',$data);
  68. }else{
  69. return $this->json_return(201,$data);
  70. }
  71. }
  72. public function recordList(Request $request){
  73. list($bool, $data) = (new TestService())->recordList($request->all());
  74. if($bool){
  75. return $this->json_return(200,'',$data);
  76. }else{
  77. return $this->json_return(201,$data);
  78. }
  79. }
  80. // 仓库档案 http://localhost:8060/api/WareHouse/Get ?CodeorName=0501 为空返回所有数据
  81. // 部门档案 http://localhost:8060/api/Department/Get ?CodeorName=0501 为空返回所有数据
  82. // 人员档案 http://localhost:8060/api/Person/Get ?CodeorName=00043&bPsnPerson=1(是否业务员) 为空返回所有数据
  83. // 客户分类 http://localhost:8060/api/Customer/GetCustomerClass ?cCCCode=01 为空返回所有数据
  84. // 客户档案 http://localhost:8060/api/Customer/GetCustomerClass ?cCCCode=01 为空返回所有数据
  85. // 存货分类 http://localhost:8060/api/Inventory/GetInventoryClass ?CodeorName=0101 为空返回所有
  86. // 存货档案 http://localhost:8060/api/System/SqlQuery
  87. //{
  88. // "customSQLFileName": "U8SQL",
  89. // "customSQLPath": "U8API/Inventory/Get",
  90. // "paramObj": {
  91. // "@pagesize": 25,
  92. // "@codeorname": "0301",
  93. // "@where": "AND cInvCode = 'BB01' AND cInvName like '%交换机%'",
  94. // "@version": "7098847"
  95. // }
  96. //}
  97. // 计量单位 http://localhost:8060/api/Inventory/GetComputationUnit ?CodeorName=0502 为空返回所有数据
  98. public function getSignatures(Request $request)
  99. {
  100. $data = $request->all();
  101. $url = $data['url'];
  102. if(empty($url)) return $this->json_return(201, 'URL不能为空');
  103. $nonceStr = Str::random();
  104. $timestamp = time();
  105. // 1. 企业级签名 (wx.config)
  106. $wechat = new qyWechatService();
  107. list($status, $ticket) = $wechat->getJsApiTicket();
  108. if(! $status) {
  109. return $this->json_return(201, $ticket);
  110. }
  111. $configSignature = $wechat->makeSignature($ticket, $nonceStr, $timestamp, $url);
  112. // 2. 应用级签名 (wx.agentConfig)
  113. list($status, $agentTicket) = $wechat->getAgentTicket();
  114. if(! $status) {
  115. return $this->json_return(201, $agentTicket);
  116. }
  117. $agentSignature = $wechat->makeSignature($agentTicket, $nonceStr, $timestamp, $url);
  118. $return = [
  119. 'corpid' => $wechat->corpId,
  120. 'agentid' => $wechat->agentId,
  121. 'timestamp' => $timestamp,
  122. 'nonceStr' => $nonceStr,
  123. 'configSignature' => $configSignature,
  124. 'agentSignature' => $agentSignature,
  125. ];
  126. return $this->json_return(200,'',$return);
  127. }
  128. }