Electronicsheet.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\electronicsheet\shop\controller;
  11. use app\model\express\ExpressCompanyTemplate;
  12. use app\shop\controller\BaseShop;
  13. use addon\electronicsheet\model\ExpressElectronicsheet as ExpressElectronicsheetModel;
  14. class Electronicsheet extends BaseShop
  15. {
  16. public function __construct()
  17. {
  18. parent::__construct();
  19. $this->forthMenu();
  20. }
  21. /*
  22. * 电子面单列表
  23. */
  24. public function lists()
  25. {
  26. $model = new ExpressElectronicsheetModel();
  27. $condition[] = [ 'site_id', '=', $this->site_id ];
  28. //获取续签信息
  29. if (request()->isAjax()) {
  30. $status = input('status', '');//模板状态
  31. if ($status) {
  32. $condition[] = [ 'status', '=', $status ];
  33. }
  34. $template_name = input('template_name', '');
  35. if ($template_name) {
  36. $condition[] = [ 'template_name', 'like', '%' . $template_name . '%' ];
  37. }
  38. $page = input('page', 1);
  39. $page_size = input('page_size', PAGE_LIST_ROWS);
  40. $list = $model->getExpressElectronicsheetPageList($condition, $page, $page_size, 'is_default desc');
  41. return $list;
  42. }
  43. return $this->fetch('electronicsheet/lists');
  44. }
  45. /**
  46. * 添加电子面单
  47. */
  48. public function add()
  49. {
  50. if (request()->isAjax()) {
  51. $data = [
  52. 'site_id' => $this->site_id,
  53. 'template_name' => input('template_name', ''),
  54. 'company_id' => input('company_id', ''),
  55. 'customer_name' => input('customer_name', ''),
  56. 'customer_pwd' => input('customer_pwd', ''),
  57. 'send_site' => input('send_site', ''),
  58. 'send_staff' => input('send_staff', ''),
  59. 'month_code' => input('month_code', ''),
  60. 'postage_payment_method' => input('postage_payment_method', ''),
  61. 'is_notice' => input('is_notice', ''),
  62. 'is_default' => input('is_default', 0),
  63. 'print_style' => input('print_style', 0),
  64. ];
  65. $model = new ExpressElectronicsheetModel();
  66. return $model->addExpressElectronicsheet($data);
  67. } else {
  68. //快递公司
  69. $express_company_model = new ExpressCompanyTemplate();
  70. $condition = [
  71. [ 'is_electronicsheet', '=', 1 ],
  72. ];
  73. $company_list = $express_company_model->getExpressCompanyTemplateList($condition, 'company_id,company_name,print_style', 'sort asc');
  74. $this->assign('company_list', $company_list[ 'data' ]);
  75. return $this->fetch('electronicsheet/add');
  76. }
  77. }
  78. /**
  79. * 编辑电子面单
  80. */
  81. public function edit()
  82. {
  83. $model = new ExpressElectronicsheetModel();
  84. $id = input('id', 0);
  85. if (request()->isAjax()) {
  86. $data = [
  87. 'id' => $id,
  88. 'site_id' => $this->site_id,
  89. 'template_name' => input('template_name', ''),
  90. 'company_id' => input('company_id', ''),
  91. 'customer_name' => input('customer_name', ''),
  92. 'customer_pwd' => input('customer_pwd', ''),
  93. 'send_site' => input('send_site', ''),
  94. 'send_staff' => input('send_staff', ''),
  95. 'month_code' => input('month_code', ''),
  96. 'postage_payment_method' => input('postage_payment_method', ''),
  97. 'is_notice' => input('is_notice', ''),
  98. 'is_default' => input('is_default', 0),
  99. 'print_style' => input('print_style', 0),
  100. ];
  101. return $model->editExpressElectronicsheet($data);
  102. } else {
  103. $info = $model->getExpressElectronicsheetInfo([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
  104. $this->assign('electronicsheet_info', $info[ 'data' ]);
  105. //快递公司
  106. $express_company_model = new ExpressCompanyTemplate();
  107. $condition = [
  108. [ 'is_electronicsheet', '=', 1 ],
  109. ];
  110. $company_list = $express_company_model->getExpressCompanyTemplateList($condition, 'company_id,company_name,print_style', 'sort asc');
  111. $this->assign('company_list', $company_list[ 'data' ]);
  112. return $this->fetch('electronicsheet/edit');
  113. }
  114. }
  115. /*
  116. * 删除
  117. */
  118. public function delete()
  119. {
  120. $id = input('id', '');
  121. $groupbuy_model = new ExpressElectronicsheetModel();
  122. return $groupbuy_model->deleteExpressElectronicsheet([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
  123. }
  124. /*
  125. * 修改默认状态
  126. */
  127. public function setDefaultStatus()
  128. {
  129. $id = input('id', '');
  130. $groupbuy_model = new ExpressElectronicsheetModel();
  131. $groupbuy_model->setExpressElectronicsheetDefault([ [ 'site_id', '=', $this->site_id ] ], 0);
  132. return $groupbuy_model->setExpressElectronicsheetDefault([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ], 1);
  133. }
  134. }