xxxrrrdddd 3 years ago
parent
commit
fd91a581e0

+ 0 - 5
application/admin/model/MobilePriceLog.php

@@ -7,9 +7,4 @@ use think\Model;
 
 class MobilePriceLog extends \app\common\model\MobilePriceLog
 {
-
-    public function admin()
-    {
-        return $this->belongsTo('Admin', 'admin_id', 'id', [], 'LEFT')->setEagerlyType(0);
-    }
 }

+ 11 - 6
application/common/model/MobilePriceLog.php

@@ -2,20 +2,25 @@
 
 namespace app\common\model;
 
+use app\admin\model\Admin;
 use think\Model;
-use Yansongda\Supports\Str;
 
 /**
  * 配置模型
  */
 class MobilePriceLog extends Model
 {
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = true;
 
+    public function admin()
+    {
+        return $this->belongsTo(Admin::class, 'admin_id', 'id', [], 'LEFT')->setEagerlyType(0);
+    }
 
 
-
-
-
-    // 自动写入时间戳字段
-    protected $autoWriteTimestamp = true;
+    public function user()
+    {
+        return $this->belongsTo(User::class, 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
+    }
 }

+ 8 - 0
application/common/service/MobilePriceLogService.php

@@ -6,6 +6,7 @@ use app\common\model\MobilePriceLog;
 
 class MobilePriceLogService{
     protected $admin_id;
+    protected $user_id;
     /** @var Mobile */
     protected $mobile;
     protected $before_price;
@@ -39,6 +40,12 @@ class MobilePriceLogService{
         return $this;
     }
 
+    public function setUserId($user_id)
+    {
+        $this->user_id = $user_id;
+        return $this;
+    }
+
     /**
      * @param Mobile $mobile
      */
@@ -52,6 +59,7 @@ class MobilePriceLogService{
         if($this->before_price!=$this->after_price){
             MobilePriceLog::create([
                 'admin_id'=>$this->admin_id,
+                'user_id'=>$this->user_id,
                 'mobile_id'=>$this->mobile->id,
                 'no'=>$this->mobile->no,
                 'before_price'=>$this->before_price,

+ 6 - 0
application/sub/controller/Index.php

@@ -46,6 +46,12 @@ class Index extends SubCommon
                         "href"=>url('order/index'),
                         "spread"=>false,
                     ],
+                    [
+                        "title"=>"改价记录",
+                        "icon"=>"icon-wenben",
+                        "href"=>url('mobile/price_log'),
+                        "spread"=>false,
+                    ],
                 ]
             ],
         ];

+ 21 - 0
application/sub/controller/Mobile.php

@@ -4,7 +4,10 @@ namespace app\sub\controller;
 
 use app\common\model\Mobile as M;
 use app\common\model\MobileHoldLog;
+use app\common\model\MobilePriceLog;
+use app\common\service\MobilePriceLogService;
 use think\Db;
+use think\db\Query;
 
 /**
  * 会员中心
@@ -27,9 +30,15 @@ class Mobile extends SubCommon
             $this->validate($data,[
                 'amount_base'=>['require','number','gt:0'],
             ]);
+            $s=(new MobilePriceLogService())
+                ->setMobile($mobile)
+                ->setAfterPrice($data['amount_base'])
+                ->setBeforePrice($mobile['amount_base'])
+                ->setUserId($this->auth->id);
             foreach ($this->request->only('amount_base') as $key=>$value){
                 $mobile[$key]=$value;
             }
+            $s->log();
             $mobile->save();
             $this->success();
         }
@@ -77,4 +86,16 @@ class Mobile extends SubCommon
         }
         $this->success();
     }
+    #改价记录
+    public function price_log(){
+        $data=input();
+        $log=new MobilePriceLog();
+        if(!empty($data['nickname'])){
+            $log->where(function (Query $query)use ($data){
+                $query->whereLike('user.nickname',"%{$data['nickname']}%")->whereOr('admin.nickname','like',"%{$data['nickname']}%");
+            });
+        }
+        $list=$log->order('id','desc')->with(['admin','user'])->paginate(input('limit',15));
+        return view('',compact('list'));
+    }
 }

+ 117 - 0
application/sub/view/mobile/price_log.html

@@ -0,0 +1,117 @@
+{extend name="layout/sub"/}
+{block name='css'}
+<link rel="stylesheet" href="__SUB__/css/news.css" media="all" />
+{/block}
+{block name='body'}
+<blockquote class="layui-elem-quote news_search">
+    <form method="get" action="">
+        <div class="layui-inline">
+            <label>修改人</label>
+            <div class="layui-input-inline">
+                <input type="text" name="nickname" class="layui-input" value="{:input('nickname')}"/>
+            </div>
+        </div>
+        <div class="layui-inline">
+            <label>时间</label>
+            <div class="layui-input-inline">
+                <input type="text" id="time" name="time" class="layui-input" value="{:input('time')}" onclick="layui.laydate({elem:this})" lay-verify="datetime"/>
+            </div>
+        </div>
+        <div class="layui-inline">
+            <button class="layui-btn search_btn">查询</button>
+            <button class="layui-btn reset-btn" type="button">重置</button>
+        </div>
+    </form>
+</blockquote>
+<div class="layui-form news_list">
+    <table class="layui-table">
+        <thead>
+        <tr>
+            <th width="20">ID</th>
+            <th width="250">手机号</th>
+            <th width="250">修改人</th>
+            <th>原价</th>
+            <th>修改后价格</th>
+            <th>创建时间</th>
+            <th>更新时间</th>
+        </tr>
+        </thead>
+        <tbody class="news_content">
+        {foreach name="list" item="a"}
+        <tr>
+            <td>{$a.id}</td>
+            <td>
+                {$a.no}
+            </td>
+            <td>
+               {notempty name='a.admin'}
+                {$a.admin.nickname}
+                {/notempty}
+                {notempty name='a.user'}
+                {$a.user.nickname}
+                {/notempty}
+            </td>
+            <td>
+                {$a.before_price}
+            </td>
+            <td>{$a.after_price}</td>
+            <td>{$a.create_time|date='Y-m-d H:i:s',###}</td>
+            <td>{$a.update_time|date='Y-m-d H:i:s',###}</td>
+        </tr>
+        {/foreach}
+        </tbody>
+    </table>
+</div>
+<div id="page">
+    <span style="float: left">共 {$list->total()} 条记录</span>
+    {$list->render()}
+</div>
+{/block}
+{block name='js'}
+
+<script>
+    layui.config({
+        base : "__SUB__/js/"
+    }).use(['form','layer','jquery','laypage','laydate'],function(){
+        var form = layui.form(),
+            layer = parent.layer === undefined ? layui.layer : parent.layer,
+            laypage = layui.laypage,
+            laydate = layui.laydate,
+            $ = layui.jquery;
+
+        //查询
+        $(".search_btn").click(function(){
+            var newArray = [];
+        })
+
+        //操作
+        $("body").on("click",".news_edit",function(){  //编辑
+            let id=$(this).data('id')
+            let index = layui.layer.open({
+                title : "退款",
+                type : 2,
+                area:['800px','500px'],
+                content : '{:url("order/refund")}?id='+id,
+                success : function(layero, index){
+                }
+            })
+        })
+
+        $('.refund_log').click(function () {
+            let id=$(this).data('id')
+            let index = layui.layer.open({
+                title : "退款记录",
+                type : 2,
+                area:['1000px','100%'],
+                content : '{:url("order/refund_log")}?id='+id,
+                success : function(layero, index){
+                }
+            })
+        })
+        $('.reset-btn').click(function (){
+            location.replace(location.pathname)
+        })
+    })
+
+</script>
+{/block}

+ 1 - 1
application/sub/view/order/refund_log.html

@@ -19,8 +19,8 @@
         {foreach name="list" item="a"}
         <tr>
             <td>{$a.id}</td>
-            <td>{$a.amount_backend}</td>
             <td>{$a.refunduser.nickname}</td>
+            <td>{$a.amount_backend}</td>
             <td>{:$a.pass?'同意':'驳回'}</td>
             <td>{:$a.reason}</td>
             <td>