1
0

seller.php 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345
  1. <?php
  2. /**
  3. * @brief 商家模块
  4. * @class Seller
  5. * @author chendeshan
  6. * @datetime 2014/7/19 15:18:56
  7. */
  8. class Seller extends IController implements sellerAuthorization
  9. {
  10. public $layout = 'seller';
  11. /**
  12. * @brief 初始化检查
  13. */
  14. public function init()
  15. {
  16. }
  17. /**
  18. * @brief 商品添加和修改视图
  19. */
  20. public function goods_edit()
  21. {
  22. $goods_id = IFilter::act(IReq::get('id'),'int');
  23. //初始化数据
  24. $goods_class = new goods_class($this->seller['seller_id']);
  25. //获取所有商品扩展相关数据
  26. $data = $goods_class->edit($goods_id);
  27. if($goods_id && !$data)
  28. {
  29. die("没有找到相关商品!");
  30. }
  31. $this->setRenderData($data);
  32. $this->redirect('goods_edit');
  33. }
  34. //商品更新动作
  35. public function goods_update()
  36. {
  37. $id = IFilter::act(IReq::get('id'),'int');
  38. $callback = IReq::get('callback');
  39. $callback = strpos($callback,'seller/goods_list') === false ? '' : $callback;
  40. //检查表单提交状态
  41. if(!$_POST)
  42. {
  43. die('请确认表单提交正确');
  44. }
  45. //初始化商品数据
  46. unset($_POST['id']);
  47. unset($_POST['callback']);
  48. $goodsObject = new goods_class($this->seller['seller_id']);
  49. $goodsObject->update($id,$_POST);
  50. $callback ? $this->redirect($callback) : $this->redirect("goods_list");
  51. }
  52. //商品列表
  53. public function goods_list()
  54. {
  55. $seller_id = $this->seller['seller_id'];
  56. $searchArray = Util::getUrlParam('search');
  57. $searchParam = http_build_query($searchArray);
  58. $condition = Util::goodsSearch(IReq::get('search'));
  59. $where = "go.seller_id='$seller_id' ";
  60. $where .= $condition ? " and ".$condition : "";
  61. $join = isset($searchArray['search']['category_id']) ? " left join category_extend as ce on ce.goods_id = go.id " : "";
  62. $page = IReq::get('page') ? IFilter::act(IReq::get('page'),'int') : 1;
  63. $goodHandle = new IQuery('goods as go');
  64. $goodHandle->order = "go.id desc";
  65. $goodHandle->fields = "distinct go.id,go.name,go.sell_price,go.market_price,go.store_nums,go.img,go.is_del,go.seller_id,go.is_share,go.sort";
  66. $goodHandle->where = $where;
  67. $goodHandle->page = $page;
  68. $goodHandle->join = $join;
  69. $this->goodHandle = $goodHandle;
  70. $goods_info = array();
  71. $goods_info['seller_id'] = $seller_id;
  72. $goods_info['searchParam'] = $searchParam;
  73. $this->setRenderData($goods_info);
  74. $this->redirect('goods_list');
  75. }
  76. //商品列表
  77. public function goods_report()
  78. {
  79. $seller_id = $this->seller['seller_id'];
  80. $condition = Util::goodsSearch(IReq::get('search'));
  81. $where = 'go.seller_id='.$seller_id;
  82. $where .= $condition ? " and ".$condition : "";
  83. $join = isset($_GET['search']['category_id']) ? " left join category_extend as ce on ce.goods_id = go.id " : "";
  84. $goodHandle = new IQuery('goods as go');
  85. $goodHandle->order = "go.id desc";
  86. $goodHandle->fields = "go.*";
  87. $goodHandle->where = $where;
  88. $goodHandle->join = $join;
  89. $goodList = $goodHandle->find();
  90. $reportObj = new report('goods');
  91. $reportObj->setTitle(array("商品名称","分类","售价","库存"));
  92. foreach($goodList as $k => $val)
  93. {
  94. $insertData = array(
  95. $val['name'],
  96. goods_class::getGoodsCategory($val['id']),
  97. $val['sell_price'],
  98. $val['store_nums'],
  99. );
  100. $reportObj->setData($insertData);
  101. }
  102. $reportObj->toDownload();
  103. }
  104. //商品删除
  105. public function goods_del()
  106. {
  107. //post数据
  108. $id = IFilter::act(IReq::get('id'),'int');
  109. //生成goods对象
  110. $goods = new goods_class();
  111. $goods->seller_id = $this->seller['seller_id'];
  112. if($id)
  113. {
  114. if(is_array($id))
  115. {
  116. foreach($id as $key => $val)
  117. {
  118. $goods->del($val);
  119. }
  120. }
  121. else
  122. {
  123. $goods->del($id);
  124. }
  125. }
  126. $this->redirect("goods_list");
  127. }
  128. //商品状态修改
  129. public function goods_status()
  130. {
  131. $id = IFilter::act(IReq::get('id'),'int');
  132. $is_del = IFilter::act(IReq::get('is_del'),'int');
  133. $is_del = $is_del === 0 ? 3 : $is_del; //不能等于0直接上架
  134. $seller_id = $this->seller['seller_id'];
  135. $goodsDB = new IModel('goods');
  136. $goodsDB->setData(array('is_del' => $is_del));
  137. if($id)
  138. {
  139. $id = is_array($id) ? join(",",$id) : $id;
  140. $goodsDB->update("id in (".$id.") and seller_id = ".$seller_id);
  141. }
  142. $this->redirect("goods_list");
  143. }
  144. //规格删除
  145. public function spec_del()
  146. {
  147. $id = IFilter::act(IReq::get('id'),'int');
  148. if($id)
  149. {
  150. $idString = is_array($id) ? join(',',$id) : $id;
  151. $specObj = new IModel('spec');
  152. $specObj->del("id in ( {$idString} ) and seller_id = ".$this->seller['seller_id']);
  153. $this->redirect('spec_list');
  154. }
  155. else
  156. {
  157. $this->redirect('spec_list',false);
  158. Util::showMessage('请选择要删除的规格');
  159. }
  160. }
  161. //修改排序
  162. public function ajax_sort()
  163. {
  164. $id = IFilter::act(IReq::get('id'),'int');
  165. $sort = IFilter::act(IReq::get('sort'),'int');
  166. $goodsDB = new IModel('goods');
  167. $goodsDB->setData(array('sort' => $sort));
  168. $goodsDB->update("id = {$id} and seller_id = ".$this->seller['seller_id']);
  169. }
  170. //咨询回复
  171. public function refer_reply()
  172. {
  173. $rid = IFilter::act(IReq::get('refer_id'),'int');
  174. $content = IFilter::act(IReq::get('content'),'text');
  175. if($rid && $content)
  176. {
  177. $tb_refer = new IModel('refer');
  178. $seller_id = $this->seller['seller_id'];//商户id
  179. $data = array(
  180. 'answer' => $content,
  181. 'reply_time' => ITime::getDateTime(),
  182. 'seller_id' => $seller_id,
  183. 'status' => 1
  184. );
  185. $tb_refer->setData($data);
  186. $tb_refer->update("id=".$rid);
  187. }
  188. $this->redirect('refer_list');
  189. }
  190. /**
  191. * @brief查看订单
  192. */
  193. public function order_show()
  194. {
  195. //获得post传来的值
  196. $order_id = IFilter::act(IReq::get('id'),'int');
  197. $data = array();
  198. if($order_id)
  199. {
  200. $order_show = new Order_Class();
  201. $data = $order_show->getOrderShow($order_id,0,$this->seller['seller_id']);
  202. if($data)
  203. {
  204. //获取地区
  205. $data['area_addr'] = join('&nbsp;',area::name($data['province'],$data['city'],$data['area']));
  206. $this->setRenderData($data);
  207. $this->redirect('order_show',false);
  208. }
  209. }
  210. if(!$data)
  211. {
  212. $this->redirect('order_list');
  213. }
  214. }
  215. /**
  216. * @brief 发货订单页面
  217. */
  218. public function order_deliver()
  219. {
  220. $order_id = IFilter::act(IReq::get('id'),'int');
  221. $data = array();
  222. if($order_id)
  223. {
  224. $order_show = new Order_Class();
  225. $data = $order_show->getOrderShow($order_id,0,$this->seller['seller_id']);
  226. if($data)
  227. {
  228. $this->setRenderData($data);
  229. $this->redirect('order_deliver');
  230. }
  231. }
  232. if(!$data)
  233. {
  234. IError::show("订单信息不存在",403);
  235. }
  236. }
  237. /**
  238. * @brief 发货操作
  239. */
  240. public function order_delivery_doc()
  241. {
  242. //获得post变量参数
  243. $order_id = IFilter::act(IReq::get('id'),'int');
  244. //发送的商品关联
  245. $sendgoods = IFilter::act(IReq::get('sendgoods'),'int');
  246. if(!$sendgoods)
  247. {
  248. die('请选择要发货的商品');
  249. }
  250. $result = Order_Class::sendDeliveryGoods($order_id,$sendgoods,$this->seller['seller_id'],'seller');
  251. if($result === true)
  252. {
  253. $this->redirect('order_list');
  254. }
  255. else
  256. {
  257. IError::show($result);
  258. }
  259. }
  260. /**
  261. * @brief 订单列表
  262. */
  263. public function order_list()
  264. {
  265. $seller_id = $this->seller['seller_id'];
  266. $searchArray = Util::getUrlParam('search');
  267. $searchParam = http_build_query($searchArray);
  268. $condition = Util::orderSearch(IReq::get('search'));
  269. $where = "o.seller_id='$seller_id' and o.if_del=0 and o.status not in(3,4)";
  270. $where .= $condition ? " and ".$condition : "";
  271. $page = IReq::get('page') ? IFilter::act(IReq::get('page'),'int') : 1;
  272. $orderHandle = new IQuery('order as o');
  273. $orderHandle->order = "o.id desc";
  274. $orderHandle->where = $where;
  275. $orderHandle->page = $page;
  276. $this->orderHandle = $orderHandle;
  277. $order_info = array();
  278. $order_info['seller_id'] = $seller_id;
  279. $order_info['searchParam'] = $searchParam;
  280. $this->setRenderData($order_info);
  281. $this->redirect('order_list');
  282. }
  283. //订单导出 Excel
  284. public function order_report()
  285. {
  286. $seller_id = $this->seller['seller_id'];
  287. $condition = Util::orderSearch(IReq::get('search'));
  288. $where = "o.seller_id = ".$seller_id." and o.if_del=0 and o.status not in(3,4)";
  289. $where .= $condition ? " and ".$condition : "";
  290. //拼接sql
  291. $orderHandle = new IQuery('order as o');
  292. $orderHandle->order = "o.id desc";
  293. $orderHandle->fields = "o.*,p.name as payment_name";
  294. $orderHandle->join = "left join payment as p on p.id = o.pay_type";
  295. $orderHandle->where = $where;
  296. $orderList = $orderHandle->find();
  297. $reportObj = new report('order');
  298. $reportObj->setTitle(array("订单编号","日期","收货人","收货地址","电话","订单金额","实际支付","支付方式","支付状态","发货状态","商品信息"));
  299. foreach($orderList as $k => $val)
  300. {
  301. $orderGoods = Order_class::getOrderGoods($val['id']);
  302. $strGoods = "";
  303. foreach($orderGoods as $good)
  304. {
  305. $strGoods .= "商品编号:".$good['goodsno']." 商品名称:".$good['name'];
  306. if ($good['value']!='') $strGoods .= " 规格:".$good['value'];
  307. $strGoods .= "<br />";
  308. }
  309. $insertData = array(
  310. $val['order_no'],
  311. $val['create_time'],
  312. $val['accept_name'],
  313. join('&nbsp;',area::name($val['province'],$val['city'],$val['area'])).$val['address'],
  314. $val['telphone'].'&nbsp;'.$val['mobile'],
  315. $val['payable_amount'],
  316. $val['real_amount'],
  317. $val['payment_name'],
  318. Order_Class::getOrderPayStatusText($val),
  319. Order_Class::getOrderDistributionStatusText($val),
  320. $strGoods,
  321. );
  322. $reportObj->setData($insertData);
  323. }
  324. $reportObj->toDownload();
  325. }
  326. //修改商户信息
  327. public function seller_edit()
  328. {
  329. $seller_id = $this->seller['seller_id'];
  330. $sellerDB = new IModel('seller');
  331. $this->sellerRow = $sellerDB->getObj('id = '.$seller_id);
  332. $this->redirect('seller_edit');
  333. }
  334. /**
  335. * @brief 商户的增加动作
  336. */
  337. public function seller_add()
  338. {
  339. $seller_id = $this->seller['seller_id'];
  340. $email = IFilter::act(IReq::get('email'));
  341. $password = IFilter::act(IReq::get('password'));
  342. $repassword = IFilter::act(IReq::get('repassword'));
  343. $phone = IFilter::act(IReq::get('phone'));
  344. $mobile = IFilter::act(IReq::get('mobile'));
  345. $province = IFilter::act(IReq::get('province'),'int');
  346. $city = IFilter::act(IReq::get('city'),'int');
  347. $area = IFilter::act(IReq::get('area'),'int');
  348. $address = IFilter::act(IReq::get('address'));
  349. $account = IFilter::act(IReq::get('account'));
  350. $server_num = IFilter::act(IReq::get('server_num'));
  351. $home_url = IFilter::act(IReq::get('home_url'));
  352. $tax = IFilter::act(IReq::get('tax'),'float');
  353. if(!$seller_id && $password == '')
  354. {
  355. $errorMsg = '请输入密码!';
  356. }
  357. if($password != $repassword)
  358. {
  359. $errorMsg = '两次输入的密码不一致!';
  360. }
  361. //操作失败表单回填
  362. if(isset($errorMsg))
  363. {
  364. $this->sellerRow = $_POST;
  365. $this->redirect('seller_edit',false);
  366. Util::showMessage($errorMsg);
  367. }
  368. //待更新的数据
  369. $sellerRow = array(
  370. 'account' => $account,
  371. 'phone' => $phone,
  372. 'mobile' => $mobile,
  373. 'email' => $email,
  374. 'address' => $address,
  375. 'province' => $province,
  376. 'city' => $city,
  377. 'area' => $area,
  378. 'server_num'=> $server_num,
  379. 'home_url' => $home_url,
  380. 'tax' => $tax,
  381. );
  382. //logo图片处理
  383. if(isset($_FILES['logo']['name']) && $_FILES['logo']['name']!='')
  384. {
  385. $uploadObj = new PhotoUpload();
  386. $uploadObj->setIterance(false);
  387. $photoInfo = $uploadObj->run();
  388. if(isset($photoInfo['logo']['img']) && file_exists($photoInfo['logo']['img']))
  389. {
  390. $sellerRow['logo'] = $photoInfo['logo']['img'];
  391. }
  392. }
  393. //创建商家操作类
  394. $sellerDB = new IModel("seller");
  395. //修改密码
  396. if($password)
  397. {
  398. $sellerRow['password'] = md5($password);
  399. }
  400. $sellerDB->setData($sellerRow);
  401. $sellerDB->update("id = ".$seller_id);
  402. $this->redirect('seller_edit');
  403. }
  404. //[团购]添加修改[单页]
  405. function regiment_edit()
  406. {
  407. $id = IFilter::act(IReq::get('id'),'int');
  408. if($id)
  409. {
  410. $regimentObj = new IModel('regiment');
  411. $where = 'id = '.$id.' and seller_id = '.$this->seller['seller_id'];
  412. $regimentRow = $regimentObj->getObj($where);
  413. if(!$regimentRow)
  414. {
  415. $this->redirect('regiment_list');
  416. }
  417. //促销商品
  418. $goodsObj = new IModel('goods');
  419. $goodsRow = $goodsObj->getObj('id = '.$regimentRow['goods_id']);
  420. $result = array(
  421. 'isError' => false,
  422. 'data' => $goodsRow,
  423. );
  424. $regimentRow['goodsRow'] = JSON::encode($result);
  425. $this->regimentRow = $regimentRow;
  426. }
  427. $this->redirect('regiment_edit');
  428. }
  429. //[团购]删除
  430. function regiment_del()
  431. {
  432. $id = IFilter::act(IReq::get('id'),'int');
  433. if($id)
  434. {
  435. $regObj = new IModel('regiment');
  436. if(is_array($id))
  437. {
  438. $id = join(',',$id);
  439. }
  440. $where = ' id in ('.$id.') and seller_id = '.$this->seller['seller_id'];
  441. $regObj->del($where);
  442. $this->redirect('regiment_list');
  443. }
  444. else
  445. {
  446. $this->redirect('regiment_list',false);
  447. Util::showMessage('请选择要删除的id值');
  448. }
  449. }
  450. //[团购]添加修改[动作]
  451. function regiment_edit_act()
  452. {
  453. $id = IFilter::act(IReq::get('id'),'int');
  454. $goodsId = IFilter::act(IReq::get('goods_id'),'int');
  455. $dataArray = array(
  456. 'id' => $id,
  457. 'title' => IFilter::act(IReq::get('title','post')),
  458. 'start_time' => IFilter::act(IReq::get('start_time','post')),
  459. 'end_time' => IFilter::act(IReq::get('end_time','post')),
  460. 'is_close' => 2,
  461. 'intro' => IFilter::act(IReq::get('intro','post')),
  462. 'goods_id' => $goodsId,
  463. 'store_nums' => IFilter::act(IReq::get('store_nums','post')),
  464. 'limit_min_count' => IFilter::act(IReq::get('limit_min_count','post'),'int'),
  465. 'limit_max_count' => IFilter::act(IReq::get('limit_max_count','post'),'int'),
  466. 'regiment_price'=> IFilter::act(IReq::get('regiment_price','post')),
  467. 'seller_id' => $this->seller['seller_id'],
  468. );
  469. $dataArray['limit_min_count'] = $dataArray['limit_min_count'] <= 0 ? 1 : $dataArray['limit_min_count'];
  470. $dataArray['limit_max_count'] = $dataArray['limit_max_count'] <= 0 ? $dataArray['store_nums'] : $dataArray['limit_max_count'];
  471. if($goodsId)
  472. {
  473. $goodsObj = new IModel('goods');
  474. $where = 'id = '.$goodsId.' and seller_id = '.$this->seller['seller_id'];
  475. $goodsRow = $goodsObj->getObj($where);
  476. //商品信息不存在
  477. if(!$goodsRow)
  478. {
  479. $this->regimentRow = $dataArray;
  480. $this->redirect('regiment_edit',false);
  481. Util::showMessage('请选择商户自己的商品');
  482. }
  483. //处理上传图片
  484. if(isset($_FILES['img']['name']) && $_FILES['img']['name'] != '')
  485. {
  486. $uploadObj = new PhotoUpload();
  487. $photoInfo = $uploadObj->run();
  488. $dataArray['img'] = $photoInfo['img']['img'];
  489. }
  490. else
  491. {
  492. $dataArray['img'] = $goodsRow['img'];
  493. }
  494. $dataArray['sell_price'] = $goodsRow['sell_price'];
  495. }
  496. else
  497. {
  498. $this->regimentRow = $dataArray;
  499. $this->redirect('regiment_edit',false);
  500. Util::showMessage('请选择要关联的商品');
  501. }
  502. $regimentObj = new IModel('regiment');
  503. $regimentObj->setData($dataArray);
  504. if($id)
  505. {
  506. $where = 'id = '.$id.' and seller_id = '.$this->seller['seller_id'];
  507. $regimentObj->update($where);
  508. }
  509. else
  510. {
  511. $regimentObj->add();
  512. }
  513. $this->redirect('regiment_list');
  514. }
  515. //结算单修改
  516. public function bill_edit()
  517. {
  518. $id = IFilter::act(IReq::get('id'),'int');
  519. $billRow = array();
  520. if($id)
  521. {
  522. $billDB = new IModel('bill');
  523. $billRow = $billDB->getObj('id = '.$id.' and seller_id = '.$this->seller['seller_id']);
  524. }
  525. $this->billRow = $billRow;
  526. $this->redirect('bill_edit');
  527. }
  528. //结算单删除
  529. public function bill_del()
  530. {
  531. $id = IFilter::act(IReq::get('id'),'int');
  532. if($id)
  533. {
  534. $billDB = new IModel('bill');
  535. $billDB->del('id = '.$id.' and seller_id = '.$this->seller['seller_id'].' and is_pay = 0');
  536. }
  537. $this->redirect('bill_list');
  538. }
  539. //结算单更新
  540. public function bill_update()
  541. {
  542. $id = IFilter::act(IReq::get('id'),'int');
  543. $start_time = IFilter::act(IReq::get('start_time'));
  544. $end_time = IFilter::act(IReq::get('end_time'));
  545. $apply_content = IFilter::act(IReq::get('apply_content'));
  546. $billDB = new IModel('bill');
  547. if($id)
  548. {
  549. $billRow = $billDB->getObj('id = '.$id);
  550. if($billRow['is_pay'] == 0)
  551. {
  552. $billDB->setData(array('apply_content' => $apply_content));
  553. $billDB->update('id = '.$id.' and seller_id = '.$this->seller['seller_id']);
  554. }
  555. }
  556. else
  557. {
  558. //判断是否存在未处理的申请
  559. $isSubmitBill = $billDB->getObj(" seller_id = ".$this->seller['seller_id']." and is_pay = 0");
  560. if($isSubmitBill)
  561. {
  562. $this->redirect('bill_list',false);
  563. Util::showMessage('请耐心等待管理员结算后才能再次提交申请');
  564. }
  565. //获取未结算的订单
  566. $queryObject = CountSum::getSellerGoodsFeeQuery($this->seller['seller_id'],$start_time,$end_time,0);
  567. $countData = CountSum::countSellerOrderFee($queryObject->find());
  568. if($countData['countFee'] > 0)
  569. {
  570. $countData['start_time'] = $start_time;
  571. $countData['end_time'] = $end_time;
  572. $billString = AccountLog::sellerBillTemplate($countData);
  573. $data = array(
  574. 'seller_id' => $this->seller['seller_id'],
  575. 'apply_time' => ITime::getDateTime(),
  576. 'apply_content' => IFilter::act(IReq::get('apply_content')),
  577. 'start_time' => $start_time,
  578. 'end_time' => $end_time,
  579. 'log' => $billString,
  580. 'order_ids' => join(",",$countData['order_ids']),
  581. 'amount' => $countData['countFee'],
  582. );
  583. $billDB->setData($data);
  584. $billDB->add();
  585. }
  586. else
  587. {
  588. $this->redirect('bill_list',false);
  589. Util::showMessage('当前时间段内没有任何结算货款');
  590. }
  591. }
  592. $this->redirect('bill_list');
  593. }
  594. //计算应该结算的货款明细
  595. public function countGoodsFee()
  596. {
  597. $seller_id = $this->seller['seller_id'];
  598. $start_time = IFilter::act(IReq::get('start_time'));
  599. $end_time = IFilter::act(IReq::get('end_time'));
  600. $queryObject = CountSum::getSellerGoodsFeeQuery($seller_id,$start_time,$end_time,0);
  601. $countData = CountSum::countSellerOrderFee($queryObject->find());
  602. if($countData['countFee'] > 0)
  603. {
  604. $countData['start_time'] = $start_time;
  605. $countData['end_time'] = $end_time;
  606. $billString = AccountLog::sellerBillTemplate($countData);
  607. $result = array('result' => 'success','data' => $billString);
  608. }
  609. else
  610. {
  611. $result = array('result' => 'fail','data' => '当前没有任何款项可以结算');
  612. }
  613. die(JSON::encode($result));
  614. }
  615. /**
  616. * @brief 显示评论信息
  617. */
  618. function comment_edit()
  619. {
  620. $cid = IFilter::act(IReq::get('cid'),'int');
  621. if(!$cid)
  622. {
  623. $this->comment_list();
  624. return false;
  625. }
  626. $query = new IQuery("comment as c");
  627. $query->join = "left join goods as goods on c.goods_id = goods.id left join user as u on c.user_id = u.id";
  628. $query->fields = "c.*,u.username,goods.name,goods.seller_id";
  629. $query->where = "c.id=".$cid." and goods.seller_id = ".$this->seller['seller_id'];
  630. $items = $query->find();
  631. if($items)
  632. {
  633. $this->comment = current($items);
  634. $this->redirect('comment_edit');
  635. }
  636. else
  637. {
  638. $this->comment_list();
  639. $msg = '没有找到相关记录!';
  640. Util::showMessage($msg);
  641. }
  642. }
  643. /**
  644. * @brief 回复评论
  645. */
  646. function comment_update()
  647. {
  648. $id = IFilter::act(IReq::get('id'),'int');
  649. $recontent = IFilter::act(IReq::get('recontents'));
  650. if($id)
  651. {
  652. $commentDB = new IQuery('comment as c');
  653. $commentDB->join = 'left join goods as go on go.id = c.goods_id';
  654. $commentDB->where= 'c.id = '.$id.' and go.seller_id = '.$this->seller['seller_id'];
  655. $checkList = $commentDB->find();
  656. if(!$checkList)
  657. {
  658. IError::show(403,'该商品不属于您,无法对其评论进行回复');
  659. }
  660. $updateData = array(
  661. 'recontents' => $recontent,
  662. 'recomment_time' => ITime::getDateTime(),
  663. );
  664. $commentDB = new IModel('comment');
  665. $commentDB->setData($updateData);
  666. $commentDB->update('id = '.$id);
  667. }
  668. $this->redirect('comment_list');
  669. }
  670. //商品退款详情
  671. function refundment_show()
  672. {
  673. //获得post传来的退款单id值
  674. $refundment_id = IFilter::act(IReq::get('id'),'int');
  675. $data = array();
  676. if($refundment_id)
  677. {
  678. $tb_refundment = new IQuery('refundment_doc as c');
  679. $tb_refundment->join=' left join order as o on c.order_id=o.id left join user as u on u.id = c.user_id';
  680. $tb_refundment->fields = 'u.username,c.*,o.*,c.id as id,c.pay_status as pay_status';
  681. $tb_refundment->where = 'c.id='.$refundment_id.' and c.seller_id = '.$this->seller['seller_id'];
  682. $refundment_info = $tb_refundment->find();
  683. if($refundment_info)
  684. {
  685. $data = current($refundment_info);
  686. $this->data = $data;
  687. $this->setRenderData($data);
  688. $this->redirect('refundment_show',false);
  689. }
  690. }
  691. if(!$data)
  692. {
  693. $this->redirect('refundment_list');
  694. }
  695. }
  696. //商品退款操作
  697. function refundment_update()
  698. {
  699. $id = IFilter::act(IReq::get('id'),'int');
  700. $pay_status = IFilter::act(IReq::get('pay_status'),'int');
  701. $dispose_idea = IFilter::act(IReq::get('dispose_idea'));
  702. $amount = IFilter::act(IReq::get('amount'),'float');
  703. if(!$pay_status)
  704. {
  705. die('选择处理状态');
  706. }
  707. //商户处理退款
  708. if($id && Order_Class::isSellerRefund($id,$this->seller['seller_id']) == 2)
  709. {
  710. $updateData = array(
  711. 'dispose_time' => ITime::getDateTime(),
  712. 'dispose_idea' => $dispose_idea,
  713. 'pay_status' => $pay_status == 1 ? 1 : 0,
  714. 'amount' => $amount,
  715. );
  716. $tb_refundment_doc = new IModel('refundment_doc');
  717. $tb_refundment_doc->setData($updateData);
  718. $tb_refundment_doc->update('id = '.$id);
  719. if($pay_status == 2)
  720. {
  721. $result = Order_Class::refund($id,$this->seller['seller_id'],'seller');
  722. if(is_string($result))
  723. {
  724. $tb_refundment_doc->rollback();
  725. die($result);
  726. }
  727. }
  728. }
  729. $this->redirect('refundment_list');
  730. }
  731. //商品复制
  732. function goods_copy()
  733. {
  734. $idArray = explode(',',IReq::get('id'));
  735. $idArray = IFilter::act($idArray,'int');
  736. $goodsDB = new IModel('goods');
  737. $goodsAttrDB = new IModel('goods_attribute');
  738. $goodsPhotoRelationDB = new IModel('goods_photo_relation');
  739. $productsDB = new IModel('products');
  740. $goodsData = $goodsDB->query('id in ('.join(',',$idArray).') and is_share = 1 and is_del = 0 and seller_id = 0','*');
  741. if($goodsData)
  742. {
  743. foreach($goodsData as $key => $val)
  744. {
  745. //判断是否重复
  746. if( $goodsDB->getObj('seller_id = '.$this->seller['seller_id'].' and name = "'.$val['name'].'"') )
  747. {
  748. die('商品不能重复复制');
  749. }
  750. $oldId = $val['id'];
  751. //商品数据
  752. unset($val['id'],$val['visit'],$val['favorite'],$val['sort'],$val['comments'],$val['sale'],$val['grade'],$val['is_share']);
  753. $val['seller_id'] = $this->seller['seller_id'];
  754. $val['goods_no'] .= '-'.$this->seller['seller_id'];
  755. $val['name'] = IFilter::act($val['name'],'text');
  756. $val['content'] = IFilter::act($val['content'],'text');
  757. $goodsDB->setData($val);
  758. $goods_id = $goodsDB->add();
  759. //商品属性
  760. $attrData = $goodsAttrDB->query('goods_id = '.$oldId);
  761. if($attrData)
  762. {
  763. foreach($attrData as $k => $v)
  764. {
  765. unset($v['id']);
  766. $v['goods_id'] = $goods_id;
  767. $goodsAttrDB->setData($v);
  768. $goodsAttrDB->add();
  769. }
  770. }
  771. //商品图片
  772. $photoData = $goodsPhotoRelationDB->query('goods_id = '.$oldId);
  773. if($photoData)
  774. {
  775. foreach($photoData as $k => $v)
  776. {
  777. unset($v['id']);
  778. $v['goods_id'] = $goods_id;
  779. $goodsPhotoRelationDB->setData($v);
  780. $goodsPhotoRelationDB->add();
  781. }
  782. }
  783. //货品
  784. $productsData = $productsDB->query('goods_id = '.$oldId);
  785. if($productsData)
  786. {
  787. foreach($productsData as $k => $v)
  788. {
  789. unset($v['id']);
  790. $v['products_no'].= '-'.$this->seller['seller_id'];
  791. $v['goods_id'] = $goods_id;
  792. $productsDB->setData($v);
  793. $productsDB->add();
  794. }
  795. }
  796. }
  797. die('success');
  798. }
  799. else
  800. {
  801. die('复制的商品不存在');
  802. }
  803. }
  804. /**
  805. * @brief 添加/修改发货信息
  806. */
  807. public function ship_info_edit()
  808. {
  809. // 获取POST数据
  810. $id = IFilter::act(IReq::get("sid"),'int');
  811. if($id)
  812. {
  813. $tb_ship = new IModel("merch_ship_info");
  814. $ship_info = $tb_ship->getObj("id=".$id." and seller_id = ".$this->seller['seller_id']);
  815. if($ship_info)
  816. {
  817. $this->data = $ship_info;
  818. }
  819. else
  820. {
  821. die('数据不存在');
  822. }
  823. }
  824. $this->setRenderData($this->data);
  825. $this->redirect('ship_info_edit');
  826. }
  827. /**
  828. * @brief 设置发货信息的默认值
  829. */
  830. public function ship_info_default()
  831. {
  832. $id = IFilter::act( IReq::get('id'),'int' );
  833. $default = IFilter::string(IReq::get('default'));
  834. $tb_merch_ship_info = new IModel('merch_ship_info');
  835. if($default == 1)
  836. {
  837. $tb_merch_ship_info->setData(array('is_default'=>0));
  838. $tb_merch_ship_info->update("seller_id = ".$this->seller['seller_id']);
  839. }
  840. $tb_merch_ship_info->setData(array('is_default' => $default));
  841. $tb_merch_ship_info->update("id = ".$id." and seller_id = ".$this->seller['seller_id']);
  842. $this->redirect('ship_info_list');
  843. }
  844. /**
  845. * @brief 保存添加/修改发货信息
  846. */
  847. public function ship_info_update()
  848. {
  849. // 获取POST数据
  850. $id = IFilter::act(IReq::get('sid'),'int');
  851. $ship_name = IFilter::act(IReq::get('ship_name'));
  852. $ship_user_name = IFilter::act(IReq::get('ship_user_name'));
  853. $sex = IFilter::act(IReq::get('sex'),'int');
  854. $province =IFilter::act(IReq::get('province'),'int');
  855. $city = IFilter::act(IReq::get('city'),'int');
  856. $area = IFilter::act(IReq::get('area'),'int');
  857. $address = IFilter::act(IReq::get('address'));
  858. $postcode = IFilter::act(IReq::get('postcode'),'int');
  859. $mobile = IFilter::act(IReq::get('mobile'));
  860. $telphone = IFilter::act(IReq::get('telphone'));
  861. $is_default = IFilter::act(IReq::get('is_default'),'int');
  862. $tb_merch_ship_info = new IModel('merch_ship_info');
  863. //判断是否已经有了一个默认地址
  864. if(isset($is_default) && $is_default==1)
  865. {
  866. $tb_merch_ship_info->setData(array('is_default' => 0));
  867. $tb_merch_ship_info->update('seller_id = 0');
  868. }
  869. //设置存储数据
  870. $arr['ship_name'] = $ship_name;
  871. $arr['ship_user_name'] = $ship_user_name;
  872. $arr['sex'] = $sex;
  873. $arr['province'] = $province;
  874. $arr['city'] =$city;
  875. $arr['area'] =$area;
  876. $arr['address'] = $address;
  877. $arr['postcode'] = $postcode;
  878. $arr['mobile'] = $mobile;
  879. $arr['telphone'] =$telphone;
  880. $arr['is_default'] = $is_default;
  881. $arr['is_del'] = 1;
  882. $arr['seller_id'] = $this->seller['seller_id'];
  883. $tb_merch_ship_info->setData($arr);
  884. //判断是添加还是修改
  885. if($id)
  886. {
  887. $tb_merch_ship_info->update('id='.$id." and seller_id = ".$this->seller['seller_id']);
  888. }
  889. else
  890. {
  891. $tb_merch_ship_info->add();
  892. }
  893. $this->redirect('ship_info_list');
  894. }
  895. /**
  896. * @brief 删除发货信息到回收站中
  897. */
  898. public function ship_info_del()
  899. {
  900. // 获取POST数据
  901. $id = IFilter::act(IReq::get('id'),'int');
  902. //加载 商家发货点信息
  903. $tb_merch_ship_info = new IModel('merch_ship_info');
  904. if($id)
  905. {
  906. $tb_merch_ship_info->del(Util::joinStr($id)." and seller_id = ".$this->seller['seller_id']);
  907. $this->redirect('ship_info_list');
  908. }
  909. else
  910. {
  911. $this->redirect('ship_info_list',false);
  912. Util::showMessage('请选择要删除的数据');
  913. }
  914. }
  915. /**
  916. * @brief 配送方式修改
  917. */
  918. public function delivery_edit()
  919. {
  920. $data = array();
  921. $delivery_id = IFilter::act(IReq::get('id'),'int');
  922. if($delivery_id)
  923. {
  924. $delivery = new IModel('delivery_extend');
  925. $data = $delivery->getObj('delivery_id = '.$delivery_id.' and seller_id = '.$this->seller['seller_id']);
  926. }
  927. else
  928. {
  929. die('配送方式');
  930. }
  931. //获取省份
  932. $areaData = array();
  933. $areaDB = new IModel('areas');
  934. $areaList = $areaDB->query('parent_id = 0');
  935. foreach($areaList as $val)
  936. {
  937. $areaData[$val['area_id']] = $val['area_name'];
  938. }
  939. $this->areaList = $areaList;
  940. $this->data_info = $data;
  941. $this->area = $areaData;
  942. $this->redirect('delivery_edit');
  943. }
  944. /**
  945. * 配送方式修改
  946. */
  947. public function delivery_update()
  948. {
  949. //首重重量
  950. $first_weight = IFilter::act(IReq::get('first_weight'),'float');
  951. //续重重量
  952. $second_weight = IFilter::act(IReq::get('second_weight'),'float');
  953. //首重价格
  954. $first_price = IFilter::act(IReq::get('first_price'),'float');
  955. //续重价格
  956. $second_price = IFilter::act(IReq::get('second_price'),'float');
  957. //是否支持物流保价
  958. $is_save_price = IFilter::act(IReq::get('is_save_price'),'int');
  959. //地区费用类型
  960. $price_type = IFilter::act(IReq::get('price_type'),'int');
  961. //启用默认费用
  962. $open_default = IFilter::act(IReq::get('open_default'),'int');
  963. //支持的配送地区ID
  964. $area_groupid = serialize(IReq::get('area_groupid'));
  965. //配送地址对应的首重价格
  966. $firstprice = serialize(IReq::get('firstprice'));
  967. //配送地区对应的续重价格
  968. $secondprice = serialize(IReq::get('secondprice'));
  969. //保价费率
  970. $save_rate = IFilter::act(IReq::get('save_rate'),'float');
  971. //最低保价
  972. $low_price = IFilter::act(IReq::get('low_price'),'float');
  973. //配送ID
  974. $delivery_id = IFilter::act(IReq::get('deliveryId'),'int');
  975. $deliveryDB = new IModel('delivery');
  976. $deliveryRow = $deliveryDB->getObj('id = '.$delivery_id);
  977. if(!$deliveryRow)
  978. {
  979. die('配送方式不存在');
  980. }
  981. //如果选择指定地区配送就必须要选择地区
  982. if($price_type == 1 && !$area_groupid)
  983. {
  984. die('请设置配送地区');
  985. }
  986. $data = array(
  987. 'first_weight' => $first_weight,
  988. 'second_weight'=> $second_weight,
  989. 'first_price' => $first_price,
  990. 'second_price' => $second_price,
  991. 'is_save_price'=> $is_save_price,
  992. 'price_type' => $price_type,
  993. 'open_default' => $open_default,
  994. 'area_groupid' => $area_groupid,
  995. 'firstprice' => $firstprice,
  996. 'secondprice' => $secondprice,
  997. 'save_rate' => $save_rate,
  998. 'low_price' => $low_price,
  999. 'seller_id' => $this->seller['seller_id'],
  1000. 'delivery_id' => $delivery_id,
  1001. );
  1002. $deliveryExtendDB = new IModel('delivery_extend');
  1003. $deliveryExtendDB->setData($data);
  1004. $deliveryObj = $deliveryExtendDB->getObj("delivery_id = ".$delivery_id." and seller_id = ".$this->seller['seller_id']);
  1005. //已经存在了
  1006. if($deliveryObj)
  1007. {
  1008. $deliveryExtendDB->update('delivery_id = '.$delivery_id.' and seller_id = '.$this->seller['seller_id']);
  1009. }
  1010. else
  1011. {
  1012. $deliveryExtendDB->add();
  1013. }
  1014. $this->redirect('delivery');
  1015. }
  1016. //[促销活动] 添加修改 [单页]
  1017. function pro_rule_edit()
  1018. {
  1019. $id = IFilter::act(IReq::get('id'),'int');
  1020. if($id)
  1021. {
  1022. $promotionObj = new IModel('promotion');
  1023. $where = 'id = '.$id.' and seller_id='.$this->seller['seller_id'];
  1024. $this->promotionRow = $promotionObj->getObj($where);
  1025. }
  1026. $this->redirect('pro_rule_edit');
  1027. }
  1028. //[促销活动] 添加修改 [动作]
  1029. function pro_rule_edit_act()
  1030. {
  1031. $id = IFilter::act(IReq::get('id'),'int');
  1032. $user_group = IFilter::act(IReq::get('user_group','post'));
  1033. $promotionObj = new IModel('promotion');
  1034. if(is_string($user_group))
  1035. {
  1036. $user_group_str = $user_group;
  1037. }
  1038. else
  1039. {
  1040. $user_group_str = ",".join(',',$user_group).",";
  1041. }
  1042. $dataArray = array(
  1043. 'name' => IFilter::act(IReq::get('name','post')),
  1044. 'condition' => IFilter::act(IReq::get('condition','post')),
  1045. 'is_close' => IFilter::act(IReq::get('is_close','post')),
  1046. 'start_time' => IFilter::act(IReq::get('start_time','post')),
  1047. 'end_time' => IFilter::act(IReq::get('end_time','post')),
  1048. 'intro' => IFilter::act(IReq::get('intro','post')),
  1049. 'award_type' => IFilter::act(IReq::get('award_type','post')),
  1050. 'type' => 0,
  1051. 'user_group' => $user_group_str,
  1052. 'award_value'=> IFilter::act(IReq::get('award_value','post')),
  1053. 'seller_id' => $this->seller['seller_id'],
  1054. );
  1055. if(!in_array($dataArray['award_type'],array(1,2,6)))
  1056. {
  1057. IError::show('促销类型不符合规范',403);
  1058. }
  1059. $promotionObj->setData($dataArray);
  1060. if($id)
  1061. {
  1062. $where = 'id = '.$id;
  1063. $promotionObj->update($where);
  1064. }
  1065. else
  1066. {
  1067. $promotionObj->add();
  1068. }
  1069. $this->redirect('pro_rule_list');
  1070. }
  1071. //[促销活动] 删除
  1072. function pro_rule_del()
  1073. {
  1074. $id = IFilter::act(IReq::get('id'),'int');
  1075. if(!empty($id))
  1076. {
  1077. $promotionObj = new IModel('promotion');
  1078. if(is_array($id))
  1079. {
  1080. $idStr = join(',',$id);
  1081. $where = ' id in ('.$idStr.')';
  1082. }
  1083. else
  1084. {
  1085. $where = 'id = '.$id;
  1086. }
  1087. $promotionObj->del($where.' and seller_id = '.$this->seller['seller_id']);
  1088. $this->redirect('pro_rule_list');
  1089. }
  1090. else
  1091. {
  1092. $this->redirect('pro_rule_list',false);
  1093. Util::showMessage('请选择要删除的促销活动');
  1094. }
  1095. }
  1096. //修改订单价格
  1097. public function order_discount()
  1098. {
  1099. $order_id = IFilter::act(IReq::get('order_id'),'int');
  1100. $discount = IFilter::act(IReq::get('discount'),'float');
  1101. $orderDB = new IModel('order');
  1102. $orderRow = $orderDB->getObj('id = '.$order_id.' and status = 1 and distribution_status = 0 and seller_id = '.$this->seller['seller_id']);
  1103. if($orderRow)
  1104. {
  1105. //还原价格
  1106. $newOrderAmount = ($orderRow['order_amount'] - $orderRow['discount']) + $discount;
  1107. $newOrderAmount = $newOrderAmount <= 0 ? 0 : $newOrderAmount;
  1108. if($newOrderAmount == 0)
  1109. {
  1110. die(JSON::encode(array('result' => false,'message' => '订单减价折扣不能低于订单总额')));
  1111. }
  1112. $orderDB->setData(array('discount' => $discount,'order_amount' => $newOrderAmount));
  1113. if($orderDB->update('id = '.$order_id))
  1114. {
  1115. die(JSON::encode(array('result' => true,'orderAmount' => $newOrderAmount)));
  1116. }
  1117. }
  1118. die(JSON::encode(array('result' => false)));
  1119. }
  1120. // 消息通知
  1121. public function message_list()
  1122. {
  1123. $page = IReq::get('page') ? IFilter::act(IReq::get('page'),'int') : 1;
  1124. $seller_messObject = new seller_mess($this->seller['seller_id']);
  1125. $msgIds = $seller_messObject->getAllMsgIds();
  1126. $msgIds = empty($msgIds) ? 0 : $msgIds;
  1127. $needReadNum = $seller_messObject->needReadNum();
  1128. $seller_messageHandle = new IQuery('seller_message');
  1129. $seller_messageHandle->where = "id in(".$msgIds.")";
  1130. $seller_messageHandle->order= "id desc";
  1131. $seller_messageHandle->page = $page;
  1132. $this->needReadNum = $needReadNum;
  1133. $this->seller_messObject = $seller_messObject;
  1134. $this->seller_messageHandle = $seller_messageHandle;
  1135. $this->redirect("message_list");
  1136. }
  1137. // 消息详情
  1138. public function message_show()
  1139. {
  1140. $id = IFilter::act(IReq::get('id'),'int');
  1141. $messageRow = null;
  1142. if($id)
  1143. {
  1144. $seller_messObject = new seller_mess($this->seller['seller_id']);
  1145. $seller_messObject->writeMessage($id, 1);
  1146. $messageRow = $seller_messObject->read($id);
  1147. }
  1148. if(!$messageRow)
  1149. {
  1150. die('信息不存在');
  1151. }
  1152. $this->setRenderData(array('messageRow' => $messageRow));
  1153. $this->redirect('message_show');
  1154. }
  1155. // 消息删除
  1156. public function message_del()
  1157. {
  1158. $id = IFilter::act(IReq::get('id'),'int');
  1159. if (!empty($id))
  1160. {
  1161. $seller_messObject = new seller_mess($this->seller['seller_id']);
  1162. if (is_array($id)) {
  1163. foreach ($id as $val)
  1164. {
  1165. $seller_messObject->delMessage($val);
  1166. }
  1167. }else {
  1168. $seller_messObject->delMessage($id);
  1169. }
  1170. }
  1171. $this->redirect('message_list');
  1172. }
  1173. //订单备注
  1174. public function order_note()
  1175. {
  1176. //获得post数据
  1177. $order_id = IFilter::act(IReq::get('order_id'),'int');
  1178. $note = IFilter::act(IReq::get('note'),'text');
  1179. //获得order的表对象
  1180. $tb_order = new IModel('order');
  1181. $tb_order->setData(array(
  1182. 'note'=>$note
  1183. ));
  1184. $tb_order->update('id = '.$order_id.' and seller_id = '.$this->seller['seller_id']);
  1185. $this->redirect("/seller/order_show/id/".$order_id,true);
  1186. }
  1187. /**
  1188. * @brief 删除咨询信息
  1189. */
  1190. function refer_del()
  1191. {
  1192. $refer_ids = IFilter::act(IReq::get('id'),'int');
  1193. $refer_ids = is_array($refer_ids) ? $refer_ids : array($refer_ids);
  1194. if($refer_ids)
  1195. {
  1196. $ids = join(',',$refer_ids);
  1197. if($ids)
  1198. {
  1199. //查询咨询的商品是否属于当前商户
  1200. $referDB = new IQuery('refer as re,goods as go');
  1201. $referDB->where = "re.id in (".$ids.") and re.goods_id = go.id and go.seller_id = ".$this->seller['seller_id'];
  1202. $referDB->fields= "re.id";
  1203. $referGoods = $referDB->find();
  1204. $referModel = new IModel('refer');
  1205. foreach($referGoods as $reId)
  1206. {
  1207. $referModel->del("id = ".$reId['id']);
  1208. }
  1209. }
  1210. }
  1211. $this->redirect('refer_list');
  1212. }
  1213. }