96 lines
2.7 KiB
PHP
96 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace app\admin\logic\shop;
|
|
|
|
use app\common\basics\Logic;
|
|
use app\common\model\LocalStore;
|
|
use app\common\model\LocalStoreOrder;
|
|
use app\common\server\ExportExcelServer;
|
|
|
|
class LocalStoreLogic extends Logic
|
|
{
|
|
public static $STATE_ENUM = [1, 2];
|
|
private static $PAYMENT_TYPE = array(
|
|
1 => '对公银行账户'
|
|
);
|
|
|
|
public static function lists()
|
|
{
|
|
return array(
|
|
'lists' => LocalStore::with('info')->select()->toArray()
|
|
);
|
|
}
|
|
|
|
public static function get_data($id)
|
|
{
|
|
return LocalStore::where(['lstore_id' => $id])->find();
|
|
}
|
|
|
|
public static function update_state($id, $state)
|
|
{
|
|
return LocalStore::where(['lstore_id' => $id])->update(['store_state' => $state]);
|
|
}
|
|
|
|
// 获取未审核数据
|
|
public static function get_unaudited_data()
|
|
{
|
|
return LocalStore::where(['store_state' => 0])->count();
|
|
}
|
|
|
|
// 获取本地生活订单列表
|
|
public static function getOrderList($get)
|
|
{
|
|
$lists = LocalStoreOrder::order('id desc')->paginate([
|
|
'page' => $get['page'] ?? 1,
|
|
'list_rows' => $get['limit'] ?? 10,
|
|
'var_page' => 'page'
|
|
])->toArray();
|
|
|
|
foreach ($lists['data'] as &$v) {
|
|
$v['payment_type'] = self::$PAYMENT_TYPE[$v['payment_type']];
|
|
}
|
|
|
|
return ['count' => $lists['total'], 'lists' => $lists['data']];
|
|
}
|
|
|
|
// 导出数据
|
|
public static function exportOrderData()
|
|
{
|
|
try {
|
|
$lists = LocalStoreOrder::order('id desc')
|
|
->select()
|
|
->toArray();
|
|
|
|
foreach ($lists as &$v) {
|
|
$v['bank_card'] = $v['bank_card'] . ' ';
|
|
$v['large_number'] = $v['large_number'] . ' ';
|
|
$v['payment_type'] = self::$PAYMENT_TYPE[$v['payment_type']];
|
|
}
|
|
|
|
$excelFields = [
|
|
'payment_type' => '收款方类型',
|
|
'account_name' => '户名',
|
|
'bank_name' => '银行名称',
|
|
'bank_card' => '银行卡号',
|
|
'large_number' => '大额行号',
|
|
'separate_account' => '分账金额',
|
|
'tips' => '交易附言',
|
|
'notes' => '备注'
|
|
];
|
|
|
|
$export = new ExportExcelServer();
|
|
$export->setFileName('本地生活订单列表');
|
|
$result = $export->createExcel($excelFields, $lists);
|
|
|
|
return ['url' => $result];
|
|
} catch (\Exception $e) {
|
|
self::$error = $e->getMessage();
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static function getPayImage($lstore_id)
|
|
{
|
|
return LocalStore::where('lstore_id', $lstore_id)->field('pay_image')->find()->toArray();
|
|
}
|
|
} |