Instalment.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace common\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "{{%ORDER}}".
  6. *
  7. * @property string $ID
  8. * @property string $USER_ID 用户ID
  9. * @property string $ORDER_TYPE 订单类型:BD, FX
  10. * @property string $STAGE 分期阶段
  11. * @property int $UPDATE_TIME 修改时间
  12. */
  13. class Instalment extends \common\components\ActiveRecord
  14. {
  15. /**
  16. * {@inheritdoc}
  17. */
  18. public static function tableName()
  19. {
  20. return '{{%INSTALMENT}}';
  21. }
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function rules()
  26. {
  27. return [
  28. ];
  29. }
  30. /**
  31. * @param $userId
  32. * @return integer
  33. */
  34. public static function getStage($userId) {
  35. $user = static::findOneAsArray("USER_ID = :USER_ID", [':USER_ID' => $userId]);
  36. if(!$user){
  37. return 0;
  38. }
  39. return $user['STAGE'];
  40. }
  41. /**
  42. * @param $userId
  43. * @param $orderType
  44. * @return integer
  45. */
  46. public static function getOneStage($userId, $orderType) {
  47. $user = static::findOneAsArray("USER_ID = :USER_ID AND ORDER_TYPE=:ORDER_TYPE", [':USER_ID' => $userId, ':ORDER_TYPE' => $orderType]);
  48. if(!$user){
  49. return 0;
  50. }
  51. return $user['STAGE'];
  52. }
  53. public static function getInfo($userId) {
  54. $userInfo = static::findOneAsArray("USER_ID = :USER_ID", [':USER_ID' => $userId]);
  55. if(!$userInfo){
  56. return [
  57. ];
  58. }
  59. return $userInfo;
  60. }
  61. }