12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace Shop\Lib;
- use Dever;
- class Share
- {
- # 验证是否已经分享
- public function getOne($uid, $shop_id, $act_id)
- {
- $where['uid'] = $uid;
- $where['shop_id'] = $shop_id;
- $where['act_id'] = $act_id;
- $where['status'] = 1;
- $info = Dever::db('shop/user_share')->find($where);
- if ($info) {
- Dever::db('shop/user_share')->update(array('where_id' => $info['id'], 'status' => 2));
- }
- return $info;
- }
- # 分享
- public function up($uid, $shop_id, $act_id, $path = '')
- {
- $data['uid'] = $uid;
- $data['shop_id'] = $shop_id;
- $data['act_id'] = $act_id;
- //$data['status'] = 1;
- $info = Dever::db('shop/user_share')->find($data);
- if (!$info) {
- $data['path'] = $path;
- $id = Dever::db('shop/user_share')->insert($data);
- return $id;
- } else {
- $data['path'] = $path;
- $data['status'] = 1;
- $data['where_id'] = $info['id'];
- Dever::db('shop/user_share')->update($data);
- return $info['id'];
- }
- return true;
- }
- }
|