UserCollect.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace app\common\model;
  3. use app\main\model\object\UserCollectObject;
  4. use app\main\service\UserCollectUpdateService;
  5. use think\Model;
  6. class UserCollect extends Model
  7. {
  8. // 表名
  9. protected $table = 'user_collect';
  10. // 开启自动写入时间戳字段
  11. protected $autoWriteTimestamp = 'int';
  12. // 定义时间戳字段名
  13. protected $createTime = 'createtime';
  14. protected $updateTime = 'updatetime';
  15. public function getTitleAttr($value, $data)
  16. {
  17. return __($value);
  18. }
  19. /**
  20. * @param $object
  21. * @return array
  22. */
  23. public function mkParamsForCheck(UserCollectObject $object)
  24. {
  25. return [
  26. 'admin_id' => $object->admin_id,
  27. 'type' => $object->type,
  28. 'createdate' => UserCollectUpdateService::instance()->getCreateDate($object->type)->data,
  29. ];
  30. }
  31. /**
  32. * @param $object
  33. * @return array
  34. */
  35. public function mkParamsForUpdate(UserCollectObject $object)
  36. {
  37. $update = $object->toArray();
  38. unset($update['admin_id']);
  39. unset($update['type']);
  40. $update['updatetime'] = time();
  41. return $update;
  42. }
  43. /**
  44. * @param $object
  45. * @return array
  46. */
  47. public function mkParamsForInsert(UserCollectObject $object)
  48. {
  49. return [
  50. 'admin_id' => $object->admin_id,
  51. 'type' => $object->type,
  52. 'createdate' => UserCollectUpdateService::instance()->getCreateDate($object->type)->data,
  53. 'updatetime' => time(),
  54. 'increase' => (int)$object->increase,
  55. 'increase_m' => (int)$object->increase_m,
  56. 'increase_f' => (int)$object->increase_f,
  57. 'increase_fllow' => (int)$object->increase_fllow,
  58. 'unfollow_num' => (int)$object->unfollow_num,
  59. 'net_follow_num' => (int)$object->net_follow_num,
  60. 'guide_follow_num' => (int)$object->guide_follow_num,
  61. 'increase_recharge' => (int)$object->increase_recharge,
  62. 'day_recharge_user_money' => (float)$object->day_recharge_user_money,
  63. 'day_recharge_user_count' => (int)$object->day_recharge_user_count,
  64. ];
  65. }
  66. }