Browse Source

Merge branch 'newNeed' into develop

# Conflicts:
#	public/build/asset-manifest.json
#	public/build/index.html
xieruidong 2 years ago
parent
commit
db6fbd1a9a

+ 2 - 2
addons/epay/config.php

@@ -11,8 +11,8 @@ return [
             'app_id' => 'wx799d545a856277fb',
             'app_secret' => 'wx799d545a856277fb',
             'miniapp_id' => 'wx799d545a856277fb',
-            'mch_id' => '1614422722',
-            'key' => 'a792f89843bc2b127ea8ba593ad781ad',
+            'mch_id' => '1617558415',
+            'key' => 'SW967SW967SW967SW967SW967SW967SW',
             'mode' => 'normal',
             'sub_mch_id' => '',
             'sub_appid' => '',

+ 1 - 0
application/admin/view/mobile_upload/index.html

@@ -12,6 +12,7 @@
                     <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
                            data-operate-error_log="{:$auth->check('mobile_upload/error_log')}"
                            data-operate-error_log_download="{:$auth->check('mobile_upload/error_log_download')}"
+                           data-operate-del="{:$auth->check('mobile_upload/del')}"
                            width="100%">
                     </table>
                 </div>

+ 2 - 0
application/api/controller/Common.php

@@ -276,6 +276,7 @@ class Common extends Api
      * @ApiReturnParams (name="bussiness_contact_mobile",description="商务合作电话")
      * @ApiReturnParams (name="beauti_no_detail_bg",description="详情页背景图")
      * @ApiReturnParams (name="beauti_no_detail_text",description="详情页详情文本")
+     * @ApiReturnParams (name="index_no_type",description="首页进入展示列表all全部local本地")
      */
     public function config(){
         $chanId=getChanId();
@@ -296,6 +297,7 @@ class Common extends Api
             'bussiness_contact_mobile'=>config('site.bussiness_contact_mobile'),
             'beauti_no_detail_bg'=>config('site.beauti_no_detail_bg'),
             'beauti_no_detail_text'=>config('site.beauti_no_detail_text'),
+            'index_no_type'=>config('site.index_no_type')?:'all',
         ];
         if($chanId){
             if(getSub()->getAdmin('wx_qr')){

+ 52 - 5
application/api/controller/MobileController.php

@@ -17,6 +17,8 @@ use app\common\model\SysConfig;
 use app\common\service\Jdpay;
 use app\common\service\SmsSend;
 use app\common\service\TransferCheck;
+use app\service\byte_dance\ByteDancePay;
+use app\service\byte_dance\OceanEngineService;
 use app\service\id\IdVerify;
 use think\App;
 use think\Db;
@@ -262,11 +264,12 @@ class MobileController extends UserApi
      * @ApiParams (name=county,description="城市ID,区县id")
      * @ApiParams (name=address,description=详细地址)
      * @ApiParams (name=remark,description=备注)
-     * @ApiParams (name=pay_type,description="1微信2支付宝3京东")
+     * @ApiParams (name=pay_type,description="1微信2支付宝3京东4抖音小程序")
      * @ApiParams (name=return_url,description="支付完成回调页面链接")
      * @ApiReturnParams (name=pay_url,description="支付链接")
      * @ApiReturnParams (name=without_pay,description="是否不需要支付")
-     *
+     * @ApiReturnParams (name=res,description="抖音支付时返回参数")
+     * @ApiParams (name=clickid,description="巨量引擎clickid")
      */
     public function apply(){
         $needId=config('site.system_id_form_open')?true:false;
@@ -288,11 +291,13 @@ class MobileController extends UserApi
         $mobile=Mobile::lock(true)->findOrFail($data['mobile_id']);
         if($mobile['type']==1){
             $this->_validate([
-                'pay_type'=>'require|in:1,2,3',
+                'pay_type'=>'require|in:1,2,3,4',
             ]);
         }
         if($needId||$mobile['type']==2){
-            IdVerify::instance()->check($data['name']??'',$data['id_no']??'');
+            if(!App::$debug) {
+                IdVerify::instance()->check($data['name'] ?? '', $data['id_no'] ?? '');
+            }
         }
         $mobile->shouldBuy();
         Area::shouldSend($data['county']);
@@ -326,14 +331,21 @@ class MobileController extends UserApi
     }
     protected function pay(MobileOrder $mobileOrder,$data){
         $data['return_url']=h5_link('pay-success/'.$mobileOrder['id']);
+        if($mobileOrder['type']==2){
+            OceanEngineService::setQuery(['clickid'=>input('clickid')])->setAddon(['order_no'=>input('clickid')])->form();
+        }
         $succ=[
             'pay_url'=>'',
             'id'=>$mobileOrder['id'],
-            'without_pay'=>0
+            'without_pay'=>0,
+            'res'=>null,
         ];
         if($mobileOrder['amount']==0){
             $succ['without_pay']=1;
             $mobileOrder->paySuccessCallback();
+            try {
+                OceanEngineService::setQuery(['clickid'=>input('clickid')])->setAddon(['order_no'=>input('clickid')])->shopping();
+            }catch (\Exception $e){}
             return $succ;
         }
 
@@ -341,6 +353,9 @@ class MobileController extends UserApi
             'order_no'=>session_create_id(),
             'amount'=>$mobileOrder['amount'],
             'mobile_order_id'=>$mobileOrder['id'],
+            'params'=>[
+                'clickid'=>input('clickid'),
+            ]
         ]);
         $filename=session_create_id(date('Ymd'));
         if(!is_dir($dir=RUNTIME_PATH.'/payment/')) {
@@ -362,6 +377,9 @@ class MobileController extends UserApi
             $jdpay=App::invokeClass(Jdpay::class);
             $payData=$jdpay->order($payment['order_no'],$payment['amount'],"购买手机号{$mobileOrder['no']}");
             $succ=array_merge($succ,$payData);
+        }elseif ($data['pay_type']==4){
+            $payData=ByteDancePay::setInfo($payment['order_no'],$payment['amount'],"购买手机号{$mobileOrder['no']}")->get();
+            $succ['res']=$payData;
         }
         return $succ;
     }
@@ -580,4 +598,33 @@ class MobileController extends UserApi
         $logistics=TransferCheck::instance()->setNo($order['trans_no'])->setLogisticsCompany(LogisticsCompany::get($order['trans_id']))->setPhone($order['phone'])->setName($order['name'])->get();
         $this->success('',$logistics);
     }
