stanley-king 4 년 전
부모
커밋
71f5529f72
8개의 변경된 파일102개의 추가작업 그리고 37개의 파일을 삭제
  1. 12 11
      admin/control/merchant.php
  2. 18 14
      data/config/dev/refill.ini.php
  3. 42 3
      mobile/control/merchant_info.php
  4. 1 1
      mobile/control/merchant_order.php
  5. 17 6
      racc/control/lzrefill.php
  6. 5 0
      test/TestDispatcher.php
  7. 2 2
      test/TestRedis.php
  8. 5 0
      test/TestTime.php

+ 12 - 11
admin/control/merchant.php

@@ -1031,9 +1031,9 @@ class merchantControl extends SystemControl
     private function speed_key($type,$form)
     {
         if ($type == 1) {
-            $rkey = $form . '_oil' . '_speed_limit';
+            $rkey = "channel-ctl-oil-{$form}-limit";
         }elseif ($type == 2) {
-            $rkey = $form . '_phone' . '_speed_limit';
+            $rkey = "channel-ctl-phone-{$form}-limit";
         }else {
             showMessage('类型有误', "index.php?act=merchant&op=provider");
         }
@@ -1050,12 +1050,14 @@ class merchantControl extends SystemControl
         $type_data = $type_data[$type-1];
         $amounts = [];
         if($type == 1) {
-            $amounts = $config['oil_refill_specs'];
+            $amounts = $config['refill_oil_specs'];
         }
         if($type == 2) {
-            $amounts = $config['phone_refill_specs'];
+            $amounts = $config['refill_phone_specs'];
         }
-        foreach ($type_text as $key => $value) {
+
+        foreach ($type_text as $key => $value)
+        {
             foreach ($amounts as $amount)
             {
                 $data['text'] = $value . '-' . $amount;
@@ -1093,13 +1095,12 @@ class merchantControl extends SystemControl
             $hours = intval($minutes / 60);
             $result = "{$minute}m{$second}s";
         }
-        else {
-            if($minutes > 0){
-                $result = "{$minutes}m{$second}s";
-            }else{
-                $result = "{$second}s";
-            }
+        elseif($minutes > 0) {
+            $result = "{$minutes}m{$second}s";
+        } else {
+            $result = "{$second}s";
         }
+
         if(isset($hours))
         {
             $result = "{$hours}h{$minute}m";

+ 18 - 14
data/config/dev/refill.ini.php

@@ -66,17 +66,18 @@
 //
 //$config['phone_providers'] = $phone_providers;
 
-define('ZERO_GOODS_ID',6245);
+define('ZERO_GOODS_ID', 6245);
+
+$config['refill_oil_specs'] = [100, 200, 500, 1000, 2000];
+$config['refill_phone_specs'] = [10, 20, 30, 50, 100, 200, 300, 500];
 
-$config['refill_oil_specs'] = [100 , 200 , 500 , 1000 , 2000];
-$config['refill_phone_specs'] = [10 , 20 , 30 , 50 , 100 , 200 , 300 , 500];
 //充值额度基本表
 $config['refill_specs'] = [
-    'petrochina'    => $config['refill_oil_specs'],
-    'sinopec'       => $config['refill_oil_specs'],
-    'chinamobile'   => $config['refill_phone_specs'],
-    'chinaunicom'   => $config['refill_phone_specs'],
-    'chinatelecom'  => $config['refill_phone_specs']
+    'petrochina' => $config['refill_oil_specs'],
+    'sinopec' => $config['refill_oil_specs'],
+    'chinamobile' => $config['refill_phone_specs'],
+    'chinaunicom' => $config['refill_phone_specs'],
+    'chinatelecom' => $config['refill_phone_specs']
 ];
 
 
@@ -84,12 +85,15 @@ $config['refill_specs'] = [
 $oil_providers = [];
 $config['oil_providers'] = $oil_providers;
 
-$baidu_phone = ['name' => 'baidu', 'store_id' => 8, 'card_type' => ['chinamobile', 'chinaunicom', 'chinatelecom'],
-    'amount' => [10 => ['goods_id' => 6245, 'price' => 9.51],
-        20 => ['goods_id' => 6247, 'price' => 19.02],
-        30 => ['goods_id' => 6249, 'price' => 28.53],
-        50 => ['goods_id' => 6250, 'price' => 47.55],
-        100 => ['goods_id' => 6251, 'price' => 95.1]],
+$baidu_phone = ['name' => 'baidu', 'store_id' => 8,
+    'amount' => [
+        10 => [['goods_id' => 6245, 'price' => 9.51,  'card_type' => 'chinaunicom'],
+            ['goods_id' => 6245, 'price' => 9.81,  'card_type' => 'chinamobile']],
+        20 => [['goods_id' => 6247, 'price' => 19.02, 'card_type' => 'chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 6249, 'price' => 28.53, 'card_type' => 'chinamobile,chinatelecom']],
+        50 => [['goods_id' => 6250, 'price' => 47.55, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 =>[['goods_id' => 6251, 'price' => 95.1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+    ],
     'official_sn' => true, 'refill_type' => 'api'];
 $phone_providers = [
     ['name' => 'baidu', 'cfg' => $baidu_phone, 'opened' => true, 'sort' => 1]];

+ 42 - 3
mobile/control/merchant_info.php

@@ -30,9 +30,14 @@ class merchant_infoControl extends mbMerchantControl
         } else {
             $merchant_info['warning_phone'] = unserialize($merchant_info['warning_phone']);
         }
-        $cond['add_time'] = ['between', [strtotime(date("Y-m-d",time())), time()]];
+
         $cond['status'] = $cond['is_operation'] = 2;
         $cond['mchid'] = $mchid;
+        $stats = Model('')->table('refill_evidence')
+            ->field('sum(amount) as amounts')
+            ->where($cond)->select();
+        $merchant_info['evidence_amounts'] = empty($stats) ? 0 : $stats[0]['amounts'];
+        $cond['add_time'] = ['between', [strtotime(date("Y-m-d",time())), time()]];
         $day_evidence = $model_merchant->getRefillEvidence($cond);
         $merchant_info['evidence_count'] = count($day_evidence);
         return self::outsuccess($merchant_info);
@@ -67,6 +72,9 @@ class merchant_infoControl extends mbMerchantControl
             }
         }
         $result['max'] = ceil($max * 1.1);
+        $week_month_stats = $this->refillStats();
+        $result['month'] = $week_month_stats['month'];
+        $result['week'] = $week_month_stats['week'];
         return self::outsuccess($result);
     }
 
@@ -141,23 +149,54 @@ class merchant_infoControl extends mbMerchantControl
 
     private function refillCountDispose($stats)
     {
-        $result['count'] = $result['sendCount'] = $result['errorCount'] = $result['successCount'] = $result['amountCount'] = 0;
+        $result['count'] = $result['sendCount'] = $result['errorCount'] = $result['successCount'] = $result['amountCount'] = $result['errorAmounts'] = $result['successAmounts'] = 0;
         foreach ($stats as $count) {
             $result['count'] += $count['order_count'];
+            $result['amountCount'] += $count['mch_amounts'];
             if($count['order_state'] == ORDER_STATE_SEND) {
                 $result['sendCount'] = $count['order_count'];
             }
             if($count['order_state'] == ORDER_STATE_CANCEL) {
                 $result['errorCount'] = $count['order_count'];
+                $result['errorAmounts'] = $count['mch_amounts'];
             }
             if($count['order_state'] == ORDER_STATE_SUCCESS) {
                 $result['successCount'] = $count['order_count'];
-                $result['amountCount'] = $count['mch_amounts'];
+                $result['successAmounts'] = $count['mch_amounts'];
             }
         }
         return $result;
     }
 
+    private function refillStats()
+    {
+        $reader = function ($mchid,$time,$end_time) {
+            $cond['mchid'] = $mchid;
+            $cond['inner_status'] = 0;
+            $cond['refill_order.order_time'] = ['between', [$time, $end_time]];
+
+            $items = Model('')->table('refill_order,vr_order')->join('inner')
+                ->on('refill_order.order_id=vr_order.order_id')
+                ->field('count(*) as order_count, vr_order.order_state, sum(mch_amount) as mch_amounts')
+                ->group('order_state')
+                ->where($cond)->select();
+
+            return $this->refillCountDispose($items);
+        };
+        $date = date("Y-m-d");
+        $first = 1;
+        $w = date('w',strtotime($date)); ;
+        $week_start = strtotime(date('Y-m-d',strtotime("$date -".($w ? $w - $first : 6).' days')));
+        $week_end = strtotime(date('Y-m-d',strtotime("$week_start +7 days"))) - 1;
+        $week = $reader($this->mchid(), $week_start,$week_end);
+
+        $month_start = strtotime(date("Y-m-1"));
+        $month_end = strtotime(date("Y-m-1",strtotime("+1month")))-1;
+        $month = $reader($this->mchid(), $month_start, $month_end);
+
+        return ['week' => $week , 'month' => $month];
+    }
+
     public function addipOp()
     {
         $mchid = $this->mchid();

+ 1 - 1
mobile/control/merchant_order.php

@@ -117,7 +117,7 @@ class merchant_orderControl extends mbMerchantControl
             if($order['channel_name'] != 'bjb') {
                 $order['ch_trade_no'] = '';
             }
-            if($order['is_retrying'] == 1) {
+            if($order['ying'] == 1) {
                 $order['order_state'] = 'retrying';
             }
             if ($order['order_state'] == ORDER_STATE_NEW || $order['order_state'] == ORDER_STATE_PAY) {

+ 17 - 6
racc/control/lzrefill.php

@@ -45,7 +45,20 @@ class lzrefillControl extends lzbaseControl
             return -9;
         }
 
-        //todo 增加时间判断
+        if(empty($params['tim'])) {
+            return -9;
+        }
+
+        $tim = strtotime($params['tim']);
+        if($tim === false) {
+            return -9;
+        }
+
+        $cur = time();
+        $start = strtotime(date('Y-m-d',$cur - 1800));
+        if($tim < $start || $tim > $cur + 1800) {
+            return -9;
+        }
 
         return true;
     }
@@ -143,21 +156,21 @@ class lzrefillControl extends lzbaseControl
         $order_sn = $_GET['ord']; //用户方的订单号,对应数据库中的mch_order
 
         if(empty($order_sn)) {
-            return self::outerr(201);
+            return self::outerr(-9,$this->available);
         }
 
         $mod_refill = Model('refill_order');
         $refill_info = $mod_refill->getOrderInfo(['mch_order' => $order_sn,'mchid' => $mchid,'inner_status' => 0]);
 
         if(empty($refill_info)) {
-            return self::outerr(201,"无此订单");
+            return self::outerr(-6,$this->available);
         }
 
         $vr_order = Model('vr_order');
         $order_info = $vr_order->getOrderInfo(['order_sn' => $refill_info['order_sn']]);
 
         if(empty($order_info)) {
-            return self::outerr(201,"无此交易号");
+            return self::outerr(-6,$this->available);
         }
 
         if($order_info['order_state'] == ORDER_STATE_SEND) {
@@ -165,8 +178,6 @@ class lzrefillControl extends lzbaseControl
         }
 
         $result = $this->format($order_info,$refill_info);
-
         return self::outsuccess($result);
     }
-
 }

+ 5 - 0
test/TestDispatcher.php

@@ -101,4 +101,9 @@ class TestDispatcher extends TestCase
         $x = MASTER_DBHOST . 'xxx';
     }
 
+    public function testPolicy()
+    {
+        $key = "common_phone_speed_";
+    }
+
 }

+ 2 - 2
test/TestRedis.php

@@ -36,9 +36,9 @@ class TestRedis extends TestCase
         $key = '100905';
         $ins = Cache::getInstance('cacheredis');
         $ret = $ins->incr($key);
-        $ret = $ins->incrby($key,6);
+        $ret = $ins->incrby($key, 6);
         $ret = $ins->decr($key);
-        $ret = $ins->decrby($key,10);
+        $ret = $ins->decrby($key, 10);
         $ret = $ins->get_org($key);
         $ret = $ins->get_org('yyyyyyxxxx');
     }

+ 5 - 0
test/TestTime.php

@@ -28,6 +28,10 @@ class TestTime extends TestCase
     public function testS()
     {
         $date = date('Y-m-d H:i:S',1517399862);
+        $x = time();
+        $date = date('YmdHis',$x);
+        $date = strtotime($date);
+
 
         $tm  = strtotime('2017-08-01 3:43:00');
         $tm1 = strtotime('2017-8-01 3:43:00');
@@ -38,6 +42,7 @@ class TestTime extends TestCase
         $tm3 = strtotime('2017-8-1 3:43:00');
         $tm3 = strtotime('2017-8-1  3:43');
     }
+
     public function testDay()
     {
         $date = date('Y-m-d',time());