ayHaru пре 4 година
родитељ
комит
273345af97

+ 1 - 0
admin/control/merchant.php

@@ -245,6 +245,7 @@ class merchantControl extends SystemControl
             {
                 $mchid = intval($merchant['mchid']);
                 $amount_lock = \refill\util::get_amount_lock($mchid);
+                Log::record("mchid: {$mchid}, amount_lock: {$amount_lock}", Log::DEBUG);
                 $result['mchid'] = $mchid;
                 if (!empty($amount_lock)) {
                     $result['amount'] = $amount_lock;

+ 2 - 2
admin/templates/default/css/login.css

@@ -73,7 +73,7 @@ box-shadow: 0 2px 3px 0 rgba(0,0,0,.1) inset;
 input:-moz-placeholder { color: #fff; }
 input:-ms-input-placeholder { color: #fff; }
 input::-webkit-input-placeholder { color: #fff; }
-input:focus { filter:progid:DXImageTransform.Microsoft.gradient(enabled='true',startColorstr='#3F000000', endColorstr='#3F000000');background:rgba(0,0,0,0.25);
+input:focus { filter:progid:DXImageTransform.Microsoft.gradient(enabled=true,startColorstr='#3F000000', endColorstr='#3F000000');background:rgba(0,0,0,0.25);
     outline: none; border-color: rgba(255,255,255,0.5);
     -moz-box-shadow:
         0 2px 3px 0 rgba(0,0,0,.1) inset,
@@ -187,7 +187,7 @@ input:focus { filter:progid:DXImageTransform.Microsoft.gradient(enabled='true',s
 }
 
 .progress-bar-success {
-  filter:progid:DXImageTransform.Microsoft.gradient(enabled='true',startColorstr='#E5FFFFFF', endColorstr='#E5FFFFFF');background:rgba(255,255,255,0.9);
+  filter:progid:DXImageTransform.Microsoft.gradient(enabled=true,startColorstr='#E5FFFFFF', endColorstr='#E5FFFFFF');background:rgba(255,255,255,0.9);
 }
 
 .progress-striped .progress-bar-success {

+ 1 - 1
admin/templates/default/css/skin_0.css

@@ -1227,7 +1227,7 @@ span.module-assembly-html { background-position: -490px -1040px;}
 .special-goods-list dd.taobao-item-delete { font-size: 0; line-height: 0; background: url(../images/sky/bg_position.gif) no-repeat -250px -640px; display: none; width: 9px; height: 9px; position: absolute; z-index: 9; top: 0; right: 0; cursor: pointer;}
 .special-goods-list dl:hover dd.taobao-item-delete { display: block}
 .special-hot-point { position: relative; z-index: 1;}
-.special-hot-point div { font-size: 16px; font-weight: 600; font-style: italic; line-height: 24px; color: #000000; text-shadow: 1px 1px 0 rgba(255,255,255,0.75); text-indent: 10px; filter:progid:DXImageTransform.Microsoft.gradient(enabled='true',startColorstr='#5900FF00', endColorstr='#5900FF00'); background:rgba(0,255,0,0.35); border-color: #F00;}
+.special-hot-point div { font-size: 16px; font-weight: 600; font-style: italic; line-height: 24px; color: #000000; text-shadow: 1px 1px 0 rgba(255,255,255,0.75); text-indent: 10px; filter:progid:DXImageTransform.Microsoft.gradient(enabled=true,startColorstr='#5900FF00', endColorstr='#5900FF00'); background:rgba(0,255,0,0.35); border-color: #F00;}
 .hot-point-list li { display: block; padding: 5px; clear: both; position: relative; z-index: 1; border: solid 2px #FFF; margin-bottom: 5px;}
 .hot-point-list li:hover { border-color: #F30;}
 .hot-point-list li i { background: url(../images/select.gif) no-repeat 0 0; vertical-align: middle; display: inline-block; width: 16px; height: 16px; margin-right: 6px;}

+ 4 - 1
admin/templates/default/oil.amount.lock.php

@@ -109,7 +109,9 @@
             </ul>
         </div>
     </div>
+
     <div class="fixed-empty"></div>
+
     <form id="price_form" enctype="multipart/form-data" method="post">
         <input type="hidden" name="form_submit" value="ok"/>
         <table class="table tb-type2 tableFixed">
@@ -171,7 +173,8 @@
             </tbody>
             <tfoot>
             <tr class="tfoot">
-                <td colspan="15"><a href="JavaScript:void(0);" class="btn" id="submitBtn"><span><?php echo $lang['nc_submit']; ?></span></a></td>
+                <td colspan="15"><a href="JavaScript:void(0);" class="btn"
+                                    id="submitBtn"><span><?php echo $lang['nc_submit']; ?></span></a></td>
             </tr>
             </tfoot>
         </table>

+ 1 - 1
crontab/control/minutes.php

@@ -51,7 +51,7 @@ class minutesControl extends BaseCronControl
             if($available_pd < $alarm_pd || $available_pd < 10000)
             {
                 $counts =  $mch_cache['send_count'];
-                if(($mch_cache['last_time'] + 300 < time()) && $counts < 5) {
+                if(($mch_cache['last_time'] + 300 < time()) && $counts < 2) {
                     $mch_cache = ['last_time' => time(), 'send_count' => $counts + 1];
                     foreach ($phones as $phone) {
                         if(!empty($phone)){

+ 3 - 4
helper/refill/RefillBase.php

@@ -112,7 +112,7 @@ class RefillBase
                 if(!empty($refill_info))
                 {
                     util::incr_notify($chname, $card_type, $spec, $quality, false);
-                    util::decr_amount_lock($refill_info['mchiid'],$card_type,$refill_info['refill_amount']);
+                    util::incr_amount_lock($refill_info['mchid'],$card_type,$refill_info['refill_amount']);
 
                     $logic_vr_order->changeOrderStateCancel($order_info, '', "{$chname}接口回调通知失败,正在重试");
 
@@ -134,7 +134,7 @@ class RefillBase
             }
             else {
                 util::incr_notify($chname, $card_type, $spec, $quality, false);
-                util::decr_amount_lock($refill_info['mchiid'],$card_type,$refill_info['refill_amount']);
+                util::incr_amount_lock($refill_info['mchid'],$card_type,$refill_info['refill_amount']);
 
                 $logic_vr_order->changeOrderStateCancel($order_info, '', "{$chname}接口回调通知失败,不可重试.");
             }
@@ -353,7 +353,7 @@ class RefillBase
             {
                 //提交成功
                 util::incr_commit($channel_name,$card_type,$amount,$quality,true);
-                util::incr_amount_lock($mchid,$card_type,$amount);
+                util::decr_amount_lock($mchid,$card_type,$amount);
                 $trade_no = $errmsg;
                 if ($provider->refill_type() == 'api') {
                     $logic_vr_order = Logic("vr_order");
@@ -374,7 +374,6 @@ class RefillBase
             else {
                 //提交失败
                 util::incr_commit($channel_name,$card_type,$amount,$quality,false);
-                util::decr_amount_lock($mchid,$card_type,$amount);
 
                 Log::record("channel:{$channel_name} err:{$errmsg}");
                 $logic_vr_order = Logic("vr_order");

+ 4 - 7
helper/refill/api/lingzh/legou/RefillPhone.php

@@ -151,14 +151,11 @@ class RefillPhone extends refill\IRefillPhone
     /**
      * 获取毫秒级别的时间戳
      */
-    private static function getMillisecond()
+    private function getMillisecond()
     {
-        //获取毫秒的时间戳
-        $time = explode ( " ", microtime () );
-        $time = $time[1] . ($time[0] * 1000);
-        $time2 = explode( ".", $time );
-        $time = $time2[0];
-        return $time;
+        $cur = microtime (true);
+        $cur = intval($cur * 1000);
+        return $cur;
     }
 
     private function encryptWithOpenssl($data = '')

+ 2 - 3
helper/refill/api/lingzh/riying/RefillCallBack.php

@@ -34,11 +34,10 @@ class RefillCallBack implements refill\IRefillCallBack
         if (empty($order_info)) {
             return [false, false, false,false];
         }
-        $order_id = $order_info['order_id'];
-        
-        $data['official_sn'] = strtolower($params['VoucherContent']) == 'null' ? '' : $params['VoucherContent'];
 
+        $order_id = $order_info['order_id'];
         if ($status === 4) {
+            $data['official_sn'] = strtolower($params['VoucherContent']) == 'null' ? '' : $params['VoucherContent'];
             Model('refill_order')->edit($order_id, $data);
             return [$order_id, true, false,true];
         }

+ 8 - 10
helper/refill/api/lingzh/riying/RefillPhone.php

@@ -41,14 +41,15 @@ class RefillPhone extends refill\IRefillPhone
         else
         {
             Log::record($resp, Log::DEBUG);
+
             $resp = json_decode($resp ,true);
             if (empty($resp)) {
                 return [false, '系统错误', true];
-            }
-            if($resp['Code'] == 10012) {
+            } elseif ($resp['Code'] == 10012) {
                 return [true, $resp['SysOrderId'], false];
+            } else {
+                return [false, $resp['Message'], false];
             }
-            return [false , $resp['Message'], false];
         }
     }
 
@@ -97,13 +98,10 @@ class RefillPhone extends refill\IRefillPhone
     /**
      * 获取毫秒级别的时间戳
      */
-    private static function getMillisecond()
+    private function getMillisecond()
     {
-        //获取毫秒的时间戳
-        $time = explode ( " ", microtime () );
-        $time = $time[1] . ($time[0] * 1000);
-        $time2 = explode( ".", $time );
-        $time = $time2[0];
-        return $time;
+        $cur = microtime (true);
+        $cur = intval($cur * 1000);
+        return $cur;
     }
 }

+ 1 - 0
helper/refill/api/lingzh/riying/config.php

@@ -4,6 +4,7 @@
 namespace refill\riying;
 
 use mtopcard;
+
 class config
 {
     const ORDER_URL = 'http://139.196.182.200:8080/order/v1.0/Pay.ashx';

+ 4 - 7
helper/refill/api/xyz/qiucheng/RefillPhone.php

@@ -98,13 +98,10 @@ class RefillPhone extends refill\IRefillPhone
     /**
      * 获取毫秒级别的时间戳
      */
-    private static function getMillisecond()
+    private function getMillisecond()
     {
-        //获取毫秒的时间戳
-        $time = explode ( " ", microtime () );
-        $time = $time[1] . ($time[0] * 1000);
-        $time2 = explode( ".", $time );
-        $time = $time2[0];
-        return $time;
+        $cur = microtime (true);
+        $cur = intval($cur * 1000);
+        return $cur;
     }
 }

+ 4 - 7
helper/refill/api/xyz/tongy/RefillPhone.php

@@ -106,14 +106,11 @@ class RefillPhone extends refill\IRefillPhone
     /**
      * 获取毫秒级别的时间戳
      */
-    private static function getMillisecond()
+    private function getMillisecond()
     {
-        //获取毫秒的时间戳
-        $time = explode ( " ", microtime () );
-        $time = $time[1] . ($time[0] * 1000);
-        $time2 = explode( ".", $time );
-        $time = $time2[0];
-        return $time;
+        $cur = microtime (true);
+        $cur = intval($cur * 1000);
+        return $cur;
     }
 
 }

+ 1 - 1
helper/refill/api/xyz/wantong/RefillCallBack.php

@@ -36,8 +36,8 @@ class RefillCallBack implements refill\IRefillCallBack
         if (empty($order_info)) {
             return [false, false, false,false];
         }
+
         $order_id = $order_info['order_id'];
-        
         $data['official_sn'] = strtolower($params['out_order_id']) == 'null' ? '' : $params['out_order_id'];
 
         if ($status === 1) {

+ 4 - 2
helper/refill/api/xyz/wantong/RefillPhone.php

@@ -22,7 +22,7 @@ class RefillPhone extends refill\IRefillPhone
         $params['orderid'] = $order_sn;
         $params['price'] = $amount;
         $params['teltype'] = $this->phone_type($phone);
-        $params['timeout'] = 7200;
+        $params['timeout'] = config::NotifyTimeout;
         $params['notify'] = config::NOTIFY_URL;
         $params['time'] = time();
         $params['rand'] = rand(100000, 999999);
@@ -72,6 +72,7 @@ class RefillPhone extends refill\IRefillPhone
         {
             Log::record($resp, Log::DEBUG);
             $resp = json_decode($resp, true);
+
             if (empty($resp)) {
                 return [false, '系统错误'];
             }
@@ -89,6 +90,7 @@ class RefillPhone extends refill\IRefillPhone
                 } else {
                     return [false, $resp['data']];
                 }
+
                 return [true, $order_state];
             }
             else {
@@ -113,7 +115,7 @@ class RefillPhone extends refill\IRefillPhone
             return 0;
         } elseif ($card_type == mtopcard\ChinaUnicomCard) {
             return 1;
-        } elseif ($card_type == mtopcard\ChinaTelecomCard) {
+        } else { // ($card_type == mtopcard\ChinaTelecomCard)
             return 2;
         }
     }

+ 1 - 0
helper/refill/api/xyz/wantong/config.php

@@ -12,4 +12,5 @@ class config
     const MCHID = 10037;
     const KEY = '7ad5f64b90f7f02a30fbd26641195f58';
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/refill_wantong.php";
+    const NotifyTimeout = 7200;
 }

+ 2 - 2
helper/refill/policy/quaility.php

@@ -38,7 +38,7 @@ class Quality
     public function find_quality($mchid,$card_type,$quality,$times,$used_time): array
     {
         if($card_type == mtopcard\ChinaMobileCard || $card_type == mtopcard\ChinaUnicomCard || $card_type == mtopcard\ChinaTelecomCard) {
-            return $this->mobile_quality($mchid,$quality,$times,$used_time);
+            return $this->mobile_quality($mchid, $quality, $times, $used_time);
         }
         elseif($card_type == mtopcard\PetroChinaCard || $card_type == mtopcard\SinopecCard) {
             return [1, [1]];
@@ -73,7 +73,7 @@ class Quality
         elseif(array_key_exists($quality,$this->mQualities)) {
             $org = $quality;
             $qualities = $this->mQualities[$quality];
-            [$sucdess,$setting_quality,$time_out] = $this->mMchctl->getCtls($mchid);
+            [$sucdess, $setting_quality, $time_out] = $this->mMchctl->getCtls($mchid);
         }
         else {
             Log::record("find_quality: cannot find any quality",Log::DEBUG);

+ 4 - 3
helper/refill/policy/xyz/policy.php

@@ -36,6 +36,7 @@ class policy extends ProviderManager implements IPolicy
 
         $turn_name = 'oil_amount_lock_turn';
         $this->mAmountLockTurn = rkcache($turn_name);
+        Log::record("AmountLockTurn = {$this->mAmountLockTurn}",Log::DEBUG);
     }
 
 
@@ -120,11 +121,11 @@ class policy extends ProviderManager implements IPolicy
 
     public function allow($mchid,$card_type,$amount,$quality) : bool
     {
-        if($this->mAmountLockTurn) {
-            return util::get_amount_lock($mchid) > 0;
+        if(empty($this->mAmountLockTurn)) {
+            return true;
         }
         else {
-            return true;
+            return util::get_amount_lock($mchid) > 0;
         }
     }
 

+ 2 - 2
helper/refill/util.php

@@ -37,13 +37,13 @@ class util
             } else {
                 $latest = current($result);
                 $cur = time();
-                $success = ($cur - $latest) > 120;
+                $success = ($cur - $latest) > 2;
 
                 if ($success) {
                     wcache("card_expired", [$card_no => time()], '');
                 }
 
-                return [$success, $latest + 120 - $cur];
+                return [$success, $latest + 2 - $cur];
             }
         } else {
             return [true, 0];

+ 6 - 2
helper/refill_proxy.php

@@ -17,13 +17,17 @@ class refill_proxy
         $params['sign'] = md5($body);
 
         $resp = $this->http_request($url,$params,'POST');
-        if($resp === false) {
+        if(empty($resp)) {
             return [false,'网络错误'];
         }
 
         $resp = json_decode($resp,true);
         $code = $resp['code'];
-        if($resp['code'] == 200) {
+
+        if(empty($resp)) {
+            return [false,'网络错误'];
+        }
+        elseif($code == 200) {
             return [$code,'success'];
         }
         else {

+ 17 - 0
test/TestRedis.php

@@ -198,10 +198,27 @@ class TestRedis extends TestCase
 
         $short_no = substr('1000115100002086143',-6);
 
+        $x = 'http://www.sina.com.cn';
+        $y = urlencode($x);
 
 
     }
 
+    public function testMillsec()
+    {
+        //获取毫秒的时间戳
+        $cur = microtime (true);
+        $cur = intval($cur * 1000);
+
+        $time = explode ( " ", microtime () );
+
+        $time = $time[1] . ($time[0] * 1000);
+        $time2 = explode( ".", $time );
+        $time = $time2[0];
+
+        return $time;
+    }
+
     public static function tearDownAfterClass() : void
     {