烂笔头新增

This commit is contained in:
Jerry Yan 2020-08-16 14:05:34 +08:00
parent de9d4a1fc4
commit c74f56a43b

View File

@ -6,7 +6,6 @@ namespace wstmart\app\controller;
use think\Db; use think\Db;
use think\Exception; use think\Exception;
use think\exception\PDOException;
class Note extends Base class Note extends Base
{ {
@ -102,25 +101,27 @@ class Note extends Base
return WSTReturn("异常请求", 0); return WSTReturn("异常请求", 0);
} }
public function creditCreate() public function creditSave()
{ {
$userId = (int)session('WST_USER.userId'); $userId = (int)session('WST_USER.userId');
$title = input("post.title"); $id = (int)input('post.id', -1);
$content = input("post.content"); $name = input("post.name");
$cash = (float)input("post.cash"); $cur_cash = input('post.cur_cash');
$credit_cash = input('post.credit_cash');
if ($id == 0){
Db::startTrans(); Db::startTrans();
try { try {
$id = Db::name('note_credit')->save([ $id = Db::name('note_credit')->insertGetId([
"title" => $title, "user_id" => $userId, "id" => $id,
"content" => $content, "cur_cash" => $cur_cash,
"user_id" => $userId, 'name' => $name,
"cur_cash" => $cash, 'credit_cash' => $credit_cash,
]); ]);
Db::name("note_credit_detail")->save([ Db::name("note_credit_detail")->insert([
"credit_id" => $id, "credit_id" => $id,
"user_id"=>$userId,
"type" => 0, "type" => 0,
"cash" => $cash, "amount" => $cur_cash,
"content" => "新建时填写的值",
"create_time" => date("Y-m-d H:i:s"), "create_time" => date("Y-m-d H:i:s"),
]); ]);
Db::commit(); Db::commit();
@ -131,14 +132,6 @@ class Note extends Base
return WSTReturn('操作失败', -1); return WSTReturn('操作失败', -1);
} }
} }
public function creditSave()
{
$userId = (int)session('WST_USER.userId');
$id = (int)input('post.id', 0);
$name = input("post.name");
$cur_cash = input('post.cur_cash');
$credit_cash = input('post.credit_cash');
$detail = Db::name('note_credit') $detail = Db::name('note_credit')
->where(["user_id" => $userId, "id" => $id])->find(); ->where(["user_id" => $userId, "id" => $id])->find();
if (!$detail) return WSTReturn("该条内容已被删除", 0); if (!$detail) return WSTReturn("该条内容已被删除", 0);