PerfMonthList.php 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <?php
  2. namespace backendApi\modules\v1\models\lists\bonus;
  3. use common\helpers\Cache;
  4. use common\helpers\user\Info;
  5. use common\models\CalcBonusBSDefault;
  6. use common\models\PerfMonth;
  7. use common\models\User as modelUser;
  8. use common\libs\dataList\column\Price;
  9. use common\libs\dataList\DataListInterface;
  10. use common\libs\dataList\column\DateTime;
  11. use common\models\UserInfo;
  12. use Yii;
  13. class PerfMonthList extends \common\libs\dataList\DataList implements DataListInterface
  14. {
  15. /**
  16. * 列表名称
  17. * @return string
  18. */
  19. public function getListName(){
  20. return '月业绩列表';
  21. }
  22. /**
  23. * 列表筛选到的数据
  24. * @throws \yii\base\Exception
  25. */
  26. public function dataHandle()
  27. {
  28. $data = PerfMonth::lists($this->condition, $this->params, [
  29. 'select'=>'PM.*, U.USER_NAME, U.REAL_NAME,RU.USER_NAME REC_USER_NAME,RU.REAL_NAME REC_REAL_NAME',
  30. 'from' => PerfMonth::tableName().' AS PM',
  31. 'join' => [
  32. ['LEFT JOIN', modelUser::tableName() . ' AS U', 'PM.USER_ID=U.ID'],
  33. ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'PM.USER_ID=UI.USER_ID'],
  34. ['LEFT JOIN', modelUser::tableName() . ' AS RU', 'UI.REC_UID=RU.ID'],
  35. ],
  36. 'orderBy' => 'PM.CREATED_AT DESC, PM.ID DESC',
  37. 'page' => $this->page,
  38. 'pageSize' => $this->pageSize,
  39. ]);
  40. if ($data['list']) {
  41. foreach ($data['list'] as $key => $value) {
  42. $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
  43. $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
  44. }
  45. }
  46. $this->listData = $data;
  47. }
  48. /**
  49. * 要展示和导出的所有字段
  50. * @return array
  51. */
  52. public function getColumn(){
  53. if(!$this->columns){
  54. $this->columns = [
  55. 'CALC_MONTH' => [
  56. 'header' => 'Bonus Month', // 结算月
  57. 'headerOther' => [
  58. 'width' => '110',
  59. ],
  60. ],
  61. 'USER_NAME' => [
  62. 'header' => 'Member Code', // 会员编号
  63. 'headerOther' => [
  64. 'width' => '120',
  65. ],
  66. ],
  67. 'REAL_NAME' => [
  68. 'header' => 'Member Name', // 会员姓名
  69. 'headerOther' => [
  70. 'width' => '150',
  71. ],
  72. ],
  73. 'REC_USER_NAME' => [
  74. 'header' => 'Recommender No', // 推荐人编号
  75. 'headerOther' => [
  76. 'width' => '140',
  77. ],
  78. ],
  79. 'REC_REAL_NAME' => [
  80. 'header' => 'Recommender Name', // 推荐人姓名
  81. 'headerOther' => [
  82. 'width' => '160',
  83. ],
  84. ],
  85. 'LAST_DEC_LV_NAME' => [
  86. 'header' => 'PC Member Level', // 结算时会员级别
  87. 'headerOther' => [
  88. 'width' => '150',
  89. ],
  90. ],
  91. 'LAST_EMP_LV_NAME' => [
  92. 'header' => 'Director Rank', // 结算时会员聘级
  93. 'headerOther' => [
  94. 'width' => '150',
  95. ],
  96. ],
  97. 'PV_PCS' => [
  98. 'header' => 'Personal Performance', // 个人业绩
  99. 'headerOther' => [
  100. 'width' => '170',
  101. ],
  102. 'value' => function($row) {
  103. return (new Price([
  104. 'value' => $row['PV_PCS'],
  105. ]))->result();
  106. },
  107. ],
  108. 'PV_PGS' => [
  109. 'header' => 'Director PGS Performance', // 管理奖个人小组业绩
  110. 'headerOther' => [
  111. 'width' => '190',
  112. ],
  113. 'value' => function($row) {
  114. return (new Price([
  115. 'value' => $row['DIRECTOR_BONUS_PGS'],
  116. ]))->result();
  117. },
  118. ],
  119. 'VIP_PV_1L_ZC' => [
  120. 'header' => 'L. New Market Entry Performance', // 一市场新增报单业绩
  121. 'headerOther' => [
  122. 'width' => '240',
  123. ],
  124. 'value' => function($row) {
  125. return (new Price([
  126. 'value' => $row['VIP_PV_1L_ZC'],
  127. ]))->result();
  128. },
  129. ],
  130. 'VIP_PV_2L_ZC' => [
  131. 'header' => 'R. New Market Entry Performance', // 二市场新增报单业绩
  132. 'headerOther' => [
  133. 'width' => '240',
  134. ],
  135. 'value' => function($row) {
  136. return (new Price([
  137. 'value' => $row['VIP_PV_2L_ZC'],
  138. ]))->result();
  139. },
  140. ],
  141. 'VIP_SURPLUS_1L_ZC' => [
  142. 'header' => 'L. Market Monthly Remaining Declaration Performance', // 一市场月剩余报单业绩
  143. 'headerOther' => [
  144. 'width' => '370',
  145. ],
  146. 'value' => function($row) {
  147. return (new Price([
  148. 'value' => $row['VIP_SURPLUS_1L_ZC'],
  149. ]))->result();
  150. },
  151. ],
  152. 'VIP_SURPLUS_2L_ZC' => [
  153. 'header' => 'R. Market Monthly Remaining Declaration Performance', // 二市场月剩余报单业绩
  154. 'headerOther' => [
  155. 'width' => '370',
  156. ],
  157. 'value' => function($row) {
  158. return (new Price([
  159. 'value' => $row['VIP_SURPLUS_2L_ZC'],
  160. ]))->result();
  161. },
  162. ],
  163. 'PV_PSS' => [
  164. 'header' => 'Monthly New Team Performance', // 月新增团队业绩
  165. 'headerOther' => [
  166. 'width' => '230',
  167. ],
  168. 'value' => function($row) {
  169. return (new Price([
  170. 'value' => $row['PV_PSS'],
  171. ]))->result();
  172. },
  173. ],
  174. 'PV_PSS_TOTAL' => [
  175. 'header' => 'Monthly Cumulative Team Performance', // 月累计团队业绩
  176. 'headerOther' => [
  177. 'width' => '270',
  178. ],
  179. 'value' => function($row) {
  180. return (new Price([
  181. 'value' => $row['PV_PSS_TOTAL'],
  182. ]))->result();
  183. },
  184. ],
  185. 'CREATED_AT' => [
  186. 'header' => 'Creation Time', // 创建时间
  187. 'value' => function($row) {
  188. return (new DateTime([
  189. 'value' => $row['CREATED_AT'],
  190. ]))->result();
  191. },
  192. 'headerOther' => ['width' => '170'],
  193. ],
  194. ];
  195. }
  196. return $this->columns;
  197. }
  198. /**
  199. * 前台用于筛选的类型集合
  200. * @return mixed
  201. */
  202. public function getFilterTypes()
  203. {
  204. if(!$this->filterTypes){
  205. $this->filterTypes = [
  206. 'CALC_MONTH'=> ['isUserTable'=> false, 'name'=> 'Bonus Month'], // 结算月
  207. 'USER_NAME'=> ['isUserTable'=> false, 'name'=> 'Member Code'], // 会员编号
  208. 'REC_USER_NAME'=> ['isUserTable'=> false, 'name'=> 'Recommender No'], // 推荐人编号
  209. 'CREATED_AT'=> ['isUserTable'=> false, 'name'=> 'Creation Time', 'other'=> 'date'], // 创建时间
  210. ];
  211. }
  212. return $this->filterTypes;
  213. }
  214. }