592 行
25 KiB
PHP
可执行文件
592 行
25 KiB
PHP
可执行文件
<?php
|
|
|
|
namespace SmallProgramApi\Controller;
|
|
|
|
use Common\Business\Store;
|
|
use Common\Model\ImageGalleryModel;
|
|
use Common\Model\RetailBillOrderModel;
|
|
use Common\Model\RetailSellModel;
|
|
|
|
//[1.8.50]
|
|
|
|
/**
|
|
* 售后
|
|
* Class CustomerController
|
|
* @package SmallProgramApi\Controller
|
|
*/
|
|
class CustomerController extends BaseController
|
|
{
|
|
/**
|
|
* 物流公司
|
|
*/
|
|
public function LogisticsCompany()
|
|
{
|
|
$express = M("express")->select();
|
|
$res = array('status' => 1, 'msg' => '获取成功', 'express' => $express);
|
|
$this->ajaxReturn($res);
|
|
}
|
|
|
|
/*
|
|
* 判断是否可以修改申请退款换货原因
|
|
* @param $bill_id 订单Id
|
|
*/
|
|
protected function TestingOrderType($bill_id)
|
|
{
|
|
if (empty($bill_id)) {
|
|
$res = array('status' => 0, 'msg' => '参数缺失,请刷新重试');
|
|
return $res;
|
|
}
|
|
$RetailBillOrderModel = D("RetailBillOrder");
|
|
$refund_status = $RetailBillOrderModel->getFindField(array('id' => $bill_id), "refund_status");
|
|
if (in_array($refund_status, array(1, 3))) {
|
|
$res = array('status' => 1, 'msg' => '可以提交原因');
|
|
} else {
|
|
$res = array('status' => 0, 'msg' => '该订单类型已改变,请刷新重试');
|
|
}
|
|
return $res;
|
|
}
|
|
|
|
/**
|
|
* 申请退款换货原因与图片展示
|
|
* @param bill_id 订单id
|
|
*/
|
|
public function reasonInfo()
|
|
{
|
|
$bill_id = I("post.id");
|
|
if (empty($bill_id)) {
|
|
$res = array('status' => 0, 'msg' => '参数缺失,请刷新重试');
|
|
$this->ajaxReturn($res);
|
|
}
|
|
$BillOrderModel = D("RetailBillOrder");
|
|
$RetailBillReasonModel = D("RetailBillReason");
|
|
$bill_info = $BillOrderModel->getFind(array('id' => $bill_id));
|
|
if (!$bill_info) {
|
|
$res = array('status' => 0, 'msg' => '未找到改订单,请刷新重试');
|
|
$this->ajaxReturn($res);
|
|
}
|
|
if ($bill_info['order_type'] == 3) {
|
|
$BillOnline = D("RetailBillOnline");
|
|
$online_info = $BillOnline->getFind(array("bill_id" => $bill_id));
|
|
}
|
|
$reason = $RetailBillReasonModel->getFind(array('bill_id' => $bill_id));
|
|
$image_list = array(); //图片列表
|
|
if (!empty($reason['goods_img_id'])) {
|
|
$img = explode(',', $reason['goods_img_id']);
|
|
foreach ($img as $key => $val) {
|
|
$image_list[$key]['goods_img_id'] = $val;
|
|
$image_list[$key]['path'] = D('ImageGallery')->getImagePath($val);
|
|
}
|
|
}
|
|
$res = array(
|
|
'status' => 1,
|
|
'msg' => '查询成功',
|
|
'reason' => $reason,
|
|
'image_list' => $image_list,
|
|
'user_address' => $online_info ? $online_info['user_address'] : "",
|
|
);
|
|
$this->ajaxReturn($res);
|
|
}
|
|
|
|
/**
|
|
* 修改申请退款退货信息
|
|
* @param id 订单id
|
|
* @param apply_reason 原因
|
|
*/
|
|
public function modifyReason()
|
|
{
|
|
$bill_id = I("post.id");
|
|
$apply_reason = I("post.apply_reason");
|
|
if (empty($bill_id)) {
|
|
$res = array('status' => 0, 'msg' => '参数缺失,请刷新重试');
|
|
$this->ajaxReturn($res);
|
|
}
|
|
if (empty($apply_reason)) {
|
|
$res = array('status' => 0, 'msg' => '请输入原因');
|
|
$this->ajaxReturn($res);
|
|
}
|
|
$RetailBillReasonModel = D("RetailBillReason");
|
|
$data = array(
|
|
'apply_reason' => $apply_reason,
|
|
);
|
|
//查询是否存在原因信息
|
|
$reason = $RetailBillReasonModel->getFind(array('bill_id' => $bill_id));
|
|
if ($reason) {
|
|
$option = $RetailBillReasonModel->updateOrder(array('bill_id' => $bill_id), $data);
|
|
} else {
|
|
$data = array(
|
|
"bill_id" => $bill_id,
|
|
"apply_reason" => $apply_reason,
|
|
"add_time" => time()
|
|
);
|
|
$option = $RetailBillReasonModel->addOrder($data);
|
|
}
|
|
if ($option) {
|
|
$res = array('status' => 1, 'msg' => '操作成功');
|
|
} else {
|
|
$res = array('status' => 0, 'msg' => '暂无修改');
|
|
}
|
|
$this->ajaxReturn($res);
|
|
}
|
|
|
|
/**
|
|
* 顾客售后列表
|
|
*/
|
|
public function customerList()
|
|
{
|
|
$RetailBillOrderModel = new RetailBillOrderModel();
|
|
$page = I('post.page');
|
|
$limit = 10;
|
|
$page = $page . "," . $limit;
|
|
$where = array(
|
|
'b.merchant_id' => self::$merchant_id,
|
|
'b.store_id' => self::$store_id,
|
|
'b.uid' => self::$uid,
|
|
'b.order_type' => array('in', '2,3'),
|
|
'o.order_genre' => array('in', '1,2,3,4'),
|
|
);
|
|
$fields = "b.id,b.order_no,b.all_money,b.add_time,b.order_type,b.refund_status,o.status,o.delivery_type,o.delivery_fee";
|
|
$bill_list = $RetailBillOrderModel->getOrderLinkSelect($where, $fields, "b.id desc", $page);
|
|
$order_list = array();
|
|
if ($bill_list) {
|
|
$RetailSellModel = new RetailSellModel();
|
|
$sell_fields = "id,goods_id,price,original_price,vip_price,plus_vip_price,all_money,num,goods_name,sku_json_info,attribute_state,goods_img_id";
|
|
foreach ($bill_list as &$val) {
|
|
$sell_list = $RetailSellModel->getSelect(array('bill_id' => $val['id']), $sell_fields);
|
|
if (empty($sell_list)) {
|
|
continue;
|
|
}
|
|
foreach ($sell_list as $k=>&$v) {
|
|
$v['goods_img'] = getGoodsImage($v['goods_img_id'], self::$store_id);
|
|
$v['price'] = floatval($v['price']);
|
|
$v['original_price'] = floatval($v['original_price']);
|
|
$v['vip_price'] = floatval($v['vip_price']);
|
|
$v['plus_vip_price'] = floatval($v['plus_vip_price']);
|
|
$v['all_money'] = floatval($v['all_money']);
|
|
$v['num'] = floatval($v['num']);
|
|
if (!empty($v["sku_json_info"])) {
|
|
$sell_list[$k]["sku_json_info"] = json_decode($v["sku_json_info"], true);
|
|
}
|
|
}
|
|
$val['sell_list'] = $sell_list;
|
|
if (($val['refund_status'] != 2 || $val['refund_status'] == 6) && $val['order_type'] == 2) {
|
|
$val['all_money'] = round($val['all_money'] + $val['delivery_fee'], 2);
|
|
} else {
|
|
$val['all_money'] = floatval($val['all_money']);
|
|
}
|
|
$val['add_time'] = date('Y-m-d H:i:s', $val['add_time']);
|
|
$order_list[] = $val;
|
|
}
|
|
}
|
|
$res['status'] = 1;
|
|
$res['msg'] = $order_list ? '获取成功' : '暂无数据';
|
|
$res['limit'] = $limit;
|
|
$res['order_list'] = $order_list;
|
|
$this->ajaxReturn($res);
|
|
}
|
|
|
|
/**
|
|
* 顾客售后列表 不限制门店版
|
|
*/
|
|
public function customerList_v1()
|
|
{
|
|
$RetailBillOrderModel = new RetailBillOrderModel();
|
|
$page = I('post.page');
|
|
$limit = 10;
|
|
$page = $page . "," . $limit;
|
|
$where = array(
|
|
'b.merchant_id' => self::$merchant_id,
|
|
'b.uid' => self::$uid,
|
|
'b.order_type' => array('in', '2,3'),
|
|
'o.order_genre' => array('in', '1,2,3,4'),
|
|
);
|
|
$fields = "b.id,b.store_id,b.order_no,b.all_money,b.add_time,b.order_type,b.refund_status,b.refund_no,o.status,o.delivery_type,o.delivery_fee";
|
|
$bill_list = $RetailBillOrderModel->getOrderLinkSelect($where, $fields, "b.id desc", $page);
|
|
$order_list = array();
|
|
if ($bill_list) {
|
|
//查询门店信息
|
|
$StoreClass = new Store();
|
|
$storeInfo = $StoreClass->storeListInfo([
|
|
'merchant_id'=>self::$merchant_id,
|
|
'state'=>2,
|
|
'fields'=>'id,storetag,shopimg_id'
|
|
]);
|
|
if(!empty($storeInfo)){
|
|
$storeInfo = array_column($storeInfo,null,'id');
|
|
}
|
|
$RetailSellModel = new RetailSellModel();
|
|
$sell_fields = "id,goods_id,price,original_price,vip_price,plus_vip_price,all_money,num,goods_name,sku_json_info,attribute_state,goods_img_id";
|
|
foreach ($bill_list as &$val) {
|
|
$sell_list = $RetailSellModel->getSelect(array('bill_id' => $val['id']), $sell_fields);
|
|
if (empty($sell_list)) {
|
|
continue;
|
|
}
|
|
foreach ($sell_list as $k=>&$v) {
|
|
$v['goods_img'] = getGoodsImage($v['goods_img_id'], self::$store_id);
|
|
$v['price'] = floatval($v['price']);
|
|
$v['original_price'] = floatval($v['original_price']);
|
|
$v['vip_price'] = floatval($v['vip_price']);
|
|
$v['plus_vip_price'] = floatval($v['plus_vip_price']);
|
|
$v['all_money'] = floatval($v['all_money']);
|
|
$v['num'] = floatval($v['num']);
|
|
if (!empty($v["sku_json_info"])) {
|
|
$sell_list[$k]["sku_json_info"] = json_decode($v["sku_json_info"], true);
|
|
}
|
|
}
|
|
$val['sell_list'] = $sell_list;
|
|
if (($val['refund_status'] != 2 || $val['refund_status'] == 6) && $val['order_type'] == 2) {
|
|
$val['all_money'] = round($val['all_money'] + $val['delivery_fee'], 2);
|
|
} else {
|
|
$val['all_money'] = floatval($val['all_money']);
|
|
}
|
|
$val['add_time'] = date('Y-m-d H:i:s', $val['add_time']);
|
|
$val['store_name'] = $storeInfo[$val['store_id']]['storetag'];
|
|
$val['store_image'] = getImage($storeInfo[$val['store_id']]['shopimg_id']);
|
|
$order_list[] = $val;
|
|
}
|
|
}
|
|
$res['status'] = 1;
|
|
$res['msg'] = $order_list ? '获取成功' : '暂无数据';
|
|
$res['limit'] = $limit;
|
|
$res['order_list'] = $order_list;
|
|
$this->ajaxReturn($res);
|
|
}
|
|
|
|
/**
|
|
* 取消申请退款,换货,撤销取消订单
|
|
* @param id 订单id
|
|
*/
|
|
public function cancelRefund()
|
|
{
|
|
$id = I('post.id');
|
|
if (empty($id)) {
|
|
$result = array('status' => 0, 'msg' => '参数缺失,请刷新重试');
|
|
$this->ajaxReturn($result);
|
|
}
|
|
$uid = self::$uid;
|
|
$merchant_id = self::$merchant_id;
|
|
$BillModel = D('RetailBillOrder');
|
|
$r_map = array(
|
|
'b.id' => $id,
|
|
'b.merchant_id' => $merchant_id,
|
|
'b.uid' => $uid,
|
|
'b.type' => 1,
|
|
'b.order_type' => array('in', '2,3'),//售后订单
|
|
'b.refund_status' => array('in', '1,3') //申请中,客户未发货中
|
|
);
|
|
$r_bill_order = $BillModel->getBillFind($r_map, "b.*,o.status");
|
|
if (empty($r_bill_order)) {
|
|
$result = array('status' => 0, 'msg' => '该订单状态已改变,请刷新重试');
|
|
$this->ajaxReturn($result);
|
|
}
|
|
if (C('IS_SET_REDIS')) {
|
|
$ApiRedis = new \Addons\Api\RedisController();
|
|
$redis_key = "customer_" . $r_bill_order['order_no'];
|
|
if ($ApiRedis::$redis->exists($redis_key)) {
|
|
$res = array('status' => 0, 'msg' => '正在操作该订单,请勿重复操作');
|
|
$this->ajaxReturn($res);
|
|
}
|
|
$ApiRedis::$redis->setex($redis_key, 10, $r_bill_order['order_no']);
|
|
}
|
|
$store_id = $r_bill_order['store_id'];
|
|
$y_map = array(
|
|
'store_id' => $store_id,
|
|
'merchant_id' => $merchant_id,
|
|
'uid' => $uid,
|
|
'type' => 1,
|
|
'order_type' => 1,
|
|
'order_no' => $r_bill_order['refund_no']
|
|
);
|
|
$y_bill_order = $BillModel->getFind($y_map); //原订单
|
|
if (!empty($y_bill_order)) {
|
|
$SellModel = D('RetailSell');
|
|
$sMap = array(
|
|
$SellModel::BILL_ID => $r_bill_order[$BillModel::ID],
|
|
);
|
|
if ($r_bill_order['order_type'] == 3) {
|
|
$sMap[$SellModel::SELL_TYPE] = 3;//换货
|
|
} else {
|
|
$sMap[$SellModel::SELL_TYPE] = 2; //退款或取消订单
|
|
}
|
|
$r_sell_list = $SellModel->getSelect($sMap);//售后单记录表
|
|
if (empty($r_sell_list)) {
|
|
if (C("IS_SET_REDIS")) {
|
|
$ApiRedis::$redis->delete($redis_key);
|
|
}
|
|
$result = array('status' => 0, 'msg' => '数据操作有误');
|
|
$this->ajaxReturn($result);
|
|
}
|
|
$success_array = array();
|
|
foreach ($r_sell_list as $value) {
|
|
$map = array(
|
|
$SellModel::ID => $value[$SellModel::SELL_ID]
|
|
);
|
|
$updateSell = $SellModel->toSetDec($map, $SellModel::WAIT_REFUND_NUM, $value[$SellModel::NUM]);
|
|
if ($updateSell) {
|
|
$success_array[] = $value;
|
|
}
|
|
}
|
|
if (count($success_array) == count($r_sell_list)) {
|
|
//修改售后状态
|
|
$BillModel->updateOrder(array("id" => $id), array('refund_status' => 7));
|
|
if ($r_bill_order['status'] == 1 && $r_bill_order['order_type'] == 2) {
|
|
$BillModel->updateOrder(array("id" => $y_bill_order["id"]), array('refund_status' => 0));
|
|
}
|
|
$data = array(
|
|
'cancel_time' => 1,
|
|
'refund_time' => 1
|
|
);
|
|
$result['data'] = $data;
|
|
$sockets = array(
|
|
'login_string' => '',
|
|
'username' => '',
|
|
);
|
|
switch ($r_bill_order['order_type']) {
|
|
case 2:
|
|
//退款订单
|
|
$OnlineModel = D('RetailBillOnline');
|
|
$onlineOrder = $OnlineModel->getFind(array($OnlineModel::BILL_ID => $y_bill_order[$BillModel::ID]));
|
|
if ($onlineOrder['status'] == 1) {
|
|
$sockets['message'] = "有线上订单撤销取消订单申请";
|
|
$sockets['type'] = 4;
|
|
sendSockets($store_id, $sockets, -1);
|
|
if ($onlineOrder[$OnlineModel::PICKUP_TYPE] == 1) {
|
|
$result['state'] = '待自提';
|
|
} else {
|
|
$result['state'] = '待发货';
|
|
}
|
|
} else {
|
|
$sockets['message'] = "有线上订单取消退款申请";
|
|
$sockets['type'] = 5;
|
|
sendSockets($store_id, $sockets, -1);
|
|
$result['state'] = '已完成';
|
|
}
|
|
break;
|
|
case 3:
|
|
//换货订单
|
|
$sockets['message'] = "有线上订单取消换货申请";
|
|
$sockets['type'] = 7;
|
|
sendSockets($store_id, $sockets, -1);
|
|
$result['state'] = '已完成';
|
|
break;
|
|
}
|
|
$result['status'] = 1;
|
|
$result['msg'] = '操作成功';
|
|
} else {
|
|
foreach ($success_array as $val) {
|
|
$map = array(
|
|
$SellModel::ID => $val[$SellModel::SELL_ID]
|
|
);
|
|
$SellModel->toSetInc($map, $SellModel::WAIT_REFUND_NUM, $val[$SellModel::NUM]);
|
|
}
|
|
$result['status'] = 0;
|
|
$result['msg'] = '数据操作有误2';
|
|
}
|
|
} else {
|
|
$result['status'] = 0;
|
|
$result['msg'] = '取消失败,请稍后重试';
|
|
}
|
|
if (C('IS_SET_REDIS')) {
|
|
$ApiRedis::$redis->delete($redis_key);
|
|
}
|
|
$this->ajaxReturn($result);
|
|
}
|
|
|
|
/*
|
|
* 客户发货操作
|
|
* @param id 订单id
|
|
* @param express_name 物流名称
|
|
* @param express_no 物流单号
|
|
*/
|
|
public function UserDeliverGoods()
|
|
{
|
|
$bill_id = I("post.id");
|
|
$express_name = I("post.express_name");
|
|
$express_code = I("post.express_code");
|
|
$express_no = I("post.express_no");
|
|
if (empty($bill_id) || empty($express_name) || empty($express_code) || empty($express_no)) {
|
|
$res = array('status' => 0, 'msg' => '参数缺失,请刷新重试');
|
|
$this->ajaxReturn($res);
|
|
}
|
|
$RetailBillOrderModel = D("RetailBillOrder");
|
|
$order = $RetailBillOrderModel->getFind(array('id' => $bill_id));
|
|
if (empty($order)) {
|
|
$res = array('status' => 0, 'msg' => '未找到该订单,请刷新重试');
|
|
$this->ajaxReturn($res);
|
|
}
|
|
if ($order['refund_status'] != 3) {
|
|
$res = array('status' => 0, 'msg' => '该订单状态已改变,请刷新重试');
|
|
$this->ajaxReturn($res);
|
|
}
|
|
if (C('IS_SET_REDIS')) {
|
|
$ApiRedis = new \Addons\Api\RedisController();
|
|
$redis_key = "customer_" . $order['order_no'];
|
|
if ($ApiRedis::$redis->exists($redis_key)) {
|
|
$res = array('status' => 0, 'msg' => '正在操作该订单,请勿重复操作');
|
|
$this->ajaxReturn($res);
|
|
}
|
|
$ApiRedis::$redis->setex($redis_key, 10, $order['order_no']);
|
|
}
|
|
$ExpressOrderModel = D("ExpressOrder");
|
|
$data = array(
|
|
'merchant_id' => self::$merchant_id,
|
|
'store_id' => $order['store_id'],
|
|
'bill_id' => $bill_id,
|
|
'express_no' => $express_no,
|
|
'express_name' => $express_name,
|
|
'express_code' => $express_code,
|
|
'add_time' => time(),
|
|
'type' => 2, //直接填写单号
|
|
'operation_type' => 2 //客户发货
|
|
);
|
|
$express_id = $ExpressOrderModel->addOrder($data);
|
|
if ($express_id) {
|
|
$modify = $RetailBillOrderModel->updateOrder(array('id' => $bill_id), array('express_id' => $express_id, 'refund_status' => 4));
|
|
if ($modify) {
|
|
$order['goods'] = (new \Common\Model\RetailSellModel)->where(['bill_id' => $order['id']])->select();
|
|
\Think\Hook::listen('pay_success', $order);
|
|
$res = array('status' => 1, 'msg' => '操作成功');
|
|
} else {
|
|
$ExpressOrderModel->updateOrder(array('id' => $express_id), array('status' => 0));
|
|
$res = array('status' => 0, 'msg' => '操作失败');
|
|
}
|
|
} else {
|
|
$res = array('status' => 0, 'msg' => '操作失败');
|
|
}
|
|
if (C('IS_SET_REDIS')) {
|
|
$ApiRedis::$redis->delete($redis_key);
|
|
}
|
|
$this->ajaxReturn($res);
|
|
}
|
|
|
|
/**
|
|
* 客户收货
|
|
* @param id 订单id
|
|
*/
|
|
public function ReceivingGoods()
|
|
{
|
|
$bill_id = I("post.id");
|
|
if (empty($bill_id)) {
|
|
$res = array('status' => 0, 'msg' => '参数缺失');
|
|
$this->ajaxReturn($res);
|
|
}
|
|
$BillModel = D('RetailBillOrder');
|
|
$OnlineModel = D('RetailBillOnline');
|
|
$where = array(
|
|
'b.id' => $bill_id,
|
|
'b.uid' => self::$uid,
|
|
'b.merchant_id' => self::$merchant_id,
|
|
'o.status' => 2
|
|
);
|
|
$bill_order = M("retail_bill_order as b")
|
|
->join("ls_retail_bill_online as o on b.id=o.bill_id")
|
|
->field("b.id,b.refund_status,b.order_type,o.status,o.order_genre")
|
|
->where($where)
|
|
->find();
|
|
if (empty($bill_order)) {
|
|
$res = array('status' => 0, 'msg' => '该订单状态已改变,请刷新重试');
|
|
$this->ajaxReturn($res);
|
|
}
|
|
if (C("IS_SET_REDIS")) {
|
|
$ApiRedis = new \Addons\Api\RedisController;
|
|
$redis_key = "customer_" . $bill_order['order_no'];
|
|
if ($ApiRedis::$redis->exists($redis_key)) {
|
|
$res = array('status' => 0, 'msg' => '正在操作该订单,请勿重复操作');
|
|
$this->ajaxReturn($res);
|
|
}
|
|
$ApiRedis::$redis->setex($redis_key, 10, $bill_order['order_no']);
|
|
}
|
|
if ($bill_order['order_type'] == 3) {
|
|
//换货订单
|
|
$BillModel->updateOrder(array('id' => $bill_id), array('refund_status' => 2, "finish_time" => time()));
|
|
}
|
|
$modify = $OnlineModel->updateOrder(array('bill_id' => $bill_id), array('status' => 3, 'receiving_goods_time' => time()));
|
|
if ($modify) {
|
|
if ($bill_order['order_type'] == 3) {
|
|
$RetailSellModel = D("RetailSell");
|
|
$sell_list = $RetailSellModel->getSelect(array('bill_id' => $bill_order['id']), "id,sell_id,num");
|
|
if ($sell_list) {
|
|
foreach ($sell_list as $val) {
|
|
$RetailSellModel->toSetDec(array('id' => $val['sell_id']), "wait_refund_num", $val['num']);
|
|
$RetailSellModel->updateOrder(array('id' => $val['id']), array("pay_state" => 1));
|
|
}
|
|
$res = array('status' => 1, 'msg' => '操作成功');
|
|
} else {
|
|
$OnlineModel->updateOrder(array('bill_id' => $bill_id), array('status' => 2, 'receiving_goods_time' => time()));
|
|
$res = array('status' => 0, 'msg' => '操作失败');
|
|
}
|
|
} else {
|
|
$res = array('status' => 1, 'msg' => '操作成功');
|
|
}
|
|
} else {
|
|
$res = array('status' => 0, 'msg' => '操作失败');
|
|
}
|
|
if (C('IS_SET_REDIS')) {
|
|
$ApiRedis::$redis->delete($redis_key);
|
|
}
|
|
$this->ajaxReturn($res);
|
|
}
|
|
|
|
/**
|
|
* 售后订单详情
|
|
*order_no 订单号
|
|
*/
|
|
public function order_info()
|
|
{
|
|
$order_no = I("post.order_no");
|
|
if (empty($order_no)) {
|
|
$res['status'] = 0;
|
|
$res['msg'] = "参数缺失订单号";
|
|
$this->ajaxReturn($res);
|
|
}
|
|
$BillOrder = D("RetailBillOrder");
|
|
$where = array(
|
|
'b.order_no' => $order_no,
|
|
'b.order_type' => array('in', '2,3'),
|
|
);
|
|
$fields = "b.id,b.refund_status,b.order_no,b.refund_no,b.all_money,b.order_type,b.express_id,o.status,b.add_time,o.user_phone,o.user_name,o.user_address,o.delivery_fee";
|
|
$bill_info = $BillOrder->getBillFind($where, $fields);
|
|
if (!$bill_info) {
|
|
$res['status'] = 0;
|
|
$res['msg'] = '未找到该售后订单';
|
|
$this->ajaxReturn($res);
|
|
}
|
|
$RetailSellModel = D("RetailSell");
|
|
$BillReason = D("RetailBillReason");
|
|
$ExpressOrder = D("ExpressOrder");
|
|
$sell_fields = "id,goods_id,price,original_price,vip_price,plus_vip_price,all_money,num,goods_name,sku_json_info,attribute_state,goods_img_id";
|
|
$sell_list = $RetailSellModel->getSelect(array('bill_id' => $bill_info['id']), $sell_fields);
|
|
if ($sell_list) {
|
|
foreach ($sell_list as $k => $v) {
|
|
$sell_list[$k]['goods_img'] = D('ImageGallery')->getImagePath($v['goods_img_id']);
|
|
$sell_list[$k]['price'] = floatval($sell_list[$k]['price']);
|
|
$sell_list[$k]['original_price'] = floatval($sell_list[$k]['original_price']);
|
|
$sell_list[$k]['vip_price'] = floatval($sell_list[$k]['vip_price']);
|
|
$sell_list[$k]['plus_vip_price'] = floatval($sell_list[$k]['plus_vip_price']);
|
|
$sell_list[$k]['all_money'] = floatval($sell_list[$k]['all_money']);
|
|
$sell_list[$k]['num'] = floatval($sell_list[$k]['num']);
|
|
if (!empty($v["sku_json_info"])) {
|
|
$sell_list[$k]["sku_json_info"] = json_decode($sell_list[$k]["sku_json_info"], true);
|
|
}
|
|
}
|
|
}
|
|
$bill_info['sell_info'] = $sell_list;
|
|
$reason_info = $BillReason->getFind(array("bill_id" => $bill_info['id']));
|
|
if (!empty($reason_info['goods_img_id'])) {
|
|
$reason_img = explode(",", $reason_info['goods_img_id']);
|
|
foreach ($reason_img as $key => $val) {
|
|
$reason_info['img_path'][$key] = D('ImageGallery')->getImagePath($val);
|
|
}
|
|
}
|
|
$bill_info['add_time'] = date("Y-m-d H:i:s", $bill_info['add_time']);
|
|
$bill_info['reason_info'] = $reason_info;
|
|
$express_info = $ExpressOrder->getFind(array("bill_id" => $bill_info['id']));
|
|
$bill_info['express_info'] = $express_info;
|
|
if (($bill_info['refund_status'] != 2 || $bill_info['refund_status'] == 6) && $bill_info['order_type'] == 2) {
|
|
$bill_info['all_money'] = round($bill_info['all_money'] + $bill_info['delivery_fee'], 2);
|
|
}
|
|
$res['status'] = 1;
|
|
$res['msg'] = '查询成功';
|
|
$res['bill_info'] = $bill_info;
|
|
$this->ajaxReturn($res);
|
|
}
|
|
} |