WxGoodsCate.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\common\model;
  3. use think\Db;
  4. class WxGoodsCate extends Base
  5. {
  6. public function updates(){
  7. $data = request()->post();
  8. $data['org_id'] = cur_org_id();
  9. $result = validate('WxGoodsCate')->check($data,[],'');
  10. if(true !== $result){
  11. $this->error = validate('WxGoodsCate')->getError();
  12. return false;
  13. }
  14. $id = $data['id'];
  15. unset($data['id']);
  16. if($id > 0){
  17. $ret = $this->allowField(true)->save($data,['id'=>$id]);
  18. }else{
  19. $data['create_time'] = date('Y-m-d H:i:s');
  20. $ret = $this->allowField(true)->save($data);
  21. }
  22. if(!$ret){
  23. $this->error = '操作失败';
  24. return false;
  25. }
  26. return true;
  27. }
  28. public function lists($orgId){
  29. $ret=Db::name('wx_goods_cate')
  30. ->field('id,title,is_water,path')
  31. ->where(['org_id'=>$orgId,'enable'=>1,'del'=>0])
  32. ->order(['sort'=>'asc','id'=>'desc'])
  33. ->select();
  34. // $data=[
  35. // [
  36. // 'id'=>0,
  37. // 'title'=>'全部'
  38. // ],
  39. // ];
  40. // foreach ($ret as $k=>$v){
  41. // $data[] = $v;
  42. // }
  43. return $ret;
  44. }
  45. public function getLabel(){
  46. $ret=Db::name('wx_goods_label')
  47. ->where('enable',1)
  48. ->where('del',0)
  49. ->select();
  50. return $ret;
  51. }
  52. }