Memberevaluate.php 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  11. * 网站地址: https://www.valimart.net/
  12. * ----------------------------------------------------------------------------
  13. *
  14. * ============================================================================
  15. * 控制器
  16. */
  17. class Memberevaluate extends BaseMember {
  18. public function initialize() {
  19. parent::initialize();
  20. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/memberevaluate.lang.php');
  21. }
  22. /**
  23. * 订单添加评价
  24. */
  25. public function add() {
  26. $order_id = intval(input('order_id'));
  27. if (!$order_id) {
  28. $this->error(lang('param_error'), 'member_order/index');
  29. }
  30. $return = model('memberevaluate', 'logic')->validation($order_id, $this->member_info['member_id']);
  31. if (isset($return['state'])) {
  32. ds_json_encode(10001, $return['msg']);
  33. }
  34. extract($return['data']);
  35. //判断是否为页面
  36. if (!request()->isPost()) {
  37. //处理积分、经验值计算说明文字
  38. $expset = rkcache('config', true);
  39. $ruleexplain = '';
  40. $exppoints_rule = $expset['expset'] ? unserialize($expset['expset']) : array();
  41. $exppoints_rule['exp_comments'] = intval($exppoints_rule['comment_exp']);
  42. if ($exppoints_rule['exp_comments'] > 0) {
  43. $ruleexplain .= lang('evaluation_completed_will_obtained');
  44. if ($exppoints_rule['exp_comments'] > 0) {
  45. $ruleexplain .= (' “' . $exppoints_rule['exp_comments'] . lang('experience_value'));
  46. }
  47. }
  48. View::assign('ruleexplain', $ruleexplain);
  49. //不显示左菜单
  50. View::assign('left_show', 'order_view');
  51. View::assign('order_id', $order_id);
  52. View::assign('order_info', $order_info);
  53. View::assign('order_goods', $order_goods);
  54. View::assign('store_info', $store_info);
  55. /* 设置买家当前菜单 */
  56. $this->setMemberCurMenu('member_evaluate');
  57. /* 设置买家当前栏目 */
  58. $this->setMemberCurItem('evaluate');
  59. return View::fetch($this->template_dir . 'evaluation_add');
  60. } else {
  61. //调用逻辑层方法,PC和手机端统一使用
  62. $return = model('memberevaluate', 'logic')->saveorderevaluate($order_info, $store_info, $order_goods, $this->member_info['member_id'], $this->member_info['member_name']);
  63. if ($return == true) {
  64. ds_json_encode(10000, lang('member_evaluation_evaluat_success'));
  65. } else {
  66. ds_json_encode(10001, lang('ds_common_save_fail'));
  67. }
  68. }
  69. }
  70. /**
  71. * 虚拟商品评价
  72. */
  73. public function add_vr() {
  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. $evaluategoods_model = model('evaluategoods');
  131. $condition = array();
  132. $condition[] = array('geval_frommemberid','=',session('member_id'));
  133. $goodsevallist = $evaluategoods_model->getEvaluategoodsList($condition, 5, 'geval_id desc');
  134. View::assign('goodsevallist', $goodsevallist);
  135. /* 设置买家当前菜单 */
  136. $this->setMemberCurMenu('member_evaluate');
  137. /* 设置买家当前栏目 */
  138. $this->setMemberCurItem('evaluate');
  139. View::assign('show_page', $evaluategoods_model->page_info->render());
  140. return View::fetch($this->template_dir . 'index');
  141. }
  142. public function add_image() {
  143. $geval_id = intval(input('geval_id'));
  144. $evaluategoods_model = model('evaluategoods');
  145. $store_model = model('store');
  146. $snsalumb_model = model('snsalbum');
  147. $geval_info = $evaluategoods_model->getEvaluategoodsInfoByID($geval_id);
  148. if (!empty($geval_info['geval_image'])) {
  149. $this->error(lang('goods_have_been_posted'));
  150. }
  151. if ($geval_info['geval_frommemberid'] != session('member_id')) {
  152. $this->error(lang('param_error'));
  153. }
  154. View::assign('geval_info', $geval_info);
  155. $store_info = $store_model->getStoreInfoByID($geval_info['geval_storeid']);
  156. View::assign('store_info', $store_info);
  157. $ac_id = $snsalumb_model->getSnsAlbumClassDefault(session('member_id'));
  158. View::assign('ac_id', $ac_id);
  159. /* 设置买家当前菜单 */
  160. $this->setMemberCurMenu('member_evaluate');
  161. /* 设置买家当前栏目 */
  162. $this->setMemberCurItem('evaluate');
  163. //不显示左菜单
  164. View::assign('left_show', 'order_view');
  165. return View::fetch($this->template_dir . 'add_image');
  166. }
  167. public function add_image_save() {
  168. $geval_id = intval(input('param.geval_id'));
  169. $geval_image = '';
  170. $evaluate_image_array = input('post.evaluate_image/a'); #获取数组
  171. foreach ($evaluate_image_array as $value) {
  172. if (!empty($value)) {
  173. $geval_image .= $value . ',';
  174. }
  175. }
  176. $geval_image = rtrim($geval_image, ',');
  177. $evaluategoods_model = model('evaluategoods');
  178. $geval_info = $evaluategoods_model->getEvaluategoodsInfoByID($geval_id);
  179. if (empty($geval_info)) {
  180. ds_json_encode(10001, lang('param_error'));
  181. }
  182. if ($geval_info['geval_frommemberid'] != session('member_id')) {
  183. ds_json_encode(10001, lang('param_error'));
  184. }
  185. $update = array();
  186. $update['geval_image'] = $geval_image;
  187. $condition = array();
  188. $condition[] = array('geval_id','=',$geval_id);
  189. $result = $evaluategoods_model->editEvaluategoods($update, $condition);
  190. if ($result) {
  191. ds_json_encode(10000, lang('ds_common_save_succ'));
  192. }
  193. }
  194. /**
  195. * 用户中心右边,小导航
  196. *
  197. * @param string $menu_type 导航类型
  198. * @param string $menu_key 当前导航的menu_key
  199. * @return
  200. */
  201. public function getMemberItemList() {
  202. $menu_array = array(
  203. array(
  204. 'name' => 'evaluate',
  205. 'text' => lang('trade_reviews_orders'),
  206. 'url' => (string)url('Memberevaluate/index')
  207. ),
  208. );
  209. return $menu_array;
  210. }
  211. }