Merge branch 'develop' into feature/sku_crawl
This commit is contained in:
@@ -81,19 +81,22 @@ class StockOrdersController extends BaseController
|
||||
if (!isset($groupedFiles[$file['file_code']])) {
|
||||
$groupedFiles[$file['file_code']] = [];
|
||||
}
|
||||
$groupedFiles[$file['file_code']][] = $file['file_url'];
|
||||
$groupedFiles[$file['file_code']][] = [
|
||||
'url' => $file['file_url'],
|
||||
'original_name' => $file['original_name']
|
||||
];
|
||||
}
|
||||
|
||||
// 映射到对应字段
|
||||
foreach ($fileTypes as $field => $fileCode) {
|
||||
if (isset($groupedFiles[$fileCode])) {
|
||||
// 原始URL数组
|
||||
// 文件信息数组,包含url和original_name
|
||||
$data[$field] = $groupedFiles[$fileCode];
|
||||
|
||||
// 完整URL数组
|
||||
$fullUrls = [];
|
||||
foreach ($groupedFiles[$fileCode] as $url) {
|
||||
$fullUrls[] = (new \app\common\service\OssService)->generatePrivateUrl($url);
|
||||
foreach ($groupedFiles[$fileCode] as $fileInfo) {
|
||||
$fullUrls[] = (new \app\common\service\OssService)->generatePrivateUrl($fileInfo['url']);
|
||||
}
|
||||
$data[$field . '_url'] = $fullUrls;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\admin\service\SysConfigService;
|
||||
|
||||
class SysConfigController extends BaseController
|
||||
{
|
||||
use CrudControllerTrait;
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->service = new SysConfigService();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据格式化
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function showFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -118,6 +118,11 @@ class UserController extends BaseController
|
||||
$data['system_ids'][] = $system['id'];
|
||||
}
|
||||
}
|
||||
if ($data['reportToInfo']) {
|
||||
$data['report_to_name'] = $data['reportToInfo']['id'] == $data['id'] ? '/' : $data['reportToInfo']['name'];
|
||||
} else {
|
||||
$data['report_to_name'] = '-';
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\dashboard;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\model\FinPaymentApply;
|
||||
use app\common\model\FinReceipt;
|
||||
use app\common\model\SysCurrency;
|
||||
use support\Request;
|
||||
|
||||
class FinStatisticsController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 收款记录统计
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function statistics(Request $request)
|
||||
{
|
||||
try {
|
||||
$currency = SysCurrency::where('status',1)->get();
|
||||
$query = FinReceipt::where('payment_apply_id','>',0);
|
||||
|
||||
$result = [];
|
||||
//已认领数量
|
||||
$result['claimed_num'] = $query->count();
|
||||
//已认领金额
|
||||
// $result['claimed_amount'] = $query->sum('amount');
|
||||
$result['claimed_amount'] = array_values($this->receiptStatisticsSum($query, $currency)); //各币种的已认领金额
|
||||
$result['claimed_amount_sum'] =$this->amountSum($result['claimed_amount']); //已认领的人民币总金额
|
||||
|
||||
//未入账数量
|
||||
$query2 = FinReceipt::whereNull('received_at');
|
||||
$result['unreceived_num'] = $query2->count();
|
||||
//未入账金额
|
||||
// $result['unreceived_amount'] = $query2->sum('amount');
|
||||
$result['unreceived_amount'] = array_values($this->receiptStatisticsSum($query2, $currency)); //各币种的未入账金额
|
||||
$result['unreceived_amount_sum'] = $this->amountSum($result['unreceived_amount']); //未入账的已认领的人民币总金额
|
||||
|
||||
//今日入账
|
||||
$query6 = FinReceipt::where('received_at','>',strtotime(date("Y-m-d")));
|
||||
//今日入账数量
|
||||
$result['received_num'] = $query6->count();
|
||||
//未入账金额
|
||||
// $result['unreceived_amount'] = $query2->sum('amount');
|
||||
$result['received_amount'] = array_values($this->receiptStatisticsSum($query6, $currency)); //各币种的未入账金额
|
||||
$result['received_amount_sum'] = $this->amountSum($result['unreceived_amount']); //未入账的已认领的人民币总金额
|
||||
|
||||
|
||||
$query3 = FinReceipt::where('payment_apply_id',0);
|
||||
|
||||
//未认领数量
|
||||
$result['unclaimed_num'] = $query3->count();
|
||||
//未认领金额
|
||||
// $result['unclaimed_amount'] = $query3->sum('amount');
|
||||
$result['unclaimed_amount'] = $this->receiptStatisticsSum($query3, $currency); //各币种的未认领金额
|
||||
$result['unclaimed_amount_sum'] = $this->amountSum($result['unclaimed_amount']); //未认领的已认领的人民币总金额
|
||||
|
||||
//已超时未认领数量
|
||||
$query4 = $query3->where('created_at','<',time()-24*3600);
|
||||
$result['timeout'] = $query4->count();
|
||||
|
||||
//在途资金
|
||||
//1、没有认领的付款资金
|
||||
$query5 = FinPaymentApply::where('receipt_id', '=', 0);
|
||||
$unclaimed_payment_amount = $this->receiptStatisticsSum($query5, $currency);
|
||||
foreach ($unclaimed_payment_amount as $key => &$value) {
|
||||
$value['amount'] = $value['amount'] - $result['unclaimed_amount'][$key]['amount'];
|
||||
}
|
||||
$result['unclaimed_payment_num'] = $query5->count();
|
||||
$result['unclaimed_payment_amount'] = array_values($unclaimed_payment_amount);
|
||||
$result['unclaimed_payment_amount_sum'] = $this->amountSum($result['unclaimed_payment_amount']);
|
||||
//在途资金 = 没有认领的付款资金-未认领的收款资金
|
||||
$result['intransit_amount_sum'] = $result['unclaimed_payment_amount_sum'] - $result['unclaimed_amount_sum'];
|
||||
$intransit_amount_amount = [];
|
||||
//在途资金各币种明细
|
||||
foreach ($unclaimed_payment_amount as $key => $value) {
|
||||
$value['amount'] = $value['amount'] - $result['unclaimed_amount'][$key]['amount'];
|
||||
$intransit_amount_amount[] = $value;
|
||||
}
|
||||
$result['intransit_amount_amount'] = $intransit_amount_amount;
|
||||
//在途数量 = 没有认领的付款数量-未认领的收款数量
|
||||
$result['intransit_count'] = $result['unclaimed_payment_num'] - $result['unclaimed_num'];
|
||||
|
||||
//未认领金额重新组织索引
|
||||
$result['unclaimed_amount'] = array_values($result['unclaimed_amount']);
|
||||
return $this->success($result);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据不同条件查询收款金额
|
||||
* @param $query
|
||||
* @param $currency
|
||||
* @return array
|
||||
*/
|
||||
public function receiptStatisticsSum($query, $currency)
|
||||
{
|
||||
$amount = [];
|
||||
foreach ($currency as $k => $v) {
|
||||
$amount[$v->currency_code] = [
|
||||
'currency_code' => $v->currency_code,
|
||||
'exchange_rate' => $v->exchange_rate,
|
||||
'amount' => $query->where('currency_id',$v->id)->sum('amount'),
|
||||
];
|
||||
}
|
||||
return $amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 不同币种汇率换算之后求和
|
||||
* @param $query
|
||||
* @param $currency
|
||||
*/
|
||||
public function amountSum($amount)
|
||||
{
|
||||
$amountSum = 0;
|
||||
foreach ($amount as $v) {
|
||||
// 转换为整数(乘以100避免浮点数问题)
|
||||
$v['amount'] = (int) round($v['amount'] * 100);
|
||||
$v['exchange_rate'] = (int) round($v['exchange_rate'] * 10000); // 汇率保留4位小数
|
||||
$amountSum += $v['amount'] * $v['exchange_rate'];
|
||||
}
|
||||
|
||||
// 转换回金额(除以1000000,因为汇率乘了10000)
|
||||
$result = $amountSum / 1000000;
|
||||
|
||||
// 四舍五入到2位小数
|
||||
return round($amountSum, 2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
namespace app\admin\controller\dashboard;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use support\Db;
|
||||
use support\Request;
|
||||
|
||||
class OfficeClerkController extends BaseController
|
||||
{
|
||||
|
||||
protected $service;
|
||||
|
||||
public function __construct()
|
||||
{}
|
||||
|
||||
// 卡片
|
||||
public function card(Request $request)
|
||||
{
|
||||
$approved = Db::table('approval_records')
|
||||
->where('approver_id', $request->user->uid)
|
||||
->where('status', 'approved')
|
||||
->count('id');
|
||||
|
||||
$pending = Db::table('approval_records')
|
||||
->where('approver_id', $request->user->uid)
|
||||
->where('status', 'pending')
|
||||
->count('id');
|
||||
|
||||
$unclaimed = Db::table('fin_payment_apply')
|
||||
->where('doc_user_id', $request->user->uid)
|
||||
->where('receipt_id', 0)
|
||||
->count('id');
|
||||
|
||||
$claimed = Db::table('fin_payment_apply')
|
||||
->where('doc_user_id', $request->user->uid)
|
||||
->where('receipt_id', '>', 0)
|
||||
->count('id');
|
||||
|
||||
$twentyFourHoursAgo = time() - (24 * 3600);
|
||||
$timeout = Db::table('fin_payment_apply')
|
||||
->where('doc_user_id', $request->user->uid)
|
||||
->where('fin_payment_apply.submit_files', '')
|
||||
->where('receipt_id', '>', 0)
|
||||
->where('claimed_at', '<', $twentyFourHoursAgo)
|
||||
->count('id');
|
||||
|
||||
return $this->success([
|
||||
'approved' => $approved,
|
||||
'pending' => $pending,
|
||||
'unclaimed' => $unclaimed,
|
||||
'claimed' => $claimed,
|
||||
'timeout' => $timeout
|
||||
]);
|
||||
}
|
||||
|
||||
// 曲线
|
||||
public function curve(Request $request)
|
||||
{
|
||||
$groupId = Db::table('user_group_members as ugm')
|
||||
->join('user_group as ug', 'ugm.group_id', '=', 'ug.id')
|
||||
->where('ugm.user_id', $request->user->uid)
|
||||
->where('ugm.is_leader', 1)
|
||||
->where('ugm.status', 1)
|
||||
->where('ug.scenario_code', 'stock_orders')
|
||||
->where('ug.status', 1)
|
||||
->value('ug.id');
|
||||
$userIds = Db::table('user_group_members')
|
||||
->where('group_id', $groupId)
|
||||
->pluck('user_id');
|
||||
$list = Db::table('stock_orders')
|
||||
->join('user', 'stock_orders.salesperson_id', '=', 'user.id')
|
||||
->whereIn('stock_orders.salesperson_id', $userIds)
|
||||
->whereIn('stock_orders.approval_status', [0, 1, 2])
|
||||
->whereNull('stock_orders.deleted_at')
|
||||
->groupBy('stock_orders.salesperson_id', 'user.name')
|
||||
->selectRaw('user.name, count(*) as count')
|
||||
->pluck('count', 'name')
|
||||
->toArray();
|
||||
$optionType = [];
|
||||
$counts = [];
|
||||
foreach ($list as $key=>$val) {
|
||||
$optionType[] = $key;
|
||||
$counts[] = $val;
|
||||
}
|
||||
$arr = [
|
||||
"optionType" => $optionType,
|
||||
"counts" => $counts
|
||||
];
|
||||
return $this->success($arr);
|
||||
}
|
||||
|
||||
// 审批
|
||||
public function approval(Request $request)
|
||||
{
|
||||
$list = Db::table('approval_records as ar')
|
||||
->join('approval_instances as ai', 'ar.instance_id', '=', 'ai.id')
|
||||
->join('stock_orders as so', 'ai.biz_id', '=', 'so.id')
|
||||
->where('ar.approver_id', $request->user->uid)
|
||||
->where('ar.status', 'pending')
|
||||
->where('ai.flow_type', 'stock_orders')
|
||||
->where('ai.biz_type', 'stock_orders')
|
||||
->where('ai.status', 'processing')
|
||||
->whereNull('so.deleted_at')
|
||||
->select(
|
||||
'so.order_no',
|
||||
'ai.created_at as approval_created_at',
|
||||
'so.salesperson_snapshot as salesperson_name'
|
||||
)
|
||||
->get()
|
||||
->map(function($item) {
|
||||
return [
|
||||
'order_no' => $item->order_no,
|
||||
'approval_created_at' => date('Y-m-d H:i:s', strtotime($item->approval_created_at)), // 格式化时间
|
||||
'salesperson_name' => $item->salesperson_name
|
||||
];
|
||||
})
|
||||
->toArray();
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
// 认领
|
||||
public function claim(Request $request)
|
||||
{
|
||||
$type = $request->get('type');
|
||||
if ($type == 'unclaimed') {
|
||||
$list = Db::table('fin_payment_apply')
|
||||
->join('sys_currency', 'fin_payment_apply.currency_id', '=', 'sys_currency.id')
|
||||
->where('fin_payment_apply.doc_user_id', $request->user->uid)
|
||||
->where('fin_payment_apply.receipt_id', 0)
|
||||
->get([
|
||||
'fin_payment_apply.id',
|
||||
'fin_payment_apply.created_at',
|
||||
'fin_payment_apply.doc_user_id',
|
||||
'fin_payment_apply.payment_entity',
|
||||
'fin_payment_apply.payment_account',
|
||||
'fin_payment_apply.currency_id',
|
||||
'sys_currency.currency_name',
|
||||
'fin_payment_apply.amount',
|
||||
'fin_payment_apply.apply_no'
|
||||
]);
|
||||
foreach ($list as $key => &$val) {
|
||||
$val->created_at = date('Y-m-d H:i:s', $val->created_at);
|
||||
}
|
||||
unset($val);
|
||||
} else {
|
||||
$twentyFourHoursAgo = time() - (24 * 3600);
|
||||
$list = Db::table('fin_payment_apply')
|
||||
->join('user', 'fin_payment_apply.doc_user_id', '=', 'user.id')
|
||||
->join('sys_currency', 'fin_payment_apply.currency_id', '=', 'sys_currency.id')
|
||||
->where('fin_payment_apply.doc_user_id', $request->user->uid)
|
||||
->where('fin_payment_apply.submit_files', '')
|
||||
->where('fin_payment_apply.receipt_id', '>', 0)
|
||||
->where('fin_payment_apply.claimed_at', '<', $twentyFourHoursAgo)
|
||||
->get([
|
||||
'fin_payment_apply.id',
|
||||
'fin_payment_apply.created_at',
|
||||
'fin_payment_apply.doc_user_id',
|
||||
'user.name',
|
||||
'fin_payment_apply.payment_entity',
|
||||
'fin_payment_apply.payment_account',
|
||||
'fin_payment_apply.currency_id',
|
||||
'sys_currency.currency_name',
|
||||
'fin_payment_apply.amount',
|
||||
'fin_payment_apply.apply_no'
|
||||
]);
|
||||
|
||||
foreach ($list as $key => &$val) {
|
||||
$stockIds = Db::table('fin_payment_stock')
|
||||
->where('payment_apply_id', $val->id)
|
||||
->pluck('stock_id')
|
||||
->toArray();
|
||||
$val->order_no = Db::table('stock_orders')
|
||||
->whereIn('id', $stockIds)
|
||||
->pluck('order_no')
|
||||
->toArray();
|
||||
$val->created_at = date('Y-m-d H:i:s', $val->created_at);
|
||||
}
|
||||
unset($val);
|
||||
}
|
||||
return $this->success($list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use app\common\model\SysConfig;
|
||||
|
||||
class SysConfigLogic
|
||||
{
|
||||
use CrudLogicTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = SysConfig::class;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\service;
|
||||
|
||||
use app\admin\validate\SysConfigValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\SysConfig;
|
||||
use support\Redis;
|
||||
use support\Request;
|
||||
|
||||
class SysConfigService
|
||||
{
|
||||
|
||||
use CrudServiceTrait;
|
||||
|
||||
/**
|
||||
* 指定当前要操作的模型
|
||||
*/
|
||||
protected string $modelClass = SysConfig::class;
|
||||
|
||||
/**
|
||||
* 验证器
|
||||
*/
|
||||
protected $validator = SysConfigValidate::class;
|
||||
|
||||
/**
|
||||
* 获取验证器
|
||||
*/
|
||||
public function getValidator()
|
||||
{
|
||||
return new $this->validator;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建查询条件
|
||||
*/
|
||||
protected function buildQueryConfig(Request $request, string $scene = 'default'): array
|
||||
{
|
||||
$p = $request->all();
|
||||
|
||||
$config = [];
|
||||
$config['model'] = $this->modelClass;
|
||||
switch ($scene) {
|
||||
case 'index':
|
||||
// ====== ====== 排序 ====== ======
|
||||
$config['order']['id'] = 'desc';
|
||||
|
||||
// ====== ====== 筛选 ====== ======
|
||||
// 状态
|
||||
if (isset($p['status']) && in_array($p['status'], [0,1])) {
|
||||
$config['where']['status'] = $p['status'];
|
||||
}
|
||||
// 关键字
|
||||
if (isset($p['keyword']) && $p['keyword']) {
|
||||
$k = '%' . $p['keyword'] . '%';
|
||||
foreach (['config_key','config_value','description'] as $col) {
|
||||
$config['orWhere'][] = [$col, 'like', $k];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'show':
|
||||
$config['where']['id'] = $p['id'];
|
||||
//$config['where']['status'] = 1;
|
||||
break;
|
||||
case 'store':
|
||||
break;
|
||||
case 'update':
|
||||
$config['where']['id'] = $p['id'];
|
||||
break;
|
||||
case 'destroy':
|
||||
$config['where']['id'] = $p['id'];
|
||||
break;
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
|
||||
public function beforeServiceUpdate($data, Request $request)
|
||||
{
|
||||
Redis::del($data['config_key']);
|
||||
}
|
||||
}
|
||||
@@ -100,6 +100,8 @@ class UserService
|
||||
$config['with']['roles'][] = 'name';
|
||||
$config['with']['systems'][] = 'id';
|
||||
$config['with']['systems'][] = 'name';
|
||||
$config['with']['reportToInfo'][] = 'id';
|
||||
$config['with']['reportToInfo'][] = 'name';
|
||||
break;
|
||||
case 'show':
|
||||
$config['where']['id'] = $p['id'];
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class SysConfigValidate extends Validate
|
||||
{
|
||||
// 规则
|
||||
protected $rule = [
|
||||
|
||||
];
|
||||
|
||||
// 提示
|
||||
protected $message = [
|
||||
|
||||
];
|
||||
|
||||
// 场景
|
||||
protected $scene = [
|
||||
'store' => [
|
||||
|
||||
],
|
||||
|
||||
'update' => [
|
||||
|
||||
]
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user