Commit 427fcb6b by mushishixian

temp

parent bc8a68b1
......@@ -93,4 +93,5 @@ PERM_ID=25
PERM_GOURL=http://perm.liexin.net
ADMIN_GROUP=10000,20000
MENU_ID=16
MENU_URL=http://data.liexin.net/api/config/
\ No newline at end of file
MENU_URL=http://data.liexin.net/api/config/
FOOTSTONE_URL=http://footstone.liexin.net
\ No newline at end of file
......@@ -3,10 +3,12 @@
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Services\SkuService;
use App\Http\Services\SupplierContactService;
use App\Http\Services\SupplierStatisticsService;
use App\Http\Transformers\SupplierContactTransformer;
use App\Http\Validators\SupplierContactValidator;
use App\Model\RedisModel;
use App\Model\SupplierContactModel;
use Illuminate\Http\Request;
......@@ -20,7 +22,51 @@ class SkuApiController extends Controller
public function GetSkuList($request)
{
$skuService = new SkuService();
$data = $skuService->getSkuList();
$this->response(0, 'ok', $data['list'], $data['total']);
}
$this->response(0, 'ok', []);
public function UpdateSkuStatus($request)
{
$map = $request->input('goods_id');
if (empty($map) || !is_array($map)) {
$this->response(-1, '请选择要操作的SKU', '0');
}
$status = $request->input('status');
$Redis = new RedisModel();
$updateData['update_time'] = time();
switch ($status) {
case 'offshelf':
$updateData['goods_status'] = 3;
$msg = '成功下架';
break;
case 'passed':
$msg = '成功上架';
$updateData['goods_status'] = 1;
break;
case 'negative':
$updateData['goods_status'] = 2;
$msg = '审核不通过';
break;
}
$skuService = new SkuService();
$i = 0;
foreach ($map as $k => $v) {
$dbinfo = resolve($v);
$list = DB::connection($dbinfo['db'])->table($dbinfo['table'])->where('goods_id', $v)->update($updateData);
if ($list) {
$info = json_decode($Redis->hget('sku', $v), true);
$info['goods_status'] = $updateData['goods_status'];
$info['goods_id'] = $v;
$info['update_time'] = $updateData['update_time'];
$skuService->HandleSku($info);
$i++;
}
}
//实时推送ES
$skuIds = implode(',', $map);
$skuService->PushSkuUpdate($skuIds);
$this->response(0, '操作成功');
}
}
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Services\SupplierStatisticsService;
use Illuminate\Http\Request;
//通用API,比如获取品牌列表,分类列表等
class SkuStatisticsApiController extends Controller
{
public function Entrance(Request $request, $id)
{
$this->$id($request, $id);
}
public function GetSupplierStatistics($request)
{
$service = new SupplierStatisticsService();
$statistics = $service->getSupplierListStatistics();
$data = [];
foreach ($statistics as $name => $count) {
$data[$name] = array_get(config('fixed.CompassMenuMap'), $name) . "(${count})";
}
$this->response(0, 'ok', $data);
}
}
......@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use App\Http\Controllers\Filter\LogFilter;
use App\Http\Controllers\Filter\SupplierLogFilter;
use App\Http\Services\LogService;
use App\Model\IntracodeModel;
use App\Model\LogModel;
use App\Model\SupplierLogModel;
use Illuminate\Http\Request;
......@@ -38,7 +39,8 @@ class SkuController extends Controller
public function SkuList($request)
{
$intracodeModel = new IntracodeModel();
$this->data['userCodes'] = $intracodeModel->getSampleEncode();
return $this->view('供应商日志');
}
......
<?php
namespace App\Http\Services;
//价格相关服务
use App\Model\RedisModel;
use Illuminate\Support\Facades\DB;
//用于判断是否已经查看的服务
class PriceService
{
//获取最小阶梯的价格
public function getMoqPrice($price)
{
$price = is_array($price) ? $price : json_decode($price, true);
if (count($price) >=1){
return $price[0];
}
return [];
}
}
\ No newline at end of file
<?php
namespace App\Http\Services;
use App\Model\IntracodeModel;
use App\Model\RedisModel;
use Illuminate\Support\Facades\DB;
class SkuService
{
//获取供应商列表需要统计的信息
public function getSkuList()
{
$data['data']['goods_id'] = [];
$map = request()->all();
//只获取专卖的数据
$map['supplier_id'] = 17;
if ((!empty($map['create_time']))) {
$times = explode('~', $map['create_time']);
$startTime = strtotime($times[0]) ?: 1420041600;
$endTime = strtotime($times[1]) ?: time();
$map['create_time/range'] = $startTime . ',' . $endTime;
}
if ((!empty($map['update_time']))) {
$times = explode('~', $map['update_time']);
$startTime = strtotime($times[0]) ?: 1420041600;
$endTime = strtotime($times[1]) ?: time();
$map['update_time/range'] = $startTime . ',' . $endTime;
}
foreach ($map as $k => $v) {
if (empty($v) and $v != '0') {
unset($map[$k]);
}
}
$url = env('ES_SKU_URL', '');
$map['p'] = $map['page'];
if (!empty($map['p']) && $map['p'] > 1000) {
$map['p'] = rand(5, 1000);
}
$map['show_status'] = 1;
$return = curl($url, $map, 1);
$data = json_decode($return, true);
$list = [];
if (isset($data['error_code']) && $data['error_code'] == 0) {
$redis = new RedisModel;
//处理供应商
foreach ($data['data']['goods_id'] as $k => $goodsId) {
$uploadItemService = new SkuUploadItemService();
$auditData = $uploadItemService->getSkuAuditData($data['data']['goods_id']);
if (empty($goodsId) || $goodsId == 0) {
continue;
}
$sku = json_decode($redis->hget('sku', $goodsId), true);
//赋值
$sku['goods_id'] = $goodsId;
$sku['update_time'] = date('Y-m-d H:i:s', $sku['update_time']);
$sku['status_name'] = Config('field.GoodsStatus')[$sku['goods_status']];
if (!empty($auditData[$goodsId])) {
$sku['audit_time'] = date('Y-m-d H:i:s', $auditData[$goodsId]['audit_time']);
$sku['audit_user'] = $auditData[$goodsId]['audit_name'];
}
//添加sku是否过期
$sku['is_expire'] = $data['data']['status'][$goodsId] && $data['data']['status'][$goodsId] > 0 ? 0 : 1;
$spu = json_decode($redis->hget('spu', $sku['spu_id']), true);
//型号处理
if (empty($sku['goods_name'])) {
$sku['goods_name'] = $spu['spu_name'];
}
$sku['encap'] = $spu['encap'];
if (array_get($auditData, $sku['goods_id'])) {
$sku['audit_time'] = $auditData[$sku['goods_id']]["audit_time"];
$sku['audit_user'] = $auditData[$sku['goods_id']]["audit_user"];
}
//制造商处理
if (empty($sku['brand_name'])) {
$brand = $redis->hget('brand_id', $spu['brand_id']);
if ($brand) {
$sku['brand_name'] = $brand;
} else {
$brand = DB::connection('spu')->table('brand')->where('brand_id',
$spu['brand_id'])->lists('brand_name', 'brand_id');
if ($brand) {
$sku['brand_name'] = $brand[$spu['brand_id']];
}
}
}
//获取价格
$priceService = new PriceService();
$moqPrice = $priceService->getMoqPrice($sku['ladder_price']);
$sku['cn_price'] = array_get($moqPrice, 'price_cn');
$sku['us_price'] = array_get($moqPrice, 'price_us');
$list[] = $sku;
}
$intracodeModel = new IntracodeModel();
$encodedList = array_column($list, 'encoded');
$encodedUsers = $intracodeModel->getEncodedUserByEncoded($encodedList);
$list = array_map(function ($item) use ($encodedUsers) {
$encoded = array_get($item, 'encoded', 0);
$item['encoded_user_name'] = array_get($encodedUsers, $encoded, '');
$item['moq'] = $item['moq'] ?: 0;
$item['stock'] = $item['stock'] ?: 0;
return $item;
}, $list);
}
return [
'list' => $list,
'total' => !empty($data['data']['total']) ? $data['data']['total'] : 0
];
}
}
\ No newline at end of file
<?php
namespace App\Http\Services;
use App\Http\Controllers\Filter\SupplierFilter;
use App\Model\SupplierChannelModel;
use Illuminate\Support\Facades\DB;
class SkuStatisticsService
{
//获取供应商列表需要统计的信息
public function getSkuListStatistics()
{
$total = $this->getStatisticsCount('all');
//七天内过期的
$pending = $this->getStatisticsCount('pending');
//下架的
$inReview = $this->getStatisticsCount('in_review');
$result = [
'total' => $total,
'pending' => $pending,
'in_review' => $inReview,
];
$result = array_map(function ($value) {
if ($value > 999) {
$value = '999+';
}
return $value;
}, $result);
return $result;
}
private function getStatisticsCount($type)
{
$model = new SupplierChannelModel();
$model = $model->where('supplier_id','>',0);
//显示默认的数据(有权限逻辑)
$filter = new SupplierFilter();
return $filter->defaultFilter($model, $type)->count();
}
}
\ No newline at end of file
<?php
namespace App\Http\Services;
//后台用户相关信息服务
use App\Model\SkuUploadItem;
use App\Model\SupplierChannelModel;
use App\Model\UserInfoModel;
use Illuminate\Support\Facades\DB;
class SkuUploadItemService
{
//获取sku审核信息
public function getSkuAuditData($goodsIds = [])
{
$uploadItemModel = new SkuUploadItem();
$auditData = $uploadItemModel->whereIn('sku_id', array_values($goodsIds))->select([
'sku_id',
'audit_user',
'audit_time',
])->where('audit_user', '!=', 0)->get();
$auditData = $auditData ? $auditData->toArray() : [];
$data = $userIds = [];
foreach ($auditData as $key => $value) {
$data[$value['sku_id']] = $value;
$userIds[] = $value['audit_user'];
}
$userModel = new UserInfoModel();
$userIds = array_unique($userIds);
$users = $userModel->whereIn('userId', $userIds)->pluck('name', 'userId');
$users = $users ? $users->toArray() : [];
$data = array_map(function ($value)use ($users) {
$value['audit_name'] = array_get($users, $value['audit_user']);
return $value;
}, $data);
return $data;
}
}
\ No newline at end of file
......@@ -37,6 +37,7 @@ Route::group(['middleware' => ['web'], 'namespace' => 'Api'], function () {
Route::match(['get', 'post'], '/api/supplier_statistics/{key}', 'SupplierStatisticsApiController@Entrance');
Route::match(['get', 'post'], '/api/supplier/{key}', 'SupplierApiController@Entrance');
Route::match(['get', 'post'], '/api/log/{key}', 'LogApiController@Entrance');
Route::match(['get', 'post'], '/api/sku/{key}', 'SkuApiController@Entrance');
Route::match(['get', 'post'], '/api/supplier_receipt/{key}', 'SupplierReceiptApiController@Entrance');
Route::match(['get', 'post'], '/api/supplier_sync_log/{key}', 'SupplierSyncLogApiController@Entrance');
});
\ No newline at end of file
......@@ -96,4 +96,24 @@ class IntracodeModel extends Model
$userCodes = $temp + $codes;
return $userCodes;
}
//获取内部编码相关信息
public function getEncodedUserByEncoded($encodedList = [])
{
$encodedUsers = [];
$codes = $this->select('code_id', 'admin_id')
->whereIn('code_id',$encodedList)
->get();
if (empty($codes)) {
return [];
}
$codes = $codes->toArray();
$adminIds = array_column($codes, 'admin_id');
$userModel = new UserInfoModel();
$users = $userModel->whereIn('userId',$adminIds)->pluck('name', 'userId');
foreach ($codes as $key=>$code) {
$encodedUsers[$code['code_id']] = array_get($users, $code['admin_id']);
}
return $encodedUsers;
}
}
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class SkuUploadItem extends Model
{
protected $table='sku_upload_item_0';
protected $primaryKey = 'id';
protected $connection = 'spu';
public $timestamps = false;
}
<?php
return [
//0:自营 1:联营 2:专卖
'GoodsStatusName' => [
0 => '自营',
1 => '联营',
2 => '专卖',
],
'GoodsStatus'=>[
1 => '上架',
3 => '下架',
],
'SKU' => array(
'spu_id' => 1,
'encoded' => 1,
'moq' => 1,
'mpq' => 1,
'old_goods_id' => 1,
'goods_type' => 1,
'goods_status' => 1,
'batch_sn' => 1,
'stock' => 1,
'hk_delivery_time' => 1,
'cn_delivery_time' => 1,
'ladder_price' => 1,
'update_time' => 1,
'goods_images' => 1,
'canal' => 1,
'supplier_id' => 1,
'cp_time' => 1,
),
];
\ No newline at end of file
......@@ -31,5 +31,4 @@ return [
'exportMonopoly' => 'http://footstone.liexin.net/footstone/exportMonopoly?', // 专卖商品批量导出
'templet' => 'http://footstone.liexin.net/footstone/templet?', // 专卖商品批量导出
],
];
{{--@include('web.supplier.SupplierListCommon')--}}
<div class="layui-btn-group demoTable" style="margin-bottom: 15px;margin-top: 15px">
@if(checkPerm('AddSupplier'))
<button type="button" class="layui-btn layui-btn-sm" id="add_supplier">新增</button>
@endif
@if(checkPerm('DisableSupplier'))
<button type="button" class="layui-btn layui-btn-sm" id="disable_supplier">禁用</button>
@endif
@if(checkPerm('AuditSupplier'))
<button type="button" class="layui-btn layui-btn-sm" id="audit_supplier">审核</button>
@endif
@if(checkPerm('AllocatePurchaseUser'))
<button type="button" class="layui-btn layui-btn-sm" id="allocate_purchase_user">分配渠道员</button>
@endif
@if(checkPerm('ChangeSupplierIsType'))
<button type="button" class="layui-btn layui-btn-sm" title="该操作可以将竞调供应商转为正式供应商" id="change_supplier_is_type">转正供应商</button>
@include('web.sku.SkuListCommon')
<div style="margin-left: 20px;margin-right: 20px">
<div class="layui-btn-group demoTable" style="margin-top: 15px">
@if(checkPerm('TempTemp'))
<button type="button" class="layui-btn layui-btn-sm" id="add_supplier">新增</button>
@endif
<button type="button" class="layui-btn layui-btn-sm" id="batch_putaway">上架</button>
<button type="button" class="layui-btn layui-btn-sm" id="batch_unshelve">下架</button>
<button type="button" class="layui-btn layui-btn-sm" id="add_supplier">批量下架</button>
</div>
<table class="layui-table" id="skuList" lay-filter="skuList"></table>
</div>
<table class="layui-table" id="skuList" lay-filter="skuList"></table>
<script>
</script>
......@@ -9,7 +9,7 @@
<div class="split-group" style="height: 130px;">
<div class="split-item" id="s1">
<div class="layui-row">
<a class="main_filter layui-badge layui-bg-green" id="all">全部({{$statistics['total']}}</a>
<a class="main_filter layui-badge layui-bg-green" id="all">全部()</a>
</div>
</div>
<div class="split-item" id="s2" style="text-align: center">
......@@ -22,9 +22,10 @@
</a>
</div>
</div>
<div class="split-item" id="s3" style="text-align: center">
</div>
<div class="split-item" id="s5">
</div>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment