PerfMonthList.php 8.9 KB

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