Kaynağa Gözat

Merge branch 'raccount' of 39.97.239.116:gyfl/xyzshop into raccount

xiaoyu 2 yıl önce
ebeveyn
işleme
10a5579ee4

+ 2 - 2
data/config/dev/base.ini.php

@@ -53,14 +53,14 @@ define('SSH_TUNEL_PROD','local');
 
 if(SSH_TUNEL_PROD ==='local') {
     $config['db'][1]['dbhost']       = MASTER_DBHOST;
-    $config['db'][1]['dbport']       = '3306';
+    $config['db'][1]['dbport']       = '3307';
     $config['db'][1]['dbuser']       = 'root';
     $config['db'][1]['dbpwd']        = '55668899';
     $config['db'][1]['dbname']       = 'ylshop';
     $config['db'][1]['dbcharset']    = 'UTF-8';
 
     $config['db']['slave'][0]['dbhost']     = SLAVE_DBHOST;
-    $config['db']['slave'][0]['dbport']     = '3306';
+    $config['db']['slave'][0]['dbport']     = '3307';
     $config['db']['slave'][0]['dbuser']     = 'root';
     $config['db']['slave'][0]['dbpwd']      = '55668899';
     $config['db']['slave'][0]['dbname']     = 'ylshop';

+ 7 - 7
data/model/account_divert.model.php

@@ -99,7 +99,7 @@ class account_divertModel extends Model
                 $update = [];
                 $update[$field] = ['exp', "{$field} + {$amount}"];
                 $update['optime'] = ['exp', 'UNIX_TIMESTAMP()'];
-                $this->table('pd_divert')->where(['member_id' => $member_id, 'slot' => $slot])->update($update);
+                $ret = $this->table('pd_divert')->where(['member_id' => $member_id, 'slot' => $slot])->update($update);
                 $slot++;
             }
 
@@ -114,9 +114,9 @@ class account_divertModel extends Model
         return true;
     }
 
-    public function edit_member($member_id,$datas,$amount)
+    public function edit_member($member_id,$datas,$total)
     {
-        if($amount > 10000)
+        if($total > 10000)
         {
             $available_amounts = 0.00;
             $freeze_amounts = 0.00;
@@ -141,7 +141,7 @@ class account_divertModel extends Model
                         }
                     }
                     else {
-                        Log::record(__METHOD__ . " canot parse {$op} opertion.",Log::ERR);
+                        Log::record(__METHOD__ . " canot parse $op opertion.",Log::ERR);
                         return false;
                     }
                 }
@@ -157,13 +157,13 @@ class account_divertModel extends Model
                 foreach ($op_amount as $op => $amount)
                 {
                     if($op =='add') {
-                        $data_pd[$field] = ['exp',"{$field}+{$amount}"];
+                        $data_pd[$field] = ['exp',"$field+$amount"];
                     }
                     elseif($op == 'reduce') {
-                        $data_pd[$field] = ['exp',"{$field}-{$amount}"];
+                        $data_pd[$field] = ['exp',"$field-$amount"];
                     }
                     else {
-                        Log::record(__METHOD__ . " canot parse {$op} opertion.",Log::ERR);
+                        Log::record(__METHOD__ . " canot parse $op opertion.",Log::ERR);
                         return false;
                     }
                 }

+ 1 - 0
data/model/predeposit.model.php

@@ -485,6 +485,7 @@ class predepositModel extends Model {
             throw new Exception('操作失败');
         }
 
+        //不需要统计到订单日志中
         if(defined('SUPPORT_UNUSE_PDLOG') && SUPPORT_UNUSE_PDLOG === true) {
             return true;
         }

+ 2 - 1
helper/refill/RefillBase.php

@@ -115,7 +115,7 @@ class RefillBase
             return (substr($haystack, 0, $length) === $needle);
         };
 
