|
@@ -7,6 +7,8 @@
|
|
|
*
|
|
|
*/
|
|
|
|
|
|
+use refill\PolicyUtil;
|
|
|
+
|
|
|
defined('InShopNC') or exit('Access Invalid!');
|
|
|
|
|
|
require_once (BASE_ROOT_PATH . '/helper/message/publisher.php');
|
|
@@ -443,8 +445,10 @@ class minutesControl extends BaseCronControl
|
|
|
while (true)
|
|
|
{
|
|
|
try {
|
|
|
- $this->_stat_util();
|
|
|
+ $this->_update_earlist_send();
|
|
|
$this->_calc_arrears();
|
|
|
+ $this->_update_mixed_cfg();
|
|
|
+
|
|
|
} catch (Exception $ex) {
|
|
|
Log::record($ex->getMessage(), Log::ERR);
|
|
|
}
|
|
@@ -453,9 +457,9 @@ class minutesControl extends BaseCronControl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private function _stat_util()
|
|
|
+ private function _update_earlist_send()
|
|
|
{
|
|
|
- //查找最早的充值中的单子
|
|
|
+ //查找最早的充值中的订单时间
|
|
|
// $update_earliest_ordertime = function () {
|
|
|
// $mod = Model('refill_detail');
|
|
|
// $time = $mod->getEarliestSendTime();
|
|
@@ -463,6 +467,7 @@ class minutesControl extends BaseCronControl
|
|
|
// };
|
|
|
// $update_earliest_ordertime();
|
|
|
|
|
|
+ //按各个机构,更新最早的充值中的订单时间
|
|
|
$update_earliest_ordertime_bymerchant = function () {
|
|
|
$mod = Model('refill_detail');
|
|
|
$mtimes = $mod->getEarliestSendTimeByMerchant();
|
|
@@ -612,6 +617,62 @@ class minutesControl extends BaseCronControl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private function _update_mixed_cfg()
|
|
|
+ {
|
|
|
+ $read_cfg = function ($cfg)
|
|
|
+ {
|
|
|
+ $lower_ratio = $cfg['lower_ratio'] ?? [];
|
|
|
+ if (empty($lower_ratio)) {
|
|
|
+ [$ratio, $period] = [0.0, 3600];
|
|
|
+ } else {
|
|
|
+ [$ratio, $period] = [$lower_ratio['ratio'], $lower_ratio['period']];
|
|
|
+ }
|
|
|
+
|
|
|
+ $profit_ratio = $cfg['profit_ratio'] ?? 0.0;
|
|
|
+ $profit_formula = $cfg['profit_formula'] ?? 'qts';
|
|
|
+
|
|
|
+ return ['ratio' => $ratio, 'period' => $period, 'profit_ratio' => $profit_ratio, 'profit_formula' => $profit_formula];
|
|
|
+ };
|
|
|
+
|
|
|
+ $mch_configs = function () use ($read_cfg)
|
|
|
+ {
|
|
|
+ $result = [];
|
|
|
+
|
|
|
+ $i = 0;
|
|
|
+ while (true)
|
|
|
+ {
|
|
|
+ $start = $i * 100;
|
|
|
+ $items = Model()->table('merchant')->where(['mchid' => ['gt', 0], 'merchant_state' => 1])->field('mchid,retry_times_cfg,quality')->order('mchid asc')->limit("{$start},100")->select();
|
|
|
+ if(empty($items)) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ $i++;
|
|
|
+
|
|
|
+ foreach ($items as $item)
|
|
|
+ {
|
|
|
+ $mchid = intval($item['mchid']);
|
|
|
+ $quality = intval($item['quality']);
|
|
|
+ if($mchid <= 0 || $quality <= 0) continue;
|
|
|
+ if (!PolicyUtil::mixed_quality($quality)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ $retry_times_cfg = unserialize($item['retry_times_cfg']);
|
|
|
+ if(empty($retry_times_cfg)) continue;
|
|
|
+
|
|
|
+
|
|
|
+ $result[$mchid] = $read_cfg($retry_times_cfg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $result;
|
|
|
+ };
|
|
|
+
|
|
|
+ $result = $mch_configs();
|
|
|
+ $val = json_encode($result);
|
|
|
+ wkcachex('stat-merchant-mixed', $val, 'refill-');
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 执行通用任务
|
|
|
*/
|