Memberbank.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. namespace app\home\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. * DSMall多用户商城
  8. * ============================================================================
  9. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  10. * 网站地址: http://www.csdeshang.com
  11. * ----------------------------------------------------------------------------
  12. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  13. * 不允许对程序代码以任何形式任何目的的再发布。
  14. * ============================================================================
  15. * 控制器
  16. */
  17. class Memberbank extends BaseMember {
  18. public function initialize() {
  19. parent::initialize();
  20. Lang::load(base_path() . 'home/lang/'.config('lang.default_lang').'/memberbank.lang.php');
  21. }
  22. public function index() {
  23. $memberbank_model=model('memberbank');
  24. $memberbank_list = $memberbank_model->getMemberbankList(array('member_id'=>session('member_id')));
  25. View::assign('memberbank_list', $memberbank_list);
  26. /* 设置买家当前菜单 */
  27. $this->setMemberCurMenu('member_bank');
  28. /* 设置买家当前栏目 */
  29. $this->setMemberCurItem('memberbank_index');
  30. return View::fetch($this->template_dir . 'index');
  31. }
  32. public function add() {
  33. if (!request()->isPost()) {
  34. $memberbank = array(
  35. 'memberbank_type' => 'bank',
  36. );
  37. View::assign('memberbank', $memberbank);
  38. /* 设置买家当前菜单 */
  39. $this->setMemberCurMenu('member_bank');
  40. /* 设置买家当前栏目 */
  41. $this->setMemberCurItem('memberbank_add');
  42. return View::fetch($this->template_dir . 'form');
  43. } else {
  44. $data = array(
  45. 'member_id' => session('member_id'),
  46. 'memberbank_type' => input('post.memberbank_type'),
  47. 'memberbank_truename' => input('post.memberbank_truename'),
  48. 'memberbank_name' => input('post.memberbank_name'),
  49. 'memberbank_no' => input('post.memberbank_no'),
  50. );
  51. $memberbank_validate = ds_validate('memberbank');
  52. if (!$memberbank_validate->scene('add')->check($data)) {
  53. ds_json_encode(10001,$memberbank_validate->getError());
  54. }
  55. $memberbank_model=model('memberbank');
  56. $result = $memberbank_model->addMemberbank($data);
  57. if ($result) {
  58. ds_json_encode(10000,lang('ds_common_save_succ'));
  59. } else {
  60. ds_json_encode(10001,lang('ds_common_save_fail'));
  61. }
  62. }
  63. }
  64. public function edit() {
  65. $memberbank_id = intval(input('param.memberbank_id'));
  66. if (0 >= $memberbank_id) {
  67. ds_json_encode(10001,lang('param_error'));
  68. }
  69. $memberbank_model=model('memberbank');
  70. $memberbank = $memberbank_model->getMemberbankInfo(array('member_id' => session('member_id'), 'memberbank_id' => $memberbank_id));
  71. if (empty($memberbank)) {
  72. ds_json_encode(10001,lang('memberbank_does_not_exist'));
  73. }
  74. if (!request()->isPost()) {
  75. View::assign('memberbank', $memberbank);
  76. /* 设置买家当前菜单 */
  77. $this->setMemberCurMenu('member_bank');
  78. /* 设置买家当前栏目 */
  79. $this->setMemberCurItem('memberbank_edit');
  80. return View::fetch($this->template_dir . 'form');
  81. } else {
  82. $data = array(
  83. 'memberbank_type' => input('post.memberbank_type'),
  84. 'memberbank_truename' => input('post.memberbank_truename'),
  85. 'memberbank_name' => input('post.memberbank_name'),
  86. 'memberbank_no' => input('post.memberbank_no'),
  87. );
  88. $memberbank_validate = ds_validate('memberbank');
  89. if (!$memberbank_validate->scene('edit')->check($data)) {
  90. ds_json_encode(10001,$memberbank_validate->getError());
  91. }
  92. $result = $memberbank_model->editMemberbank($data,array('member_id' => session('member_id'), 'memberbank_id' => $memberbank_id));
  93. if ($result) {
  94. ds_json_encode(10000,lang('ds_common_save_succ'));
  95. } else {
  96. ds_json_encode(10001,lang('ds_common_save_fail'));
  97. }
  98. }
  99. }
  100. public function drop() {
  101. $memberbank_id = intval(input('param.memberbank_id'));
  102. if (0 >= $memberbank_id) {
  103. ds_json_encode(10001,lang('empty_error'));
  104. }
  105. $memberbank_model=model('memberbank');
  106. $condition = array();
  107. $condition[] = array('memberbank_id','=',$memberbank_id);
  108. $condition[] = array('member_id','=',session('member_id'));
  109. $result = $memberbank_model->delMemberbank($condition);
  110. if ($result) {
  111. ds_json_encode(10000,lang('ds_common_del_succ'));
  112. } else {
  113. ds_json_encode(10001,lang('ds_common_del_fail'));
  114. }
  115. }
  116. /**
  117. * 栏目菜单
  118. */
  119. function getMemberItemList() {
  120. $item_list = array(
  121. array(
  122. 'name' => 'memberbank_index',
  123. 'text' => lang('memberbank_index'),
  124. 'url' => (string)url('Memberbank/index'),
  125. ),
  126. array(
  127. 'name' => 'memberbank_add',
  128. 'text' => lang('memberbank_add'),
  129. 'url' => (string)url('Memberbank/add'),
  130. ),
  131. );
  132. if (request()->action() == 'edit') {
  133. $item_list[] = array(
  134. 'name' => 'memberbank_edit',
  135. 'text' => lang('memberbank_edit'),
  136. 'url' => "javascript:void(0)",
  137. );
  138. }
  139. return $item_list;
  140. }
  141. }