stanley-king 4 gadi atpakaļ
vecāks
revīzija
3b96d669c4

+ 2 - 0
data/config/dev/special.ini.php

@@ -22,3 +22,5 @@ $config['bargain_goods']  = ['special_ids' => [303],'usable_days' => 5,'max_day_
 $config['ugc_banner'] = ['pub' => 269,'friend' => 0, 'mine' => 0];
 $config['bonus_detail_banner'] = ['usable' => [0,0],'expiring' => [0,0],'used' => [0,0],'expired' => [0,0],'send' => [0,0]];
 $config['special_header'] = ['guess_like' => 305];
+
+$config['special_pay_success'] = 1036;

+ 2 - 0
data/config/prod/special.ini.php

@@ -23,3 +23,5 @@ $config['bargain_goods']  = ['special_ids' => [303],'usable_days' => 5,'max_day_
 $config['ugc_banner'] = ['pub' => 269,'friend' => 0, 'mine' => 0];
 $config['bonus_detail_banner'] = ['usable' => [0,0],'expiring' => [0,0],'used' => [0,0],'expired' => [0,0],'send' => [0,0]];
 $config['special_header'] = ['guess_like' => 305];
+
+$config['special_pay_success'] = 1036;

+ 2 - 0
data/config/test/special.ini.php

@@ -23,3 +23,5 @@ $config['bargain_goods']  = ['special_ids' => [303],'usable_days' => 5,'max_day_
 $config['ugc_banner'] = ['pub' => 269,'friend' => 0, 'mine' => 0];
 $config['bonus_detail_banner'] = ['usable' => [0,0],'expiring' => [0,0],'used' => [0,0],'expired' => [0,0],'send' => [0,0]];
 $config['special_header'] = ['guess_like' => 305];
+
+$config['special_pay_success'] = 1036;

+ 1 - 2
data/config/test/vgoods.ini.php

@@ -53,8 +53,7 @@ $share_policy[6227] = [
 
 //6220 话费 amount = 200
 $share_policy[6218] = [
-    ['num' => 3,  'discount' => 10,  'price' => 190],
-    ['num' => 2,  'discount' => 9,  'price'  => 191],
+    ['num' => 2,  'discount' => 10,  'price' => 190],
     ['num' => 1,  'discount' => 6,  'price'  => 194]
 ];
 

+ 63 - 0
data/logic/queue.logic.php

@@ -89,10 +89,73 @@ class queueLogic
             if(!$length) {
                 Log::record("Cannot write file: {$save_path}",Log::ERR);
             }
+            else {
+                $ret = $this->create_shareimage($member_id);
+            }
         }
         else {
             Log::record("request mini code error when member_id = {$member_id}",Log::ERR);
         }
+        if(empty($ret)) {
+            return callback(false,'生成用户mini code 失败');
+        }
+        else {
+            return callback(true);
+        }
+    }
+
+    private function create_shareimage($uid)
+    {
+        $back_img = BASE_RESOURCE_PATH . '/mobile/member/images/share.png';
+        $passwd = util::passwd;
+        $name = md5("{$uid}.{$passwd}") . ".png";
+        $mini_path = BASE_UPLOAD_PATH . DS . ATTACH_MINI_QRCODE . DS . $name;
+
+        $name = "share-{$name}";
+        $dest_img = BASE_UPLOAD_PATH . DS . ATTACH_MINI_QRCODE . DS . $name;
+
+        $back = $this->create_image($back_img);
+        $mini = $this->create_image($mini_path);
+        if($back== false || $mini == false) {
+            Log::record("back or mini image load error",Log::ERR);
+            return false;
+        }
+
+        $dest = imagecreatetruecolor(imagesx($back), imagesy($back));
+        if($dest == false) return false;
+
+        imagecopy($dest,$back, 0, 0, 0,0, imagesx($back), imagesy($back));
+        imagecopyresized($dest,$mini, 30, 648, 0,0, 168,168,imagesx($mini), imagesy($mini));
+        imagepng($dest, $dest_img);
+        return true;
+    }
+    private function create_image($file)
+    {
+        $imagetype = exif_imagetype($file);
+        if ($imagetype === false) {
+            return false;
+        }
+
+        switch ($imagetype)
+        {
+            case IMAGETYPE_GIF:
+                $image = @imagecreatefromgif($file);
+                break;
+            case IMAGETYPE_JPEG:
+            case IMAGETYPE_JPEG2000:
+                $image = @imagecreatefromjpeg($file);
+                break;
+            case IMAGETYPE_PNG:
+                $image = @imagecreatefrompng($file);
+                break;
+            case IMAGETYPE_BMP:
+                $image = @imagecreatefrombmp($file);
+                break;
+            default:
+                return false;
+        }
+
+        return $image;
     }
 
     //邀请好友成功后向,邀请者发送微信push消息。

BIN
data/resource/mobile/member/images/share.png


+ 1 - 1
helper/account_helper.php

@@ -392,7 +392,7 @@ class account_helper
         }
     }
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-    public static function onRegister($member_id,$relay_id)
+    public static function onRegister($member_id,$relay_id,$channel = 0)
     {
         QueueClient::push('makeMemberMiniQrCode',['member_id' => $member_id]);
         QueueClient::push('sendInviterSubMsg', ['inviter_id' => $relay_id,'invitee_id' => $member_id]);

+ 4 - 1
helper/login/ilogin.php

@@ -36,7 +36,7 @@ abstract class ILogin
 
     abstract public function ismember();
 
-    public function register($user_info,$relay_id,$mobile)
+    public function register($user_info,$relay_id,$mobile,$channel = 0)
     {
         if(empty($user_info) && empty($mobile)) return false;
 
@@ -64,6 +64,9 @@ abstract class ILogin
         } else {
             $info['member_wechat_bind'] = 0;
         }
+        if($channel > 0) {
+            $info['channel'] = $channel;
+        }
 
         $mod_member = Model('member');
         $insert_id = $mod_member->addMember($info);

+ 7 - 0
mobile/control/index.php

@@ -197,10 +197,17 @@ class indexControl extends specialControl
         $ret['inviter_tips'] = empty($ret['goods_inviter_tips']) ? '' : $ret['goods_inviter_tips'][0]['tip'];
         $ret['goods'] = $goods;
         $ret['member_mobile'] = session_helper::mobile();
+        $ret['special_id'] = $this->paysuccess_special();
 
         return self::outsuccess($ret);
     }
 
