|
|
|
@ -18,6 +18,10 @@ use think\response\Json; |
|
|
|
|
use app\common\model\UploadFile as UploadFileModel; |
|
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions\F; |
|
|
|
|
use app\common\model\MerchantRemarks as MerchantRemarksModel; |
|
|
|
|
use app\store\model\OrderRefund as OrderRefundModel; |
|
|
|
|
use app\common\model\UploadFile; |
|
|
|
|
use app\common\model\TransferRecord as TransferRecordModel; |
|
|
|
|
use app\api\model\Express as ExpressModel; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 订单管理 |
|
|
|
@ -143,5 +147,161 @@ class Order extends Controller |
|
|
|
|
return $this->renderSuccess(compact('detail')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 订单列表 |
|
|
|
|
* @param string $dataType |
|
|
|
|
* @return Json |
|
|
|
|
*/ |
|
|
|
|
public function orderList(string $dataType): Json |
|
|
|
|
{ |
|
|
|
|
$params = $this->request->param(); |
|
|
|
|
$params['searchType'] = 'all'; |
|
|
|
|
$goodsModel = new GoodsModel; |
|
|
|
|
$MerchantRemarks = new MerchantRemarksModel(); |
|
|
|
|
// 订单列表 |
|
|
|
|
if (!empty($params['dataType']) && $params['dataType'] == 'refund') { |
|
|
|
|
$model = new OrderRefundModel; |
|
|
|
|
$list = $model->getOrderNewList($params); |
|
|
|
|
if (!empty($list['data'])) { |
|
|
|
|
foreach ($list['data'] as $key => &$value) { |
|
|
|
|
$goods_images = $goodsModel->storeUsePlatformGoodsImage(array_column($value['goods'], 'origin_goods_id')); |
|
|
|
|
foreach ($value['goods'] as &$good) { |
|
|
|
|
//使用总后台的商品图片 |
|
|
|
|
if ($good['origin_goods_id'] && $value['store_id'] > 0) { |
|
|
|
|
$good['goods_image'] = $goods_images[$good['origin_goods_id']][0]['file']['preview_url'] ?? ""; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return $this->renderSuccess(compact('list')); |
|
|
|
|
} else { |
|
|
|
|
$model = new OrderModel; |
|
|
|
|
$list = $model->getOrderList($params); |
|
|
|
|
if (!empty($list['data'])) { |
|
|
|
|
foreach ($list['data'] as $key => &$value) { |
|
|
|
|
if (!empty($value['transfer']) && !empty($value['transfer']['chat_image_id'])) { |
|
|
|
|
$chat_image_ids = UploadFile::whereIn('file_id', explode(",", $value['transfer']['chat_image_id']))->field('file_id,file_path,file_type,storage,domain')->select(); |
|
|
|
|
foreach ($chat_image_ids as &$chat_image_id) { |
|
|
|
|
$chat_image_id['file_path'] = getUrl($chat_image_id['file_path'], $chat_image_id['domain']); |
|
|
|
|
} |
|
|
|
|
$list['data'][$key]['transfer']['chat_image_ids'] = $chat_image_ids; |
|
|
|
|
} |
|
|
|
|
if (!empty($value['transfer']) && !empty($value['transfer']['transfer_image_id'])) { |
|
|
|
|
$transfer_image_ids = UploadFile::whereIn('file_id', explode(",", $value['transfer']['transfer_image_id']))->field('file_id,file_path,file_type,storage,domain')->select(); |
|
|
|
|
foreach ($transfer_image_ids as &$transfer_image_id) { |
|
|
|
|
$transfer_image_id['file_path'] = getUrl($transfer_image_id['file_path'], $transfer_image_id['domain']); |
|
|
|
|
} |
|
|
|
|
$list['data'][$key]['transfer']['transfer_image_ids'] = $transfer_image_ids; |
|
|
|
|
} |
|
|
|
|
//复制信息 |
|
|
|
|
$copy_text = "订单号:{$value['order_no']}\n"; |
|
|
|
|
$goods_images = $goodsModel->storeUsePlatformGoodsImage(array_column($value['goods'], 'origin_goods_id')); |
|
|
|
|
|
|
|
|
|
foreach ($value['goods'] as &$good) { |
|
|
|
|
//使用总后台的商品图片 |
|
|
|
|
if ($good['origin_goods_id'] && $value['store_id'] > 0) { |
|
|
|
|
$good['goods_image'] = $goods_images[$good['origin_goods_id']][0]['file']['preview_url'] ?? ""; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$copy_text .= "商品名称:{$good['goods_name']}\n"; |
|
|
|
|
if (!empty($good['goods_no'])) { |
|
|
|
|
$copy_text .= "商品编码:{$good['goods_no']}\n"; |
|
|
|
|
} |
|
|
|
|
$copy_text .= "单价:{$good['goods_price']}\n"; |
|
|
|
|
$copy_text .= "数量:{$good['total_num']}\n"; |
|
|
|
|
$copy_text .= "总价:{$good['total_price']}\n"; |
|
|
|
|
$copy_text .= "\n"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!empty($value['address'])) { |
|
|
|
|
$copy_text .= "\n"; |
|
|
|
|
$copy_text .= "收件人:{$value['address']['name']}\n"; |
|
|
|
|
$copy_text .= "电话:{$value['address']['phone']}\n"; |
|
|
|
|
$address = ''; |
|
|
|
|
if (!empty($value['address']['region'])) { |
|
|
|
|
$address = $value['address']['region']['province'] . $value['address']['region']['city'] . $value['address']['region']['region']; |
|
|
|
|
} |
|
|
|
|
$copy_text .= "地址:$address{$value['address']['detail']}\n"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$list['data'][$key]['copy_text'] = $copy_text; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return $this->renderSuccess(compact('dataType', 'list')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 非商城订单 |
|
|
|
|
*/ |
|
|
|
|
public function transferList(): Json |
|
|
|
|
{ |
|
|
|
|
$params = $this->request->param(); |
|
|
|
|
$where = []; |
|
|
|
|
if (!empty($params['search'])) { |
|
|
|
|
$where[] = ['goods_sn', 'like', "%{$params["search"]}%"]; |
|
|
|
|
} |
|
|
|
|
$list = TransferRecordModel::where('status', 1) |
|
|
|
|
->where($where) |
|
|
|
|
->order("id desc") |
|
|
|
|
->paginate(10)->each(function ($item, $key) { |
|
|
|
|
$goods_sn = explode("、", $item['goods_sn']); |
|
|
|
|
$goods_num = explode("、", $item['goods_num']); |
|
|
|
|
$goods_price = explode("、", $item['goods_price']); |
|
|
|
|
$goods = []; |
|
|
|
|
$total_price = 0; |
|
|
|
|
foreach ($goods_sn as $seq => $value) { |
|
|
|
|
$price = (float)$goods_price[$seq] ?? 0.00; |
|
|
|
|
$goods[] = [ |
|
|
|
|
'name' => $value, |
|
|
|
|
'price' => $price, |
|
|
|
|
'num' => $goods_num[$seq] ?? 0, |
|
|
|
|
"image" => 'https://imgservice5.suning.cn/uimg1/b2c/image/nXmtUUkwKxasCEBIX90d7w.png' |
|
|
|
|
]; |
|
|
|
|
$total_price += $price; |
|
|
|
|
} |
|
|
|
|
$item['goods'] = $goods; |
|
|
|
|
$item['total_price'] = $total_price; |
|
|
|
|
$transfer_image_ids = UploadFile::whereIn('file_id', explode(",", $item['transfer_image_id']))->field('file_id,file_path,file_type,storage,domain')->select(); |
|
|
|
|
foreach ($transfer_image_ids as &$transfer_image_id) { |
|
|
|
|
$transfer_image_id['file_path'] = getUrl($transfer_image_id['file_path'], $transfer_image_id['domain']); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$chat_image_ids = UploadFile::whereIn('file_id', explode(",", $item['chat_image_id']))->field('file_id,file_path,file_type,storage,domain')->select(); |
|
|
|
|
foreach ($chat_image_ids as &$chat_image_id) { |
|
|
|
|
$chat_image_id['file_path'] = getUrl($chat_image_id['file_path'], $chat_image_id['domain']); |
|
|
|
|
} |
|
|
|
|
$item['transfer_image_ids'] = $transfer_image_ids; |
|
|
|
|
$item['chat_image_ids'] = $chat_image_ids; |
|
|
|
|
return $item; |
|
|
|
|
})->toArray(); |
|
|
|
|
return $this->renderSuccess($list); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function addTransfer(): Json |
|
|
|
|
{ |
|
|
|
|
$params = $this->request->param(); |
|
|
|
|
$storeid = request()->header()['storeid']; |
|
|
|
|
$params['user_id'] = \app\api\service\User::getCurrentLoginUserId(); |
|
|
|
|
$params['store_id'] = $storeid; |
|
|
|
|
TransferRecordModel::create($params); |
|
|
|
|
return $this->renderSuccess('ok'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 物流公司列表 |
|
|
|
|
* @return Json |
|
|
|
|
* @throws \think\db\exception\DataNotFoundException |
|
|
|
|
* @throws \think\db\exception\DbException |
|
|
|
|
* @throws \think\db\exception\ModelNotFoundException |
|
|
|
|
*/ |
|
|
|
|
public function expressList(): Json |
|
|
|
|
{ |
|
|
|
|
$model = new ExpressModel; |
|
|
|
|
$list = $model->getAll(); |
|
|
|
|
return $this->renderSuccess(compact('list')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|