255], [['keyword'], 'trim'], ]; } public function search() { if (!$this->validate()) { return [ 'code' => 1, 'msg' => $this->getErrorSummary(false)[0] ]; } $saas_user_id = 0; if ((int)$this->is_daili === 1) { $admin = get_admin(); $saas_user_id = $admin->saas_user_id; $SaasUser = SaasUser::findOne($saas_user_id); } $query = SaasProfitCash::find()->alias('spc') ->leftJoin(['su' => SaasUser::tableName()],'su.id=spc.user_id')->where(['spc.is_delete' => 0]); if (!empty($saas_user_id)) { $query->andWhere(['spc.user_id' => $saas_user_id]); } // 名称 if ($this->name) { $query->andWhere(['like', 'su.name', $this->name]); } // 手机号 if ($this->mobile) { $query->andWhere(['like', 'spc.mobile', $this->mobile]); } // 提现方式 if ((int)$this->type !== -1 && $this->type !== null && $this->type !== '') { $query->andWhere(['spc.type' => $this->type]); } // 状态 if ((int)$this->status !== -1 && $this->status !== null) { $query->andWhere(['spc.status' => $this->status]); } $query->orderBy('spc.created_at DESC, spc.updated_at DESC') ->groupBy('spc.order_no') ->select('spc.*, su.name, su.avatar, su.name'); $list = pagination_make($query); foreach ($list['list'] as &$val) { $val['created_at'] = date('Y-m-d H:i:s', $val['created_at']); $val['updated_at'] = date('Y-m-d H:i:s', $val['updated_at']); } return [ 'code' => 0, 'msg' => 'success', 'data' => [ 'data' => $list['list'], 'pageNo' => $list['pageNo'], 'totalCount' => $list['totalCount'], 'share_profit' => $SaasUser->share_profit ?? '0.00' ] ]; } /** * 联盟佣金提现审核 * @return array * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException * @throws \GuzzleHttp\Exception\GuzzleException */ public function audit() { $cash = SaasProfitCash::findOne(['is_delete' => 0, 'id' => $this->id, 'status' => SaasProfitCash::CASH_STATUS_WAIT]); if (!$cash) { return [ 'code' => 1, 'msg' => '记录不存在' ]; } // 拒绝 if ($this->status == SaasProfitCash::CASH_STATUS_FAIL) { $saas_user = SaasUser::findOne($cash->user_id); $saas_user->share_profit = (($saas_user->share_profit * 1) + ($cash->amount * 1) + ($cash->service_money * 1)); $saas_user->save(); $cash->status = SaasProfitCash::CASH_STATUS_FAIL; $cash->refuse_reason = !empty($this->reason) ? trim($this->reason) : ''; if (!$cash->save()) { return [ 'code' => 1, 'msg' => implode(';', array_values($cash->firstErrors)) ]; } return [ 'code' => 0, 'msg' => '操作成功' ]; } // 通过 if ($this->status == SaasProfitCash::CASH_STATUS_PASS) { $cash->status = SaasProfitCash::CASH_STATUS_PASS; if (!$cash->save()) { return [ 'code' => 1, 'msg' => implode(';', array_values($cash->firstErrors)) ]; } $form = new StoreShareMoney(); $form->user_id = $cash->user_id; $form->store_id = 0; $form->profit = 0; $form->total_price = $cash->amount; $form->desc = "用户提现"; $form->order_id = $cash->id; $form->created_at = time(); $form->status = StoreShareMoney::STATUS_STORE_PAYOUTS; $form->commission = 0; if (!$form->save()) { return [ 'code' => 1, 'msg' => implode(';', array_values($form->firstErrors)) ]; } return [ 'code' => 0, 'msg' => '操作成功' ]; } return [ 'code' => 1, 'msg' => '操作异常' ]; } public function del() { try { $id = $this->id; $cash = SaasProfitCash::findOne($id); if (!$cash) { throw new \Exception("查找失败"); } $cash->is_delete = 1; if (get_saas_user_id()) { throw new \Exception("身份信息错误"); } if (!$cash->save()) { throw new \Exception(json_encode($cash->errors)); } return [ 'code' => 0, 'msg' => "操作成功" ]; } catch (\Exception $e) { return [ 'code' => 1, 'msg' => '操作异常' . $e->getMessage() ]; } } }