|
|
@@ -39,6 +39,39 @@ class ExpendController extends BaseController
|
|
|
util::success(['list' => $arr]);
|
|
|
}
|
|
|
|
|
|
+ //报销金额 ssh 20240308
|
|
|
+ public function actionBx()
|
|
|
+ {
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $amount = $get['amount'] ?? 0;
|
|
|
+ $staffId = $get['staffId'] ?? 0;
|
|
|
+ if ($amount <= 0) {
|
|
|
+ util::fail('没有需要报销的金额');
|
|
|
+ }
|
|
|
+ $connection = Yii::$app->db;//事务处理
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ $list = ExpendClass::getAllByCondition(['mainId' => $this->mainId, 'bx' => 0, 'staffId' => $staffId], null, '*', null, true);
|
|
|
+ $total = 0;
|
|
|
+ foreach ($list as $it) {
|
|
|
+ $amount = $it->amount ?? 0;
|
|
|
+ $total = bcadd($total, $amount, 2);
|
|
|
+ $it->bx = 1;
|
|
|
+ $it->save();
|
|
|
+ }
|
|
|
+ if (floatval($amount) != floatval($total)) {
|
|
|
+ util::fail('金额有问题,返回上页再进来');
|
|
|
+ }
|
|
|
+ $transaction->commit();
|
|
|
+ util::complete();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ $msg = $e->getMessage();
|
|
|
+ noticeUtil::push("报销出错了,错误信息:{$msg}", '15280215347');
|
|
|
+ util::fail();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//类型列表 ssh 20240308
|
|
|
public function actionGetTypeList()
|
|
|
{
|