-        $headers = ['SP', 'J98', 'WX', '110110']; //, '11010336J' '0095', 
+        $headers = ['SP', 'J98', 'WX', '110110']; //, '11010336J' '0095',
         $spcheker = function () use ($start_with, $headers, $official_sn)
         {
             $official_sn = strtoupper($official_sn);
@@ -903,6 +903,7 @@ class RefillBase
                 $mod_refill = Model('refill_order');
                 $refill_info = $mod_refill->getOrderInfo(['order_id' => $order_id]);
                 $order_time = intval($refill_info['order_time']);
+                util::onOrderSuccess($refill_info,$order_info);
 
                 $mod_refill->partition(util::part_refill($order_time))->edit($order_id, ['notify_time' => time(), 'notify_state' => 1,'is_retrying' => 0]);
                 mtopcard\cards_helper::assign($order_id);

+ 124 - 0
test/TestPdDivert.php

@@ -0,0 +1,124 @@
+<?php
+
+use PHPUnit\Framework\TestCase;
+
+define('APP_ID', 'test');
+define('BASE_ROOT_PATH', str_replace('/test', '', dirname(__FILE__)));
+define('SUPPORT_UNUSE_PDLOG',true);
+
+require_once(BASE_ROOT_PATH . '/global.php');
+require_once(BASE_CORE_PATH . '/lrlz.php');
+require_once(BASE_ROOT_PATH . '/fooder.php');
+
+class TestPdDivert extends TestCase
+{
+    public static function setUpBeforeClass(): void
+    {
+        Base::run_util();
+    }
+
+    public function testPredeposit()
+    {
+        $data_pd['member_id'] = 65741;
+        $data_pd['amount'] = 100000;
+
+        $model_pd = Model('predeposit');
+        $model_pd->changePd('sys_add_money',$data_pd,true);
+        $model_pd->changePd('sys_del_money',$data_pd,true);
+    }
+
+    //docker-compose run -d phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestPdDivert::testChangeA)( .*)?$/" --test-suffix TestPdDivert.php /var/www/html/test
+
+    public function testChangeA()
+    {
+        Log::short_name('dirvert_a');
+        $this->trans_change();
+    }
+
+    //docker-compose run -d phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestPdDivert::testChangeB)( .*)?$/" --test-suffix TestPdDivert.php /var/www/html/test
+    public function testChangeB()
+    {
+        Log::short_name('dirvert_b');
+        $this->trans_change();
+    }
+
+    //docker-compose run -d phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestPdDivert::testChangeC)( .*)?$/" --test-suffix TestPdDivert.php /var/www/html/test
+    public function testChangeC()
+    {
+        Log::short_name('dirvert_c');
+        $this->trans_change();
+    }
+
+    //docker-compose run -d phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestPdDivert::testChangeD)( .*)?$/" --test-suffix TestPdDivert.php /var/www/html/test
+    public function testChangeD()
+    {
+        Log::short_name('dirvert_d');
+        $this->trans_change();
+    }
+
+    //docker-compose run -d phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestPdDivert::testChangeE)( .*)?$/" --test-suffix TestPdDivert.php /var/www/html/test
+    public function testChangeE()
+    {
+        Log::short_name('dirvert_e');
+        $this->trans_change();
+    }
+
+    private function change()
+    {
+        $total = 0.0000;
+        for($i = 0; $i < 10000000; $i++)
+        {
+            $amount = mt_rand(-1000,1000);
+            $total += $amount;
+
+            $data_pd['member_id'] = 65741;
+            $data_pd['amount'] = $amount > 0.0000 ? $amount : -$amount;
+
+            $model_pd = Model('predeposit');
+            try
+            {
+                if($amount > 0.0000) {
+                    $model_pd->changePd('order_pay',$data_pd,true);
+                } else {
+                    $model_pd->changePd('order_cancel',$data_pd,true);
+                }
+            }
+            catch (Exception $ex)
+            {
+                Log::record($ex->getMessage(),Log::ERR);
+            }
+        }
+        Log::record("testChange total = $total",Log::DEBUG);
+    }
+
+    private function trans_change()
+    {
+        $total = 0.0000;
+        for($i = 0; $i < 10000000; $i++)
+        {
+            $amount = mt_rand(-1000,1000);
+            $total += $amount;
+
+            $data_pd['member_id'] = 65741;
+            $data_pd['amount'] = $amount > 0.0000 ? $amount : -$amount;
+
+            $model_pd = Model('predeposit');
+            $trans = new trans_wapper($model_pd, __METHOD__);
+            try
+            {
+                if($amount > 0.0000) {
+                    $model_pd->changePd('order_pay',$data_pd,true);
+                } else {
+                    $model_pd->changePd('order_cancel',$data_pd,true);
+                }
+                $trans->commit();
+            }
+            catch (Exception $ex)
+            {
+                $trans->rollback();
+                Log::record($ex->getMessage(),Log::ERR);
+            }
+        }
+        Log::record("testChange total = $total",Log::DEBUG);
+    }
+}

+ 11 - 0
test/start.php

@@ -0,0 +1,11 @@
+<?php
+
+define('APP_ID', 'test');
+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_HELPER_PATH . '/PHPExcel/PHPExcel.php');
+
+Base::run_util();