feat: 修改了StoreProductLists.php, LoginLogic.php, OperationLogMiddleware.php, IndexController.php, OrderEnum.php, CommissionLogic.php, StoreFinanceFlowLogic.php, StoreOrderController.php, middleware.php等文件

This commit is contained in:
mkm 2024-06-27 13:46:42 +08:00
parent 8a86ee976a
commit b812b36e3e
9 changed files with 97 additions and 66 deletions

View File

@ -58,7 +58,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
}
}
return StoreProduct::where($this->searchWhere)
->field(['id', 'image', 'store_name','swap', 'cate_id','batch', 'price','vip_price','sales', 'stock', 'is_show', 'unit', 'cost','rose','purchase','bar_code','manufacturer_information'])
->field(['id', 'image', 'store_name','swap','product_type','cate_id','batch', 'price','vip_price','sales', 'stock', 'is_show', 'unit', 'cost','rose','purchase','bar_code','manufacturer_information'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function ($item) {

View File

@ -19,7 +19,7 @@ use app\common\model\auth\Admin;
use app\admin\service\AdminTokenService;
use app\common\model\auth\AdminRole;
use app\common\service\FileService;
use app\MyBusinessException;
use Exception;
use think\facade\Db;
use Webman\Config;
@ -44,6 +44,9 @@ class LoginLogic extends BaseLogic
{
$time = time();
$admin = Admin::where('account', '=', $params['account'])->find();
if(!$admin) {
throw new Exception('账号不存在');
}
//用户表登录信息更新
$admin->login_time = $time;
$admin->login_ip = request()->getLocalIp();

View File

@ -0,0 +1,71 @@
<?php
namespace app\admin\middleware;
use Exception;
use ReflectionClass;
use Webman\Http\Request;
use Webman\Http\Response;
use Webman\MiddlewareInterface;
class OperationLogMiddleware implements MiddlewareInterface
{
public function process(Request $request, callable $handler): Response
{
//需要登录的接口,无效访问时不记录
if (!$request->controllerObject->isNotNeedLogin() && empty($request->adminInfo)) {
return $handler($request);
}
//不记录日志操作
if (strtolower(str_replace('.', '\\', $request->controller)) === 'setting\system\log') {
return $handler($request);
}
//获取操作注解
$notes = '';
try {
$re = new ReflectionClass($request->controllerObject);
$doc = $re->getMethod($request->action)->getDocComment();
if (empty($doc)) {
throw new Exception('请给控制器方法注释');
}
preg_match('/\s(\w+)/u', $re->getMethod($request->action)->getDocComment(), $values);
$notes = $values[0];
} catch (Exception $e) {
$notes = $notes ?: '无法获取操作名称,请给控制器方法注释';
}
$params = $request->all();
//过滤密码参数
if (isset($params['password'])) {
$params['password'] = "******";
}
//过滤密钥参数
if(isset($params['app_secret'])){
$params['app_secret'] = "******";
}
//导出数据操作进行记录
if (isset($params['export']) && $params['export'] == 2) {
$notes .= '-数据导出';
}
//记录日志
$systemLog = new \app\common\model\OperationLog();
$systemLog->admin_id = $request->adminInfo['admin_id'] ?? 0;
$systemLog->admin_name = $request->adminInfo['name'] ?? '';
$systemLog->action = $notes;
$systemLog->account = $request->adminInfo['account'] ?? '';
$systemLog->url = $request->url(true);
$systemLog->type = $request->post()?'POST':'GET';
$systemLog->params = json_encode($params, true);
$systemLog->ip = $request->getRemoteIp();
// $systemLog->result = $response->getContent();
$systemLog->save();
return $handler($request);
}
}

View File

@ -32,53 +32,7 @@ class IndexController extends BaseApiController
public function index()
{
$config = [
// HTTP 请求的超时时间(秒)
'timeout' => 5.0,
// 默认发送配置
'default' => [
// 网关调用策略,默认:顺序调用
'strategy' => \Overtrue\EasySms\Strategies\OrderStrategy::class,
// 默认可用的发送网关
'gateways' => [
'yunpian', 'aliyun',
],
],
// 可用的网关配置
'gateways' => [
'errorlog' => [
'file' => runtime_path() . '/logs/' . date('Ymd') . '/easy-sms.log',
],
'aliyun' => [
'access_key_id' => 'LTAI5t7mhH3ij2cNWs1zhPmv',
'access_key_secret' => 'gqo2wMpvi8h5bDBmCpMje6BaiXvcPu',
'sign_name' => '里海科技',
],
//...
],
];
try {
$easySms = new EasySms($config);
$template = getenv('SMS_TEMPLATE');
$a = $easySms->send(18715753257, [
'content' => '您的验证码为: 6379',
'template' => $template,
'data' => [
'code' => 6379
],
]);
// d($a);
}catch (NoGatewayAvailableException $exception){
throw new \Exception($exception->getExceptions());
}
d($a,getenv('SMS_TEMPLATE'));
return json([1]);
$all_where['paid'] = 1;
d(OrderLogic::dayPayPrice($all_where,date('Y-m-d',time())));

View File

@ -46,6 +46,7 @@ class OrderEnum
const CASHIER_FACE_PAY = 17;//现金收银
const PURCHASE_FUNDS = 18;//采购款收银
const USER_ORDER_REFUND = 19;//订单返还
const PAY_BACK =-1;
@ -165,11 +166,7 @@ class OrderEnum
self::ORDER_MARGIN=>'保证金',
self::VIP_ORDER_OBTAINS=>'会员',
self::OTHER_ORDER_OBTAINS=>'其他',
self::USER_ORDER_REFUND=>'订单返还'
];
if ($value === true) {

View File

@ -14,7 +14,6 @@ class CommissionLogic extends BaseLogic
*/
public static function setVillage($order, $transaction_id)
{
self::user($order, 0.05, $transaction_id,$order['uid'],14);
$village_uid=0;
$brigade_uid=0;
if ($order['uid'] > 0) {
@ -36,7 +35,8 @@ class CommissionLogic extends BaseLogic
}
}
}
self::user($order, 0.03, $transaction_id,$village_uid,12);//会员
self::user($order, 0.05, $transaction_id,$village_uid,14);//村长
self::user($order, 0.03, $transaction_id,0,12);//会员、厨师
self::user($order, 0.01, $transaction_id,$brigade_uid,15);//队长
self::user($order, 0.01, $transaction_id,0,16);//其他
}
@ -45,7 +45,6 @@ class CommissionLogic extends BaseLogic
*/
public static function setBrigade($order, $transaction_id)
{
self::user($order, 0.05, $transaction_id,$order['uid'],14);
$village_uid=0;
$brigade_uid=0;
if ($order['uid'] > 0) {
@ -67,8 +66,9 @@ class CommissionLogic extends BaseLogic
}
}
}
self::user($order, 0.03, $transaction_id,$village_uid,12);//会员
self::user($order, 0.01, $transaction_id,$brigade_uid,15);//队长
self::user($order, 0.05, $transaction_id,$brigade_uid,14);//队长
self::user($order, 0.03, $transaction_id,0,12);////会员、厨师
self::user($order, 0.01, $transaction_id,$village_uid,15);//村长
self::user($order, 0.01, $transaction_id,0,16);//其他
}
/**
@ -76,7 +76,6 @@ class CommissionLogic extends BaseLogic
*/
public static function setCook($order, $transaction_id)
{
self::user($order, 0.07, $transaction_id,$order['uid'],12);//改到带返还金中
$village_uid=0;
$brigade_uid=0;
if ($order['uid'] > 0) {
@ -98,6 +97,7 @@ class CommissionLogic extends BaseLogic
}
}
}
self::user($order, 0.07, $transaction_id,0,12);//会员、厨师
self::user($order, 0.01, $transaction_id,$village_uid,14);//村长
self::user($order, 0.01, $transaction_id,$brigade_uid,15);//队长
self::user($order, 0.01, $transaction_id,0,16);//其他

