|
|
@@ -6,7 +6,9 @@ namespace app\api\service;
|
|
|
|
|
|
use app\admin\controller\AuthGroup;
|
|
|
use app\common\model\AdminModel;
|
|
|
-use app\common\model\AuthGroupModel;
|
|
|
+use app\common\model\OrderProductModel;
|
|
|
+use app\common\model\ProductCategoryModel;
|
|
|
+use app\common\model\ProductModel;
|
|
|
use app\common\model\StoreModel;
|
|
|
|
|
|
class AdminService extends \app\BaseService
|
|
|
@@ -14,11 +16,17 @@ class AdminService extends \app\BaseService
|
|
|
|
|
|
private $adminModel;
|
|
|
private $storeModel;
|
|
|
+ private $productModel;
|
|
|
+ private $orderProductModel;
|
|
|
+ private $productCategoryModel;
|
|
|
|
|
|
public function __construct()
|
|
|
{
|
|
|
$this->adminModel = new AdminModel();
|
|
|
$this->storeModel = new StoreModel();
|
|
|
+ $this->productModel = new ProductModel();
|
|
|
+ $this->orderProductModel = new OrderProductModel();
|
|
|
+ $this->productCategoryModel = new ProductCategoryModel();
|
|
|
}
|
|
|
|
|
|
public function search($text = null) {
|
|
|
@@ -45,7 +53,6 @@ class AdminService extends \app\BaseService
|
|
|
return $admins;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
public function fetchMenus($admin_id) {
|
|
|
$admin = $this->adminModel->findById($admin_id);
|
|
|
$group = $admin['access']['group'];
|
|
|
@@ -57,11 +64,37 @@ class AdminService extends \app\BaseService
|
|
|
return array_map(function ($id) use($fmt_reception_rules) {
|
|
|
return $fmt_reception_rules[$id];
|
|
|
},$reception_rule_ids);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function performance($username, $password, $start_time = null, $end_time = null) {
|
|
|
+ $admin = $this->adminModel->loadByLogin($username, $password);
|
|
|
+ if(!$admin) return $this->fail(lang("Account password error"));
|
|
|
+ $counts = $this->orderProductModel->countByAdviser($admin->id, $start_time, $end_time);
|
|
|
+ $res = [
|
|
|
+ 'total_sales' => fixed2Float($counts[0]),
|
|
|
+ 'numerology' => "{$counts[1]}/{$counts[2]}",
|
|
|
+ 'crape_myrtle' => rand(1000,100000),
|
|
|
+ 'geomancy_serve' => rand(1000,100000),
|
|
|
+ ];
|
|
|
+ $items = [
|
|
|
+ ['key' => '商品销售总额', 'value' => fixed2Float($counts[3])],
|
|
|
+ ['key' => '大商品销售总额', 'value' => fixed2Float($counts[4])],
|
|
|
+ ['key' => '服务销售总额', 'value' => fixed2Float($counts[5])],
|
|
|
+ ];
|
|
|
+ $categorys = $this->productCategoryModel->findAll();
|
|
|
+ foreach ($categorys as $category) {
|
|
|
+ array_push($items, [
|
|
|
+ 'key' => $category->name,
|
|
|
+ 'value' => rand(1,999),
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ $res['items'] = $items;
|
|
|
|
|
|
+ return $this->ok($res);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
@@ -87,3 +120,27 @@ class AdminService extends \app\BaseService
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|