diff --git a/hyhproject/admin/model/TradeRule.php b/hyhproject/admin/model/TradeRule.php index 1bca90c..59b7ec9 100644 --- a/hyhproject/admin/model/TradeRule.php +++ b/hyhproject/admin/model/TradeRule.php @@ -48,6 +48,7 @@ class TradeRule extends Base public function add(){ $data = input('post.'); WSTUnset($data,'id,dataFlag,isShow'); + $data['content'] = htmlspecialchars_decode($data['content']); $data['create_time'] = date('Y-m-d H:i:s'); Db::startTrans(); try{ @@ -77,6 +78,7 @@ class TradeRule extends Base public function edit(){ $id = input('post.id/d'); $data = input('post.'); + $data['content'] = htmlspecialchars_decode($data['content']); WSTUnset($data,'id,dataFlag,isShow,create_time'); Db::startTrans(); try{ diff --git a/hyhproject/admin/view/trade_rule/trade_rule.js b/hyhproject/admin/view/trade_rule/trade_rule.js index 494d0d6..8f15da2 100644 --- a/hyhproject/admin/view/trade_rule/trade_rule.js +++ b/hyhproject/admin/view/trade_rule/trade_rule.js @@ -5,7 +5,7 @@ function initGrid(){ {title:'文章ID', name:'id' ,width:30,sortable:true}, {title:'标题', name:'title' ,width:200,sortable:true}, {title:'是否显示', name:'isShow' ,width:50,sortable:true, renderer: function(val,item,rowIndex){ - return '
'; + return '
'; }}, {title:'创建时间', name:'create_time' ,width:120,sortable:true}, {title:'操作', name:'' ,width:100, align:'center', renderer: function(val,item,rowIndex){ diff --git a/hyhproject/app/controller/Note.php b/hyhproject/app/controller/Note.php index 60ddb2e..4117c53 100644 --- a/hyhproject/app/controller/Note.php +++ b/hyhproject/app/controller/Note.php @@ -6,7 +6,6 @@ namespace wstmart\app\controller; use think\Db; use think\Exception; -use think\exception\PDOException; class Note extends Base { @@ -65,6 +64,14 @@ class Note extends Base return WSTReturn("异常请求", 0); } + public function delete() { + $userId = (int)session('WST_USER.userId'); + $id = (int)input('post.id', -1); + Db::name('note') + ->where(["user_id" => $userId, "id" => $id])->delete(); + return WSTReturn("OK", 1); + } + public function creditIndex() { $userId = (int)session('WST_USER.userId'); @@ -102,43 +109,39 @@ class Note extends Base return WSTReturn("异常请求", 0); } - public function creditCreate() - { - $userId = (int)session('WST_USER.userId'); - $title = input("post.title"); - $content = input("post.content"); - $cash = (float)input("post.cash"); - Db::startTrans(); - try { - $id = Db::name('note_credit')->save([ - "title" => $title, - "content" => $content, - "user_id" => $userId, - "cur_cash" => $cash, - ]); - Db::name("note_credit_detail")->save([ - "credit_id" => $id, - "type" => 0, - "cash" => $cash, - "content" => "新建时填写的值", - "create_time" => date("Y-m-d H:i:s"), - ]); - Db::commit(); - return WSTReturn("OK", 1); - } catch (\Exception $e) { - Db::rollback(); - errLog($e); - return WSTReturn('操作失败', -1); - } - } - public function creditSave() { $userId = (int)session('WST_USER.userId'); - $id = (int)input('post.id', 0); + $id = (int)input('post.id', -1); $name = input("post.name"); $cur_cash = input('post.cur_cash'); $credit_cash = input('post.credit_cash'); + $return_date = input('post.return_date', 1); + if ($id == 0){ + Db::startTrans(); + try { + $id = Db::name('note_credit')->insertGetId([ + "user_id" => $userId, "id" => $id, + "cur_cash" => $cur_cash, + 'name' => $name, + 'credit_cash' => $credit_cash, + "return_date" => $return_date, + ]); + Db::name("note_credit_detail")->insert([ + "credit_id" => $id, + "user_id"=>$userId, + "type" => 0, + "amount" => $cur_cash, + "create_time" => date("Y-m-d H:i:s"), + ]); + Db::commit(); + return WSTReturn("OK", 1); + } catch (\Exception $e) { + Db::rollback(); + errLog($e); + return WSTReturn('操作失败', -1); + } + } $detail = Db::name('note_credit') ->where(["user_id" => $userId, "id" => $id])->find(); if (!$detail) return WSTReturn("该条内容已被删除", 0); @@ -158,7 +161,7 @@ class Note extends Base } Db::name('note_credit') ->where(["user_id" => $userId, "id" => $id]) - ->update(compact('name', 'credit_cash')); + ->update(compact('name', 'credit_cash', 'return_date')); Db::commit(); return WSTReturn("OK", 1); } catch (Exception $e) { @@ -184,11 +187,11 @@ class Note extends Base switch ($type) { case 1: //+ - $credit["amount"] += $amount; + $credit["cur_cash"] -= $amount; break; case 2: //- - $credit["amount"] -= $amount; + $credit["cur_cash"] += $amount; break; } Db::startTrans(); @@ -196,7 +199,7 @@ class Note extends Base Db::name('note_credit')->where([ "user_id" => $userId, "id" => $id, - ])->save($credit); + ])->update($credit); Db::name("note_credit_detail")->insert([ "credit_id" => $id, "user_id"=>$userId, @@ -212,4 +215,58 @@ class Note extends Base return WSTReturn('操作失败', -1); } } + + public function creditDelete() { + $userId = (int)session('WST_USER.userId'); + $id = (int)input('post.id', -1); + Db::name('note_credit') + ->where(["user_id" => $userId, "id" => $id])->delete(); + return WSTReturn("OK", 1); + } + + public function creditDeleteInfo () { + $userId = (int)session('WST_USER.userId'); + $id = (int)input('post.id', 0); + $cid = (int)input('post.credit_id', 0); + $credit = Db::name('note_credit')->where([ + "user_id" => $userId, + "id" => $cid, + ])->field(true)->find(); + $detail = Db::name("note_credit_detail")->where([ + "credit_id" => $cid, + "user_id"=>$userId, + "id" => $id, + ])->field(true)->find(); + if (empty($credit) || empty($detail)) { + return WSTReturn("数据不存在", 0); + } + switch ((int)$detail['type']) { + case 1: + //+ + $credit["cur_cash"] += $detail['amount']; + break; + case 2: + //- + $credit["cur_cash"] -= $detail['amount']; + break; + } + Db::startTrans(); + try { + Db::name('note_credit')->where([ + "user_id" => $userId, + "id" => $cid, + ])->update($credit); + Db::name("note_credit_detail")->where([ + "credit_id" => $cid, + "user_id"=>$userId, + "id" => $id, + ])->delete(); + Db::commit(); + return WSTReturn("OK", 1); + } catch (\Exception $e) { + Db::rollback(); + errLog($e); + return WSTReturn('操作失败', -1); + } + } } \ No newline at end of file diff --git a/hyhproject/app/controller/TradeRule.php b/hyhproject/app/controller/TradeRule.php index 90d8b82..0b5a78a 100644 --- a/hyhproject/app/controller/TradeRule.php +++ b/hyhproject/app/controller/TradeRule.php @@ -4,22 +4,29 @@ namespace wstmart\app\controller; +use think\Db; + class TradeRule extends Base { public function index() { - $model = model("trade_rule")->field(true) + $model = Db::name("trade_rule")->field(true) ->order("create_time", "desc") + ->where('isShow', '1') ->select(); + foreach ($model as &$detail) { + $detail['content'] = htmlspecialchars_decode($detail['content']); + } return WSTReturn("OK", 1, $model); } public function detail() { if(($id = (int)input( 'id', 0)) > 0){ - $detail = model("trade_rule")->field(true) + $detail = Db::name("trade_rule")->field(true) ->where(["id"=>$id])->find(); if(!$detail) return WSTReturn("该条内容已被删除",0); + $detail['content'] = htmlspecialchars_decode($detail['content']); return WSTReturn("OK", 1, $detail); } return WSTReturn("异常请求",0); diff --git a/hyhproject/app/controller/Users.php b/hyhproject/app/controller/Users.php index 532a89e..a247db8 100755 --- a/hyhproject/app/controller/Users.php +++ b/hyhproject/app/controller/Users.php @@ -1,5 +1,6 @@ getShareInfo(); } + + + public function setting_recive() { + $userId = $this->getUserId(); + if ($this->request->isPost()) { + $data = [ + 'realname'=>input('post.realname'), + 'bankName'=>input('post.bankName'), + 'bankNo'=>input('post.bankNo'), + 'alipayRecive'=>input('post.alipayRecive'), + 'wechatRecive'=>input('post.wechatRecive'), + ]; + if(Db::name('user_recive')->where('userId', '=', $userId)->count() > 0) { + Db::name('user_recive')->where('userId', '=', $userId)->update($data); + } else { + $data['userId'] = $userId; + Db::name('user_recive')->insert($data); + } + return WSTReturn("成功", 1, $data); + } else { + $data = Db::name('user_recive')->where('userId', '=', $userId)->find(); + return WSTReturn("成功", 1, $data); + } + } + /** + * 注销 + */ + public function unregister(){ + $m = new M(); + $userId = $this->getUserId(); + $user = $m->getById($userId); + if (empty($user)) exit(jsonReturn('系统异常',0,[])); + $opUser = input('post.op_user'); + $opContent = input('post.op_content'); + // TODO: 记录操作人员名称 + // TODO: 验证规则 + Db::startTrans(); + Db::name('user_lock')->insert([ + 'lockTime'=>0, + 'lockReason'=>'账号已注销,操作人:'.$opUser.',注销申请内容:'.$opContent, + 'createTime'=>time(), + 'adminId'=>0, + 'userId'=>$userId, + ]); + $m->where('userId', '=', $userId)->update([ + 'userStatus'=>0, + ]); + Db::commit(); + exit(jsonReturn('账号注销成功',1,[])); + } } diff --git a/hyhproject/common/model/Orders.php b/hyhproject/common/model/Orders.php index b1a34b9..8937f5e 100755 --- a/hyhproject/common/model/Orders.php +++ b/hyhproject/common/model/Orders.php @@ -1528,7 +1528,7 @@ class Orders extends Base{ if((int)$order["helpUserLevel"]!==0){ $vm->insertHelpSaleNotice($order["helpUserId"], $orderId, $calBaseNum*((float)dataConf('helpSaleCouponsCalBase')/100), '预获助购转换所扣', 0); - $sm->addSysSummary($calBaseNum*((float)dataConf('helpSaleCouponsCalBase')/100),0,2,'订单【'.$order['orderNo']?:'--'.'】被助购转换所扣'); + $sm->addSysSummary($calBaseNum*((float)dataConf('helpSaleCouponsCalBase')/100),0,2,'订单【'.($order['orderNo']?:'--').'】被助购转换所扣'); $vm->insertVouchersNotice($order['helpUserId'], $orderId, $calBaseNum*((float)dataConf('helpSaleCouponsCalBase')/100), 0, '预获产品券转换所扣',0); $vm->insertAlreadyVouchersNotice($order['helpUserId'], $orderId, $calBaseNum*((float)dataConf('helpSaleCouponsCalBase')/100), 0, diff --git a/hyhproject/common/model/Settlements.php b/hyhproject/common/model/Settlements.php index d3f0cf4..7c0743d 100755 --- a/hyhproject/common/model/Settlements.php +++ b/hyhproject/common/model/Settlements.php @@ -28,7 +28,7 @@ class Settlements extends Base //加入快代付值 $fastScale = dataConf('fastPayInSaleScale'); $fastNum = round($discountMoney * ($fastScale*0.01),5); - Model('SysSummary')->addToPayFast($orderId,$fastNum,$fastScale,'订单【'.$order['orderNo']?:'--'.'】优惠款加入'); + Model('SysSummary')->addToPayFast($orderId,$fastNum,$fastScale,'订单【'.($order['orderNo']?:'--').'】优惠款加入'); //获取产品额 $totalMoney = $order->realTotalMoney;//产品额 if(2 != $order->goodsType){//助微吧商品不给购户券值 diff --git a/hyhproject/common/model/Users.php b/hyhproject/common/model/Users.php index dc01756..0717c83 100755 --- a/hyhproject/common/model/Users.php +++ b/hyhproject/common/model/Users.php @@ -168,8 +168,11 @@ class Users extends Base{ ->where(["dataFlag"=>1]) ->find(); if(isset($rs['userStatus']) && 0 == $rs['userStatus']){//禁用状态 - $lockInfo = Db::name('user_lock')->where(['userId'=>$rs['userId']])->field('lockReason,lockTime,createTime')->order('id DESC')->find(); + $lockInfo = Db::name('user_lock')->where(['userId'=>$rs['userId']])->field('adminId,lockReason,lockTime,createTime')->order('id DESC')->find(); if($lockInfo){ + if(0 == $lockInfo['adminId']){ + return WSTReturn($lockInfo['lockReason']); + } if(0 == $lockInfo['lockTime']){ return WSTReturn("账号已禁用,禁用原因:".$lockInfo['lockReason'].',禁用时间:永久'); } @@ -660,7 +663,7 @@ class Users extends Base{ Db::commit(); return WSTReturn("绑定成功",1); }else{ - Db::rollback();errLog($e); + Db::rollback();errLog('失败'); return WSTReturn("",-1); } }catch (\Exception $e) { @@ -726,7 +729,7 @@ class Users extends Base{ session('findPass',null); return WSTReturn("修改成功", 1); } - return $rs; + return []; } /**