SystemStockBill.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. *
  4. * @author: xaboy<365615158@qq.com>
  5. * @day: 2017/12/13
  6. */
  7. namespace app\models\store;
  8. use crmeb\basic\BaseModel;
  9. use think\facade\Db;
  10. use crmeb\traits\ModelTrait;
  11. /**
  12. * TODO 产品属性Model
  13. * Class StoreProductAttr
  14. * @package app\models\store
  15. */
  16. class SystemStockBill extends BaseModel
  17. {
  18. use ModelTrait;
  19. public static function getAddTimeAttr($value)
  20. {
  21. return date("Y-m-d H:i:s",$value);
  22. }
  23. public static function getAuditTimeAttr($value)
  24. {
  25. return $value?date("Y-m-d H:i:s",$value):'-';
  26. }
  27. public static function getStatusAttr($value)
  28. {
  29. switch ($value)
  30. {
  31. case 0:
  32. return '待审核';
  33. break;
  34. case 1:
  35. return '已通过';
  36. break;
  37. case -1:
  38. return '已拒绝';
  39. break;
  40. }
  41. }
  42. /**
  43. *创建记录
  44. */
  45. public static function order_create($data)
  46. {
  47. if ($data['product_id'] > 0 && $data['in_stock'] > 0) {
  48. $data['add_time'] = time();
  49. self::create($data);
  50. return true;
  51. }
  52. return false;
  53. }
  54. /**
  55. *获取列表
  56. */
  57. public static function lst($where)
  58. {
  59. $model = new self;
  60. $model = $model->alias("a")->join("store_product b","a.product_id=b.id","right");
  61. if(isset($where['status']) && $where['status']>-2) $model = $model->where('a.status',$where['status']);
  62. if(isset($where['key']) && $where['key']) $model = $model->wherelike('b.store_name',"%".$where['key']."%");
  63. if(isset($where['product_id']) && $where['product_id']) $model = $model->wherelike('a.product_id',$where['product_id']);
  64. $model = $model->where('a.id','>',0);
  65. $model = $model->field('a.*,b.image,b.is_show,b.is_del,b.store_name');
  66. $count = $model->count();
  67. $data = $model->page($where['page'],$where['limit'])->order("id desc")->select()->toarray();
  68. return compact('count','data');
  69. }
  70. }