wupengfei 3 years ago
parent
commit
36cd849287

+ 36 - 14
application/common.php

@@ -1,10 +1,5 @@
 <?php
-/**
- * @param string $address 地址
- * @return array
- */
-
-
+use think\Db;
 /**
  * 秒转换为天
  */
@@ -39,14 +34,6 @@ function image_path($image_data){
     }
     return $image_res;
 }
-//通过user_id判断是用户还是媒体(返回1:用户 2:媒体)
-function user_type($user_id){
-    $type = 1;
-    if($user_id < 500){
-        $type = 2;
-    }
-    return $type;
-}
 
 function get_order_sn(){
     $order_id_main = date('YmdHis') . rand(10000000,99999999);
@@ -58,3 +45,38 @@ function get_order_sn(){
     $osn = $order_id_main . str_pad((100 - $order_id_sum % 100) % 100,2,'0',STR_PAD_LEFT);
     return $osn;
 }
+
+/**
+ * 更新会员积分
+ * @param $user_id
+ * @param $integral
+ * @param $desc
+ * @param int $rel_id
+ * @throws \think\Exception
+ * @throws \think\db\exception\DataNotFoundException
+ * @throws \think\db\exception\ModelNotFoundException
+ * @throws \think\exception\DbException
+ * @throws \think\exception\PDOException
+ */
+function update_user_integral($user_id,$integral,$type,$desc,$rel_id = 0)
+{
+    $user = Db::table('store_member')->find($user_id);
+    $integral_info=[
+        'user_id'=> $this->uid,
+        'create_at'=> date("Y-m-d H:i:s"),
+        'integral'=> $integral,
+        'before'=> $user['integral'],
+        'after'=> $user['integral'] - $integral,
+        'type'=>$type,
+        'desc'=> $desc,
+        'rel_id'=> $rel_id,
+    ];
+    Db::table('integral_info')->insert($integral_info);
+    Db::table('store_member')->where(['id'=>$user_id])->update(['integral'=>$integral_info['after']]);
+}
+
+
+
+
+
+

+ 8 - 0
application/store/controller/OrderShift.php

@@ -50,12 +50,20 @@ class OrderShift  extends  Controller
 
     protected function _form_filter(&$data)
     {
+        //  查看
         if($this->request->isGet() && $this->request->action() == 'aduit')
         {
             $this->user = Db::table('store_member')
                 ->field('headimg,name,phone')
                 ->find($data['uid']);
         }
+        // 积分赠送integral_info
+        if($this->request->isPost() && $this->request->action() == 'aduit') {
+            if($data['sh_status'] == 1  && $data['integral']) {
+                update_user_integral($data['uid'],$data['integral'],1,'积分转换',$data['id']);
+            }
+        }
+
     }
 
 

+ 1 - 1
application/store/view/order_shift/form.html

@@ -55,7 +55,7 @@
         {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
         {if $vo.sh_status == 0}
             <button class="layui-btn" type='submit'>确定审核</button>
-            <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消审核吗?" data-close>取消审核</button>
+            <button class="layui-btn layui-btn-danger" type='button' data-close>取消审核</button>
         {else}
             <button class="layui-btn layui-btn-danger" type='button' data-close>关闭</button>
         {/if}