Browse Source

fix error

stanley-king 4 years ago
parent
commit
af871cbbbd

+ 4 - 2
data/config/dev/vgoods.ini.php

@@ -29,7 +29,8 @@ $mcard_params =['type' => 'member_card',
 $handlers[6217] = $mcard_params;
 
 #oil card
-$oil_params = ['type' => 'oil_card', 'order_method'    => 'OnReserveOilCard',
+$oil_params = ['type' => 'oil_card', 'order_check'     => 'OnOilCardCheck',
+                                     'order_method'    => 'OnReserveOilCard',
                                      'complete_method' => 'OnCardKeyComplete',
                                      'cancel_method' => 'OnCardKeyCancel',
                                      'input_params'  => ['card_no','card_type']];
@@ -39,7 +40,8 @@ $handlers[6224] = $oil_params;
 $handlers[6225] = $oil_params;
 
 #phone card
-$phone_card_prams = ['type' => 'phone_card', 'order_method'    => 'OnReservePhoneCard',
+$phone_card_prams = ['type' => 'phone_card', 'order_check'     => 'OnPhoneCardCheck',
+                                             'order_method'    => 'OnReservePhoneCard',
                                              'complete_method' => 'OnCardKeyComplete',
                                              'cancel_method' => 'OnCardKeyCancel',
                                              'input_params'  => ['card_no','card_type']];

+ 6 - 2
data/config/prod/vgoods.ini.php

@@ -21,7 +21,9 @@ $mcard_params =['type' => 'member_card', 'order_method' => '', 'paid_oper' => 'a
 $handlers[6217] = $mcard_params;
 
 #oil card
-$oil_params = ['type' => 'oil_card', 'order_method' => 'OnReserveOilCard',
+$oil_params = ['type' => 'oil_card',
+    'order_check'     => 'OnOilCardCheck',
+    'order_method' => 'OnReserveOilCard',
     'complete_method' => 'OnCardKeyComplete',
     'cancel_method' => 'OnCardKeyCancel',
     'input_params' => ['card_no','card_type']];
@@ -32,7 +34,9 @@ $handlers[6220] = $oil_params;
 $handlers[6227] = $oil_params;
 
 #phone card
-$phone_card_prams = ['type' => 'phone_card', 'order_method' => 'OnReservePhoneCard',
+$phone_card_prams = ['type' => 'phone_card',
+    'order_check'     => 'OnPhoneCardCheck',
+    'order_method' => 'OnReservePhoneCard',
     'complete_method' => 'OnCardKeyComplete',
     'cancel_method' => 'OnCardKeyCancel',
     'input_params' => ['card_no','card_type']];

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

@@ -21,7 +21,9 @@ $mcard_params =['type' => 'member_card', 'order_method' => '', 'paid_oper' => 'a
 $handlers[6217] = $mcard_params;
 
 #oil card
-$oil_params = ['type' => 'oil_card', 'order_method' => 'OnReserveOilCard',
+$oil_params = ['type' => 'oil_card',
+    'order_check'     => 'OnOilCardCheck',
+    'order_method' => 'OnReserveOilCard',
     'complete_method' => 'OnCardKeyComplete',
     'cancel_method' => 'OnCardKeyCancel',
     'input_params' => ['card_no','card_type']];
@@ -32,7 +34,9 @@ $handlers[6220] = $oil_params;
 $handlers[6227] = $oil_params;
 
 #phone card
-$phone_card_prams = ['type' => 'phone_card', 'order_method' => 'OnReservePhoneCard',
+$phone_card_prams = ['type' => 'phone_card',
+    'order_check'     => 'OnPhoneCardCheck',
+    'order_method' => 'OnReservePhoneCard',
     'complete_method' => 'OnCardKeyComplete',
     'cancel_method' => 'OnCardKeyCancel',
     'input_params' => ['card_no','card_type']];

File diff suppressed because it is too large
+ 313 - 208
data/logic/queue.logic.php


+ 6 - 22
data/model/topcard.model.php

@@ -4,8 +4,6 @@ declare(strict_types=0);
 
 defined('InShopNC') or exit('Access Invalid!');
 
-use mtopcard;
-
 class topcardModel extends Model
 {
     public function add($card_no,$card_type,$add_time)
@@ -18,28 +16,14 @@ class topcardModel extends Model
     }
     public function add_money($card_no,$amount,$time)
     {
-        $this->table('topcard')->where(['card_no' => $card_no])
-             ->update(['total_amount' => ['exp',"total_amount+{$amount}"],
-                       'add_times' => ['exp',"add_times+1"],
-                       'last_time' => time()]);
-
-        $stamp = mtopcard\month_stamp($time);
-        if(empty($this->find_log($card_no,$stamp))) {
-            $datas = ['card_no' => $card_no,'month_stamp' => $stamp,'month_amount' => $amount,
-                      'add_times' => 1,'last_time' => time()];
-            $ret = $this->table('topcard_log')->insert($datas);
-        }
-        else {
-            $ret = $this->where(['card_no' => $card_no,'month_stamp' => $stamp])
-                        ->update(['month_amount' => ['exp',"month_amount+{$amount}"],
-                                  'add_times' => ['exp',"add_times+1"],
-                                  'last_time' => time()]);
-        }
-
+        $ret = $this->table('topcard')->where(['card_no' => $card_no])
+                    ->update(['total_amount' => ['exp',"total_amount+{$amount}"],
+                              'add_times' => ['exp',"add_times+1"],
+                              'last_time' => $time]);
         return $ret;
     }
-    private function find_log($card_no,$month_stamp)
+    public function get_cards($low,$high)
     {
-        return $this->table('topcard_log')->where(['card_no' => $card_no,'month_stamp' => $month_stamp])->select();
+        return $this->table('topcard')->where(['card_no' => ['between' => [$low,$high]]])->select();
     }
 }

+ 12 - 0
helper/exceptionex.php

@@ -28,6 +28,18 @@ class UnloginException extends Exception
     }
 }
 
+class UnSignException extends Exception
+{
+    public function __construct()
+    {
+        $code = errcode::ErrSignParamter;
+        $message = errcode::msg($code);
+
+        parent::__construct($message, $code, null);
+    }
+}
+
+
 class UnImplementsException extends Exception
 {
     public function __construct($method)

+ 6 - 1
mobile/control/control.php

@@ -51,7 +51,12 @@ class mobileControl
         statistics_helper::instance()->add_call($param);
 
         if(session_helper::version_code() > 168) {
-            $this->verify();
+            if(!$this->verify()) {
+                throw new UnSignException();
+            }
+        }
+        else {
+            throw new UnSignException();
         }
     }
     private function verify()

+ 11 - 4
mobile/control/member_buy.php

@@ -222,13 +222,20 @@ class member_buyControl extends mbMemberControl
         $input['buyer_name'] = $_POST['buyer_name'] ?? session_helper::nickname();
         $input['buyer_msg'] = $_POST['buyer_msg'] ?? '';
 
-        $city_id = intval($_POST['city_id']);
-
-        [$fExtra, $extra_info, $order_method] = $this->extra_info($input['goods_id'], $_POST);
+        [$fExtra, $extra_info, $order_check] = $this->extra_info($input['goods_id'], $_POST);
         if (!$fExtra) {
             Log::record("step_vsecond error", Log::ERR);
             return self::outerr(errcode::ErrInputParam, '缺少虚拟商品,额外指定参数.');
         }
+        if(!empty($order_check))
+        {
+            $logic = Logic('queue');
+            $ret = $logic->$order_check(['extra_info' => $extra_info,'goods_id' => $input['goods_id']]);
+
+            if(!$ret['state']) {
+                return self::outerr(errcode::ErrInputParam, $ret['msg']);
+            }
+        }
 
         $input['order_from'] = 2;
         $calctor = new CalcPrice(session_helper::memberid());
@@ -289,7 +296,7 @@ class member_buyControl extends mbMemberControl
                 $extra['additional'] = $handler['additional'];
             }
 
-            return [true, $extra, $handler['order_method']];
+            return [true, $extra, $handler['order_check']];
         }
         return [true, [], ''];
     }

+ 3 - 0
mobile/util/errcode.php

@@ -31,6 +31,7 @@ class errcode //extends SplEnum
     const ErrUploadFileFailed = 10018; //上传文件失败
     const ErrUnImplements = 10019;
     const ErrLittleParamter = 10020;
+    const ErrSignParamter = 10021;
 
     const ErrSpecial = 10100;
 
@@ -214,6 +215,8 @@ class errcode //extends SplEnum
                 return '房间不支持此操作.';
             case errcode::ErrRoomAccessOp:
                 return '房间服务器不支持此access操作.';
+            case errcode::ErrSignParamter:
+                return '请求参数需要做签名.';
             default :
                 return '系统错误.';
         }

+ 63 - 1
test/TestMemberCard.php

@@ -1,4 +1,4 @@
-<?php declare(strict_types=1);
+<?php declare(strict_types=0);
 
 use PHPUnit\Framework\TestCase;
 
@@ -31,6 +31,47 @@ class TestMemberCard extends TestCase
         Base::run_util();
     }
 
+    public function testAddCardno()
+    {
+        $vr_order = Model();
+
+        $count = 1000;
+        $i = 0;
+        while (true)
+        {
+            $start = $i * $count;
+            $items = $vr_order->table('vr_order')->field('*')->order('order_id asc')->limit("{$start},{$count}")->select();
+            if(empty($items)) {
+                break;
+            }
+            $i++;
+
+            foreach ($items as $item)
+            {
+                try {
+                    if(empty($item['extra_info'])) {
+                        continue;
+                    }
+
+                    $extra_info = json_decode($item['extra_info'],true);
+                    if(empty($extra_info)) {
+                        continue;
+                    }
+                    $card_no   = $extra_info['input']['card_no'];
+                    $card_type = mtopcard\topcard_type($extra_info['input']['card_type']);
+
+                    Log::record("{$card_no} {$card_type}",Log::DEBUG);
+                    if(empty($card_no)) continue;
+
+                    $vr_order->table('vr_order')->where(['order_id' => $item['order_id']])->update(['card_no' => $card_no]);
+                }
+                catch (Exception $ex) {
+                    Log::record($ex->getMessage(),Log::DEBUG);
+                }
+            }
+        }
+    }
+
     public function testLoadTopcards()
     {
         global $config;
@@ -111,6 +152,27 @@ class TestMemberCard extends TestCase
         }
     }
 
+    public function testTime()
+    {
+        $this->month_range(time());
+        $x = strtotime(date('Y-m-d',time()));
+        $y = strtotime('+1 day',$x);
+
+        $x1 = date('Y-m-01',strtotime(date('Y-m-d')));
+        $x2 = date('Y-m-t',strtotime(date('Y-m-d')));
+        $x3 = date('Y-m-01',strtotime('-1 month'));
+        $x4 = date('Y-m-t',strtotime('-1 month'));
+
+    }
+
+    private function month_range($time)
+    {
+        $x = strtotime(date('Y-m-d',$time));
+        $x = strtotime(date('Y-m-01',$x));
+        $y = strtotime('+1 month',$x);
+        
+        return [$x,$y];
+    }
 
     public function testGetOils()
     {