+    /**
+     * 预占号码
+     * @ApiParams (name=id,description=号码ID)
+     * @ApiParams (name=chanId,description=通道ID)
+     */
+    public function take(){
+        $data=$this->_validate([
+            'id|号码'=>['require','gt:0'],
+        ]);
+        $open=config('site.auto_take_open');
+        $discount=config('site.auto_take_discount');
+        if(!$open){
+            $this->success('未开启');
+        }
+        if($discount<=0||$discount>10){
+            $this->success('参数错误');
+        }
+        Db::startTrans();
+        $mobile=Mobile::lock(true)->findOrFail($data['id']);
+        if($mobile['is_activity']){
+            Db::rollback();
+            $this->success('已开启');
+        }
+        $chanId=getChanId();
+        $amount_kill=bcmul($mobile['amount_base'],$discount/10,0);
+        $mobile->makeActivity($amount_kill,$chanId);
+        Db::commit();
+        $this->success('改价成功');
+    }
 }

+ 22 - 338
application/api/controller/User.php

@@ -10,6 +10,8 @@ use app\common\model\Guest;
 use app\common\model\User as U;
 use app\common\model\UserSign;
 use app\common\service\ScoreSend;
+use app\service\byte_dance\ByteDanceCode2Session;
+use app\service\byte_dance\ByteDanceDecrypt;
 use EasyWeChat\Kernel\Exceptions\DecryptException;
 use EasyWeChat\Kernel\Exceptions\InvalidConfigException;
 use fast\Mini;
