Memberevaluate.php 9.6 KB

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