业务员

This commit is contained in:
2024-12-12 18:32:37 +08:00
parent 3822c7873c
commit 278020850d

View File

@@ -666,11 +666,42 @@ class DoctorController extends BaseAdminController
// 如果用户角色是店铺管理员则添加店铺ID条件到查询中
if ($user->role == UserRoleEnum::STORE_ADMIN) {
$query->andWhere(['p.store_id' => $user->store_id]);
// $Reconciliation_query->andWhere(['r.store_id' => $user->store_id, 'r.status' => 1]);
$Ledger_query->andWhere(['re.user_id' => $user->store_id]);
}
// TODO 临时救急
switch ($user->role) {
case UserRoleEnum::STORE_ADMIN:
// 门店
if (empty($user->store_id)) throw new \yii\db\Exception('门店信息获取失败');
$where = ['re.user_id' => $user->store_id];
break;
case UserRoleEnum::PROVINCE_DAI:
// 省代
if (empty($user->province_id)) throw new Exception('省区经理信息获取失败' . $user->province_id);
$store_id = Store::find()->select(['id'])->where(['province_id' => $user->province_id])->column();
$where = ['in', 're.user_id', $store_id];
break;
case UserRoleEnum::CITY_DAI:
// 市代
if (empty($user->city_id)) throw new Exception('市区经理信息获取失败' . $user->city_id);
$store_id = Store::find()->select(['id'])->where(['city_id' => $user->city_id])->column();
$where = ['in', 're.user_id', $store_id];
break;
case UserRoleEnum::SUPPLY:
// 业务员
if (empty($user->code)) throw new Exception('市区经理信息获取失败' . $user->code);
$store_id = Store::find()->select(['id'])->where(['code' => $user->code])->column();
$where = ['in', 're.user_id', $store_id];
break;
default:
// 不需要额外的条件,直接排序
throw new Exception('角色参数错误');
break;
}
// ds($where);
$Ledger_query->andWhere($where);
// 计算订单销售总额
$order_sale = $query->andWhere([
@@ -720,49 +751,6 @@ class DoctorController extends BaseAdminController
$number += $v['number'];
}
}
// return;
// $admin = \Yii::$app->user->identity;
//// ->joinWith(['store' => function ($s) use ($admin) {
//// $s->alias('s');
//// $s->andWhere(['like', 's.code', $admin->code]);
//// }]);
// switch ($admin->role) {
// case UserRoleEnum::STORE_ADMIN:
// // 门店
// if (empty($admin->store_id)) throw new \yii\db\Exception('门店信息获取失败');
// $where = ['store_id' => $admin->store_id];
// break;
// case UserRoleEnum::PROVINCE_DAI:
// // 省代
// if (empty($admin->province_id)) throw new Exception('省区经理信息获取失败' . $admin->province_id);
// $store_id = Store::find()->select(['id'])->where(['province_id' => $admin->province_id])->column();
// $where = ['in', 'store_id', $store_id];
// break;
// case UserRoleEnum::CITY_DAI:
// // 市代
// if (empty($admin->city_id)) throw new Exception('市区经理信息获取失败' . $admin->city_id);
// $store_id = Store::find()->select(['id'])->where(['city_id' => $admin->city_id])->column();
// $where = ['in', 'store_id', $store_id];
// break;
// case UserRoleEnum::SUPPLY:
// // 业务员
// if (empty($admin->code)) throw new Exception('市区经理信息获取失败' . $admin->code);
// $store_id = Store::find()->select(['id'])->where(['code' => $admin->code])->column();
// $where = ['in', 'store_id', $store_id];
// break;
// default:
// // 不需要额外的条件,直接排序
// throw new Exception('角色参数错误');
// break;
// }
// foreach ($order_id as $val) {
// $Ledger = Ledger::find()->alias('re')->where(['order_id' => $val, 'order_type' => 1, 'status' => [0, 1], 'drugstore_id' => $store_id])->all();
// foreach ($Ledger as $v) {
// $price_data[] = $v['money'];
// $price = bcadd($price, $v['money'], 3);
// $number += $v['number'];
// }
// }
}
// 获取注册金流水数据