|
|
@@ -38,6 +38,7 @@ class ExpendController extends BaseController
|
|
|
|
|
|
$where = ['mainId' => $this->mainId];
|
|
|
$where['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
|
|
|
+ $where['delStatus'] = 0; //过滤掉已删除的
|
|
|
$list = ExpendClass::getAllByCondition($where, null, '*', null);
|
|
|
$arr = [];
|
|
|
$cat = [];
|
|
|
@@ -92,7 +93,7 @@ class ExpendController extends BaseController
|
|
|
{
|
|
|
ini_set('memory_limit', '2045M');
|
|
|
set_time_limit(0);
|
|
|
- $where = ['mainId' => $this->mainId, 'bx' => 0];
|
|
|
+ $where = ['mainId' => $this->mainId, 'bx' => 0, 'delStatus' => 0];
|
|
|
$list = ExpendClass::getAllByCondition($where, null, '*', null);
|
|
|
$arr = [];
|
|
|
if (!empty($list)) {
|
|
|
@@ -103,7 +104,7 @@ class ExpendController extends BaseController
|
|
|
$currentAmount = $amount;
|
|
|
$unAmount = $amount;
|
|
|
if (isset($arr[$staffId])) {
|
|
|
- $arr[$staffId]['amount'] = bcadd($arr[$staffId]['amount'], $unAmount,2);
|
|
|
+ $arr[$staffId]['amount'] = bcadd($arr[$staffId]['amount'], $unAmount, 2);
|
|
|
$arr[$staffId]['num'] = bcadd($arr[$staffId]['num'], 1);
|
|
|
} else {
|
|
|
$arr[$staffId]['totalAmount'] = $currentAmount;
|
|
|
@@ -148,7 +149,8 @@ class ExpendController extends BaseController
|
|
|
$connection = Yii::$app->db;
|
|
|
$transaction = $connection->beginTransaction();
|
|
|
try {
|
|
|
- $list = ExpendClass::getAllByCondition(['mainId' => $this->mainId, 'bx' => 0, 'staffId' => $staffId], null, '*', null, true);
|
|
|
+ $condition = ['mainId' => $this->mainId, 'bx' => 0, 'staffId' => $staffId, 'delStatus' => 0];
|
|
|
+ $list = ExpendClass::getAllByCondition($condition, null, '*', null, true);
|
|
|
$total = 0;
|
|
|
$staff = $this->shopAdmin;
|
|
|
$bxData = [
|
|
|
@@ -168,7 +170,7 @@ class ExpendController extends BaseController
|
|
|
$bx->amount = $total;
|
|
|
$bx->save();
|
|
|
if (floatval($postAmount) != floatval($total)) {
|
|
|
- util::fail('金额错误,请刷新页面,实际:'.floatval($total));
|
|
|
+ util::fail('金额错误,请刷新页面,实际:' . floatval($total));
|
|
|
}
|
|
|
$transaction->commit();
|
|
|
util::complete();
|
|
|
@@ -205,6 +207,7 @@ class ExpendController extends BaseController
|
|
|
if ($bx != -1) {
|
|
|
$where['bx'] = $bx;
|
|
|
}
|
|
|
+ $where['delStatus'] = 0;
|
|
|
$searchTime = isset($get['searchTime']) && !empty($get['searchTime']) ? $get['searchTime'] : 'thisYear';
|
|
|
$startTime = $get['startTime'] ?? '';
|
|
|
$endTime = $get['endTime'] ?? '';
|
|
|
@@ -256,7 +259,7 @@ class ExpendController extends BaseController
|
|
|
$amount = $post['amount'] ?? 0;
|
|
|
$remark = $post['remark'] ?? '';
|
|
|
$bx = $post['bx'] ?? -1;
|
|
|
- if (is_numeric($amount) == false || $amount <= 0) {
|
|
|
+ if (!is_numeric($amount) || $amount <= 0) {
|
|
|
util::fail('请输入正确的金额');
|
|
|
}
|
|
|
if ($bx == -1) {
|
|
|
@@ -359,6 +362,52 @@ class ExpendController extends BaseController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //删除支出
|
|
|
+ public function actionDelExpend()
|
|
|
+ {
|
|
|
+ $staff = $this->shopAdmin;
|
|
|
+ if ($staff->finance == 0) {
|
|
|
+ util::fail('没有财务权限');
|
|
|
+ }
|
|
|
+
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $staffId = intVal($post['staffId']);
|
|
|
+ $staff = ShopAdminClass::getById($staffId, true);
|
|
|
+ if (empty($staff)) {
|
|
|
+ util::fail('没有找到员工');
|
|
|
+ }
|
|
|
+ if ($staff->mainId != $this->mainId) {
|
|
|
+ util::fail('员工不存在');
|
|
|
+ }
|
|
|
+
|
|
|
+ $id = intval($post['id']);
|
|
|
+ $expend = ExpendClass::getById($id, true);
|
|
|
+ if ($expend->mainId != $this->mainId) {
|
|
|
+ util::fail('没有找到支出数据');
|
|
|
+ }
|
|
|
+ if ($expend->delStatus == 1) {
|
|
|
+ util::fail('此支出数据已是删除状态');
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理报销表数据
|
|
|
+ if ($expend->bxId != 0) {
|
|
|
+ $expendBx = ExpendBxClass::getById($expend->bxId, true);
|
|
|
+ $expendBx->amount = bcsub($expendBx->amount, $expend->amount, 2);
|
|
|
+ $expendBx->remark = $expendBx->remark . " | " . date("Y-m-d H:i") . " 删除支出:ID=" . $expend->id;
|
|
|
+ $expendBx->save();
|
|
|
+ }
|
|
|
+
|
|
|
+ $expend->delStaffId = $staffId;
|
|
|
+ $expend->delStaffName = $staff->name;
|
|
|
+ $expend->delStatus = 1;
|
|
|
+ $rs = $expend->save();
|
|
|
+ if ($rs) {
|
|
|
+ util::complete();
|
|
|
+ } else {
|
|
|
+ util::fail('删除支出失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//修改账单日期 ssh 20241122
|
|
|
public function actionChangePayTime()
|
|
|
{
|