| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- <?php
- /**
- * Created by PhpStorm.
- * User: kaifa
- * Date: 2020-05-10
- * Time: 17:57
- */
- namespace addons\Store\common\models;
- use common\models\order\CommonOrderDetail;
- use common\models\order\PriceLog;
- use common\models\user\User;
- use addons\Store\common\models\BossLevelCommon;
- use addons\Store\common\models\Boss;
- use addons\Store\common\models\BossPriceLog;
- use addons\Store\common\models\BossLevel;
- use addons\Store\common\models\BossOrderGoodsLog;
- use addons\Store\common\models\BossPriceLogType;
- use addons\Store\common\models\BossSetting;
- use addons\Boss\common\enums\LevelEnum;
- use common\enums\StatusEnum;
- use addons\Boss\common\models\AddonsBossCommissionLog;
- use yii\data\Pagination;
- class StoreBossIncome extends BaseModel
- {
- public $keyword;
- public $id;
- public $platform;
- public $limit = 10;
- public $page = 1;
- public $sort;
- public $fields;
- public $flag;
- public $store_id = 0;
- public function rules()
- {
- return [
- [['keyword', 'platform'], 'trim'],
- [['keyword', 'platform', 'flag'], 'string'],
- [['limit', 'page','id','store_id'], 'integer'],
- [['fields'], 'safe'],
- [['sort'], 'default', 'value' => ['l.created_at' => SORT_DESC]],
- ];
- }
- /**
- * 明细列表
- * @return array
- */
- public function getList($params)
- {
- if (!$this->validate()) {
- return $this->responseErrorInfo();
- }
- // $boss_level_list = AddonsBossLevel::getBossLevel([['mall_id' => $store['mall_id']]], [],true,'level,name');
- $boss_level_list = (new \addons\Store\common\models\StoreBossLevelCommon)->getList();
- $boss_level_arr = array_column($boss_level_list, null,'level');
- $settlement_method = LevelEnum::getSettlementMethod();// 结算方式
- $compute_type = LevelEnum::getComputeType();// 佣金计算方式
- // 获取用户信息
-
- $user = User::find()->select('nickname,avatar_url')->where(['mall_id' => $params['mall_id'],'id' => $params['id']])->asArray()->one();
- $where = [];
- $where[] = ['=', 'mall_id', $params['mall_id']];
- // $where[] = ['=', 'store_id', $params['store_id']];
- $where[] = ['=', 'user_id', $params['id']];
- $where[] = ['=', 'type', $params['type']];
- $where[] = ['between', 'date', str_replace('-','',$params['start_time']), str_replace('-','',$params['end_time'])];
- $where[] = ['=', 'is_settlement', StatusEnum::ENABLED];
- $where[] = ['=', 'status', StatusEnum::ENABLED];
- $order = 'created_at desc';
- $params = array('where' => $where, 'order' => $order, 'limit' => 20);
- $list = StoreBossRewardLog::listPage($params, false, true);
-
- return [
- 'code' => 0,
- 'msg' => '获取成功',
- 'data' => [
- 'list' => $list,
- 'boss_level_arr' => $boss_level_arr,
- 'user'=>$user,
- 'settlement_method' => $settlement_method,
- 'compute_type' => $compute_type,
- ]
- ];
-
- }
- /**
- * 结算列表
- * @return array
- */
- public function getSettlementList($params)
- {
- if (!$this->validate()) {
- return $this->responseErrorInfo();
- }
- $store = \Yii::$app->session->get('o2o');
- $commonission_type = LevelEnum::getCommissionType();// 分红类型
- $compute_period = LevelEnum::getComputePeriod();// 分红周期
- $where = [];
- $where[] = ['=', 'mall_id', $store['mall_id']];
- $where[] = ['=', 'store_id', $store['id']];
- // 根据用户昵称搜索
- if (isset($params['keyword'])) {
- $where[] = ['=', 'user_id', $params['keyword']];
- // $user_id = User::find()->select('id')->where(['mall_id' => $this->mall_id,'mobile' => $params['keyword'],'status' => StatusEnum::ENABLED])->asArray()->scalar();
- // if ($user_id) $where[] = ['=', 'user_id', $user_id];
- }
- $where[] = ['=', 'status', StatusEnum::ENABLED];
- $where[] = ['in', 'source', [StoreBossRewardLog::SOURCE_ORDER_STORE,StoreBossRewardLog::SOURCE_CASHIER_STORE]];
- $order = 'created_at desc';
- $with = ['user'];
- $params = array('where' => $where, 'order' => $order, 'with' => $with, 'limit' => 20);
-
- $list = StoreBossCommissionLog::listPage($params, false, true);
- if (empty($list)){
- return [
- 'code' => 0,
- 'msg' => '',
- 'data' => []
- ];
- }
- foreach ($list['list'] as &$item) {
- $item['start_time'] = date("Y-m-d", $item['start_time']);
- $item['end_time'] = date("Y-m-d", $item['end_time']);
- }
-
- return [
- 'code' => 0,
- 'msg' => '',
- 'data' => [
- 'list' => $list,
- 'commonission_type' => $commonission_type,
- 'compute_period' => $compute_period,
-
- ]
- ];
- }
- }
|