| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace pt\controllers;
- use biz\sj\classes\SjClass;
- use common\components\util;
- use biz\sj\services\MerchantService;
- use Yii;
- class SjController extends BaseController
- {
- //新增商家 shish 2021.3.29
- public function actionAdd()
- {
- $get = Yii::$app->request->get();
- $name = isset($get['name']) && !empty($get['name']) ? $get['name'] : '';
- if (empty($name)) {
- util::fail('请填写名称');
- }
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- try {
- $apply['name'] = $name;
- $apply['style'] = SjClass::STYLE_KM_SUPPLIER;
- $has = SjClass::getByCondition(['name' => $name]);
- if (!empty($has)) {
- util::fail('名称已经存在');
- }
- MerchantService::initSjInfo($apply);
- $transaction->commit();
- util::complete();
- } catch (\Exception $exception) {
- Yii::info("添加商家失败:" . $exception->getMessage());
- util::fail('操作失败');
- }
- }
- //商家列表 ssh 2019.12.20
- public function actionList()
- {
- $get = Yii::$app->request->get();
- $where = ['delStatus' => 0];
- if (isset($get['name']) && !empty($get['name'])) {
- $where['name'] = ['like', $get['name']];
- }
- $list = MerchantService::getMerchantList($where);
- util::success($list);
- }
- }
|