admin/addon/cashier/storeapi/controller/Cashierorderrefund.php

100 lines
3.7 KiB
PHP

<?php
/**
* ThinkShop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.cdcloudshop.com
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
* =========================================================
*/
namespace addon\cashier\storeapi\controller;
use app\storeapi\controller\BaseStoreApi;
use app\model\order\OrderRefund as OrderRefundModel;
use addon\cashier\model\order\CashierOrderRefund as CashierOrderRefundModel;
class Cashierorderrefund extends BaseStoreApi
{
/**
* 商品计算
* @return false|string
*/
public function getRefundApplyData()
{
$token = $this->checkToken();
if ($token[ 'code' ] < 0) return $this->response($token);
$order_refund_model = new CashierOrderRefundModel();
$params = array (
'site_id' => $this->site_id,//站点id
'store_id' => $this->store_id,
'order_id' => $this->params[ 'order_id' ] ?? 0,
'refund_array' => $this->params[ 'refund_array' ] ?? '{}',// ['order_goods_id1','order_goods_id2','order_goods_id2']
);
$res = $order_refund_model->getRefundApplyData($params);
return $this->response($res);
}
public function refund()
{
$token = $this->checkToken();
if ($token[ 'code' ] < 0) return $this->response($token);
$order_refund_model = new CashierOrderRefundModel();
$data = [
'site_id' => $this->site_id,//站点id
'store_id' => $this->store_id,
'order_id' => $this->params[ 'order_id' ] ?? 0,
'refund_transfer_type' => $this->params[ 'refund_transfer_type' ] ?? '',
'refund_array' => empty($this->params[ 'refund_array' ]) ? [] : json_decode($this->params[ 'refund_array' ], true),// {'order_goods_id1':{'refund_money':10}},
'refund_reason' => $this->params[ 'refund_reason' ] ?? '',
'refund_remark' => $this->params[ 'refund_remark' ] ?? '',
'operator' => $this->user_info,//操作人员,
];
$res = $order_refund_model->refund($data);
return $this->response($res);
}
/**
* 为维权列表
* @return false|string
*/
public function lists()
{
$page_index = $this->params[ 'page' ] ?? 1;
$search = $this->params[ 'search' ] ?? '';
$page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS;
$order_refund_model = new OrderRefundModel();
$condition = [
[ 'nop.site_id', '=', $this->site_id ],
[ 'no.store_id', '=', $this->store_id ]
];
//商品名称
if (!empty($search)) {
$condition[] = [ 'nop.sku_name|no.order_no', 'like', '%' . $search . '%' ];
}
$list = $order_refund_model->getRefundOrderGoodsPageList($condition, $page_index, $page_size, 'nop.refund_action_time desc');
return $this->response($list);
}
/**
* 详情
* @return false|string
*/
public function detail()
{
$token = $this->checkToken();
if ($token[ 'code' ] < 0) return $this->response($token);
$order_goods_id = $this->params[ 'order_goods_id' ] ?? 0;
$order_refund_model = new OrderRefundModel();
$detail = $order_refund_model->getRefundDetail($order_goods_id, $this->site_id, $this->store_id);
return $this->response($detail);
}
}