|
@@ -93,7 +93,17 @@ class refill_balance
|
|
|
$time_types = $this->find_timetypes($type,$cid);
|
|
|
foreach ($time_types as $time_type)
|
|
|
{
|
|
|
- [$parent_id,$start] = $this->find_parent($type, $cid, $time_type);
|
|
|
+ [$parent_id,$start,$confirmed] = $this->find_parent($type, $cid, $time_type);
|
|
|
+ if($start == $end) {
|
|
|
+ Log::record("type=$type cid=$cid, time_type=$time_type has been stat.",Log::DEBUG);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if($parent_id > 0 && $confirmed == false) {
|
|
|
+ Log::record("type=$type cid=$cid, time_type=$time_type had not confirmed.",Log::DEBUG);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
$ret = $this->add_balance($type, $cid, $start, $end, $time_type, $parent_id);
|
|
|
if(!$ret) {
|
|
|
Log::record("type=$type cid=$cid, time_type=$time_type fail",Log::ERR);
|
|
@@ -106,11 +116,13 @@ class refill_balance
|
|
|
private function find_parent($type, $cid, $time_type)
|
|
|
{
|
|
|
$mod = Model('refill_balance');
|
|
|
- $cond = ['type' => $type, 'cid' => $cid, 'time_type' => $time_type, 'confirmed' => 1];
|
|
|
+ $cond = ['type' => $type, 'cid' => $cid, 'time_type' => $time_type];
|
|
|
+
|
|
|
+ $item = $mod->field('balance_id,end_stamp,confirmed')->where($cond)->order('end_stamp desc')->find();
|
|
|
|
|
|
- $item = $mod->field('balance_id,end_stamp')->where($cond)->order('end_stamp desc')->find();
|
|
|
+ $confirmed = boolval($item['confirmed']);
|
|
|
|
|
|
- return [intval($item['balance_id']),intval($item['end_stamp'])];
|
|
|
+ return [intval($item['balance_id']), intval($item['end_stamp']), $confirmed];
|
|
|
}
|
|
|
|
|
|
private function refill_time_finder($type, $cid, $start,$end)
|