PaiGoodsAction.class.php 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Fanwe 方维直播系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. class PaiGoodsAction extends CommonAction
  10. {
  11. public function index()
  12. {
  13. parent::index();
  14. }
  15. /**
  16. *
  17. * 搜索查询
  18. */
  19. public function search()
  20. {
  21. $map = array();
  22. if (trim($_REQUEST['name']) != '') {
  23. $map['name'] = array('like', '%' . trim($_REQUEST['name']) . '%');
  24. }
  25. $log_begin_time = trim($_REQUEST['log_begin_time']) == '' ? 0 : to_timespan($_REQUEST['log_begin_time']);
  26. $log_end_time = trim($_REQUEST['log_end_time']) == '' ? 0 : to_timespan($_REQUEST['log_end_time']);
  27. if ($log_end_time != 0 && $log_begin_time != 0) {
  28. $map['create_time'] = array('between', array($log_begin_time, $log_end_time));
  29. } elseif ($log_begin_time != 0 && $log_end_time == 0) {
  30. $map['create_time'] = array('gt', $log_begin_time);
  31. } elseif ($log_begin_time == 0 && $log_end_time != 0) {
  32. $map['create_time'] = array('lt', $log_begin_time);
  33. }
  34. $count = M('pai_goods')->where($map)->count();
  35. $p = new Page($count, $listRows = 20);
  36. if ($count > 0) {
  37. $list = M('pai_goods')->where($map)->order('id desc')->limit($p->firstRow . ',' . $p->listRows)->select();
  38. }
  39. $page = $p->show();
  40. $this->assign("page", $page);
  41. $this->assign("list", $list);
  42. $this->display('index');
  43. }
  44. public function add()
  45. {
  46. $this->assign("type_list", $this->type_list);
  47. $this->assign("new_sort", M("Pai_goods")->max("sort") + 1);
  48. $this->display();
  49. }
  50. /**
  51. *
  52. * 拍品添加
  53. */
  54. public function insert()
  55. {
  56. B('FilterString');
  57. $ajax = intval($_REQUEST['ajax']);
  58. $data = $_POST;
  59. //开始验证有效性
  60. $this->assign("jumpUrl", u(MODULE_NAME . "/add"));
  61. if (!check_empty($data['name'])) {
  62. $this->error("请输入拍品名称");
  63. }
  64. if (!check_empty($data['date_time'])) {
  65. $this->error("请输入约会时间");
  66. }
  67. $data['date_time'] = to_timespan($data['date_time']);
  68. if (!check_empty($data['contact'])) {
  69. $this->error("请输入联系人");
  70. }
  71. if (!check_empty($data['mobile'])) {
  72. $this->error("请输入联系电话");
  73. }
  74. if (!check_empty($data['bz_diamonds'])) {
  75. $this->error("请输入竞拍保证金");
  76. }
  77. if (!check_empty($data['qp_diamonds'])) {
  78. $this->error("请输入起拍价");
  79. }
  80. if (!check_empty($data['jj_diamonds'])) {
  81. $this->error("请输入每次加价");
  82. }
  83. if (!check_empty($data['description'])) {
  84. $this->error("请输入拍品描述");
  85. }
  86. // 更新数据
  87. $log_info = $data['name'];
  88. $data['create_time'] = to_timespan(get_gmtime());
  89. $list = M("pai_goods")->add($data);
  90. if (false !== $list) {
  91. //load_auto_cache("index_image",'',false);
  92. //redis缓存
  93. clear_auto_cache("banner_list");
  94. load_auto_cache("banner_list");
  95. //成功提示
  96. save_log($log_info . L("INSERT_SUCCESS"), 1);
  97. $this->success(L("INSERT_SUCCESS"));
  98. } else {
  99. //错误提示
  100. save_log($log_info . L("INSERT_FAILED"), 0);
  101. $this->error(L("INSERT_FAILED"));
  102. }
  103. }
  104. /**
  105. *
  106. * 拍品详情
  107. */
  108. public function edit()
  109. {
  110. $this->assign("type_list", $this->type_list);
  111. $id = intval($_REQUEST['id']);
  112. if (!isset($id) || empty($id)) {
  113. $this->error('系统繁忙,参数不存在!');
  114. }
  115. $vo = M(MODULE_NAME)->where(array('id' => $id))->find();
  116. if (!empty($vo['imgs'])) {
  117. $imgs = json_decode($vo['imgs']);
  118. foreach($imgs as $k =>$v){
  119. $imgs[$k]=get_spec_image($v);
  120. }
  121. $this->assign('imgs', $imgs);
  122. }
  123. if ($vo['date_time'] == '0000-00-00 00:00:00') {
  124. $vo['date_time'] = '无';
  125. }
  126. if ($vo['order_time'] == '0000-00-00 00:00:00') {
  127. $vo['order_time'] = '无';
  128. }
  129. $vo['create_time'] = to_date($vo['create_time']) ?: '无';
  130. $vo['podcast_name'] = emoji_decode($vo['podcast_name']);
  131. $vo['last_user_name'] = emoji_decode($vo['last_user_name']);
  132. $vo['user_name'] = emoji_decode($vo['user_name']);
  133. if ($vo['is_true'] == 0) {
  134. $vo['is_true'] = "虚拟";
  135. } else {
  136. $vo['is_true'] = "实物";
  137. }
  138. switch ($vo['status']) {
  139. case '0':
  140. $vo['status'] = "竞拍中";
  141. break;
  142. case '1':
  143. // (完成)
  144. $vo['status'] = "竞拍成功";
  145. break;
  146. case '2':
  147. $vo['status'] = "流拍";
  148. break;
  149. case '3':
  150. $vo['status'] = "竞拍失败";
  151. break;
  152. case '4':
  153. // (完成)
  154. $vo['status'] = "竞拍成功";
  155. break;
  156. default:
  157. # code...
  158. break;
  159. }
  160. if ($vo['status'] == "竞拍成功") {
  161. $user = M('PaiJoin')->where(array('pai_id' => $id, 'user_id' => $vo['user_id']))->find();
  162. $this->assign('user', $user);
  163. }
  164. $this->assign('vo', $vo);
  165. $this->display();
  166. }
  167. /**
  168. *
  169. * 参拍记录
  170. */
  171. public function pai_record()
  172. {
  173. $id = intval($_REQUEST['id']);
  174. if (!isset($id) || empty($id)) {
  175. $this->error('系统繁忙,参数不存在!');
  176. }
  177. $map = array('pai_id' => $id);
  178. $count = M('pai_join')->where($map)->count();
  179. $p = new Page($count, $listRows = 20);
  180. if ($count > 0) {
  181. $max = M('pai_join')->where($map)->max('pai_diamonds');
  182. $list = M('pai_join')->where($map)->limit($p->firstRow . ',' . $p->listRows)->select();
  183. foreach ($list as &$value) {
  184. $podcast_name = emoji_decode(M('pai_goods')->where(array('id' => $value['pai_id']))->field('podcast_name')->find());
  185. $user = emoji_decode(M('user')->where(array('id' => $value['user_id']))->field('nick_name')->find());
  186. $value['podcast_name'] = $podcast_name['podcast_name'];
  187. $value['user_name'] = $user['nick_name'];
  188. $value['create_time'] = to_date($value['create_time']);
  189. $value['max'] = $max;
  190. }
  191. }
  192. $page = $p->show();
  193. $this->assign("page", $page);
  194. $this->assign("list", $list);
  195. $this->display();
  196. }
  197. /**
  198. *
  199. * 出价记录
  200. */
  201. public function price_record()
  202. {
  203. $id = intval($_REQUEST['id']);
  204. if (!isset($id) || empty($id)) {
  205. $this->error('系统繁忙,参数不存在!');
  206. }
  207. $count = M('pai_log')->where(array('pai_id' => $id))->count();
  208. $p = new Page($count, $listRows = 20);
  209. if ($count > 0) {
  210. $info = M('pai_log')->where(array('pai_id' => $id))->limit($p->firstRow . ',' . $p->listRows)->select();
  211. foreach ($info as $k => $v) {
  212. $info[$k]['user_name'] = emoji_decode($v['user_name']);
  213. }
  214. }
  215. $page = $p->show();
  216. $this->assign("page", $page);
  217. $this->assign("list", $info);
  218. $this->display();
  219. }
  220. public function security_deposit_records()
  221. {
  222. $id = intval($_REQUEST['id']);
  223. if (!$id) {
  224. $this->error('系统繁忙,参数不存在!');
  225. }
  226. $mod = M('user_diamonds_log');
  227. $count = $mod->where(array('pai_id' => $id, 'type' => 1))->count();
  228. $p = new Page($count, $listRows = 20);
  229. if ($count > 0) {
  230. $info = $mod->table('fanwe_user_diamonds_log log, fanwe_user user')->where("log.user_id = user.id and log.pai_id = $id and log.type=1")->field('log.*,user.nick_name')->order('log.id desc')->limit($p->firstRow . ',' . $p->listRows)->select();
  231. }
  232. foreach ($info as $key => $value) {
  233. $info[$key]['nick_name'] = emoji_decode($info[$key]['nick_name']);
  234. }
  235. $page = $p->show();
  236. $this->assign("page", $page);
  237. $this->assign("list", $info);
  238. $this->display();
  239. }
  240. public function detail()
  241. {
  242. $this->assign("type_list", $this->type_list);
  243. $id = intval($_REQUEST['id']);
  244. if (!isset($id) || empty($id)) {
  245. $this->error('系统繁忙,参数不存在!');
  246. }
  247. $podcast_id = M('pai_goods')->where(array('id' => $id))->getField('podcast_id');
  248. $user = M('user')->where(array('id' => $podcast_id))->field('is_authentication')->find();
  249. if ($user['is_authentication'] == 2) {
  250. $this->redirect(u("User/index", array('is_authentication' => $user['is_authentication'], 'id' => $podcast_id)));
  251. } else {
  252. $this->redirect(u("UserGeneral/index", array('is_authentication' => $user['is_authentication'], 'id' => $podcast_id)));
  253. }
  254. }
  255. }