| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- namespace addons\WechatVideoShop\backend\controllers;
- use addons\WechatVideoShop\common\models\WechatVideoShopCommission;
- use addons\WechatVideoShop\common\service\CommissionService;
- use addons\WechatVideoShop\common\service\ShopService;
- use common\enums\DownloadEnum;
- use common\helpers\csv\CsvExportHelper;
- class CommissionController extends BaseController
- {
- public $enableCsrfValidation = false;
- public function actionIndex()
- {
- if (\Yii::$app->request->isAjax) {
- if (\Yii::$app->request->isGet) {
- $data = \Yii::$app->request->get();
- $valid = \Yii::$app->services->validate->validate($data, [
- [['page', 'limit', 'shop_id', 'user_id', 'settle_status'], 'integer'],
- [['member', 'mobile', 'date_start', 'date_end'], 'string'],
- ], []);
- if ($valid === false) return $this->error(\Yii::$app->services->validate->getErrorMessage());
- // 获取数据
- $ret = (new CommissionService())->page($this->mall_id, $data);
- // 获取所有店铺键值对
- $ret['shop'] = (new ShopService())->ShopArr($this->mall_id);
- $ret['export_list'] = WechatVideoShopCommission::exportFieldsList();
- return $this->success('获取成功', $ret);
- }
- if (\Yii::$app->request->post('flag') == 'EXPORT') {
- $post = \Yii::$app->request->post();
- $post['mall_id'] = $this->mall_id;
- $filename = '微信视频号小店分销员奖励明细列表-' . date('YmdHis') . '_' . rand(10000, 99999);
- $res = CsvExportHelper::exportDownLoadCenter($this->mall_id, $filename, DownloadEnum::TYPE_WECHAT_VIDEO_SHOP, WechatVideoShopCommission::class, 'exportHandle', $post);
- if ($res === false) return $this->error('加入导出任务失败' . CsvExportHelper::getStaticError());
- return $this->success('添加导出任务成功,任务完成后请在下载中心进行下载!');
- }
- }
- return $this->render('index');
- }
- }
|