| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace pt\controllers;
- use bizHd\saas\services\ApplyService;
- use common\components\dict;
- use common\components\sms;
- use common\components\util;
- use Yii;
- class ApplyController extends BaseController
- {
- //申请列表
- public function actionList()
- {
- $get = Yii::$app->request->get();
- $status = $get['status'] ?? 0;
- $where = [];
- if (!empty($status)) {
- $where['status'] = $status;
- }
- $list = ApplyService::getApplyList($where);
- util::success($list);
- }
- //审核
- public function actionCheck()
- {
- $id = Yii::$app->request->post('id');
- $status = Yii::$app->request->post('status', 0);
- $remark = Yii::$app->request->post('remark', '');
- $apply = ApplyService::getById($id);
- if (empty($apply)) {
- util::fail('找不到申请记录');
- }
- if (isset($apply['status']) && $apply['status'] == 2) {
- util::fail('已经审过了');
- }
- if (isset($apply['style']) && $apply['style'] != dict::getDict('ptStyle', 'ghs')) {
- util::fail('暂时只支持审核批发商的申请');
- }
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- try {
- ApplyService::updateById($id, ['status' => $status, 'remark' => $remark]);
- if ($status == 1) {
- \bizGhs\apply\services\ApplyService::pass($id);
- }
- $transaction->commit();
- if ($status == 1) {
- $mobile = $apply['mobile'] ?? '';
- $cf = '15280215347';
- sms::freeSend($mobile . ',' . $cf, '恭喜,开店申请审核通过了,登录后请及时修改密码,如有疑问请联系 {$var}');
- }
- } catch (\Exception $exception) {
- $transaction->rollBack();
- Yii::info("审核操作报错:" . $exception->getMessage());
- util::fail('操作失败');
- }
- util::complete();
- }
- }
|