12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <?php
- namespace app\common\model;
- use app\main\model\object\UserCollectObject;
- use app\main\service\UserCollectUpdateService;
- use think\Model;
- class UserCollect extends Model
- {
- // 表名
- protected $table = 'user_collect';
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- public function getTitleAttr($value, $data)
- {
- return __($value);
- }
- /**
- * @param $object
- * @return array
- */
- public function mkParamsForCheck(UserCollectObject $object)
- {
- return [
- 'admin_id' => $object->admin_id,
- 'type' => $object->type,
- 'createdate' => UserCollectUpdateService::instance()->getCreateDate($object->type)->data,
- ];
- }
- /**
- * @param $object
- * @return array
- */
- public function mkParamsForUpdate(UserCollectObject $object)
- {
- $update = $object->toArray();
- unset($update['admin_id']);
- unset($update['type']);
- $update['updatetime'] = time();
- return $update;
- }
- /**
- * @param $object
- * @return array
- */
- public function mkParamsForInsert(UserCollectObject $object)
- {
- return [
- 'admin_id' => $object->admin_id,
- 'type' => $object->type,
- 'createdate' => UserCollectUpdateService::instance()->getCreateDate($object->type)->data,
- 'updatetime' => time(),
- 'increase' => (int)$object->increase,
- 'increase_m' => (int)$object->increase_m,
- 'increase_f' => (int)$object->increase_f,
- 'increase_fllow' => (int)$object->increase_fllow,
- 'unfollow_num' => (int)$object->unfollow_num,
- 'net_follow_num' => (int)$object->net_follow_num,
- 'guide_follow_num' => (int)$object->guide_follow_num,
- 'increase_recharge' => (int)$object->increase_recharge,
- 'day_recharge_user_money' => (float)$object->day_recharge_user_money,
- 'day_recharge_user_count' => (int)$object->day_recharge_user_count,
- ];
- }
- }
|