@@ -252,351 +254,33 @@ class User extends Api
         ]);
     }
     /**
-     * 退出登录
-     * @ApiMethod (POST)
-     */
-    public function logout()
-    {
-        if (!$this->request->isPost()) {
-            $this->error(__('Invalid parameters'));
-        }
-        $this->auth->logout();
-        $this->success(__('Logout successful'));
-    }
-    /**
-     * 修改邮箱
-     *
-     * @ApiMethod (POST)
-     * @param string $email   邮箱
-     * @param string $captcha 验证码
-     */
-    public function changeemail()
-    {
-        $user = $this->auth->getUser();
-        $email = $this->request->post('email');
-        $captcha = $this->request->post('captcha');
-        if (!$email || !$captcha) {
-            $this->error(__('Invalid parameters'));
-        }
-        if (!Validate::is($email, "email")) {
-            $this->error(__('Email is incorrect'));
-        }
-        if (UserModel::where('email', $email)->where('id', '<>', $user->id)->find()) {
-            $this->error(__('Email already exists'));
-        }
-        $result = Ems::check($email, $captcha, 'changeemail');
-        if (!$result) {
-            $this->error(__('Captcha is incorrect'));
-        }
-        $verification = $user->verification;
-        $verification->email = 1;
-        $user->verification = $verification;
-        $user->email = $email;
-        $user->save();
-
-        Ems::flush($email, 'changeemail');
-        $this->success();
-    }
-    /**
-     * 修改手机号
-     *
-     * @ApiMethod (POST)
-     * @param string $mobile  手机号
-     * @param string $captcha 验证码
-     */
-    public function changemobile()
-    {
-        $user = $this->auth->getUser();
-        $mobile = $this->request->post('mobile');
-        $captcha = $this->request->post('captcha');
-        if (!$mobile || !$captcha) {
-            $this->error(__('Invalid parameters'));
-        }
-        if (!Validate::regex($mobile, "^1\d{10}$")) {
-            $this->error(__('Mobile is incorrect'));
-        }
-        if (UserModel::where('mobile', $mobile)->where('id', '<>', $user->id)->find()) {
-            $this->error(__('Mobile already exists'));
-        }
-        $result = Sms::check($mobile, $captcha, 'changemobile');
-        if (!$result) {
-            $this->error(__('Captcha is incorrect'));
-        }
-        $user->mobile=$mobile;
-        $user->save();
-
-        Sms::flush($mobile, 'changemobile');
-        $this->success();
-    }
-    /**
-     * 第三方登录
-     *
-     * @ApiMethod (POST)
-     * @param string $platform 平台名称
-     * @param string $code     Code码
-     */
-    public function third()
-    {
-        $this->error('功能已禁用');
-        $url = url('user/index');
-        $platform = $this->request->post("platform");
-        $code = $this->request->post("code");
-        $config = get_addon_config('third');
-        if (!$config || !isset($config[$platform])) {
-            $this->error(__('Invalid parameters'));
-        }
-        $app = new \addons\third\library\Application($config);
-        //通过code换access_token和绑定会员
-        $result = $app->{$platform}->getUserInfo(['code' => $code]);
-        if ($result) {
-            $loginret = \addons\third\library\Service::connect($platform, $result);
-            if ($loginret) {
-                $data = [
-                    'userinfo'  => $this->auth->getUserinfo(),
-                    'thirdinfo' => $result
-                ];
-                $this->success(__('Logged in successful'), $data);
-            }
-        }
-        $this->error(__('Operation failed'), $url);
-    }
-    /**
-     * 重置密码
-     *
-     * @ApiMethod (POST)
-     * @param string $mobile      手机号
-     * @param string $newpassword 新密码
-     * @param string $captcha     验证码
-     */
-    public function resetpwd()
-    {
-        $type = $this->request->post("type");
-        $mobile = $this->request->post("mobile");
-        $email = $this->request->post("email");
-        $newpassword = $this->request->post("newpassword");
-        $captcha = $this->request->post("captcha");
-        if (!$newpassword || !$captcha) {
-            $this->error(__('Invalid parameters'));
-        }
-        if ($type == 'mobile') {
-            if (!Validate::regex($mobile, "^1\d{10}$")) {
-                $this->error(__('Mobile is incorrect'));
-            }
-            $user = UserModel::getByMobile($mobile);
-            if (!$user) {
-                $this->error(__('User not found'));
-            }
-            $ret = Sms::check($mobile, $captcha, 'resetpwd');
-            if (!$ret) {
-                $this->error(__('Captcha is incorrect'));
-            }
-            Sms::flush($mobile, 'resetpwd');
-        } else {
-            if (!Validate::is($email, "email")) {
-                $this->error(__('Email is incorrect'));
-            }
-            $user = UserModel::getByEmail($email);
-            if (!$user) {
-                $this->error(__('User not found'));
-            }
-            $ret = Ems::check($email, $captcha, 'resetpwd');
-            if (!$ret) {
-                $this->error(__('Captcha is incorrect'));
-            }
-            Ems::flush($email, 'resetpwd');
-        }
-        //模拟一次登录
-        $this->auth->direct($user->id);
-        $ret = $this->auth->changepwd($newpassword, '', true);
-        if ($ret) {
-            $this->success(__('Reset password successful'));
-        } else {
-            $this->error($this->auth->getError());
-        }
-    }
-    /**
-     * 小程序登录
-     * @ApiMethod (POST)
-     * @ApiParams (name=code,description="小程序code")
-     * @ApiParams (name=mob_brand,description="手机品牌")
-     * @ApiParams (name=mob_model,description="手机型号")
-     */
-    public function minilogin(){
-        $data=input();
-        $this->validate($data,[
-            'code'=>'require',
-            'mob_brand'=>'require',
-            'mob_model'=>'require',
-            //'encryptedData'=>'require',
-            //'iv'=>'require',
-        ]);
-        $session=Mini::mini()->auth->session($data['code']);
-        //$decryptedData = Mini::mini()->encryptor->decryptData($session, $data['iv'], $data['encryptedData']);
-        $user=\app\admin\model\User::where('openid',$session['openid'])->find();
-        user_log('minilogin',"code:{$data['code']},session:".json_encode($session).',user:'.json_encode($user));
-
-        //$user1=\app\admin\model\User::where('mobile',$decryptedData['phoneNumber'])->find();
-        //$user=$user?:$user1;
-        if(!$user){
-            $ret = $this->auth->register($username=session_create_id(), '', '', $decryptedData['phoneNumber']??'', [
-                'openid'=>$session['openid'],
-                'mob_brand'=>$data['mob_brand'],
-                'nickname'=>'游客',
-                'mob_model'=>$data['mob_model'],
-                'unionid'=>$session['unionid']??'',
-            ]);
-            if ($ret) {
-                $data = ['userinfo' => $this->auth->getUserinfo()];
-                $this->success(__('Sign up successful'), $data);
-            } else {
-                $this->error($this->auth->getError());
-            }
-        }else{
-            $user['unionid']=$session['unionid']??'';
-            $user['mob_brand']=$data['mob_brand'];
-            $user['mob_model']=$data['mob_model'];
-            $user->save();
-        }
-
-        $this->auth->direct($user['id']);
-        $data = ['userinfo' => $this->auth->getUserinfo()];
-        $this->success(__('successful'), $data);
-    }
-    /**
-     * 授权获取手机号
-     * @ApiParams (name=code,description="小程序code")
-     * @ApiParams (name=encryptedData,description="encryptedData")
-     * @ApiParams (name=iv,description="iv")
+     * 抖音小程序登陆
+     * @ApiParams (name=code,description=code)
+     * @ApiParams (name=encryptedData,description=encryptedData)
+     * @ApiParams (name=iv,description=iv)
      */
