PerfOrderList.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <?php
  2. namespace backendApi\modules\v1\models\lists\bonus;
  3. use backendApi\modules\v1\models\Admin;
  4. use backendApi\modules\v1\models\User;
  5. use common\models\Countries;
  6. use common\models\User as modelUser;
  7. use common\helpers\Cache;
  8. use common\helpers\user\Info;
  9. use common\libs\dataList\column\Price;
  10. use common\libs\dataList\column\YesNo;
  11. use common\libs\dataList\DataListInterface;
  12. use common\models\PerfOrder;
  13. use common\models\Region;
  14. use common\models\UserBind;
  15. use common\models\UserBonus;
  16. use common\models\UserInfo;
  17. use common\libs\dataList\column\DateTime;
  18. use common\models\UserSystem;
  19. use common\models\Withdraw;
  20. use Yii;
  21. class PerfOrderList extends \common\libs\dataList\DataList implements DataListInterface
  22. {
  23. /**
  24. * 列表名称
  25. * @return string
  26. */
  27. public function getListName(){
  28. return '业绩单列表';
  29. }
  30. /**
  31. * 列表筛选到的数据
  32. * @throws \yii\base\Exception
  33. */
  34. public function dataHandle()
  35. {
  36. $data = PerfOrder::lists($this->condition, $this->params, [
  37. 'select'=>'PO.*, U.USER_NAME, U.REAL_NAME, C.NAME AS COUNTRY',
  38. 'from' => PerfOrder::tableName().' AS PO',
  39. 'join' => [
  40. ['INNER JOIN', modelUser::tableName() . ' AS U', 'PO.USER_ID=U.ID'],
  41. ['INNER JOIN', Countries::tableName() . ' AS C', 'U.COUNTRY_ID=C.ID'],
  42. ],
  43. 'orderBy' => 'PO.CREATED_AT DESC, PO.ID DESC',
  44. 'page' => $this->page,
  45. 'pageSize' => $this->pageSize,
  46. ]);
  47. if($data['list']){
  48. foreach($data['list'] as $key=>$value){
  49. $data['list'][$key]['DEC_STATUS_NAME'] = PerfOrder::STATUS_NAME[$data['list'][$key]['DEC_STATUS']];
  50. }
  51. }
  52. $this->listData = $data;
  53. }
  54. /**
  55. * 要展示和导出的所有字段
  56. * @return array
  57. */
  58. public function getColumn(){
  59. if(!$this->columns){
  60. $this->columns = [
  61. 'PERIOD_NUM' => [
  62. 'header' => Yii::t('ctx', 'payCycle'), // 结算期数
  63. 'headerOther' => [
  64. 'width' => '120',
  65. ],
  66. ],
  67. 'SN' => [
  68. 'header' => Yii::t('ctx', 'salesNo'),//业绩单编号
  69. 'value' => function($row) {
  70. return "\t".$row['SN'];
  71. },
  72. 'headerOther' => [
  73. 'width' => '220',
  74. ],
  75. ],
  76. 'DEC_TYPE' => [
  77. 'header' => Yii::t('ctx', 'saleType'), // 业绩单类型
  78. 'headerOther' => [
  79. 'width' => '160',
  80. ],
  81. 'value' => function($row){
  82. $decTypes = [
  83. 'ZC'=> 'Welcome Pack Order', // 首购单
  84. 'YH'=> 'Coupon', // 优惠单
  85. 'ZG'=> 'Additional Purchase Order', // 增购单
  86. 'LS'=> 'Retail Order', // 零售单
  87. 'FX'=> 'Re Sales Order', // 复销单
  88. ];
  89. return $decTypes[strtoupper($row['DEC_TYPE'])];
  90. },
  91. ],
  92. 'DEC_STATUS_NAME' => [
  93. 'header' => Yii::t('ctx', 'saleStatus'), // 业绩单状态
  94. 'headerOther' => [
  95. 'width' => '110',
  96. ],
  97. ],
  98. 'USER_NAME' => [
  99. 'header' => Yii::t('ctx', 'memberCode'), // 会员编号
  100. 'headerOther' => [
  101. 'width' => '110',
  102. ],
  103. ],
  104. 'REAL_NAME' => [
  105. 'header' => Yii::t('ctx', 'memberName'), // 会员姓名
  106. 'headerOther' => [
  107. 'width' => '150',
  108. ],
  109. ],
  110. 'COUNTRY' => [
  111. 'header' => Yii::t('ctx', 'country'),
  112. ],
  113. 'LAST_REC_USER_NAME' => [
  114. 'header' => Yii::t('ctx', 'sponsorNoAtSettlement'), // 结算时开拓者编号
  115. 'headerOther' => [
  116. 'width' => '190',
  117. ],
  118. ],
  119. 'LAST_REC_REAL_NAME' => [
  120. 'header' => Yii::t('ctx', 'sponsorNameAtSettlement'), // 结算时开拓者姓名
  121. 'headerOther' => [
  122. 'width' => '210',
  123. ],
  124. ],
  125. 'PV' => [
  126. 'header' => Yii::t('ctx', 'entryBV'), // 报单BV
  127. 'headerOther' => [
  128. 'width' => '150',
  129. ],
  130. 'value' => function($row) {
  131. return (new Price([
  132. 'value' => $row['PV'],
  133. ]))->result();
  134. },
  135. ],
  136. 'DEC_AMOUNT' => [
  137. 'header' => Yii::t('ctx', 'entryAmount'), // 报单金额
  138. 'headerOther' => [
  139. 'width' => '150',
  140. ],
  141. 'value' => function($row) {
  142. return (new Price([
  143. 'value' => $row['DEC_AMOUNT'],
  144. ]))->result();
  145. },
  146. ],
  147. 'DEC_SN' => [
  148. 'header' => Yii::t('ctx', 'entryNo'), // 报单编号
  149. 'headerOther' => [
  150. 'width' => '250',
  151. ],
  152. ],
  153. 'FROM_TABLES' => [
  154. 'header' => Yii::t('ctx', 'orderSource'),
  155. 'headerOther' => [
  156. 'width' => '250',
  157. ],
  158. ],
  159. 'CREATED_AT' => [
  160. 'header' => Yii::t('ctx', 'createAt'), // 创建时间
  161. 'value' => function($row) {
  162. return (new DateTime([
  163. 'value' => $row['CREATED_AT'],
  164. ]))->result();
  165. },
  166. 'headerOther' => ['width' => '170'],
  167. ],
  168. ];
  169. }
  170. return $this->columns;
  171. }
  172. /**
  173. * 前台用于筛选的类型集合
  174. * @return mixed
  175. */
  176. public function getFilterTypes()
  177. {
  178. if(!$this->filterTypes){
  179. $this->filterTypes = [
  180. 'PERIOD_NUM'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'payCycle')], // 结算期数
  181. 'SN'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'salesNo')], // 业绩单编号
  182. 'DEC_STATUS_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'saleStatus'),'other'=> 'select',
  183. 'selectData'=> [['id'=> 1, 'name'=> Yii::t('ctx', 'reviewed')], ['id'=> 2, 'name'=> Yii::t('ctx', 'wastedisposal')]],], // 业绩单状态,已审核,置废
  184. 'USER_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'memberCode')], // 会员编号
  185. 'REAL_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'memberName')], // 会员姓名
  186. 'LAST_REC_USER_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'sponsorNoAtSettlement')], // 结算时开拓者编号
  187. 'LAST_REC_REAL_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'sponsorNameAtSettlement')], // 结算时开拓者姓名
  188. 'PV'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'entryBV')], // 报单BV
  189. 'DEC_AMOUNT'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'entryAmount')], // 报单金额
  190. 'DEC_SN'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'entryNo')], // 报单编号
  191. 'CREATED_AT'=> ['isUserTable'=> true, 'name'=> Yii::t('ctx', 'createAt'), 'other'=> 'date'], // 创建时间
  192. ];
  193. }
  194. return $this->filterTypes;
  195. }
  196. }