Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 

107 rindas
2.3 KiB

  1. <?php
  2. namespace common\models;
  3. use Yii;
  4. use yii\db\Expression;
  5. /**
  6. * This is the model class for table "fx_user_qrcode".
  7. *
  8. * @property integer $id
  9. * @property integer $fx_uid
  10. * @property integer $qr_id
  11. */
  12. class FxUserQrcode extends \yii\db\ActiveRecord
  13. {
  14. /**
  15. * @inheritdoc
  16. */
  17. public static function tableName()
  18. {
  19. return 'fx_user_qrcode';
  20. }
  21. /**
  22. * @inheritdoc
  23. */
  24. public function rules()
  25. {
  26. return [
  27. [['fx_uid', 'qr_id'], 'integer'],
  28. [['qr_id'], 'unique'],
  29. ];
  30. }
  31. /**
  32. * @inheritdoc
  33. */
  34. public function attributeLabels()
  35. {
  36. return [
  37. 'id' => 'ID',
  38. 'fx_uid' => 'Fx Uid',
  39. 'qr_id' => 'Qr ID',
  40. ];
  41. }
  42. /**
  43. * Des:根据qrId获取详细
  44. * Name: getInfoByQrId
  45. * @param $qrCodeId
  46. * @return array|null|\yii\db\ActiveRecord
  47. * @author 倪宗锋
  48. */
  49. public function getInfoByQrId($qrCodeId)
  50. {
  51. $where = ['=', 'qr_id', $qrCodeId];
  52. $select = ['fx_uid', 'qr_id'];
  53. $getInfo = self::find()->select($select)
  54. ->where($where)
  55. ->asArray()
  56. ->one();
  57. return $getInfo;
  58. }
  59. /**
  60. * Des:添加新记录
  61. * Name: addNew
  62. * @param $qrCodeId
  63. * @return bool
  64. * @author 倪宗锋
  65. */
  66. public function addNew($qrCodeId)
  67. {
  68. $params = [
  69. 'qr_id' => $qrCodeId,
  70. 'fx_uid' => 0
  71. ];
  72. $this->setAttributes($params);
  73. $return = $this->insert(false);
  74. return $return;
  75. }
  76. /**
  77. * Des:获取所有列表数据
  78. * Name: getList
  79. * @return array|\yii\db\ActiveRecord[]
  80. * @author 倪宗锋
  81. */
  82. public function getList()
  83. {
  84. $select = [
  85. 'a.fx_uid',
  86. 'a.qr_id',
  87. 'img_url' => new Expression("concat('/web/fx/images/FxQrCode/',a.qr_id,'.jpg')"),
  88. 'nickname' => new Expression("if(b.nickname is null,'未设置',concat(b.nickname,' - ',b.phone))")
  89. ];
  90. $getList = self::find()->select($select)
  91. ->from(static::tableName().' a')
  92. ->leftJoin(FxUser::tableName().' b','a.fx_uid = b.uid')
  93. ->asArray()
  94. ->all();
  95. return $getList;
  96. }
  97. }