|
|
@@ -52,7 +52,6 @@ class MoneyLog extends Base
|
|
|
//添加记账
|
|
|
public function money(MonuyModel $monuyModel)
|
|
|
{
|
|
|
-
|
|
|
$data = $this->request->post();
|
|
|
$result = false;
|
|
|
Db::startTrans();
|
|
|
@@ -77,6 +76,56 @@ class MoneyLog extends Base
|
|
|
$this->success();
|
|
|
}
|
|
|
|
|
|
+ //账单编辑
|
|
|
+ public function moneyedit(MonuyModel $monuyModel)
|
|
|
+ {
|
|
|
+ $data = $this->request->post();
|
|
|
+ $result = false;
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+ validate(MoneyValidate::class)->scene('edit')->check($data);
|
|
|
+
|
|
|
+ $rows = $monuyModel->where('id', $data['id'])->where('user_id', $this->userinfo['id'])->find();
|
|
|
+ if(!$rows) $this->error('数据不存在');
|
|
|
+ //发货数据
|
|
|
+ $result = $rows->save($data);
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+ }catch (ValidateException $e) {
|
|
|
+ Db::rollback();
|
|
|
+ return $this->error($e->getError());
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+ if ($result === false) {
|
|
|
+ $this->error(__('没有更新任何数据'));
|
|
|
+ }
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除账单
|
|
|
+ public function moneydel(MonuyModel $monuyModel)
|
|
|
+ {
|
|
|
+ $id = $this->request->post('id/d');
|
|
|
+ $result = false;
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+ $rows = $monuyModel->where('id', $id)->where('user_id', $this->userinfo['id'])->find();
|
|
|
+ if(!$rows) $this->error('数据不存在');
|
|
|
+ //发货数据
|
|
|
+ $result = $rows->delete();
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+ if ($result === false) {
|
|
|
+ $this->error(__('没有删除任何数据'));
|
|
|
+ }
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* @return void 全部类型图标
|