|
@@ -698,4 +698,87 @@ class UserController
|
|
|
return app('json')->success('ok', SystemStore::getStoreDispose($admin_indo['store_id']) ? SystemStore::getStoreDispose($admin_indo['store_id'])->toArray() : []);
|
|
|
}
|
|
|
|
|
|
+ public function areaAchievementMonth(Request $request)
|
|
|
+ {
|
|
|
+ $user = $request->user();
|
|
|
+ if ($user['area_admin']) {
|
|
|
+ $where = [];
|
|
|
+ $where['province'] = $user['area_province'];
|
|
|
+ if ($user['area_admin'] == 2 || $user['area_admin'] == 1) $where['city'] = $user['area_city'];
|
|
|
+ if ($user['area_admin'] == 1) $where['district'] = $user['area_district'];
|
|
|
+ $start = StoreOrder::min('add_time');
|
|
|
+ $data = [];
|
|
|
+ while ($start < time()) {
|
|
|
+ $start_month = date('Y-m', $start);
|
|
|
+ $end = strtotime('+1month', strtotime($start_month)) - 1;
|
|
|
+ $frontPrice = StoreOrder:: getOrderTimeBusinessVolumePrice($start, $end, $where);
|
|
|
+ $frontNumber = StoreOrder:: getOrderTimeBusinessVolumeNumber($start, $end, $where);
|
|
|
+ $start = $end + 1;
|
|
|
+ $data[$start_month] = compact('frontPrice', 'frontNumber');
|
|
|
+ }
|
|
|
+ return app('json')->successful($data);
|
|
|
+ }
|
|
|
+ return app('json')->fail('非区域代理');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 订单交易额/订单数量时间统计
|
|
|
+ * @param Request $request
|
|
|
+ * @return bool
|
|
|
+ */
|
|
|
+ public function areaAchievementTime(Request $request)
|
|
|
+ {
|
|
|
+ $user = $request->user();
|
|
|
+ list($start, $stop, $type) = UtilService::getMore([
|
|
|
+ ['start', strtotime(date('Y-m'))],
|
|
|
+ ['stop', time()],
|
|
|
+ ['type', 1]
|
|
|
+ ], $request, true);
|
|
|
+ if ($user['area_admin']) {
|
|
|
+ $where = [];
|
|
|
+ $where['province'] = $user['area_province'];
|
|
|
+ if ($user['area_admin'] == 2 || $user['area_admin'] == 1) $where['city'] = $user['area_city'];
|
|
|
+ if ($user['area_admin'] == 1) $where['district'] = $user['area_district'];
|
|
|
+ if ($start == $stop) {
|
|
|
+ return app('json')->fail('开始时间不能等于结束时间');
|
|
|
+ }
|
|
|
+ if ($start > $stop) {
|
|
|
+ $middle = $stop;
|
|
|
+ $stop = $start;
|
|
|
+ $start = $middle;
|
|
|
+ }
|
|
|
+ $space = bcsub($stop, $start, 0);
|
|
|
+ $front = bcsub($start, $space, 0);
|
|
|
+ if ($type == 1) {
|
|
|
+ $frontPrice = StoreOrder:: getOrderTimeBusinessVolumePrice($front, $start, $where);
|
|
|
+ $afterPrice = StoreOrder:: getOrderTimeBusinessVolumePrice($start, $stop, $where);
|
|
|
+ $chartInfo = StoreOrder::chartTimePrice($start, $stop, $where);
|
|
|
+ $data['chart'] = $chartInfo;
|
|
|
+ $data['time'] = $afterPrice;
|
|
|
+ $increase = (float)bcsub($afterPrice, $frontPrice, 2);
|
|
|
+ $growthRate = abs($increase);
|
|
|
+ if ($growthRate == 0) $data['growth_rate'] = 0;
|
|
|
+ else if ($frontPrice == 0) $data['growth_rate'] = $growthRate;
|
|
|
+ else $data['growth_rate'] = (int)bcmul(bcdiv($growthRate, $frontPrice, 2), 100, 0);
|
|
|
+ $data['increase_time'] = abs($increase);
|
|
|
+ $data['increase_time_status'] = $increase >= 0 ? 1 : 2;
|
|
|
+ } else {
|
|
|
+ $frontNumber = StoreOrder:: getOrderTimeBusinessVolumeNumber($front, $start, $where);
|
|
|
+ $afterNumber = StoreOrder:: getOrderTimeBusinessVolumeNumber($start, $stop, $where);
|
|
|
+ $chartInfo = StoreOrder::chartTimeNumber($start, $stop, $where);
|
|
|
+ $data['chart'] = $chartInfo;
|
|
|
+ $data['time'] = $afterNumber;
|
|
|
+ $increase = (int)bcsub($afterNumber, $frontNumber, 0);
|
|
|
+ $growthRate = abs($increase);
|
|
|
+ if ($growthRate == 0) $data['growth_rate'] = 0;
|
|
|
+ else if ($frontNumber == 0) $data['growth_rate'] = $growthRate;
|
|
|
+ else $data['growth_rate'] = (int)bcmul(bcdiv($growthRate, $frontNumber, 2), 100, 0);
|
|
|
+ $data['increase_time'] = abs($increase);
|
|
|
+ $data['increase_time_status'] = $increase >= 0 ? 1 : 2;
|
|
|
+ }
|
|
|
+ return app('json')->successful($data);
|
|
|
+ }
|
|
|
+ return app('json')->fail('非区域代理');
|
|
|
+ }
|
|
|
}
|