Dispatch.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * 配送模板数据操作
  4. * Created by PhpStorm.
  5. * Author: 芸众商城 www.yunzshop.com
  6. * Date: 2017/2/24
  7. * Time: 下午2:31
  8. */
  9. namespace app\backend\modules\goods\models;
  10. class Dispatch extends \app\common\models\goods\Dispatch
  11. {
  12. static protected $needLog = true;
  13. /**
  14. * 获取配送模板所有数据
  15. * @param int $goodsId
  16. * @return array
  17. */
  18. public static function getList()
  19. {
  20. return self::uniacid()
  21. ->get();
  22. }
  23. public static function getAll()
  24. {
  25. return self::getDispatchList();
  26. }
  27. public static function getTemplate(){
  28. return self::getDispatch();
  29. }
  30. /**
  31. * 获取配送模板单条数据
  32. * @param int $goodsId
  33. * @return array
  34. */
  35. public static function getOne($id)
  36. {
  37. return self::where('id', $id)
  38. ->first();
  39. }
  40. /**
  41. * 获取配送模板单条数据
  42. * @param int $goodsId
  43. * @return array
  44. */
  45. public static function getOneByDefault()
  46. {
  47. return self::uniacid()->where('is_default', 1)
  48. ->first();
  49. }
  50. /**
  51. * 配送模板数据添加
  52. * @param array $DispatchInfo
  53. * @return bool
  54. */
  55. public static function createdDispatch($DispatchInfo)
  56. {
  57. return self::insert($DispatchInfo);
  58. }
  59. /**
  60. * 配送模板数据更新
  61. * @param array $DispatchInfo
  62. * @return mixed
  63. */
  64. public static function updatedDispatch($dispatchId, $DispatchInfo)
  65. {
  66. return self::where('id', $dispatchId)->update($DispatchInfo);
  67. }
  68. /**
  69. * 配送模板数据删除
  70. * @param int $goodsId
  71. * @return mixed
  72. */
  73. public static function deletedDispatch($dispatchId)
  74. {
  75. return self::where('id', $dispatchId)->delete();
  76. }
  77. public static function quickUpdatedDispatch($id, $type,$status)
  78. {
  79. if ($type == 'is_default' && $status){
  80. self::uniacid()->where('is_default', 1)->update(['is_default' => 0]);
  81. }
  82. return self::where('id', $id)->update([$type => $status]);
  83. }
  84. }