BoxModel.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace app\index\model;
  3. use think\Model;
  4. class BoxModel extends Model {
  5. // 确定链接表名
  6. protected $name = 'box';
  7. public function Order()
  8. {
  9. return $this->hasOne('OrderModel', 'order_sn', 'order_sn')->joinType('LEFT');
  10. }
  11. /**
  12. * 根据柜号箱号获取箱子信息
  13. * @cabinet_number $param
  14. * @box_number $param
  15. */
  16. public function getOneCabinetBox($cabinet_number,$box_number)
  17. {
  18. return $this->where(['cabinet_number' => $cabinet_number, 'box_number'=>$box_number])->find();
  19. }
  20. /**
  21. * 根据既定条件修改信息
  22. * @where $param
  23. * @update $param
  24. */
  25. public function editData($where,$update)
  26. {
  27. try{
  28. $result = $this->save($update, $where);
  29. if(false === $result){
  30. // 验证失败 输出错误信息
  31. return msg(-1, '', $this->getError());
  32. }else{
  33. return msg(1, '', 'success');
  34. }
  35. }catch(\Exception $e){
  36. return msg(-2, '', $e->getMessage());
  37. }
  38. }
  39. /**
  40. * 根据搜索条件获取箱子列表信息
  41. * @param $offset
  42. * @param $limit
  43. */
  44. public function getBoxsByWhere($where)
  45. {
  46. return $this->Order()->haswhere($where)->order('sc_box.box_number asc')->field('sc_box.*,OrderModel.enter_time')->select();
  47. }
  48. /**
  49. * 根据搜索条件获取所有的箱子数量
  50. */
  51. public function getAllCounts($where)
  52. {
  53. return $this->count();
  54. }
  55. /**
  56. * 根据搜索条件获取箱子列表信息
  57. * @param $offset
  58. * @param $limit
  59. */
  60. public function getBoxNumbers($where)
  61. {
  62. return $this->where($where)->order('box_number asc')->field('box_number')->select();
  63. }
  64. public function CheckCode($code){
  65. return $this->where('fetch_code' , $code)->find();
  66. }
  67. }