v1.0
bruce 8 months ago
parent 1679fc7964
commit 60016ea5d5
  1. 26
      app/api/controller/User.php
  2. 5
      app/common/model/MaintenanceCategory.php

@ -16,6 +16,7 @@ use app\api\model\Agreement as AgreementModel;
use app\api\model\User as UserModel; use app\api\model\User as UserModel;
use app\api\model\Invite\InviteLog; use app\api\model\Invite\InviteLog;
use app\common\service\qrcode\BaseQRcode; use app\common\service\qrcode\BaseQRcode;
use app\store\model\MaintenanceCategory as MaintenanceCategoryModel;
use app\store\model\User as StoreUserModel; use app\store\model\User as StoreUserModel;
use app\api\model\user\BalanceLog; use app\api\model\user\BalanceLog;
use app\api\model\user\GoodSource as GoodsSourceModel; use app\api\model\user\GoodSource as GoodsSourceModel;
@ -397,26 +398,17 @@ class User extends Controller
return $this->renderSuccess(str_replace(root_path() . "public/", base_url(), $qrcode)); return $this->renderSuccess(str_replace(root_path() . "public/", base_url(), $qrcode));
} }
/**
* @throws ModelNotFoundException
* @throws DataNotFoundException
* @throws DbException
*/
public function maintenance() public function maintenance()
{ {
$qrObj = new BaseQRcode();
$storeId = request()->header()['storeid']; $storeId = request()->header()['storeid'];
$list = Db::table('yoshop_maintenance_category') $model = new MaintenanceCategoryModel;
->where(['store_id' => $storeId, 'status' => 1,]) $list = $model->getList(['store_id' => $storeId])->toArray();
->select()
->toArray();
foreach ($list as &$item) {
$tags = [];
$data = Db::table('yoshop_maintenance')
->where(['category_id' => $item['id'], 'is_delete' => 0])
->select()
->toArray();
foreach ($data as &$v) {
$v['url_path'] = $v['url'] ? str_replace(root_path() . "public/", base_url(), $qrObj->getOtherQrcode((int)$storeId, $v['url'])) : '';
$tags[] = $v;
}
$item['tags'] = $tags;
}
return $this->renderSuccess($list); return $this->renderSuccess($list);
} }

@ -47,7 +47,12 @@ class MaintenanceCategory extends BaseModel
public function getList(array $where = []): \think\Collection public function getList(array $where = []): \think\Collection
{ {
return $this->where($where) return $this->where($where)
->with(['maintenances'])
->order(['sort', $this->getPk()]) ->order(['sort', $this->getPk()])
->select(); ->select();
} }
public function maintenances() {
return $this->hasMany(MaintenanceCategory::class);
}
} }

Loading…
Cancel
Save