UserBonus.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <?php
  2. namespace common\models;
  3. use common\helpers\user\Info;
  4. use Yii;
  5. use common\libs\logging\operate\valueType\Config as ValueTypeConfig;
  6. /**
  7. * This is the model class for table "{{%USER_BONUS}}".
  8. *
  9. * @property string $ID
  10. * @property string $USER_ID 会员ID
  11. * @property string $BONUS 奖金总额
  12. * @property string $BONUS_FREEZE 奖金冻结部分
  13. * @property string $CF 车房养老奖
  14. * @property string $LX 领袖分红奖
  15. * @property string $TOURISM_POINTS 旅游积分
  16. * @property string $GARAGE_POINTS 车房积分
  17. * @property string $QY_TOTAL 区域津贴累计
  18. * @property string $YC_TOTAL 育成津贴累计
  19. * @property string $VIP_TOTAL VIP奖金累计
  20. * @property string $FX_TOTAL 复销奖累计
  21. * @property string $LS_TOTAL 零售奖累计
  22. * @property string $FW_TOTAL 区级店业绩提成累计
  23. * @property string $BT_TOTAL 店补累计
  24. * @property string $BT_PROD_TOTAL 产品补贴累计
  25. * @property string $BT_TOOL_TOTAL 工具流补贴累计
  26. * @property string $CF_TOTAL 车房养老奖累计
  27. * @property string $LX_TOTAL 领袖分红累计
  28. * @property string $DEDUCT_ZR_TOTAL 责任业绩扣除累计
  29. * @property string $FL_TOTAL 形象店货补累计
  30. * @property string $TOURISM_POINTS_TOTAL 旅游积分累积
  31. * @property string $GARAGE_POINTS_TOTAL 车奖积分累积
  32. * @property string $VILLA_POINTS_TOTAL 房奖积分累积
  33. * @property int $VER 乐观锁标识
  34. * @property int $CREATED_AT 创建时间
  35. * @property int $BD_TOTAL 服务奖累计
  36. * @property int $TG_TOTAL 推广奖累计
  37. * @property int $YJ_TOTAL 业绩奖累计
  38. * @property int $GX_TOTAL 共享奖累计
  39. * @property int $GL_TOTAL 管理奖累计
  40. * @property int $ORI_QY_TOTAL 团队奖原奖金累计
  41. * @property int $ORI_YC_TOTAL 荣衔奖原奖金累计
  42. * @property int $ORI_VIP_TOTAL VIP奖原奖金累计
  43. * @property int $ORI_BD_TOTAL 服务奖原奖金累计
  44. * @property int $ORI_TG_TOTAL 推广奖原奖金累计
  45. * @property int $ORI_YJ_TOTAL 业绩奖原奖金累计
  46. * @property int $ORI_GX_TOTAL 共享奖原奖金累计
  47. * @property int $ORI_GL_TOTAL 管理奖原奖金累计
  48. * @property int $RECONSUME_POINTS 复消积分
  49. * @property int $RECONSUME_POINTS_EXPIRED 复消积分过期
  50. * @property int $RECONSUME_POINTS_TOTAL 复消积分累计
  51. * @property int $MANAGE_TAX 管理费累计
  52. * @property int $BONUS_TOTAL 总奖金累计
  53. */
  54. class UserBonus extends \common\components\ActiveRecord
  55. {
  56. const TYPE = BalanceAudit::TYPE;
  57. /**
  58. * {@inheritdoc}
  59. */
  60. public static function tableName()
  61. {
  62. return '{{%USER_BONUS}}';
  63. }
  64. /**
  65. * {@inheritdoc}
  66. */
  67. public function rules()
  68. {
  69. return [
  70. [['USER_ID', 'CREATED_AT'], 'required'],
  71. [['BS_TOTAL','ORI_BS_TOTAL','BS','BONUS', 'BONUS_FREEZE', 'CF', 'LX', 'QY_TOTAL', 'YC_TOTAL', 'VIP_TOTAL', 'FX_TOTAL', 'LS_TOTAL', 'FW_TOTAL', 'BT_TOTAL', 'BT_PROD_TOTAL', 'BT_TOOL_TOTAL', 'CF_TOTAL', 'LX_TOTAL', 'DEDUCT_ZR_TOTAL', 'FL_TOTAL', 'BD_TOTAL','TG_TOTAL','YJ_TOTAL','GX_TOTAL','GL_TOTAL', 'ORI_QY_TOTAL','ORI_YC_TOTAL','ORI_YC_TOTAL','ORI_BD_TOTAL','ORI_TG_TOTAL','ORI_YJ_TOTAL','ORI_GX_TOTAL','ORI_GL_TOTAL','RECONSUME_POINTS','MANAGE_TAX', 'RECONSUME_POINTS_EXPIRED', 'RECONSUME_POINTS_TOTAL', 'BONUS_TOTAL', 'TOURISM_POINTS', 'GARAGE_POINTS', 'VILLA_POINTS'], 'number'],
  72. [['VER', 'CREATED_AT'], 'integer'],
  73. [['ID','USER_ID'], 'string', 'max' => 32],
  74. [['USER_ID'], 'unique'],
  75. ];
  76. }
  77. /**
  78. * {@inheritdoc}
  79. */
  80. public function attributeLabels()
  81. {
  82. return [
  83. 'ID' => 'ID',
  84. 'USER_ID' => '会员ID',
  85. 'BONUS' => '奖金总额',
  86. 'BONUS_FREEZE' => '奖金冻结部分',
  87. 'CF' => '车房养老奖',
  88. 'LX' => '领袖分红奖',
  89. 'QY_TOTAL' => '区域津贴累计',
  90. 'YC_TOTAL' => '育成津贴累计',
  91. 'VIP_TOTAL' => 'VIP奖金累计',
  92. 'FX_TOTAL' => '复销奖累计',
  93. 'LS_TOTAL' => '零售奖累计',
  94. 'FW_TOTAL' => '服务奖累计',
  95. 'BT_TOTAL' => '店补累计',
  96. 'BT_PROD_TOTAL' => '产品补贴累计',
  97. 'BT_TOOL_TOTAL' => '工具流补贴累计',
  98. 'CF_TOTAL' => '车房养老奖累计',
  99. 'LX_TOTAL' => '领袖分红累计',
  100. 'DEDUCT_ZR_TOTAL' => '责任业绩扣除累计',
  101. 'FL_TOTAL' => '形象店货补累计',
  102. 'VER' => '乐观锁标识',
  103. 'CREATED_AT' => '创建时间',
  104. 'BD_TOTAL'=> '服务奖累计',
  105. 'TG_TOTAL'=> '推广奖累计',
  106. 'YJ_TOTAL'=> '业绩奖累计',
  107. 'GX_TOTAL'=> '共享奖累计',
  108. 'GL_TOTAL'=> '管理奖累计',
  109. 'ORI_QY_TOTAL' => '团队奖原奖金累计',
  110. 'ORI_YC_TOTAL' => '荣衔奖原奖金累计',
  111. 'ORI_VIP_TOTAL' => 'VIP奖原奖金累计',
  112. 'ORI_BD_TOTAL' => '服务奖原奖金累计',
  113. 'ORI_TG_TOTAL' => '推广奖原奖金累计',
  114. 'ORI_YJ_TOTAL' => '业绩奖原奖金累计',
  115. 'ORI_GX_TOTAL' => '共享奖原奖金累计',
  116. 'ORI_GL_TOTAL' => '管理奖原奖金累计',
  117. 'RECONSUME_POINTS' => '复消积分',
  118. 'RECONSUME_POINTS_TOTAL' => '复消积分累计',
  119. 'RECONSUME_POINTS_EXPIRED' => '复消积分过期',
  120. 'MANAGE_TAX' => '管理费累计',
  121. 'BONUS_TOTAL' => '总奖金累计',
  122. 'BS' => '蓝星奖(即新的管理奖)',
  123. 'BS_TOTAL' => '蓝星(管理)累计',
  124. 'ORI_BS_TOTAL' => '蓝星原奖金累计',
  125. 'TOURISM' => '旅游积分',
  126. 'TOURISM_TOTAL' => '旅游积分累计',
  127. 'GARAGE' => '车奖积分',
  128. 'GARAGE_TOTAL' => '车奖积分累计',
  129. 'VILLA' => '房奖积分',
  130. 'VILLA_TOTAL' => '房奖积分累计',
  131. ];
  132. }
  133. /**
  134. * 操作日志记录条件
  135. * @return array
  136. */
  137. public function attrLabelsWithLogType(){
  138. return [
  139. 'USER_ID' => '会员ID',
  140. 'BONUS' => '会员账户',
  141. 'CF' => '车房养老奖',
  142. 'LX' => '领袖分红奖',
  143. 'TOURISM' => '旅游积分',
  144. 'GARAGE' => '车奖积分',
  145. 'VILLA' => '房奖积分',
  146. ];
  147. }
  148. /**
  149. * 乐观锁
  150. * @return string
  151. */
  152. public function optimisticLock()
  153. {
  154. return 'VER';
  155. }
  156. /**
  157. * 获取一名会员的余额
  158. * @param $userId
  159. * @return array|null
  160. */
  161. public static function getBonusByUserId($userId){
  162. $data = UserBonus::findOneAsArray('USER_ID=:USER_ID', [':USER_ID'=>$userId], 'USER_ID,BONUS,CF,LX');
  163. if(!$data){
  164. $data = [
  165. 'USER_ID' => $userId,
  166. 'BONUS' => 0,
  167. 'CF' => 0,
  168. 'LX' => 0,
  169. 'TOURISM' => 0,
  170. 'GARAGE' => 0,
  171. 'VILLA' => 0,
  172. ];
  173. }
  174. return $data;
  175. }
  176. }