| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <?php
- namespace App\Models;
- /**
- *
- */
- class Hit_code extends BaseModel {
- protected $table = "hit_code";
- public $timestamps = false;
- //获取打码量详情
- function getHitcodeDetails($value, $type = 2) {
- $key = $this->getFeild($type);
- $data = $this->where($key, $value)->first();
- if (!$data) {
- return -7012000102; //没有详情信息
- }
- return $data->toArray();
- }
- //字段对应值
- private function getFeild($num) {
- $data = array(
- '1' => 'id',
- '2' => 'account_identity',
- '3' => 'account_name',
- '4' => 'hitcode_game',
- '5' => 'hitcode_count',
- '6' => 'star_time',
- '7' => 'sort',
- );
- return $data[$num];
- }
-
- //插入数据
- function saveData($data) {
- if(!$this->checkInfo($data['account_identity'])){
- $res = $this->updateInfo($data,'account_identity',$data['account_identity']);
- return $res;
- }
- $this->account_name = $data['account_name'];
- $this->account_identity = $data['account_identity'];
- $this->star_time = $data['star_time'];
- $this->add_time = $data['add_time'];
- $res = $this->save();
- if (!$res) {
- return -7012000202; //更新失败
- }
- return $this->order_id;
- }
-
-
- /**
- * 通过用户ID选择入款初始时间
- * 'user description'
- * @return 'type' 'description'
- */
- function selectHitcodetimeById($value,$hitcode_time) {
- $account = new \App\Models\Account;
- $info = $account->getinfo($value,1);
- if($info<0){
- return $info; //用户暂无记录
- }
- $data = array(
- 'account_identity' => $info['identity'],
- 'account_name' => $info['account'],
- 'star_time' => $hitcode_time,
- 'add_time' => date('Y-m-d H:i:s',time()),
- );
-
- $res = $this->saveData($data);
- return $res;
- }
-
- /**
- * 通过用户identity选择入款初始时间
- * 'user description'
- * @return 'type' 'description'
- */
- function selectHitcodetimeByIdentity($value,$hitcode_time) {
- $account = new \App\Models\Account;
- $info = $account->getinfo($value,2);
- if($info<0){
- return $info; //用户暂无记录
- }
- $data = array(
- 'account_identity' => $info['identity'],
- 'account_name' => $info['account'],
- 'star_time' => $hitcode_time,
- 'add_time' => date('Y-m-d H:i:s',time()),
- );
-
- $res = $this->saveData($data);
- return $res;
- }
-
- //修改信息
- function updateInfo($data,$field,$value){
- $res = $this->where($field,$value)->update($data);
- if($res<0){
- return -7012000302; //操作失败
- }
- return 1;
- }
-
- //检测订单号
- function checkInfo($account_identity){
- $res=$this->where('account_identity',$account_identity)->first();
- if(!$res){
- return true;
- }
- return false;
- }
- }
- ?>
|