OrderAutoSendArea.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace app\common\model;
  3. use think\Db;
  4. class OrderAutoSendArea extends Base
  5. {
  6. protected $createTime = 'create_time';
  7. protected $table = 'order_auto_send_area';
  8. protected $validateName = 'OrderAutoSendArea';
  9. public function updates(){
  10. $data = request()->post();
  11. $data['org_id'] =cur_org_id();
  12. $result = validate($this->validateName)->check($data,[],'');
  13. if(true !== $result){
  14. $this->error = validate($this->validateName)->getError();
  15. return false;
  16. }
  17. $id = $data['id'];
  18. unset($data['id']);
  19. if($id > 0){
  20. $data['update_time'] = date('Y-m-d H:i:s');
  21. $ret = $this->allowField(true)->save($data,['id'=>$id]);
  22. }else{
  23. $data['create_time'] = date('Y-m-d H:i:s');
  24. $ret = $this->allowField(true)->save($data);
  25. }
  26. if(!$ret){
  27. $this->error = '操作失败';
  28. return false;
  29. }
  30. $content = '新增';
  31. if($id > 0){
  32. $content = '编辑';
  33. $data['id'] = $id;
  34. }else{
  35. $data['id'] = $this->id;
  36. }
  37. return true;
  38. }
  39. }