Browse Source

Add get user bonus proccess

Wan Xin 9 years ago
parent
commit
fb3fed86c8
3 changed files with 47 additions and 2 deletions
  1. 1 1
      admin/control/bonus.php
  2. 17 1
      data/model/user_bonus.model.php
  3. 29 0
      mobile/control/member_bonus.php

+ 1 - 1
admin/control/bonus.php

@@ -51,7 +51,7 @@ class bonusControl extends SystemControl{
                 }
                 $bonus_file_content = file_get_contents($bonus_file['tmp_name']);
                 $bonus = Model('user_bonus');
-                $bonus->load_file($bonus_file_content);
+                $bonus->loadFile($bonus_file_content);
             }
         }
         $this->bonus_typeOp();

+ 17 - 1
data/model/user_bonus.model.php

@@ -10,7 +10,7 @@ class user_bonusModel extends Model {
         parent::__construct('user_bonus');
     }
 
-    public function load_file($content){
+    public function loadFile($content){
         $lines = explode("\n", $content);
         foreach($lines as $line){
             $bonus = explode(',', trim($line));
@@ -18,6 +18,22 @@ class user_bonusModel extends Model {
         }
     }
 
+    public function getBonus($user_id, $user_mobile){
+        $bonus = $this->where(array('user_mobile' => $user_mobile))->select();
+        if(intval($bonus[0]['user_id']) === 0){
+            $update_data = array(
+                'user_id' => $user_id,
+                'get_time' => time()
+            );
+            $this->where(array('user_mobile' => $user_mobile))->update($update_data);
+        }
+        $bonus_data = array(
+            'bonus_sn' => $bonus[0]['bonus_sn'],
+            'bonus_value' => $bonus[0]['bonus_value']
+        );
+        return $bonus_data;
+    }
+
     private function createBonus($bonus){
         $bouns_sn = $this->generateSn();
         $bonus_value = array(

+ 29 - 0
mobile/control/member_bonus.php

@@ -0,0 +1,29 @@
+<?php
+/**
+ * 红包
+ *
+ *
+ *
+ *
+
+ */
+
+defined('InShopNC') or exit('Access Invalid!');
+
+class member_bonusControl extends mobileMemberControl
+{
+    public function __construct(){
+        parent::__construct();
+    }
+
+    public function get_bonusOp(){
+        $bonus_type = $_POST['type'];
+        $bonus = Model($bonus_type);
+        if($bonus_type === 'user_bonus') {
+            $user_id = $this->member_info['member_id'];
+            $user_mobile = $_POST['mobile'];
+            $bonus_data = $bonus->getBonus($user_id, $user_mobile);
+        }
+        joutput_data($bonus_data);
+    }
+}