Express.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. *
  4. * @copyright ©2020 点小铺
  5. * @author hanj
  6. * @link: https://dyuit.com
  7. * Created by VSCode
  8. */
  9. namespace app\store\model;
  10. use app\common\model\Express as ExpressModel;
  11. class Express extends ExpressModel
  12. {
  13. /**
  14. * 添加新记录
  15. * @param $data
  16. * @return false|int
  17. */
  18. public function add($data)
  19. {
  20. $data['wxapp_id'] = self::$wxapp_id;
  21. return $this->allowField(true)->save($data);
  22. }
  23. /**
  24. * 编辑记录
  25. * @param $data
  26. * @return bool|int
  27. */
  28. public function edit($data)
  29. {
  30. return $this->allowField(true)->save($data);
  31. }
  32. /**
  33. * 删除记录
  34. * @return bool|int
  35. */
  36. public function remove()
  37. {
  38. // 判断当前物流公司是否已被订单使用
  39. $Order = new Order;
  40. if ($orderCount = $Order->where(['express_id' => $this['express_id']])->count()) {
  41. $this->error = '当前物流公司已被' . $orderCount . '个订单使用,不允许删除';
  42. return false;
  43. }
  44. return $this->delete();
  45. }
  46. }