BalanceList.php 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <?php
  2. namespace backendApi\modules\v1\models\lists\bonus;
  3. use backendApi\modules\v1\models\Admin;
  4. use common\helpers\user\Info;
  5. use common\libs\dataList\column\Price;
  6. use common\libs\dataList\column\YesNo;
  7. use common\libs\dataList\DataListInterface;
  8. use common\models\User;
  9. use common\models\UserBind;
  10. use common\models\UserBonus;
  11. use common\models\UserInfo;
  12. use common\libs\dataList\column\DateTime;
  13. use common\models\UserWallet;
  14. use common\models\Withdraw;
  15. use Yii;
  16. class BalanceList extends \common\libs\dataList\DataList implements DataListInterface
  17. {
  18. /**
  19. * 列表名称
  20. * @return string
  21. */
  22. public function getListName(){
  23. return '会员奖金余额列表';
  24. }
  25. /**
  26. * 列表筛选到的数据
  27. * @throws \yii\base\Exception
  28. */
  29. public function dataHandle()
  30. {
  31. $this->condition .= ' AND UI.STATUS=1 AND I.LAST_LOGIN_AT>=1620748800';
  32. $this->listData = UserBonus::lists($this->condition, $this->params, [
  33. 'select' => 'UB.*,UI.*,UW.CASH',
  34. 'from' => UserBonus::tableName() . ' AS UB',
  35. 'join' => [
  36. // ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'UI.USER_ID=UB.USER_ID'],
  37. ['LEFT JOIN', User::tableName() . ' AS UI', 'UI.ID=UB.USER_ID'],
  38. ['LEFT JOIN', UserWallet::tableName() . ' AS UW', 'UW.USER_ID=UB.USER_ID'],
  39. ['LEFT JOIN', UserInfo::tableName() . ' AS I', 'I.USER_ID=UB.USER_ID']
  40. ],
  41. 'orderBy' => 'UB.CREATED_AT ASC, UB.ID ASC',
  42. 'page' => $this->page,
  43. 'pageSize' => $this->pageSize,
  44. ]);
  45. }
  46. /**
  47. * 要展示和导出的所有字段
  48. * @return array
  49. */
  50. public function getColumn(){
  51. if(!$this->columns){
  52. $this->columns = [
  53. 'USER_ID' => null, // 这种传输方式主要是用于索引,因为过滤后的字段可能没有这种ID,但是一些功能的操作还需要用这种ID去关联,例如前台会员列表中的勾选批量状态管理,这里需要的就是USER_ID
  54. 'USER_NAME' => [
  55. 'header' => 'Member Code', // 会员编号
  56. 'headerOther' => [
  57. 'width' => '150',
  58. ],
  59. 'valueOther' => [
  60. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border']
  61. ],
  62. ],
  63. 'REAL_NAME' => [
  64. 'header' => 'Member Name', // 会员姓名
  65. 'headerOther' => [
  66. 'width' => '120',
  67. ],
  68. 'valueOther' => [
  69. 'tag'=>['type'=>'success', 'size' => 'small', 'class'=>'no-border']
  70. ],
  71. ],
  72. 'IS_DEC' => [
  73. 'header' => 'Whether Stockist', // 是否报单中心
  74. 'value' => function($row) {
  75. return (new YesNo([
  76. 'value' => $row['IS_DEC'],
  77. ]))->result();
  78. },
  79. 'headerOther' => function($row) {
  80. return [
  81. 'width' => '200',
  82. ];
  83. },
  84. 'valueOther' => function($row) {
  85. return [
  86. 'tag'=>['type'=>(isset($row['IS_DEC']) && $row['IS_DEC'] )? 'success' : 'info', 'size' => 'small']
  87. ];
  88. },
  89. ],
  90. 'BONUS' => [
  91. 'header' => 'Member Bonus', // 会员奖金余额
  92. 'value' => function($row) {
  93. return (new Price([
  94. 'value' => $row['BONUS'],
  95. ]))->result();
  96. },
  97. 'headerOther' => [
  98. 'width' => '150',
  99. 'prop'=>'BONUS',
  100. ],
  101. 'valueOther' => [
  102. 'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
  103. ],
  104. ],
  105. 'CASH' => [
  106. 'header' => 'Member Ecoin', // 会员余额
  107. 'value' => function($row) {
  108. return (new Price([
  109. 'value' => $row['CASH'],
  110. ]))->result();
  111. },
  112. 'headerOther' => [
  113. 'width' => '150',
  114. 'prop'=>'BONUS',
  115. ],
  116. 'valueOther' => [
  117. 'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
  118. ],
  119. ],
  120. 'TOURISM_POINTS' => [
  121. 'header' => 'Travel Incentive', // 旅游积分
  122. 'value' => function($row) {
  123. return (new Price([
  124. 'value' => $row['TOURISM_POINTS'],
  125. ]))->result();
  126. },
  127. 'headerOther' => [
  128. 'width' => '150',
  129. 'prop'=>'TOURISM_POINTS',
  130. ],
  131. 'valueOther' => [
  132. 'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
  133. ],
  134. ],
  135. 'GARAGE_POINTS' => [
  136. 'header' => 'Car Incentive', // 车积分
  137. 'value' => function($row) {
  138. return (new Price([
  139. 'value' => $row['GARAGE_POINTS'],
  140. ]))->result();
  141. },
  142. 'headerOther' => [
  143. 'width' => '150',
  144. 'prop'=>'GARAGE_POINTS',
  145. ],
  146. 'valueOther' => [
  147. 'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
  148. ],
  149. ],
  150. 'VILLA_POINTS' => [
  151. 'header' => 'Villa Incentive', // 房积分
  152. 'value' => function($row) {
  153. return (new Price([
  154. 'value' => $row['VILLA_POINTS'],
  155. ]))->result();
  156. },
  157. 'headerOther' => [
  158. 'width' => '150',
  159. 'prop'=>'VILLA_POINTS',
  160. ],
  161. 'valueOther' => [
  162. 'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
  163. ],
  164. ],
  165. 'PERIOD_AT' => [
  166. 'header' => 'Joining Period', // 加入期数
  167. 'headerOther' => ['width' => '110'],
  168. ],
  169. 'MOBILE' => [
  170. 'header' => 'Phone Number', // 手机号码
  171. 'value' => function($row) {
  172. return "\t".$row['MOBILE'];
  173. },
  174. 'headerOther' => ['width' => '120'],
  175. ],
  176. 'TEL' => [
  177. 'header' => 'Alternate Phone Number', // 备用手机号码
  178. 'value' => function($row) {
  179. return "\t".$row['TEL'];
  180. },
  181. 'headerOther' => ['width' => '180'],
  182. ],
  183. ];
  184. }
  185. return $this->columns;
  186. }
  187. /**
  188. * 前台用于筛选的类型集合
  189. * @return mixed
  190. */
  191. public function getFilterTypes()
  192. {
  193. if(!$this->filterTypes){
  194. $this->filterTypes = [
  195. 'USER_NAME'=> ['isUserTable'=> false, 'name'=> 'Member Code'], // 会员编号
  196. 'REAL_NAME'=> ['isUserTable'=> false, 'name'=> 'Member Name'], // 会员姓名
  197. 'IS_DEC'=> ['isUserTable'=> false, 'name'=> 'Whether Stockist', 'other'=> 'yesOrNo'], // 是否报单中心
  198. 'BONUS'=> ['isUserTable'=> false, 'name'=> 'Member Bonus'], // 会员奖金余额
  199. 'CASH'=> ['isUserTable'=> false, 'name'=> 'Member Ecoin'], // 会员余额
  200. 'PERIOD_AT'=> ['isUserTable'=> false, 'name'=> 'Joining Period'], // 加入期数
  201. 'MOBILE'=> ['isUserTable'=> false, 'name'=> 'Phone Number'], // 手机号码
  202. 'TEL'=> ['isUserTable'=> false, 'name'=> 'Alternate Phone Number'], // 备用手机号码
  203. ];
  204. }
  205. return $this->filterTypes;
  206. }
  207. }