View File

@ -5,6 +5,7 @@ namespace app\common\logic;
use app\common\enum\OrderEnum;
use app\common\enum\PayEnum;
use app\common\model\store_finance_flow\StoreFinanceFlow;
use app\common\model\user\User;
class StoreFinanceFlowLogic extends BaseLogic
{
@ -126,4 +127,13 @@ class StoreFinanceFlowLogic extends BaseLogic
$model->save();
}
/**
* 核销后更新余额
*/
public function updateStatusUser($id,$uid,$money){
StoreFinanceFlow::where('id', $id)->update(['status' => 1]);
User::where('id',$uid)->inc('now_money',$money)->update();
}
}

View File

@ -358,12 +358,6 @@ class StoreOrderController extends BaseAdminController
*/
public function rechange_amount()
{
// $order = UserRecharge::where('order_id','CZ1719052252643357')->find();
// $order['pay_price'] = $order['price'];
// d(1);
// PayNotifyLogic::handle('recharge', $order['order_id'], $order);
// d(1);
$pay_type = $this->request->post('pay_type');
$auth_code = $this->request->post('auth_code'); //微信支付条码
if ($auth_code == '' && $pay_type != PayEnum::CASH_PAY) {

View File

@ -23,6 +23,8 @@ return [
app\admin\middleware\LoginMiddleware::class,
// 权限认证
app\admin\middleware\AuthMiddleware::class,
// 操作日志记录
app\admin\middleware\OperationLogMiddleware::class,
],
'api' => [
// 跨域中间件