Share.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Shop\Lib;
  3. use Dever;
  4. class Share
  5. {
  6. # 验证是否已经分享
  7. public function getOne($uid, $shop_id, $act_id)
  8. {
  9. $where['uid'] = $uid;
  10. $where['shop_id'] = $shop_id;
  11. $where['act_id'] = $act_id;
  12. $where['status'] = 1;
  13. $info = Dever::db('shop/user_share')->find($where);
  14. if ($info) {
  15. Dever::db('shop/user_share')->update(array('where_id' => $info['id'], 'status' => 2));
  16. }
  17. return $info;
  18. }
  19. # 分享
  20. public function up($uid, $shop_id, $act_id, $path = '')
  21. {
  22. $data['uid'] = $uid;
  23. $data['shop_id'] = $shop_id;
  24. $data['act_id'] = $act_id;
  25. //$data['status'] = 1;
  26. $info = Dever::db('shop/user_share')->find($data);
  27. if (!$info) {
  28. $data['path'] = $path;
  29. $id = Dever::db('shop/user_share')->insert($data);
  30. return $id;
  31. } else {
  32. $data['path'] = $path;
  33. $data['status'] = 1;
  34. $data['where_id'] = $info['id'];
  35. Dever::db('shop/user_share')->update($data);
  36. return $info['id'];
  37. }
  38. return true;
  39. }
  40. }