'选择项', ]; } //删除 public function delete() { if (!$this->validate()) { return $this->getModelError(); } $t = \Yii::$app->db->beginTransaction(); foreach ($this->ids as $item) { $model = StoreUser::findOne([ 'id' => $item, 'is_delete' => 0, ]); if ($model == null) { return Model::asReturnError('该账号不存在或已被清理'); } if ($model->is_delete == 1) { continue; } $model->is_delete = 1; $model->deleted_at = time(); if (!$model->save()) { $t->rollBack(); return Model::getModelErrorInfo($model); } $user = User::findOne(['id' => $model->user_id]); if ($user != null) { $user->type = 0; if (!$user->save()) { $t->rollBack(); return Model::getModelErrorInfo($user); } } if ($model->user_type == '1') { $admin = \Yii::$app->db->createCommand()->update(Admin::tableName(), ['is_delete' => 1], ['user_id' => $model->user_id, 'is_delete' => 0])->execute(); $role = RoleUser::updateAll(['is_delete' => 1], ['is_delete' => 0, 'user_id' => $model->user_id, 'cx_mch_id' => 0]); } } $t->commit(); return Model::asReturnSuccess('操作成功'); } //正常 public function statusYes() { if (!$this->validate()) { return $this->getModelError(); } $t = \Yii::$app->db->beginTransaction(); foreach ($this->ids as $item) { $model = StoreUser::findOne([ 'id' => $item, 'is_delete' => 0, // 'status' => 1, ]); if ($model == null) { return Model::asReturnError('该账号不存在或已被清理'); } if ($model->status == 1) { continue; } $model->status = 1; $model->updated_at = time(); if (!$model->save()) { $t->rollBack(); return Model::getModelErrorInfo($model); } } $t->commit(); return Model::asReturnSuccess('操作成功'); } //拒绝 public function statusNo() { if (!$this->validate()) { return $this->getModelError(); } $t = \Yii::$app->db->beginTransaction(); foreach ($this->ids as $item) { $model = StoreUser::findOne([ 'id' => $item, 'is_delete' => 0, // 'status' => 0, ]); if ($model == null) { return Model::asReturnError('该账号不存在或已被清理'); } if ($model->status == 2) { continue; } $model->status = 2; $model->updated_at = time(); if (!$model->save()) { $t->rollBack(); return Model::getModelErrorInfo($model); } } $t->commit(); return Model::asReturnSuccess('操作成功'); } //店长审核成功短信 public function actionStoreMakeSendYesSms() { $find = StoreMake::findOne([ 'id' => $this->id, ]); if(empty($find)){ return Model::asReturnError('暂无数据'); } $find_user = User::findOne([ 'id' => $find->id, ]); $find_store = Store::findOne([ 'id' => $find->store_id, ]); // 发送短信 $sms_sender = new SmsMsgHelper(0); $tpl_type = SmsTpl::getTplKey(1); $date = date('m-d 08:00',$find->make_time); $end_date = date('m-d 07:59',$find->make_time+60*60*24); $res = $sms_sender->sender($find_user->mobile_phone, $tpl_type, $find_user->mobile_prefix, $find_user->id,[ 'store' => $find_store->name, 'location' => $find_store->region.$find_store->location_detail, 'date1' => $date, 'date2' => $end_date, 'phone' => $find_store->store_mobile, ]); // 变更状态 $find->is_send_sms = 1; $find->save(); return Model::asReturnSuccess('操作成功',$res); } //店长审核失败短信 public function actionStoreMakeSendNoSms() { $find = StoreMake::findOne([ 'id' => $this->id, ]); if(empty($find)){ return Model::asReturnError('暂无数据'); } // 发送短信 $find_user = User::findOne([ 'id' => $find->user_id, ]); $find_store = Store::findOne([ 'id' => $find->store_id, ]); // 发送短信 $sms_sender = new SmsMsgHelper(0); $tpl_type = SmsTpl::getTplKey(2); $date = date('m-d 08:00',$find->make_time); $end_date = date('m-d 07:59',$find->make_time+60*60*24); // $find_user->mobile_phone = '18120779920'; $sms_sender->sender($find_user->mobile_phone, $tpl_type, $find_user->mobile_prefix, $find_user->id,[ 'store' => $find_store->name, 'date1' => $date, 'date2' => $end_date, 'phone' => $find_store->store_mobile, ]); // 变更状态 $find->is_send_sms = 1; $find->save(); return Model::asReturnSuccess('操作成功'); } //店长审核删除 public function actionStoreMakeDelete() { $find = StoreMake::findOne([ 'id' => $this->id, ]); if(empty($find)){ return Model::asReturnError('暂无数据'); } // 变更状态 $find->is_delete = 1; $find->save(); return Model::asReturnSuccess('操作成功'); } }