-    public function wx_mobile(){
+    public function dy_login(ByteDanceCode2Session $code2Session,ByteDanceDecrypt $byteDanceDecrypt){
         $data=$this->_validate([
-            'code'=>'require',
-            'encryptedData'=>'require',
-            'iv'=>'require',
-        ]);
-        $user=$this->auth->getUser();
-        try {
-            $session=Mini::mini()->auth->session($data['code']);
-            $decryptedData = Mini::mini()->encryptor->decryptData($session, $data['iv'], $data['encryptedData']);
-            $user['mobile']=$decryptedData['phoneNumber'];
-            $user->save();
-        } catch (DecryptException | InvalidConfigException $e) {
-            $this->error(sprintf("授权失败(%s)",$e->getMessage()));
-        }
-        $this->success('',$user);
-    }
-    /**
-     * 关注取消关注博主
-     * @ApiParams (name=id,description=博主ID)
-     * @ApiParams (name=status,description=1关注2取消)
-     */
-    public function follow(){
-        $data=$this->_validate([
-            'status'=>'require',
-            'id'=>'require',
-        ]);
-        $user=$this->auth->getUser();
-        if($data['status']==1) {
-            if(!Guest::find($data['id'])){
-                $this->error('博主不存在');
-            }
-            if($user->follow()->guest($data['id'])->find()){
-                $this->error('您已关注');
-            }
-            $user->follow()->attach($data['id']);
-        }else{
-            $user->follow()->detach($data['id']);
-        }
-        $this->success();
-    }
-    /**
-     * 关注列表
-     * @ApiParams (name=limit,description=每页数量)
-     * @ApiParams (name=page,description=第几页)
-     * @ApiReturnParams (name=id,description=博主ID)
-     * @ApiReturnParams (name=name,description=名称)
-     * @ApiReturnParams (name=logo,description=logo)
-     */
-    public function my_follow(){
-        $user=$this->auth->getUser();
-        $list=$user->follow()
-            ->paginate(input('limit'));
-        $this->success('',$list);
-    }
-    /**
-     * 已签到日期列表
-     * @ApiParams (name=date,description="月份,2020-02")
-     */
-    public function sign_list(){
-        $data=$this->_validate([
-            'date'=>['require','date'],
-        ]);
-        $user=$this->auth->getUser();
-        $data=$user->sign()->where('date','>=',$data['date'])->column('date');
-        $this->success('',$data);
-    }
-    /**
-     * 签到
-     * @ApiReturnParams (name=score,description="赠送积分数量")
-     */
-    public function sign(ScoreSend $send){
-        $user=$this->auth->getUser();
-        $date=date('Y-m-d');
-        Db::startTrans();
-        if($user->sign()->where('date',$date)->find()){
-            Db::rollback();
-            $this->error('您已签到');
-        }
-        $sign=$user->sign()->save([
-            'date'=>$date,
-        ]);
-        $finally=['score'=>0];
-        $finally['score']=$send->setUser($user)->setField('score')->setMemo("[{$date}]签到")->setObject(['user_sign',$sign['id']])->setConfig('score_sign')->onlyOne();
-        Db::commit();
-        $this->success('',$finally);
-    }
-    /**
-     * 微信公众号登录获取参数
-     * @ApiParams (name=redirect_uri,description=跳转链接)
-     */
-    public function wxp(WxPublic $wxPublic){
-        $this->validate($data=input(),[
-            'redirect_uri'=>['require'],
-        ]);
-
-        $url=$wxPublic->getApp()->oauth->redirect($data['redirect_uri'])->getTargetUrl();
-        $this->success('',[
-            'url'=>$url,
-        ]);
-    }
-    /**
-     * 微信公众号登录
-     * @ApiParams (name=code,description=微信code)
-     * @ApiReturnParams (name=userinfo.nickname,description=昵称)
-     * @ApiReturnParams (name=userinfo.avatar,description=头像)
-     */
-    public function wxp_handle(WxPublic $wxPublic){
-        $this->validate($data=input(),[
             'code'=>['require'],
+            'encryptedData'=>['require'],
+            'iv'=>['require'],
         ]);
-        $user=$wxPublic->getApp()->oauth->user();
-        $localUser=U::where('wxp_openid',$user->getId())->find();
-        if($localUser){
-            $this->auth->direct($localUser['id']);
+        $info=$code2Session->setCode($data['code'])->get();
+        $byteDanceDecrypt->setEncryptedData($data['encryptedData']);
+        $byteDanceDecrypt->setIv($data['iv']);
+        $byteDanceDecrypt->setSessionKey($info['session_key']);
+        $mobileInfo=$byteDanceDecrypt->get();
+        Db::startTrans();
+        $user= UserModel::where('openid',$info['openid'])->find();
+        if($user){
+            $this->auth->direct($user['id']);
         }else{
-            $reg=$this->auth->register(session_create_id(),session_create_id(),'','',[
-                'wxp_openid'=>$user->getId(),
-                'nickname'=>$user->getNickname(),
-                'avatar'=>$user->getAvatar(),
+            $this->auth->register(session_create_id(),'','',$mobileInfo['phoneNumber'],[
+                'openid'=>$info['openid'],
+                'unionid'=>$info['unionid'],
             ]);
-            if(!$reg){
-                $this->error('注册失败'.$this->auth->getError());
-            }
         }
-        $data = [
-            'userinfo'  => $this->auth->getUserinfo(),
-        ];
-        $data['userinfo']['token']=$this->auth->getToken();
+        $data = ['userinfo' => $this->auth->getUserinfo()];
         $this->success(__('Logged in successful'), $data);
     }
 }

+ 9 - 0
application/common/model/Mobile.php

@@ -391,6 +391,15 @@ class Mobile extends Model
             $this->save();
         }
     }
+    #设置活动
+    public function makeActivity($amountKill,$chanId){
+        $this['is_activity'] = 1;
+        $this['activity_time'] = time();
+        $this['hold_chan']=$chanId;
+        $this['hold_user']=$chanId;
+        $this['amount_kill']=$amountKill;
+        $this->save();
+    }
     #已售
     public function scopeFilterSaled(Query $query){
         $query->where('status',1);

+ 3 - 3
application/common/service/MobilePriceLogService.php

@@ -56,10 +56,10 @@ class MobilePriceLogService{
     }
 
     public function log(){
-        if(empty($_SERVER['admin'])){
+        /*if(empty($_SERVER['admin'])){
             return;
-        }
-        $this->setAdminId($_SERVER['admin']['id']);
+        }*/
+        $this->setAdminId($_SERVER['admin']['id']??0);
         if($this->before_price!=$this->after_price){
             MobilePriceLog::create([
                 'admin_id'=>$this->admin_id,

+ 2 - 1
application/index/controller/Index.php

@@ -6,6 +6,7 @@ use app\common\controller\Frontend;
 use app\common\model\Mobile;
 use app\common\service\MobileComputer;
 use app\service\byte_dance\ByteDance;
+use app\service\byte_dance\ByteDancePay;
 use app\service\id\IdVerify;
 use PhpOffice\PhpSpreadsheet\IOFactory;
 use think\helper\Str;
@@ -19,7 +20,7 @@ class Index extends Frontend
 
     public function index()
     {
-        return $this->view->fetch();
+        $this->redirect('/build');
     }
     public function payment($a=null){
         if(!$a){

+ 4 - 0
application/index/controller/Payment.php

@@ -6,6 +6,7 @@ use addons\epay\library\Service;
 use app\common\controller\Frontend;
 use app\common\model\MobileOrder;
 use app\common\service\SmsSend;
+use app\service\byte_dance\OceanEngineService;
 use think\Db;
 
 /**
@@ -64,6 +65,9 @@ class Payment extends Frontend
             Db::rollback();
             return $e->getMessage();
         }
+        try {
+            OceanEngineService::setQuery($payment['params']?:[])->setAddon(['order_no'=>$order_no])->shopping();
+        }catch (\Exception $e){}
 
         echo "success";
         return;

+ 26 - 0
application/service/byte_dance/ByteDanceCode2Session.php

@@ -0,0 +1,26 @@
+<?php
+namespace app\service\byte_dance;
+
+use think\Cache;
+
+class ByteDanceCode2Session implements ByteDanceInterface {
+    protected $code;
+
+    public function setCode($code)
+    {
+        $this->code = $code;
+        return $this;
+    }
+    public function get()
+    {
+        return ByteDance::httpPost('https://developer.toutiao.com/api/apps/v2/jscode2session',$this->params());
+    }
+
+    protected function params(){
+        return [
+            'appid'=>ByteDance::appId(),
+            'secret'=>ByteDance::appSecret(),
+            'code'=>$this->code,
+        ];
+    }
+}

+ 42 - 0
application/service/byte_dance/ByteDanceDecrypt.php

@@ -0,0 +1,42 @@
+<?php
+namespace app\service\byte_dance;
+
+use think\Cache;
+
+class ByteDanceDecrypt implements ByteDanceInterface {
+    protected $session_key;
+    protected $encryptedData;
+    protected $iv;
+
+    public function setSessionKey($sessionKey)
+    {
+        $this->session_key = $sessionKey;
+        return $this;
+    }
+
+    /**
+     * @param mixed $encryptedData
+     */
+    public function setEncryptedData($encryptedData): void
+    {
+        $this->encryptedData = $encryptedData;
+    }
+
+    /**
+     * @param mixed $iv
+     */
+    public function setIv($iv): void
+    {
+        $this->iv = $iv;
+    }
+
+    public function get()
+    {
+        try {
+            $decrypted=openssl_decrypt(base64_decode($this->encryptedData),'AES-128-CBC',base64_decode($this->session_key),OPENSSL_RAW_DATA,base64_decode($this->iv));
+            return json_decode($decrypted,true);
+        }catch (\Exception $e){
+            ByteDance::throwIf(1,"数据解密失败({$e->getMessage()})");
+        }
+    }
+}

+ 76 - 0
application/service/byte_dance/ByteDancePay.php

@@ -0,0 +1,76 @@
+<?php
+namespace app\service\byte_dance;
+
+use think\Cache;
+use think\Collection;
+
+class ByteDancePay implements ByteDanceInterface {
+    protected $data=[
+        'out_order_no'=>'',
+        'total_amount'=>'',
+        'subject'=>'',
+        'body'=>'',
+        'valid_time'=>86400,
+        'notify_url'=>'',
+        'thirdparty_id'=>''
+    ];
+
+    public function __construct()
+    {
+    }
+
+    /**
+     * @param mixed $order_no
+     * @param $amount
+     * @param $subject
+     * @return ByteDancePay
+     */
+    public static function setInfo($order_no,$amount,$subject)
+    {
+        $class=new self;
+        $class->data['app_id']=ByteDance::appId();
+        $class->data['out_order_no'] = $order_no;
+        $class->data['total_amount'] = $amount*100;
+        $class->data['subject'] = $subject;
+        $class->data['body'] = $subject;
+        $class->data['notify_url']=request()->domain().'/index/payment/notify_dy/order_no/'.$order_no;
+        return $class;
+    }
+
+    public function get()
+    {
+        $data=$this->data;
+        $data['sign']=$this->sign($data);
+        $order=ByteDance::httpPost('https://developer.toutiao.com/api/apps/ecpay/v1/create_order',$data);
+        $obj=ByteDanceResult::make();
+        foreach ($order as $key=>$item){
+            $obj->offsetSet($key,$item);
+        }
+        return $obj;
+    }
+
+    protected function sign($map) {
+        $rList = array();
+        foreach($map as $k =>$v) {
+            if ($k == "other_settle_params" || $k == "app_id" || $k == "sign" || $k == "thirdparty_id")
+                continue;
+            $value = trim(strval($v));
+            $len = strlen($value);
+            if ($len > 1 && substr($value, 0,1)=="\"" && substr($value,$len, $len-1)=="\"")
+                $value = substr($value,1, $len-1);
+            $value = trim($value);
+            if ($value == "" || $value == "null")
+                continue;
+            array_push($rList, $value);
+        }
+        array_push($rList, config('site.byte_dance_mapp_pay_salt'));
+        sort($rList, 2);
+        return md5(implode('&', $rList));
+    }
+}
+/**
+ * @property string $order_id
+ * @property string $order_token
+ * @property string $url
+ */
+class ByteDanceResult extends Collection {}

+ 74 - 0
application/service/byte_dance/OceanEngineService.php

@@ -0,0 +1,74 @@
+<?php
+namespace app\service\byte_dance;
+
+use GuzzleHttp\Client;
+use traits\think\Instance;
+
+class OceanEngineService{
+    use Instance;
+    protected $query=[];
+    protected $addon=[];
+    public function __construct($query)
+    {
+        $this->query=$query;
+    }
+
+    /**
+     * @param array $query
+     */
+    public static function setQuery(array $query)
+    {
+        return self::instance($query);
+    }
+
+    /**
+     * @param array $addon
+     */
+    public function setAddon(array $addon)
+    {
+        $this->addon = $addon;
+        return $this;
+    }
+    public function form(){
+        $this->conversion('form');
+    }
+    protected function conversion($evenType){
+        if(empty($this->query['clickid'])){
+            return false;
+        }
+        $p=$this->client()->post('https://analytics.oceanengine.com/api/v2/conversion',[
+            'json'=>[
+                'event_type'=>$evenType,
+                'context'=>[
+                    'ad'=>[
+                        'callback'=>$this->query['clickid'],
+                    ]
+                ],
+                'timestamp'=>time()*1000,
+            ]
+        ]);
+        $result=json_decode($p->getBody()->getContents(),true);
+        $codeArr=[
+            0=>'成功',
+            10=>'服务暂时不可用,请稍后重试',
+            100=>'无效的请求,请求数据解析失败',
+            101=>'鉴权认证失败, 数据会被丢弃',
+            102=>'参数:event_type无效',
+            103=>'参数:callback无效',
+            107=>'鉴权认证失败,请修正签名,当前状态下本次回传不受影响',
+        ];
+        user_log('oceanEngineService',[
+            'query'=>$this->query,
+            'addon'=>$this->addon,
+            'response'=>$result,
+            'code_text'=>$codeArr[$result['code']??-1]??null
+        ]);
+        return $result;
+    }
+    public function shopping(){
+        $this->conversion('shopping');
+    }
+    protected function client(){
+        return new Client();
+    }
+}

+ 6 - 0
application/service/mobile_get/ChinaMobileService.php

@@ -0,0 +1,6 @@
+<?php
+namespace app\service\mobile_get;
+
+class ChinaMobileService {
+
+}

+ 6 - 0
application/service/mobile_get/MobileGetService.php

@@ -0,0 +1,6 @@
+<?php
+namespace app\service\mobile_get;
+
+abstract class MobileGetService {
+
+}

+ 2 - 1
apply_data.yml

@@ -2,4 +2,5 @@
 公众号:
 小程序1:
 小程序2:
-微信支付:
+微信支付:
+  6002C8899C37EDA24131ACD40F681851

File diff suppressed because it is too large
+ 283 - 307
public/api.html


+ 18 - 0
public/assets/js/backend/mobile_upload.js

@@ -68,6 +68,24 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                         //返回true时按钮显示,返回false隐藏
                                         return table.data('operate-error_log') && row.rows_fail>0;
                                     }
+                                },
+                                {
+                                    name: 'detail',
+                                    text: __('删除'),
+                                    title: __('删除'),
+                                    confirm:"确认删除吗?",
+                                    classname: 'btn btn-xs btn-danger btn-ajax',
+                                    icon: 'fa fa-list',
+                                    url: 'mobile_upload/del',
+                                    callback: function (data) {
+                                    },
+                                    visible: function (row) {
+                                        //返回true时按钮显示,返回false隐藏
+                                        return table.data('operate-del');
+                                    },
+                                    success(){
+                                        $('.btn-refresh').trigger('click')
+                                    }
                                 }
                             ]
                         }

File diff suppressed because it is too large
+ 0 - 0
public/build/static/css/main.6e79da22.css


File diff suppressed because it is too large
+ 1 - 0
public/build/static/js/main.4ed4dd4f.js


+ 68 - 0
public/build/static/js/main.4ed4dd4f.js.LICENSE.txt

@@ -0,0 +1,68 @@
+/*
+object-assign
+(c) Sindre Sorhus
+@license MIT
+*/
+
+/*!
+  Copyright (c) 2018 Jed Watson.
+  Licensed under the MIT License (MIT), see
+  http://jedwatson.github.io/classnames
+*/
+
+/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
+
+/**
+ * @license React
+ * use-sync-external-store-shim.production.min.js
+ *
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+/** @license React v0.20.2
+ * scheduler.production.min.js
+ *
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+/** @license React v16.13.1
+ * react-is.production.min.js
+ *
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+/** @license React v17.0.2
+ * react-dom.production.min.js
+ *
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+/** @license React v17.0.2
+ * react-jsx-runtime.production.min.js
+ *
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+/** @license React v17.0.2
+ * react.production.min.js
+ *
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */

File diff suppressed because it is too large
+ 0 - 0
public/build/static/js/main.4ed4dd4f.js.map


+ 5 - 0
thinkphp/library/think/Collection.php

@@ -464,4 +464,9 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
     {
         return $items instanceof self ? $items->all() : (array) $items;
     }
+
+    public function __get($name)
+    {
+        return $this->offsetGet($name);
+    }
 }

Some files were not shown because too many files changed in this diff