+    private function paysuccess_special()
+    {
+        global $config;
+        return $config['special_pay_success'];
+    }
+
     private function card_goods($card_type,$calctor)
     {
         global $config;

+ 3 - 2
mobile/control/login.php

@@ -262,6 +262,7 @@ class loginControl extends mobileHomeControl
     {
         $user_info  = $_GET['user_info'];
         $phone_info = $_GET['phone_info'];
+        $channel = intval($_GET['channel']);
 
         if (empty($user_info)) {
             return self::outerr(errcode::ErrParamter, "上传的用户信息为空.");
@@ -305,9 +306,9 @@ class loginControl extends mobileHomeControl
             account_helper::onLogin(session_helper::memberid());
         }
         else {
-            $uid_login->register($user_info, session_helper::relay_id(), session_helper::mobile());
+            $uid_login->register($user_info, session_helper::relay_id(), session_helper::mobile(),$channel);
             $uid_login->login();
-            account_helper::onRegister(session_helper::memberid(), session_helper::relay_id());
+            account_helper::onRegister(session_helper::memberid(), session_helper::relay_id(),$channel);
             session_helper::clear_regmobile();
             wechat_helper::clear_userinfo();
         }

+ 42 - 5
test/TestGD.php

@@ -1,4 +1,6 @@
-<?php
+<?php declare(strict_types=1);
+
+use PHPUnit\Framework\TestCase;
 
 /**
  * Created by PhpStorm.
@@ -8,11 +10,44 @@
  */
 define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
 
+require_once(BASE_ROOT_PATH . '/global.php');
+require_once(BASE_CORE_PATH . '/lrlz.php');
 require_once(BASE_ROOT_PATH . '/fooder.php');
-require_once(BASE_ROOT_PATH . '/helper/tools/image_scaler.php');
+require_once(BASE_HELPER_PATH . '/tools/image_scaler.php');
+require_once(BASE_HELPER_PATH . '/util_helper.php');
+
 
-class TestGD extends PHPUnit_Framework_TestCase
+class TestGD extends TestCase
 {
+    public static function setUpBeforeClass() : void
+    {
+        Base::run_util();
+    }
+
+    public function testShare()
+    {
+        $this->create_shareimage(52620);
+    }
+
+    private function create_shareimage($uid)
+    {
+        $back_img = BASE_RESOURCE_PATH . '/mobile/member/images/share.png';
+        $passwd = util::passwd;
+        $name = md5("{$uid}.{$passwd}") . ".png";
+        $mini_path = BASE_UPLOAD_PATH . DS . ATTACH_MINI_QRCODE . DS . $name;
+
+        $name = "share-{$name}";
+        $dest_img = BASE_UPLOAD_PATH . DS . ATTACH_MINI_QRCODE . DS . $name;
+
+        $back = $this->create_image($back_img);
+        $mini = $this->create_image($mini_path);
+
+        $dest = imagecreatetruecolor(imagesx($back), imagesy($back));
+        imagecopy($dest,$back, 0, 0, 0,0, imagesx($back), imagesy($back));
+        imagecopyresized($dest,$mini, 30, 648, 0,0, 168,168,imagesx($mini), imagesy($mini));
+        imagepng($dest, $dest_img);
+    }
+
     public function testMerge()
     {
         $back_img = BASE_UPLOAD_PATH . '/tmp/back.jpg';
@@ -20,11 +55,13 @@ class TestGD extends PHPUnit_Framework_TestCase
         $dest_img = BASE_UPLOAD_PATH . '/tmp/dest.jpg';
 
         $back = imagecreatefromjpeg($back_img);
-        $icon = imagecreatefrompng($icon_img);
-        imageinterlace($back);
 
+        $icon = imagecreatefrompng($icon_img);
         imagecopy($back, $icon, 60, 60, 0, 0, imagesx($icon), imagesy($icon));
         imagejpeg($back, $dest_img,100);
+
+
+
     }
 
     public function testMini()

+ 3 - 3
test/TestQRcode.php

@@ -14,8 +14,8 @@ define('BASE_ROOT_PATH', str_replace('/test', '', dirname(__FILE__)));
 require_once(BASE_ROOT_PATH . '/global.php');
 require_once(BASE_CORE_PATH . '/lrlz.php');
 require_once(BASE_ROOT_PATH . '/fooder.php');
-require_once(BASE_ROOT_PATH . '/helper/util_helper.php');
-require_once(BASE_ROOT_PATH . '/helper/third_author/signaturer.php');
+require_once(BASE_HELPER_PATH . '/util_helper.php');
+require_once(BASE_HELPER_PATH . '/third_author/signaturer.php');
 
 class TestQRcode extends TestCase
 {
@@ -35,7 +35,7 @@ class TestQRcode extends TestCase
 
     public function testSendInviter()
     {
-        $inviter_id = 52640;
+        $inviter_id = 52641;
         $invitee_id = 52638;
 
         $queue_logic = Logic('queue');