AllwinUnmarketVerif.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 https://www.sapixx.com All rights reserved.
  4. * @license Licensed (http://www.apache.org/licenses/LICENSE-2.0).
  5. * @author pillar<ltmn@qq.com>
  6. * 核销
  7. */
  8. namespace app\allwin\model;
  9. use think\Model;
  10. class AllwinUnmarketVerif extends Model{
  11. protected $pk = 'id';
  12. //和主用户表绑定关系
  13. public function user(){
  14. return $this->hasOne('app\common\model\SystemUser','id','uid');
  15. }
  16. //获得主表
  17. public function store(){
  18. return $this->hasOne('AllwinUnmarketStore','id','store_id');
  19. }
  20. //添加或编辑
  21. public static function edit(array $param){
  22. $data = [
  23. 'uid' => trim($param['uid']),
  24. 'union_id' => trim($param['union_id']),
  25. 'store_id' => trim($param['store_id']),
  26. 'times' => strtotime($param['times']),
  27. ];
  28. if(isset($param['id'])){
  29. $condition['id'] = $param['id'];
  30. $condition['member_miniapp_id'] = $param['member_miniapp_id'];
  31. return self::where($condition)->update($data);
  32. }else{
  33. $data['member_miniapp_id'] = $param['member_miniapp_id'];
  34. return self::insert($data);
  35. }
  36. }
  37. }