$mall_id], ['status' => StatusEnum::ENABLED], ]; if (!empty($params['user_id'])) { $where[] = ['user_id' => $params['user_id']]; } if (!empty($params['mobile'])) { $uids = User::find() ->where(['mall_id' => $mall_id]) ->andWhere(['or', ['like', 'username', $params['mobile']], ['like', 'mobile', $params['mobile']], ['like', 'nickname', $params['mobile']]]) ->select('id') ->column(); if (empty($uids)) return []; $where[] = ['user_id' => $uids]; } if (!empty($params['settle_status'])) { $where[] = ['settle_status' => $params['settle_status']]; } if (!empty($params['date_start'])) $where[] = ['>=', 'created_at', strtotime($params['date_start'])]; if (!empty($params['date_end'])) $where[] = ['<=', 'created_at', strtotime($params['date_end'])]; $ret = WechatVideoShopCommission::listPage([ 'where' => $where, 'order' => 'id desc', 'limit' => $params['limit'] ?? 10, 'with' => ['user', 'buyUser'] ]); if (!empty(WechatVideoShopCommission::getStaticError())) return WechatVideoShopCommission::getStaticError(); return $ret; } /** * @param Order $order * @return bool * @throws \Exception */ public function create(Order $order) { // 这里是创建分佣 $model = new WechatVideoShopCommission(); $model->mall_id = $order->mall_id; $model->user_id = $order->mall_id; $model->buy_user_id = $order->mall_id; $model->order_no = $order->mall_id; $model->order_id = $order->mall_id; $model->order_amount = $order->mall_id; $model->remark = $order->mall_id; $model->settle_status = $order->mall_id; $model->commission = $order->mall_id; $model->commission_type = $order->mall_id; $model->shop_id = 0; if (!$model->save()) throw new \Exception($model->getErrorMessage()); return true; } }