|
@@ -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']]);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|