AllwinUnmarketStore.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 AllwinUnmarketStore extends Model{
  11. protected $pk = 'id';
  12. //是否核销
  13. public function verif(){
  14. return $this->hasOne('AllwinUnmarketVerif','store_id','id');
  15. }
  16. //添加或编辑
  17. public static function edit(array $param){
  18. $data = [
  19. 'union_id' => $param['union_id'],
  20. 'name' => trim($param['name']),
  21. 'address' => trim($param['address']),
  22. 'telphone' => trim($param['tel']),
  23. 'content' => $param['content'],
  24. 'note' => $param['note'],
  25. 'about' => $param['about'],
  26. 'pictext' => $param['pictext'],
  27. 'img' => $param['img'],
  28. 'imgs' => json_encode($param['imgs']),
  29. 'endtime' => strtotime($param['end_time']),
  30. 'store_id' => $param['store_id'],
  31. ];
  32. if(isset($param['id'])){
  33. $condition['id'] = $param['id'];
  34. $condition['member_miniapp_id'] = $param['member_miniapp_id'];
  35. return self::where($condition)->update($data);
  36. }else{
  37. $data['member_miniapp_id'] = $param['member_miniapp_id'];
  38. return self::insert($data);
  39. }
  40. }
  41. }