|
|
@@ -21,22 +21,33 @@ class ShopMoneyController extends BaseController
|
|
|
if (is_numeric($amount) == false || $amount <= 0) {
|
|
|
util::fail('请填写金额');
|
|
|
}
|
|
|
- $mainId = $this->mainId;
|
|
|
- $staffId = $this->shopAdminId ?? 0;
|
|
|
- $staff = $this->shopAdmin;
|
|
|
- $data = [];
|
|
|
- $data['mainId'] = $mainId;
|
|
|
- $data['sjId'] = $this->sjId;
|
|
|
- $data['amount'] = $amount;
|
|
|
- $data['staffId'] = $staffId;
|
|
|
- $data['staffName'] = $staff->name ?? '';
|
|
|
- $data['ptStyle'] = dict::getDict('ptStyle', 'ghs');
|
|
|
- $main = MainClass::getLockById($mainId);
|
|
|
- if (empty($main)) {
|
|
|
- util::fail('没有门店信息');
|
|
|
+
|
|
|
+ $connection = Yii::$app->db;//事务处理
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+
|
|
|
+ $mainId = $this->mainId;
|
|
|
+ $staffId = $this->shopAdminId ?? 0;
|
|
|
+ $staff = $this->shopAdmin;
|
|
|
+ $data = [];
|
|
|
+ $data['mainId'] = $mainId;
|
|
|
+ $data['sjId'] = $this->sjId;
|
|
|
+ $data['amount'] = $amount;
|
|
|
+ $data['staffId'] = $staffId;
|
|
|
+ $data['staffName'] = $staff->name ?? '';
|
|
|
+ $data['ptStyle'] = dict::getDict('ptStyle', 'ghs');
|
|
|
+ $main = MainClass::getLockById($mainId);
|
|
|
+ if (empty($main)) {
|
|
|
+ util::fail('没有门店信息');
|
|
|
+ }
|
|
|
+ ShopMoneyClass::inAmount($data, $main);
|
|
|
+ $transaction->commit();
|
|
|
+ util::complete();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ Yii::info("失败原因:" . $e->getMessage());
|
|
|
+ util::fail('存入失败');
|
|
|
}
|
|
|
- ShopMoneyClass::inAmount($data, $main);
|
|
|
- util::complete();
|
|
|
}
|
|
|
|
|
|
//取出现金 ssh 20220811
|
|
|
@@ -46,27 +57,35 @@ class ShopMoneyController extends BaseController
|
|
|
if (isset($staff->super) == false || $staff->super != 1) {
|
|
|
util::fail('没有权限');
|
|
|
}
|
|
|
-
|
|
|
- $get = Yii::$app->request->get();
|
|
|
- $amount = $get['amount'] ?? 0;
|
|
|
- if (is_numeric($amount) == false || $amount <= 0) {
|
|
|
- util::fail('请填写金额');
|
|
|
- }
|
|
|
- $mainId = $this->mainId;
|
|
|
- $staffId = $this->shopAdminId ?? 0;
|
|
|
- $data = [];
|
|
|
- $data['mainId'] = $mainId;
|
|
|
- $data['sjId'] = $this->sjId;
|
|
|
- $data['amount'] = $amount;
|
|
|
- $data['staffId'] = $staffId;
|
|
|
- $data['staffName'] = $staff->name ?? '';
|
|
|
- $data['ptStyle'] = dict::getDict('ptStyle', 'ghs');
|
|
|
- $main = MainClass::getLockById($mainId);
|
|
|
- if (empty($main)) {
|
|
|
- util::fail('没有门店信息');
|
|
|
+ $connection = Yii::$app->db;//事务处理
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $amount = $get['amount'] ?? 0;
|
|
|
+ if (is_numeric($amount) == false || $amount <= 0) {
|
|
|
+ util::fail('请填写金额');
|
|
|
+ }
|
|
|
+ $mainId = $this->mainId;
|
|
|
+ $staffId = $this->shopAdminId ?? 0;
|
|
|
+ $data = [];
|
|
|
+ $data['mainId'] = $mainId;
|
|
|
+ $data['sjId'] = $this->sjId;
|
|
|
+ $data['amount'] = $amount;
|
|
|
+ $data['staffId'] = $staffId;
|
|
|
+ $data['staffName'] = $staff->name ?? '';
|
|
|
+ $data['ptStyle'] = dict::getDict('ptStyle', 'ghs');
|
|
|
+ $main = MainClass::getLockById($mainId);
|
|
|
+ if (empty($main)) {
|
|
|
+ util::fail('没有门店信息');
|
|
|
+ }
|
|
|
+ ShopMoneyClass::outAmount($data, $main);
|
|
|
+ $transaction->commit();
|
|
|
+ util::complete();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ Yii::info("失败原因:" . $e->getMessage());
|
|
|
+ util::fail('取出失败');
|
|
|
}
|
|
|
- ShopMoneyClass::outAmount($data, $main);
|
|
|
- util::complete();
|
|
|
}
|
|
|
|
|
|
}
|