Memberevaluate.php 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <?php
  2. namespace app\home\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. use think\Model;
  6. /**
  7. *
  8. *
  9. * ----------------------------------------------------------------------------
  10. *
  11. * 控制器
  12. */
  13. class Memberevaluate extends BaseMember
  14. {
  15. public function initialize()
  16. {
  17. parent::initialize();
  18. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/memberevaluate.lang.php');
  19. }
  20. /**
  21. * 订单添加评价
  22. */
  23. public function add()
  24. {
  25. $order_id = intval(input('order_id'));
  26. if (!$order_id) {
  27. $this->error(lang('param_error'), 'member_order/index');
  28. }
  29. $return = model('memberevaluate', 'logic')->validation($order_id, $this->member_info['member_id']);
  30. if (isset($return['state'])) {
  31. ds_json_encode(10001, $return['msg']);
  32. }
  33. extract($return['data']);
  34. //判断是否为页面
  35. if (!request()->isPost()) {
  36. //处理积分、经验值计算说明文字
  37. $expset = rkcache('config', true);
  38. $ruleexplain = '';
  39. $exppoints_rule = $expset['expset'] ? unserialize($expset['expset']) : array();
  40. $exppoints_rule['exp_comments'] = intval($exppoints_rule['comment_exp']);
  41. if ($exppoints_rule['exp_comments'] > 0) {
  42. $ruleexplain .= lang('evaluation_completed_will_obtained');
  43. if ($exppoints_rule['exp_comments'] > 0) {
  44. $ruleexplain .= (' “' . $exppoints_rule['exp_comments'] . lang('experience_value'));
  45. }
  46. }
  47. View::assign('ruleexplain', $ruleexplain);
  48. //不显示左菜单
  49. View::assign('left_show', 'order_view');
  50. View::assign('order_id', $order_id);
  51. View::assign('order_info', $order_info);
  52. View::assign('order_goods', $order_goods);
  53. View::assign('store_info', $store_info);
  54. /* 设置买家当前菜单 */
  55. $this->setMemberCurMenu('member_evaluate');
  56. /* 设置买家当前栏目 */
  57. $this->setMemberCurItem('evaluate');
  58. return View::fetch($this->template_dir . 'evaluation_add');
  59. } else {
  60. //调用逻辑层方法,PC和手机端统一使用
  61. $return = model('memberevaluate', 'logic')->saveorderevaluate($order_info, $store_info, $order_goods, $this->member_info['member_id'], $this->member_info['member_name']);
  62. if ($return == true) {
  63. ds_json_encode(10000, lang('member_evaluation_evaluat_success'));
  64. } else {
  65. ds_json_encode(10001, lang('ds_common_save_fail'));
  66. }
  67. }
  68. }
  69. /**
  70. * 虚拟商品评价
  71. */
  72. public function add_vr()
  73. {
  74. $order_id = intval(input('param.order_id'));
  75. if (!$order_id) {
  76. ds_json_encode('10001', lang('param_error'));
  77. }
  78. $vrorder_model = model('vrorder');
  79. $store_model = model('store');
  80. $evaluategoods_model = model('evaluategoods');
  81. $return = model('memberevaluate', 'logic')->validationVr($order_id, $this->member_info['member_id']);
  82. if (isset($return['state'])) {
  83. ds_json_encode(10001, $return['msg']);
  84. }
  85. extract($return['data']);
  86. $order_goods = array($order_info);
  87. //判断是否为页面
  88. if (!request()->isPost()) {
  89. $order_goods[0]['goods_image_url'] = goods_cthumb($order_info['goods_image'], 240, $order_info['store_id']);
  90. //处理积分、经验值计算说明文字
  91. $ruleexplain = '';
  92. $exppoints_rule = config("ds_config.exppoints_rule") ? unserialize(config("ds_config.exppoints_rule")) : array();
  93. $exppoints_rule['exp_comments'] = intval($exppoints_rule['exp_comments']);
  94. $points_comments = intval(config('ds_config.points_comments'));
  95. if ($exppoints_rule['exp_comments'] > 0 || $points_comments > 0) {
  96. $ruleexplain .= lang('evaluation_completed_will_obtained');
  97. if ($exppoints_rule['exp_comments'] > 0) {
  98. $ruleexplain .= (' “' . $exppoints_rule['exp_comments'] . lang('experience_value'));
  99. }
  100. if ($points_comments > 0) {
  101. $ruleexplain .= (' “' . $points_comments . lang('integral'));
  102. }
  103. $ruleexplain .= '。';
  104. }
  105. View::assign('ruleexplain', $ruleexplain);
  106. //不显示左菜单
  107. View::assign('left_show', 'order_view');
  108. View::assign('order_info', $order_info);
  109. View::assign('order_goods', $order_goods);
  110. View::assign('store_info', $store_info);
  111. /* 设置买家当前菜单 */
  112. $this->setMemberCurMenu('member_evaluate');
  113. /* 设置买家当前栏目 */
  114. $this->setMemberCurItem('evaluate');
  115. return View::fetch($this->template_dir . 'evaluation_add');
  116. } else {
  117. //调用逻辑层方法,PC和手机端统一使用
  118. $return = model('memberevaluate', 'logic')->saveVr($order_info, $store_info, $order_goods, $this->member_info['member_id'], $this->member_info['member_name']);
  119. if (!$return['state']) {
  120. ds_json_encode(10000, lang('member_evaluation_evaluat_success'));
  121. } else {
  122. ds_json_encode(10001, lang('ds_common_save_fail'));
  123. }
  124. }
  125. }
  126. /**
  127. * 评价列表
  128. */
  129. public function index()
  130. {
  131. $evaluategoods_model = model('evaluategoods');
  132. $condition = array();
  133. $condition[] = array('geval_frommemberid', '=', session('member_id'));
  134. $goodsevallist = $evaluategoods_model->getEvaluategoodsList($condition, 5, 'geval_id desc');
  135. View::assign('goodsevallist', $goodsevallist);
  136. /* 设置买家当前菜单 */
  137. $this->setMemberCurMenu('member_evaluate');
  138. /* 设置买家当前栏目 */
  139. $this->setMemberCurItem('evaluate');
  140. View::assign('show_page', $evaluategoods_model->page_info->render());
  141. return View::fetch($this->template_dir . 'index');
  142. }
  143. public function add_image()
  144. {
  145. $geval_id = intval(input('geval_id'));
  146. $evaluategoods_model = model('evaluategoods');
  147. $store_model = model('store');
  148. $snsalumb_model = model('snsalbum');
  149. $geval_info = $evaluategoods_model->getEvaluategoodsInfoByID($geval_id);
  150. if (!empty($geval_info['geval_image'])) {
  151. $this->error(lang('goods_have_been_posted'));
  152. }
  153. if ($geval_info['geval_frommemberid'] != session('member_id')) {
  154. $this->error(lang('param_error'));
  155. }
  156. View::assign('geval_info', $geval_info);
  157. $store_info = $store_model->getStoreInfoByID($geval_info['geval_storeid']);
  158. View::assign('store_info', $store_info);
  159. $ac_id = $snsalumb_model->getSnsAlbumClassDefault(session('member_id'));
  160. View::assign('ac_id', $ac_id);
  161. /* 设置买家当前菜单 */
  162. $this->setMemberCurMenu('member_evaluate');
  163. /* 设置买家当前栏目 */
  164. $this->setMemberCurItem('evaluate');
  165. //不显示左菜单
  166. View::assign('left_show', 'order_view');
  167. return View::fetch($this->template_dir . 'add_image');
  168. }
  169. public function add_image_save()
  170. {
  171. $geval_id = intval(input('param.geval_id'));
  172. $geval_image = '';
  173. $evaluate_image_array = input('post.evaluate_image/a'); #获取数组
  174. foreach ($evaluate_image_array as $value) {
  175. if (!empty($value)) {
  176. $geval_image .= $value . ',';
  177. }
  178. }
  179. $geval_image = rtrim($geval_image, ',');
  180. $evaluategoods_model = model('evaluategoods');
  181. $geval_info = $evaluategoods_model->getEvaluategoodsInfoByID($geval_id);
  182. if (empty($geval_info)) {
  183. ds_json_encode(10001, lang('param_error'));
  184. }
  185. if ($geval_info['geval_frommemberid'] != session('member_id')) {
  186. ds_json_encode(10001, lang('param_error'));
  187. }
  188. $update = array();
  189. $update['geval_image'] = $geval_image;
  190. $condition = array();
  191. $condition[] = array('geval_id', '=', $geval_id);
  192. $result = $evaluategoods_model->editEvaluategoods($update, $condition);
  193. if ($result) {
  194. ds_json_encode(10000, lang('ds_common_save_succ'));
  195. }
  196. }
  197. /**
  198. * 用户中心右边,小导航
  199. *
  200. * @param string $menu_type 导航类型
  201. * @param string $menu_key 当前导航的menu_key
  202. * @return
  203. */
  204. public function getMemberItemList()
  205. {
  206. $menu_array = array(
  207. array(
  208. 'name' => 'evaluate',
  209. 'text' => lang('trade_reviews_orders'),
  210. 'url' => (string)url('Memberevaluate/index')
  211. ),
  212. );
  213. return $menu_array;
  214. }
  215. }