提交 b2dc8b91 authored 作者: 窦斌's avatar 窦斌
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use DB;
class DeductionFee extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'DeductionFee';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command DeductionFee';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$find_data = DB::table('admin')
->groupBy('company_id')
->get();
foreach ($find_data as $key => $value) {
$find_balance = DB::table('admin_recharge')
->where('adre_company_id', $value['company_id'])
->first();
if (empty($find_balance)) {
$add_data['adre_company_id'] = $value['company_id'];
$add_data['adre_banlance'] = -100;
$add_data['adre_first_monthFee'] = date('Y-m-d H:i:s');
$add_data['adre_next_monthFee'] = date('Y-m-d H:i:s', strtotime('+1 month'));
$add_res = DB::table('admin_recharge')->insertGetId($add_data);
} else {
if (empty($find_balance['adre_next_monthFee'])) {
$update['adre_banlance'] = $find_balance['adre_banlance'] - 100;
$update['adre_first_monthFee'] = date('Y-m-d H:i:s');
$update['adre_next_monthFee'] = date('Y-m-d H:i:s', strtotime('+1 month'));
$update_res = DB::table('admin_recharge')
->where('adre_id', $find_balance['adre_id'])
->update($update);
} else {
if (time() >= strtotime($find_balance['adre_next_monthFee'])) {
$update['adre_banlance'] = $find_balance['adre_banlance'] - 100;
$update['adre_next_monthFee'] = date('Y-m-d H:i:s', strtotime($find_balance['adre_next_monthFee'],'+1 month'));
$update_res = DB::table('admin_recharge')
->where('adre_id', $find_balance['adre_id'])
->update($update);
}
}
}
$order_number = 'YF'.date('YmdHis').rand(1000,9999);
$recharge_order['reo_adm_id'] = $value['id'];
$recharge_order['reo_company_id'] = $value['company_id'];
$recharge_order['reo_order_number'] = $order_number;
$recharge_order['reo_price'] = -100;
$recharge_order['reo_pay_state'] = 1;
$recharge_order['reo_state'] = 1;
$recharge_order['reo_type'] = 3;//扣月费
if ($value['admin_groupnew'] == 2) {
$recharge_order['reo_client_type'] = 1;
} elseif ($value['admin_groupnew'] == 3) {
$recharge_order['reo_client_type'] = 2;
} else {
$recharge_order['reo_client_type'] = 3;
}
$recharge_order['reo_pay_way'] = 1;
$recharge_order['reo_create_time'] = date('Y-m-d H:i:s');
$recharge_order['reo_pay_time'] = date('Y-m-d H:i:s');
$add_res = DB::table('recharge_order')->insertGetId($recharge_order);
}
}
}
......@@ -18,6 +18,7 @@ class Kernel extends ConsoleKernel
Commands\GetJdSelfOrder::class,
Commands\GetJdSelfRefund::class,
Commands\GetJdSelfShhOrder::class
Commands\DeductionFee::class
];
/**
......@@ -35,6 +36,7 @@ class Kernel extends ConsoleKernel
$schedule->command('getJdSelfOrder')->everyFiveMinutes();//每五分钟执行一次
$schedule->command('getJdSelfRefund')->everyFiveMinutes();//每五分钟执行一次
$schedule->command('GetJdSelfShhOrder')->everyFiveMinutes();//每五分钟执行一次
$schedule->command('DeductionFee')->everyFiveMinutes();//每五分钟执行一次
}
/**
......
......@@ -179,7 +179,10 @@ class CommonController extends BaseController
}
if($request->get('session_token')['admin_groupnew'] != 7) {//管理员默认展示全部平台
$session = Request()->get('session_token');//用户信息
$brand = CommonService::arrayFilterFieldValue($brand,[['company_id'=>$session['company_id']]]);
$brand_id = Company::where('com_id',$session['company_id'])->value('com_brand');
// $brand = CommonService::arrayFilterFieldValue($brand,[['company_id'=>$session['company_id']]]);
$brand = CommonService::arrayFilterFieldValue($brand,[['id'=>explode(',',$brand_id)]]);
}
if($brand){
return $this->success('操作成功', $brand);
......@@ -268,7 +271,22 @@ class CommonController extends BaseController
}
$session = $request->get('session_token');
if ($session['admin_groupnew'] != 7){//管理员可以看全部
$where['company_id_searchin'] = $session['com_parent_id'];
$brand_id = Company::where('com_id',$session['company_id'])->value('com_brand');
$where['gs_bid_searchin'] = $brand_id;
}
if ($request->filled('function')) {
if ($request->input('function') == 'supplierPrice') {
$gh_price = DB::table('gh_price')
->where('ser_id', $request->input('ser_id'))
->where('company_id', $request->input('company_id'))
->where('type', $request->input('type'))
->select('goods_id')
->get()->toarray();
$goods_id = array_column($gh_price, 'goods_id');
if (!empty($goods_id)) {
$where['pg_id_notin'] = $goods_id;
}
}
}
$list = GoodsService::getGoodsBy($where);
if($list){
......@@ -370,7 +388,7 @@ class CommonController extends BaseController
$com_parent_id = array_filter($com_parent_id, function($value) {
return $value != 1; // 这里可以修改条件来移除不同的值
});
// 重置数组键名
// 重置数组键名
$com_parent_id = array_values($com_parent_id);
}
$parameter['company_id_searchin'] = $com_parent_id;
......@@ -384,7 +402,6 @@ class CommonController extends BaseController
unset($parameter['token']);
unset($parameter['Login_id']);
unset($parameter['Pri_id']);
// $parameter['enable'] = 1;
switch ( $type )
{
case 1:
......@@ -1264,4 +1281,48 @@ class CommonController extends BaseController
}
/**
* 获取公司
* @authors ldj
* @email 909490343@qq.com
* @date 2024-09-20
* @param Request $request [description]
* @return [type] [description]
*/
public function getCompany(Request $request){
$session = $request->get('session_token');
$data = new Company();
$data = $data->where('com_type', 1)
->where('com_id', '!=', 1)
->where(function($query) use($request) {
if (!empty($request['com_name'] )) {
$query->where('com_name',$request['com_name']);
}
})
->select('com_id','com_name')
->get()->toarray();
return $this->success('获取成功', $data);
}
/**
* 查询经销商
* @authors ldj
* @email 909490343@qq.com
* @date 2024-09-20
* @param Request $request [description]
* @return [type] [description]
*/
public function getDistributor ( Request $request )
{
$list = DB::table('admin')
->where('admin_groupnew', 3)
->select('id', 'admin_acc', 'admin_name', 'company_name')
->get()->toarray();
if($list){
return $this->success('操作成功', $list);
}else{
return $this->error('无数据', ErrorInc::DATA_EMPTY, []);
}
}
}
......@@ -79,8 +79,8 @@ class CompanyController extends BaseController
* @Time: 14:24
*/
public function addCom(Request $request){
$parameter = $request->only('com_name','com_phone','com_start_time','com_end_time');
$checkKey = CommonService::checkKey(['com_name','com_phone','com_start_time','com_end_time'],$parameter);
$parameter = $request->only('com_name','com_phone','com_start_time','com_end_time', 'com_brand');
$checkKey = CommonService::checkKey(['com_name','com_phone','com_start_time','com_end_time','com_brand'],$parameter);
if($checkKey['code']!=1){
return $this->error('参数'.$checkKey['data'].'未填写,或值为空', ErrorInc::INVALID_PARAM, []);exit;
}
......@@ -95,6 +95,7 @@ class CompanyController extends BaseController
$dataArr['com_start_time'] = $parameter['com_start_time'];
$dataArr['com_end_time'] = $parameter['com_end_time'];
$dataArr['com_name'] = $parameter['com_name'];
$dataArr['com_brand'] = $parameter['com_brand'];
$dataArr['com_parent_id'] = $request->get('session_token')['com_parent_id'];
$res = Company::insert($dataArr);
......@@ -116,8 +117,8 @@ class CompanyController extends BaseController
* @Time: 14:31
*/
public function editCom(Request $request){
$parameter = $request->only('id','com_name','com_phone','com_start_time','com_end_time');
$checkKey = CommonService::checkKey(['id','com_name','com_phone','com_start_time','com_end_time'],$parameter);
$parameter = $request->only('id','com_name','com_phone','com_start_time','com_end_time','com_brand');
$checkKey = CommonService::checkKey(['id','com_name','com_phone','com_start_time','com_end_time','com_brand'],$parameter);
if($checkKey['code']!=1){
return $this->error('参数'.$checkKey['data'].'未填写,或值为空', ErrorInc::INVALID_PARAM, []);exit;
}
......@@ -130,6 +131,7 @@ class CompanyController extends BaseController
$dataArr['com_phone'] = $request->input('com_phone');
$dataArr['com_start_time'] = $request->input('com_start_time');
$dataArr['com_end_time'] = $request->input('com_end_time');
$dataArr['com_brand'] = $request->input('com_brand');
$dataArr['com_name'] = $com_name;
$dataArr['com_update_id'] = $request->get('session_token')['id'];
$dataArr['com_update_time'] = date("Y-m-d H:i:s");
......
......@@ -112,8 +112,9 @@ class PayController extends BaseController
}elseif($v['reo_type'] == 2){
$list[$k]['reo_type_name'] = "扣费";
$list[$k]['reo_pay_way_name'] = "派单扣费";
} else {
$list[$k]['reo_type_name'] = "--";
} elseif($v['reo_type'] == 3) {
$list[$k]['reo_type_name'] = "扣费";
$list[$k]['reo_pay_way_name'] = "月费扣费";
}
if ($v['reo_pay_state'] == 1){
......
......@@ -96,9 +96,10 @@ public function index(Request $request)
//根据权限格式化页面button
$token = $request->input('token');
$priId = $request->input('Pri_id');
$data = $this->dataService->formatPageContent($token, $priId, $data);
$data = $this->dataService->formatPageContent($token, $priId, $data, $session, $request);
}
$data['service_type'][] = ['type'=>1,'name'=>'自营'];
$data['service_type'][] = ['type'=>2,'name'=>'平台'];
if (!empty($data['list'])) {
return $this->success('获取成功', $data);
......@@ -131,32 +132,78 @@ public function index(Request $request)
* {"ErrorCode":1,"ErrorMessage":"","Data":[]}
*
*/
// public function store(Request $request)
// {
// $input = $request->only('goods_id', 'ser_id', 'supply_price', 'goods_name','remark');
// if ($this->validateRules) {
// $validate = validator()->make($input, $this->validateRules['create_rules'], $this->validateRules['messages'], $this->validateRules['attributes']);
// if ($validate->fails()) {
// $error = CommonService::validatorToString($validate);
// return $this->error($error, ErrorInc::INVALID_PARAM);
// }
// }
// $input['company_id'] = $request->get('session_token')['company_id'];
// //新增时直接查询是不是已经存在该服务商的指定商品签约价
// $exist = SupplierPriceService::checkExistPrice($input['ser_id'], $input['goods_id'],$input['company_id']);
// if ($exist) {
// return $this->error('选择的服务商已拥有该商品的供货价', ErrorInc::REPEAT_SUBMIT);
// }
// $data = $this->_setStore($input);
// $data['company_id'] = $request->get('session_token')['company_id'];
// $res = $this->dataService->create($data);
// if ($res) {
// $this->_afterStore($data);
// return $this->success('新增成功');
// } else {
// return $this->error('新增失败', ErrorInc::MYSQL_FAILED);
// }
// }
/**
* 新增供货价
* @authors ldj
* @email 909490343@qq.com
* @date 2024-09-20
* @param Request $request [description]
* @return [type] [description]
*/
public function store(Request $request)
{
$input = $request->only('goods_id', 'ser_id', 'supply_price', 'goods_name','remark');
$session = $request->get('session_token');
if ($this->validateRules) {
$validate = validator()->make($input, $this->validateRules['create_rules'], $this->validateRules['messages'], $this->validateRules['attributes']);
if ($validate->fails()) {
$error = CommonService::validatorToString($validate);
return $this->error($error, ErrorInc::INVALID_PARAM);
}
if ($session['admin_groupnew'] != 7) {
$request['company_id'] = $session['company_id'];
}
$input['company_id'] = $request->get('session_token')['company_id'];
//新增时直接查询是不是已经存在该服务商的指定商品签约价
$exist = SupplierPriceService::checkExistPrice($input['ser_id'], $input['goods_id'],$input['company_id']);
if ($exist) {
return $this->error('选择的服务商已拥有该商品的供货价', ErrorInc::REPEAT_SUBMIT);
if (empty($request['goods_data'])) {
return $this->error('请选择商品', ErrorInc::REPEAT_SUBMIT);
}
$data = $this->_setStore($input);
$data['company_id'] = $request->get('session_token')['company_id'];
$res = $this->dataService->create($data);
if ($res) {
$this->_afterStore($data);
return $this->success('新增成功');
} else {
return $this->error('新增失败', ErrorInc::MYSQL_FAILED);
DB::beginTransaction();
foreach ($request['goods_data'] as $key => $value) {
$poss['ser_id'] = $request['ser_id'];
$poss['goods_id'] = $value['goods_id'];
$poss['goods_name'] = $value['goods_name'];
$poss['company_id'] = $request['company_id'];
$poss['supply_price'] = $value['supply_price'];
$poss['remark'] = $value['remark'];
$poss['type'] = $request['type'];
//新增时直接查询是不是已经存在该服务商的指定商品签约价
$exist = SupplierPriceService::checkExistPrice($poss['ser_id'], $poss['goods_id'],$poss['company_id']);
if ($exist) {
return $this->error('选择的服务商已拥有该商品的供货价', ErrorInc::REPEAT_SUBMIT);
}
$data = $this->_setStore($poss);
$res = $this->dataService->create($data);
if ($res) {
$this->_afterStore($data);
} else {
DB::rollback();
return $this->error('新增失败', ErrorInc::MYSQL_FAILED);
}
}
DB::commit();
return $this->success('新增成功');
}
/**
......@@ -175,6 +222,8 @@ public function index(Request $request)
$arr['remarks'] = $input['remark'];
}
$arr['gh_gname'] = $input['goods_name'];
$arr['company_id'] = $input['company_id'];
$arr['type'] = $input['type'];
return $arr;
}
......
......@@ -72,8 +72,10 @@ class SupplierPriceService extends Service
$time = date('Y-m-d H:i:s', strtotime($param['end_time']));
$Db = $Db->where("create_time", '<=', $time);
}
if ($session['admin_groupnew'] != 7){//管理员可以看全部 && $session['admin_groupnew'] != 8
if (!empty($param['type'])) { //结束时间
$Db = $Db->where("gh_price.type", $param['type']);
}
if ($session['admin_groupnew'] != 7){//管理员可以看全部 && $session['admin_groupnew'] != 8
$Db = $Db->where("gh_price.company_id",$session['company_id']);
}
......@@ -96,12 +98,16 @@ class SupplierPriceService extends Service
return ['list' => $list, 'totalPage' => $totalPage, 'count' => $count, 'page' => $page, 'page_size' => $pageSize];
}
public function formatPageContent($token, $priID, $data)
public function formatPageContent($token, $priID, $data, $session, $request)
{
$list = $data['list'];
//按钮-添加
$all_button = BmmcService::wherebutton($token, $priID);
$addPt = BmmcService::getTopButton('addGhprice', '', $all_button);
if (($request['type'] == 2 && $session['admin_groupnew'] == 7) || ($request['type'] == 1 && $session['admin_groupnew'] != 7)) {
$addPt = BmmcService::getTopButton('addGhprice', '', $all_button);
} else {
$addPt = BmmcService::getTopButton('', '', $all_button);
}
$data['button_top'] = $addPt['button_top'] ?? [];//顶部按钮
$data['button_search'] = $addPt['button_search'] ?? [];//搜索栏按钮
......@@ -116,8 +122,12 @@ class SupplierPriceService extends Service
} else {
$list[$kl]['type'] = $vl['pg_series'] . '-' . $vl['version'];
}
$button = BmmcService::getListButton(['editGhprice, delGhPrice'], $all_button);//编辑,删除按钮
if (($request['type'] == 2 && $session['admin_groupnew'] == 7) || $request['type'] == 1) {
$button = BmmcService::getListButton(['editGhprice, delGhPrice'], $all_button);//编辑,删除按钮
} else {
$button = BmmcService::getListButton([], $all_button);//编辑,删除按钮
}
// $button = BmmcService::getListButton(['editGhprice, delGhPrice'], $all_button);//编辑,删除按钮
$list[$kl]['button_one'] = $button['button_one'] ?? [];
$list[$kl]['button_two'] = $button['button_two'] ?? [];
$list[$kl]['button_three'] = $button['button_three'] ?? [];
......
......@@ -288,6 +288,8 @@ Route::group(
Route::post('getBrand', 'CommonController@getBrand'); //获取商品品牌
Route::post('getPt', 'CommonController@getPt'); //获取平台
Route::post('getAdmins', 'CommonController@getAdmins'); //获取用户信息
Route::post('getCompany', 'CommonController@getCompany'); //获取公司-门店运营商
Route::post('getDistributor', 'CommonController@getDistributor'); //获取经销商
Route::post('getGoods', 'CommonController@getGoods'); //获取用户信息
Route::post('getAdminDetail', 'CommonController@getAdminDetail'); //获取用户信息详情
Route::post('addRemarks', 'CommonController@addRemarks'); //添加备注
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论