<?php
/** 
 * UQ云商：	www.uqcms.com  
 * 联系QQ：	2200631718 
 * 可免费商用，需要留UQ云商链接作为交换，只首页底部留取即可，不影响使用。
 */

defined('IN_UQ') or exit('Access Denied'); class order_uqcms extends control { function __construct(){ $this->spid = $_SESSION['shop']['id']; parent::__construct(); } public function send_goods() { if($_POST){ $uq0 = P('oid','订单号提交错误'); $uq1 = $this->db->get_one("select id,uid,shop_id,order_no,order_status from ".table('order_info')." where shop_id = ".$this->spid." and order_no = '".$uq0."'"); if($uq1['id']){ if($uq1['order_status'] == 2){ $uq2['kd_code'] = P('kd_code', '请选择快递'); $uq2['kd_number'] = P('kd_number', '快递单号不能为空'); $uq2['kd_mktime'] = time(); $this->db->autocommit(); $uq3 = $this->db->update(table('order_address'), $uq2, 'oid = '.$uq1['id']); $uq4 = $this->db->update(table('order_info'), ['order_status'=>'3', 'deliver_time'=>time()], 'id = '.$uq1['id']); $uq5 = $this->db->update(table('order_goods'), ['order_status'=>'3'], 'oid = '.$uq1['id']); if($uq4 && $uq5 && $uq3){ $this->db->commit(); $uq6 = ''; $uq7 = 0; $uq8 = $this->db->get_all("select id,oid,title,buy_num from ".table('order_goods')." where oid = ".$uq1['id']); if($uq8){ foreach($uq8 as $uq9){ $uq6 .= $uq9['title'].' 和 '; $uq7 += $uq9['buy_num']; } $uq6 = cut_str(rtrim($uq6, '和 '), 15); if(count($uq8) > '1'){ $uq6 .= ' 共计'.count($uq8).'个商品'; } } $uq10 = $this->module('common')->category(['name'=>'express']); $uq11 = $uq10[$uq2['kd_code']]; $uq12['order_no'] = $uq1['order_no']; $uq12['title'] = $uq6; $uq12['buy_num'] = $uq7; $uq12['kd_name'] = $uq11; $uq12['kd_code'] = $uq2['kd_number']; $uq12['time'] = date('Y-m-d H:i:s', time()); $uq12['link'] = cfg('site_url').'buy/index'; right_json(); }else{ $this->db->rollback(); error_json('发货失败'); } }else{ error_json('不允许操作'); } }else{ error_json('获取订单失败'); } } } public function del() { error_json('商家无法删除订单'); } public function remark() { $uq0 = G('oid', '编号错误'); $uq1 = $this->db->get_one("select * from ".table('order_info')." where order_no = '".$uq0."'"); if($uq1['id']){ $this->assign('row', $uq1); } $this->display(); } public function remark_save() { if($_POST){ $uq13 = P('oid','订单号不能为空'); $uq14['remark'] = P('remark'); $uq15 = $this->db->update(table('order_info'), $uq14, "order_no = '".$uq13."'"); if($uq15){ right_json(); }else{ error_json('保存失败'); } }else{ error_json('提交错误'); } } public function refund_save() { if($_POST){ $uq16 = P('service_id', '提交售后错误'); $uq17 = P('action', '请选择退货操作'); $uq18 = P('content'); if($uq17 == '1'){ $uq1 = $this->db->get_one("select * from ".table('refund')." where spid = ".$this->spid." and service_id = '".$uq16."'"); if($uq1['id']){ if($uq1['is_return_goods'] == '1' && $uq1['status'] == '1'){ $this->db->autocommit(); $uq19 = $this->db->get_one("select * from ".table('shop_address')." where spid = ".$this->spid); if($uq19['id']){ $uq20 = $uq19['prov_cn'].', '.$uq19['city_cn'].', '.$uq19['dist_cn']." "; } $uq21 = '退货地址：'.$uq19['name'].', '.$uq19['mobile'].', '.@$uq20.', '.$uq19['address'].'<br>
								退货说明：'.$uq19['explain'].'<br>'; $uq18 = P('content'); if(!empty($uq18)){ $uq21 .= '退货备注：'.$uq18.'<br>'; } $uq22['rid'] = $uq1['id']; $uq22['uid'] = $uq1['uid']; $uq22['spid'] = $uq1['spid']; $uq22['content'] = '卖家：同意退货 '.$uq21; $q1 = $this->module('refund')->add_process($uq22); $q2 = $this->db->update(table('refund'), ['status'=>'2', 'passtime'=>time()], 'id = '.$uq1['id']); if($q1 && $q2){ $this->db->commit(); $uq24 = $this->db->get_one("select id,uid,shop_id,oid,service_id,title,order_status,receipt_time from ".table('order_goods')." where service_id = '".$uq1['service_id']."'"); $uq12['title'] = $uq24['title']; $uq12['service_id'] = $uq1['service_id']; $uq12['price'] = $uq1['price']; $uq12['time'] = date('Y-m-d H:i:s', time()); $uq12['link'] = cfg('site_url').'refund/index'; $this->module('api')->notice_add_all('user_refund_goods', $uq1['uid'], $uq12); right_json(); }else{ $this->db->rollback(); error_json('操作错误'); } }elseif($uq1['is_return_goods'] == '1' && $uq1['status'] == '3'){ $uq25 = $this->module('refund')->act_refund_success($uq16, $this->spid); echo json_encode($uq25); }elseif($uq1['is_return_goods'] == '0' && $uq1['status'] == '1'){ $uq25 = $this->module('refund')->act_refund_success($uq16, $this->spid); echo json_encode($uq25); }else{ error_json('当前操作不存在'); } }else{ error_json('售后不存在'); } }elseif($uq17 == '2'){ $uq1 = $this->db->get_one("select * from ".table('refund')." where spid = ".$this->spid." and service_id = '".$uq16."'"); if($uq1['id']){ if($uq1['status'] == '1'){ $this->db->rollback(); $uq22['rid'] = $uq1['id']; $uq22['uid'] = $uq1['uid']; $uq22['spid'] = $uq1['spid']; $uq22['content'] = '商家不同意申请。原因：'.$uq18; $q1 = $this->module('refund')->add_process($uq22); $q2 = $this->db->update(table('refund'), ['status'=>'0'], 'id = '.$uq1['id']); $q3 = $this->db->update(table('order_goods'), ['service_status'=>'0'], 'id = '.$uq1['ogid']); if($q1 && $q2 && $q3){ $this->db->commit(); right_json(); }else{ $this->db->rollback(); error_json('介入失败'); } }elseif($uq1['is_return_goods'] == '1' && $uq1['status'] == '3'){ $this->db->rollback(); $uq22['rid'] = $uq1['id']; $uq22['uid'] = $uq1['uid']; $uq22['spid'] = $uq1['spid']; $uq22['content'] = '商家不同意退货。愿意：'.$uq18; $q1 = $this->module('refund')->add_process($uq22); $q2 = $this->db->update(table('refund'), ['status'=>'2'], 'id = '.$uq1['id']); $q3 = $this->db->update(table('order_goods'), ['service_status'=>'2'], 'id = '.$uq1['ogid']); if($q1 && $q2 && $q3){ $this->db->commit(); right_json(); }else{ $this->db->rollback(); error_json('介入失败'); } }else{ error_json('操作失败'); } }else{ error_json('售后不存在'); } } }else{ error_json('操作错误'); } } } 