Wechat.php 725 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace User\Lib;
  3. use Dever;
  4. class Wechat
  5. {
  6. public function getInfo($uid, $system_source = 5, $project_id = 1)
  7. {
  8. return Dever::db('user/wechat')->one(array('uid' => $uid, 'project_id' => $project_id, 'system_source' => $system_source));
  9. }
  10. public function update($uid, $openid, $system_source = 5, $project_id = 1)
  11. {
  12. $info = $this->getInfo($uid, $system_source, $project_id);
  13. $data['uid'] = $uid;
  14. $data['openid'] = $openid;
  15. $data['system_source'] = $system_source;
  16. $data['project_id'] = $project_id;
  17. if ($info) {
  18. $data['where_id'] = $info['id'];
  19. return Dever::db('user/wechat')->update($data);
  20. } else {
  21. return Dever::db('user/wechat')->insert($data);
  22. }
  23. }
  24. }