Qc.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\model\ChinaArea;
  4. use app\common\model\ForumReply;
  5. use app\common\model\GoodsOrder;
  6. use app\common\model\LevelOrder;
  7. use app\common\model\LevelOrder as LOM;
  8. use app\common\model\StoreGoods;
  9. use app\common\model\User;
  10. use think\cache\driver\Redis;
  11. use think\Db;
  12. class Qc extends Base {
  13. public function index()
  14. {
  15. var_dump(config('mini_program')['app_id'],config('mini_program')['secret']);
  16. }
  17. /**
  18. * @title 获取分享的签名
  19. * @desc 获取分享的签名
  20. * @url /api/qc/getWeChatSign
  21. * @method POST
  22. * @tag 基础
  23. *
  24. **/
  25. public function getWeChatSign(){
  26. $urls = input('url');
  27. $appid = config('app.official_account')['appid'];
  28. $secret = config('app.official_account')['secret'];
  29. $redis = new Redis();
  30. $access_token = $redis->get('access_token');
  31. if (!$access_token){
  32. $access_token = '';
  33. $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$secret";
  34. $res= http_curl($url);
  35. if (isset($res['access_token'])){
  36. $redis->set('access_token',$res['access_token'],'7000');
  37. $access_token = $res['access_token'];
  38. }
  39. }
  40. $url2 ="https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=".$access_token."&type=jsapi";
  41. $res2=http_curl($url2);
  42. if (!isset($res2) || $res2['errcode']!=0) $this->error('获取ticket失败');
  43. $timestamp = time();
  44. $noncestr = get32Str(15);
  45. $string = "jsapi_ticket=".$res2['ticket']."&noncestr=$noncestr&timestamp=$timestamp&url=".$urls;
  46. $sign = sha1($string);
  47. $return = [
  48. 'appid'=>$appid,
  49. 'noncestr'=>$noncestr,
  50. 'timestamp'=>$timestamp,
  51. 'url'=>$urls,
  52. 'sign'=>$sign,
  53. 'ticket'=>$res2['ticket']
  54. ];
  55. $this->success('成功',$return);
  56. }
  57. /**
  58. * 导入子项目数据
  59. * @auth true
  60. * @throws \think\Exception
  61. * @throws \think\exception\PDOException
  62. */
  63. public function import()
  64. {
  65. $get = $this->request->get();
  66. $import_path = $_SERVER['DOCUMENT_ROOT'].'/'.$get['path'];
  67. $project_id = $get['project_id'];
  68. $num = 5;
  69. try {
  70. $objReader =\PHPExcel_IOFactory::createReader('Excel2007');
  71. $objExcel = $objReader->load($import_path);
  72. $list = $objExcel->getActiveSheet()->toArray();
  73. if (!isset($list[2][15]) || !$list[2][15]){
  74. $this->error('失败');
  75. }
  76. if (isset($list[2][16])){
  77. $this->error('失败');
  78. }
  79. Db::name($this->table3)->where('project_id',$project_id)->delete();
  80. Db::name($this->table)->where('id',$project_id)->update(['url'=>$get['url']]);
  81. $result = 0;
  82. foreach ($list as $k=>$v){
  83. if($k>=$num-1){
  84. if(array_filter($v)){
  85. $data=[];
  86. foreach ($v as $kk=>$vv){
  87. $data[IntToChr($kk)]=trim($vv);
  88. }
  89. $date['project_id'] = $project_id;
  90. $date['number'] = $data['A'];
  91. $date['cost_project'] = $data['B'];
  92. $date['area_calculating_aperture'] = $data['C'];
  93. $date['single_party_cost'] = $data['D'];
  94. $date['single_party_cost1'] = str_replace(',','',$data['D']);
  95. $date['total_price_included'] = $data['E'];
  96. $date['total_price_included1'] = str_replace(',','',$data['E']);
  97. $date['single_party_cost_excluding'] = $data['F'];
  98. $date['single_party_cost_excluding1'] = str_replace(',','',$data['F']);
  99. $date['total_price_included_excluding'] = $data['G'];
  100. $date['total_price_included_excluding1'] = str_replace(',','',$data['G']);
  101. $date['single_party_cost_tax'] = $data['H'];
  102. $date['single_party_cost_tax1'] = str_replace(',','',$data['H']);
  103. $date['single_party_cost_no_tax'] = $data['I'];
  104. $date['single_party_cost_no_tax1'] = str_replace(',','',$data['I']);
  105. $date['quantities'] = $data['J'];
  106. $date['quantities1'] = str_replace(',','',$data['J']);
  107. $date['calculating_unit'] = $data['K'];
  108. $date['unilateral_content'] = $data['L'];
  109. $date['unilateral_content1'] = str_replace(',','',$data['L']);
  110. $date['unilateral_content_excluding'] = $data['M'];
  111. $date['unilateral_content_excluding1'] = str_replace(',','',$data['M']);
  112. $date['saleable_single_party_tax'] = $data['N'];
  113. $date['saleable_single_party_tax1'] = str_replace(',','',$data['N']);
  114. $date['saleable_single_party_no_tax'] = $data['O'];
  115. $date['saleable_single_party_no_tax1'] = str_replace(',','',$data['O']);
  116. $date['note'] = $data['P'];
  117. $date['create_at'] = date('Y-m-d H:i:s');
  118. $numbers = explode('.',$data['A']);
  119. if (count($numbers)>1){
  120. array_pop($numbers); //去掉数组最后一组元素
  121. $number = implode('.',$numbers);
  122. $date['pid'] = Db::name($this->table3)->where('project_id',$project_id)->where('number',$number)->value('id');
  123. $date['pname'] = Db::name($this->table3)->where('project_id',$project_id)->where('number',$number)->value('cost_project');
  124. }else{
  125. $date['pid'] = 0;
  126. $date['pname'] = '';
  127. }
  128. if (Db::table($this->table3)->insertGetId($date)){
  129. $result = 1;
  130. }else{
  131. $result = 0;
  132. break;
  133. }
  134. }
  135. }
  136. }
  137. if ($result==1){
  138. $this->success('成功');
  139. }else{
  140. $this->error('失败');
  141. }
  142. } catch (\think\exception\ValidateException $e) {
  143. $this->error($e->getMessage());
  144. }
  145. }
  146. function excelToArray(){
  147. //加载excel文件
  148. $filename = dirname(__FILE__).'/result.xlsx';
  149. $objPHPExcelReader = \PHPExcel_IOFactory::load($filename);
  150. $sheet = $objPHPExcelReader->getSheet(0); // 读取第一个工作表(编号从 0 开始)
  151. $highestRow = $sheet->getHighestRow(); // 取得总行数
  152. $highestColumn = $sheet->getHighestColumn(); // 取得总列数
  153. $arr = array('A','B','C','D','E','F','G','H','I','J','K','L','M', 'N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
  154. // 一次读取一列
  155. $res_arr = array();
  156. for ($row = 2; $row <= $highestRow; $row++) {
  157. $row_arr = array();
  158. for ($column = 0; $arr[$column] != 'F'; $column++) {
  159. $val = $sheet->getCellByColumnAndRow($column, $row)->getValue();
  160. $row_arr[] = $val;
  161. }
  162. $res_arr[] = $row_arr;
  163. }
  164. return $res_arr;
  165. }
  166. public function index_match()
  167. {
  168. $password = "123456879_/";
  169. //密码必须包含大小写字母/数字/符号任意两者组合
  170. $regStr = "/^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)(?!([^(0-9a-zA-Z)]|[\(\)])+$)([^(0-9a-zA-Z)]|[\(\)]|[a-z]|[A-Z]|[0-9]){6,16}$/";
  171. var_dump(preg_match($regStr, $password));
  172. }
  173. }