quguofeng 2 年之前
父節點
當前提交
68e5430868
共有 2 個文件被更改,包括 324 次插入0 次删除
  1. 314 0
      application/api/controller/Qc.php
  2. 10 0
      application/api/controller/Task.php

+ 314 - 0
application/api/controller/Qc.php

@@ -0,0 +1,314 @@
+<?php
+
+namespace app\api\controller;
+use app\common\model\ChinaArea;
+use app\common\model\ForumReply;
+use app\common\model\GoodsOrder;
+use app\common\model\LevelOrder;
+use app\common\model\LevelOrder as LOM;
+use app\common\model\StoreGoods;
+use app\common\model\User;
+use app\common\model\UserLevelRank;
+use app\common\model\UserMessage;
+use app\common\model\UserWallet;
+use app\common\model\VideoIntro;
+use app\common\service\Activity;
+use app\common\service\OrderCallback;
+use app\order\controller\StoreOrder;
+use EasyWeChat\MiniProgram\Application;
+use library\tools\Data;
+use MongoDB\Driver\Server;
+use Qiniu\Auth;
+use Qiniu\Storage\UploadManager;
+use think\Exception;
+use think\Session;
+use think\cache\driver\Redis;
+use EasyWeChat\Factory;
+use Firebase\JWT\JWT;
+use think\Db;
+use AlibabaCloud\Client\AlibabaCloud;
+use AlibabaCloud\Client\Exception\ClientException;
+use AlibabaCloud\Client\Exception\ServerException;
+use function AlibabaCloud\Client\value;
+use function EasyWeChat\Kernel\data_get;
+use function Stringy\create;
+
+use JPush\Client;
+require_once env('root_path').'vendor/jpush/jpush/autoload.php';
+class Qc extends Base {
+
+    public function index()
+    {
+        $user_id = 3333 ;
+        $alert ='aaa';
+        if(empty($user_id)) return false;
+        $appKey = '02a7faefd91c8a6a446a6a14';
+        $masterSecret = 'ba2e100db997024d9b6e5d35';
+        $client = new Client($appKey, $masterSecret,null);
+        $push_payload = $client->push()
+            ->setPlatform(array('ios', 'android'))
+            ->addAlias(strval($user_id))
+            //->addAllAudience()
+            ->iosNotification($alert, array(
+                'badge' => '+1',
+                'content-available' => true,
+                'mutable-content' => true,
+                'category' => 'jiguang',
+                'extras' => array(
+                    'key' => 'value',
+                    'jiguang'
+                ),
+            ))->androidNotification($alert, array(
+                'title' => '消息通知',
+                // 'builder_id' => 2,
+                'extras' => array(
+                    'key' => 'value',
+                    'jiguang'
+                ),
+            ))->options(array(
+                'apns_production' => True,
+            ));
+        try {
+            $response = $push_payload->send();
+            return $response;
+        } catch  (\JPush\Exceptions\APIConnectionException $e) {
+            return $e;
+        } catch (\JPush\Exceptions\APIRequestException $e) {
+            return $e;
+        }
+
+    }
+
+
+
+
+    public function payOrder()
+    {
+        $this->user_id = 22;
+        $order_id = input('post.order_id');
+        $pay_type = input('post.pay_type',1);
+        $order_info = LOM::where('id',$order_id)->find()->toArray();
+        if($order_info['status'] != 0) $this->error('订单状态错误');
+        if($order_info['cancel_state'] != 0 || $order_info['is_deleted'] != 0) $this->error('订单异常');
+        if($order_info['price_total'] <= 0) $this->error('订单金额错误');
+        $pay_no  = $order_info['pay_no'] ? $order_info['pay_no'] : get_order_sn();// 支付单号
+        if(!$order_info['pay_no']) LOM::where('id',$order_id)->update(['pay_no'=>$pay_no]);
+        $user_info = User::where('id',$this->user_id)->find()->toArray();
+        $ret_data = ['pay_status'=>0,'config'=>[],'code_url'=>'','openid'=>$user_info['openid']];
+        Db::startTrans();
+        try {
+            switch ($pay_type){
+                case 1://微信小程序
+                    $notify_url = $this->request->root(true) . '/api/we_chat_pay/LevelOrderNotify';
+                    $pay_config = WeChatPay::wxPay('订单支付',$pay_no,$order_info['price_total'],$notify_url,'MWEB');
+                    if($pay_config['code'] != 200) $this->exception($pay_config['msg']);
+                    $pay_config['config']['mch_id'] = config('app.wx_pay')['mch_id'];
+                    $pay_config['config']['pay_no'] = $pay_no;
+                    $pay_config['config']['notify_url'] = $notify_url;
+                    $pay_config['config']['mweb_url'] = $pay_config['mweb_url'];
+                    $pay_config['config']['total_fee'] = $order_info['price_total'] * 100;
+                    $ret_data['config'] = $pay_config['config'];
+                    break;
+                case 2 :
+                    if(!$user_info['openid']) $this->exception('请绑定公众号');
+                    $notify_url = $this->request->root(true) . '/api/we_chat_pay/LevelOrderNotify';
+                    $pay_config = WeChatPay::wxPay('订单支付',$pay_no,$order_info['price_total'],$notify_url,'JSAPI',$user_info['openid']);
+                    if($pay_config['code'] != 200) $this->exception($pay_config['msg']);
+                    $ret_data['config'] = $pay_config['config'];
+                    break;
+            }
+
+            Db::commit();
+        }catch (\Exception $e){
+            $this->is_commit = false;
+            $this->ret_msg =  $e->getMessage();
+            Db::rollback();
+        }
+        $this->transReturn($ret_data);
+    }
+
+
+
+    /**
+     * @title 获取分享的签名
+     * @desc 获取分享的签名
+     * @url /api/qc/getWeChatSign
+     * @method POST
+     * @tag 基础
+     *
+     **/
+    public function getWeChatSign(){
+        $urls = input('url');
+        $appid = config('app.official_account')['appid'];
+        $secret =  config('app.official_account')['secret'];
+        $redis = new Redis();
+        $access_token = $redis->get('access_token');
+        if (!$access_token){
+            $access_token = '';
+            $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$secret";
+            $res= http_curl($url);
+            if (isset($res['access_token'])){
+                $redis->set('access_token',$res['access_token'],'7000');
+                $access_token = $res['access_token'];
+            }
+        }
+
+        $url2 ="https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=".$access_token."&type=jsapi";
+        $res2=http_curl($url2);
+        if (!isset($res2) || $res2['errcode']!=0) $this->error('获取ticket失败');
+        $timestamp = time();
+        $noncestr = get32Str(15);
+        $string = "jsapi_ticket=".$res2['ticket']."&noncestr=$noncestr&timestamp=$timestamp&url=".$urls;
+        $sign = sha1($string);
+        $return = [
+            'appid'=>$appid,
+            'noncestr'=>$noncestr,
+            'timestamp'=>$timestamp,
+            'url'=>$urls,
+            'sign'=>$sign,
+            'ticket'=>$res2['ticket']
+        ];
+        $this->success('成功',$return);
+    }
+
+    /**
+     * 导入子项目数据
+     * @auth true
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public function import()
+    {
+        $get = $this->request->get();
+        $import_path = $_SERVER['DOCUMENT_ROOT'].'/'.$get['path'];
+        $project_id = $get['project_id'];
+        $num = 5;
+        try {
+            $objReader =\PHPExcel_IOFactory::createReader('Excel2007');
+            $objExcel = $objReader->load($import_path);
+
+            $list = $objExcel->getActiveSheet()->toArray();
+            if (!isset($list[2][15]) || !$list[2][15]){
+                $this->error('失败');
+            }
+            if (isset($list[2][16])){
+                $this->error('失败');
+            }
+            Db::name($this->table3)->where('project_id',$project_id)->delete();
+            Db::name($this->table)->where('id',$project_id)->update(['url'=>$get['url']]);
+            $result = 0;
+            foreach ($list as $k=>$v){
+                if($k>=$num-1){
+                    if(array_filter($v)){
+                        $data=[];
+                        foreach ($v as $kk=>$vv){
+                            $data[IntToChr($kk)]=trim($vv);
+                        }
+                        $date['project_id'] = $project_id;
+                        $date['number'] = $data['A'];
+                        $date['cost_project'] = $data['B'];
+                        $date['area_calculating_aperture'] = $data['C'];
+                        $date['single_party_cost'] = $data['D'];
+                        $date['single_party_cost1'] = str_replace(',','',$data['D']);
+                        $date['total_price_included'] = $data['E'];
+                        $date['total_price_included1'] = str_replace(',','',$data['E']);
+                        $date['single_party_cost_excluding'] = $data['F'];
+                        $date['single_party_cost_excluding1'] = str_replace(',','',$data['F']);
+                        $date['total_price_included_excluding'] = $data['G'];
+                        $date['total_price_included_excluding1'] = str_replace(',','',$data['G']);
+
+                        $date['single_party_cost_tax'] = $data['H'];
+                        $date['single_party_cost_tax1'] = str_replace(',','',$data['H']);
+                        $date['single_party_cost_no_tax'] = $data['I'];
+                        $date['single_party_cost_no_tax1'] = str_replace(',','',$data['I']);
+
+                        $date['quantities'] = $data['J'];
+                        $date['quantities1'] = str_replace(',','',$data['J']);
+                        $date['calculating_unit'] = $data['K'];
+                        $date['unilateral_content'] = $data['L'];
+                        $date['unilateral_content1'] = str_replace(',','',$data['L']);
+                        $date['unilateral_content_excluding'] = $data['M'];
+                        $date['unilateral_content_excluding1'] = str_replace(',','',$data['M']);
+
+                        $date['saleable_single_party_tax'] = $data['N'];
+                        $date['saleable_single_party_tax1'] = str_replace(',','',$data['N']);
+
+                        $date['saleable_single_party_no_tax'] = $data['O'];
+                        $date['saleable_single_party_no_tax1'] = str_replace(',','',$data['O']);
+
+                        $date['note'] = $data['P'];
+                        $date['create_at'] = date('Y-m-d H:i:s');
+
+                        $numbers = explode('.',$data['A']);
+                        if (count($numbers)>1){
+                            array_pop($numbers); //去掉数组最后一组元素
+                            $number = implode('.',$numbers);
+                            $date['pid'] = Db::name($this->table3)->where('project_id',$project_id)->where('number',$number)->value('id');
+                            $date['pname'] = Db::name($this->table3)->where('project_id',$project_id)->where('number',$number)->value('cost_project');
+                        }else{
+                            $date['pid'] = 0;
+                            $date['pname'] = '';
+                        }
+                        if (Db::table($this->table3)->insertGetId($date)){
+                            $result = 1;
+                        }else{
+                            $result = 0;
+                            break;
+                        }
+                    }
+                }
+            }
+            if ($result==1){
+                $this->success('成功');
+            }else{
+                $this->error('失败');
+            }
+        } catch (\think\exception\ValidateException $e) {
+            $this->error($e->getMessage());
+
+        }
+    }
+
+    function excelToArray(){
+        //加载excel文件
+        $filename = dirname(__FILE__).'/result.xlsx';
+        $objPHPExcelReader = \PHPExcel_IOFactory::load($filename);
+
+        $sheet = $objPHPExcelReader->getSheet(0);        // 读取第一个工作表(编号从 0 开始)
+        $highestRow = $sheet->getHighestRow();           // 取得总行数
+        $highestColumn = $sheet->getHighestColumn();     // 取得总列数
+
+        $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');
+        // 一次读取一列
+        $res_arr = array();
+        for ($row = 2; $row <= $highestRow; $row++) {
+            $row_arr = array();
+            for ($column = 0; $arr[$column] != 'F'; $column++) {
+                $val = $sheet->getCellByColumnAndRow($column, $row)->getValue();
+                $row_arr[] = $val;
+            }
+
+            $res_arr[] = $row_arr;
+        }
+
+        return $res_arr;
+    }
+
+
+
+
+
+
+    public function index_match()
+    {
+        $password = "123456879_/";
+        //密码必须包含大小写字母/数字/符号任意两者组合
+        $regStr = "/^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)(?!([^(0-9a-zA-Z)]|[\(\)])+$)([^(0-9a-zA-Z)]|[\(\)]|[a-z]|[A-Z]|[0-9]){6,16}$/";
+        var_dump(preg_match($regStr, $password));
+
+    }
+
+
+
+
+}

+ 10 - 0
application/api/controller/Task.php

@@ -0,0 +1,10 @@
+<?php
+namespace app\api\controller;
+
+class Task extends Base
+{
+
+
+
+
+}