|
@@ -4,8 +4,6 @@ declare(strict_types=0);
|
|
|
|
|
|
defined('InShopNC') or exit('Access Invalid!');
|
|
defined('InShopNC') or exit('Access Invalid!');
|
|
|
|
|
|
-use mtopcard;
|
|
|
|
-
|
|
|
|
class topcardModel extends Model
|
|
class topcardModel extends Model
|
|
{
|
|
{
|
|
public function add($card_no,$card_type,$add_time)
|
|
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)
|
|
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;
|
|
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();
|
|
}
|
|
}
|
|
}
|
|
}
|