DeliveryModel.class.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. /**
  3. * 小梦科技资源nanodreamtech.com
  4. *
  5. * ==========================================================================
  6. * @link https://www.nanodreamtech.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license https://www.nanodreamtech.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Seller\Model;
  15. class DeliveryModel{
  16. public function adddelivery_clerk($data, $uniacid = 0)
  17. {
  18. $ins_data = array();
  19. $ins_data['name'] = $data['name'];
  20. $ins_data['logo'] = $data['logo'];
  21. $ins_data['mobile'] = $data['mobile'];
  22. $ins_data['addtime'] = time();
  23. $id = $data['id'];
  24. if( !empty($id) && $id > 0 )
  25. {
  26. unset($ins_data['addtime']);
  27. M('lionfish_comshop_deliveryclerk')->where( array('id' => $id) )->save( $ins_data );
  28. $id = $data['id'];
  29. }else{
  30. $ins_data['line_id'] = 0;
  31. $id = M('lionfish_comshop_deliveryclerk')->add($ins_data);
  32. }
  33. }
  34. public function adddeliverylist($data, $uniacid = 0)
  35. {
  36. $head_id_arr = $data['head_id'];
  37. $ins_data = array();
  38. $ins_data['name'] = $data['name'];
  39. $ins_data['clerk_id'] = $data['clerk_id'];
  40. $ins_data['addtime'] = time();
  41. $id = $data['id'];
  42. if( !empty($id) && $id > 0 )
  43. {
  44. unset($ins_data['addtime']);
  45. M('lionfish_comshop_deliveryline')->where( array('id' => $id) )->save($ins_data);
  46. $id = $data['id'];
  47. }else{
  48. $id = M('lionfish_comshop_deliveryline')->add( $ins_data );
  49. }
  50. M('lionfish_comshop_deliveryclerk')->where( array('line_id' => $id ) )->save( array('line_id' => 0 ) );
  51. //修改配送员的线路
  52. M('lionfish_comshop_deliveryclerk')->where( array('id' => $data['clerk_id'] ) )->save( array('line_id' => $id) );
  53. //修改配送员的线路todo....
  54. M('lionfish_comshop_deliveryline_headrelative')->where( array('line_id' => $id) )->delete();
  55. $rel_data = array();
  56. $rel_data['line_id'] = $id;
  57. $rel_data['uniacid'] = $uniacid;
  58. $rel_data['addtime'] = time();
  59. if(!empty($head_id_arr))
  60. {
  61. if(is_array($head_id_arr) )
  62. {
  63. foreach($head_id_arr as $vv)
  64. {
  65. if(!is_numeric($vv))
  66. {
  67. continue;
  68. }
  69. $rel_data['head_id'] = $vv;
  70. M('lionfish_comshop_deliveryline_headrelative')->add($rel_data);
  71. }
  72. }
  73. }
  74. }
  75. public function update($data, $uniacid = 0)
  76. {
  77. $ins_data = array();
  78. $ins_data['title'] = $data['title'];
  79. $ins_data['content'] = $data['content'];
  80. $ins_data['displayorder'] = $data['displayorder'];
  81. $ins_data['enabled'] = $data['enabled'];
  82. $ins_data['addtime'] = time();
  83. $id = $data['id'];
  84. if( !empty($id) && $id > 0 )
  85. {
  86. unset($ins_data['addtime']);
  87. M('lionfish_comshop_article')->where( array('id' => $id) )->save( $ins_data );
  88. $id = $data['id'];
  89. }else{
  90. $id = M('lionfish_comshop_article')->add( $ins_data );
  91. }
  92. }
  93. }
  94. ?>