Commit 14c0b581 by 肖康

Merge branch 'dev/ver/1.0.0' of http://git.ichunt.net/semour/semour_web into dev/ver/1.0.0

parents ac2d8a59 56298307
......@@ -19,7 +19,7 @@ QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
REDIS_HOST=192.168.1.235
REDIS_HOST=192.168.1.234
REDIS_PASSWORD=icDb29mLy2s
REDIS_PORT=6379
......
......@@ -14,3 +14,4 @@ Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
.idea/workspace.xml
......@@ -133,6 +133,7 @@ class AuthApiController extends Controller
Redis::expire($redisKey, 60);
$subject = config('mail.from.name');
$msg = 'Email Code:' . $code . '.';
return $this->setSuccessData($code);
Mail::raw($msg, function ($message) use ($email, $subject) {
$message->to($email)->subject($subject);
});
......
......@@ -21,7 +21,7 @@ class CartApiController extends Controller
{
//添加购物车, items: {"goods_id":1166788996788323407,"goods_number":2}
public function addCart(Request $request)
public function saveCart(Request $request)
{
$validator = Validator::make($request->all(), [
'items' => 'required|string',
......@@ -37,13 +37,13 @@ class CartApiController extends Controller
'data',
]);
$result = CartService::addCart($data, $request->user->id);
$result = CartService::saveCart($data, $request->user->id);
return !$result ? $this->setError('Add cart failed , please contact administrator'):$this->setSuccess('Add inquiry success');
}
//购物车列表
public function cartLists(){
public function cartLists(Request $request){
$result = CartService::cartLists($request->user->id);
}
......
......@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Http\Services\BrandService;
use Illuminate\Http\Request;
class BrandController extends Controller
......@@ -23,7 +24,8 @@ class BrandController extends Controller
*/
public function map()
{
return view('brand.map');
$brandList = BrandService::getStandardBrandList();
return view('brand.map',compact('brandList'));
}
public function list()
{
......
<?php
namespace App\Http\Services;
use Illuminate\Support\Facades\Redis;
class BrandService
{
//获取品牌页的数据(标准品牌)
public static function getStandardBrandList()
{
$redisKey = 'semour_standard_brand_map';
$standardBrandList = Redis::get($redisKey);
if ($standardBrandList) {
return $standardBrandList;
}
$standardBrandCache = Redis::hgetall('standard_brand');
$standardBrandCache = array_map(function ($value) {
return json_decode($value, true);
}, $standardBrandCache);
$letters = generate_letters();
$standardBrandList = [];
foreach ($standardBrandCache as $standardBrand) {
$matchLetter = false;
foreach ($letters as $letter) {
if (start_with(strtoupper($standardBrand['brand_name']),$letter)) {
$standardBrandList[$letter][] = $standardBrand;
$matchLetter = true;
}
}
if (!$matchLetter) {
$standardBrandList['#'][] = $standardBrand;
}
}
$data = [];
ksort($standardBrandList);
Redis::set($redisKey, json_encode($standardBrandList), 60);
return $standardBrandList;
}
}
......@@ -14,8 +14,8 @@ use App\Models\CartModel;
//购物车服务器层
class CartService
{
//添加购物车
public static function addCart($data, $user_id)
//添加或者更新购物车
public static function saveCart($data, $user_id)
{
try{
......@@ -47,14 +47,14 @@ class CartService
$checkHas = CartModel::where(["user_id"=>$user_id,"goods_id"=>$goods_id,"status"=>1])->first();
if ($checkHas){ //存在累计库存
$temp["goods_number"] = $skuInfo["stock"] > ($item['buy_number']+$checkHas["buy_number"]) ? $item['buy_number']+$checkHas["buy_number"] : $skuInfo["stock"];
$temp["buy_number"] = $skuInfo["stock"] > ($item['buy_number']+$checkHas["buy_number"]) ? $item['buy_number']+$checkHas["buy_number"] : $skuInfo["stock"];
$temp["update_time"] = time();
$flag = CartModel::where(["cart_id"=>$checkHas["cart_id"]])->update($temp);
if (!$flag){
return false;
}
}else{ //不存在插入购物车
$temp["goods_number"] = $skuInfo["stock"] > $item['buy_number'] ? $item['buy_number'] : $skuInfo["stock"];
$temp["buy_number"] = $skuInfo["stock"] > $item['buy_number'] ? $item['buy_number'] : $skuInfo["stock"];
$temp["create_time"] = time();
$temp["update_time"] = time();
......@@ -75,7 +75,7 @@ class CartService
}
//刷新购物车并且返回列表
public static function cartUpdateGetLists($user_id){
public static function cartLists($user_id){
//当前用户所有可用的购物车数据
$query = CartModel::where(['user_id'=>$user_id,"status"=>1])
......@@ -92,6 +92,7 @@ class CartService
$redis = Redis::connection();
$goodsInfoArr = ThirdService::getGoodsInfo(array_column($result,"goods_id"));
$cartList = [];
foreach ($result as $item) {
$goods_id = $item['goods_id'];
......
......@@ -2,7 +2,50 @@
namespace App\Http\Services;
use Illuminate\Support\Facades\Redis;
class ClassService
{
//获取首页需要的所有分类,没有英文名称的不要
public static function getClassificationForHome()
{
//先获取所有分类
$classCache = Redis::hgetall('pool_class_info');
$topClassList = [];
foreach ($classCache as $key => &$class) {
$class = json_decode($class, true);
if (!$class['parent_id']) {
$topClassList[] = $class;
}
}
unset($class);
foreach ($classCache as $key => $class) {
if (!$class['parent_id']) {
continue;
}
foreach ($topClassList as &$topClass) {
if ($topClass['class_id'] == $class['parent_id']) {
$topClass['children'][] = $class;
}
}
unset($topClass);
}
$topClassMapping = config('field.top_class_mapping');
$topFields = array_map(function ($value){
return [
'class_name' => $value,
];
},$topClassMapping);
foreach ($topClassMapping as $key => $mapping) {
foreach ($topClassList as $topClass) {
if (in_array($topClass['class_id'], $topClassMapping[$key])) {
$topFields[$key]['children'][] = $topClass;
}
}
}
return array_values($topFields);
}
}
<?php
namespace App\Http\Services;
class DataService
{
}
<?php
namespace App\Http\ViewComposers;
use App\Http\Services\ClassService;
use Illuminate\View\View;
class ClassificationViewComposer
{
public function compose(View $view)
{
$classification = ClassService::getClassificationForHome();
$view->with('classification', $classification);
}
}
......@@ -25,6 +25,5 @@ class AppServiceProvider extends ServiceProvider
public function boot()
{
//
View::share ('public',config('field.public_url'));
}
}
<?php
namespace App\Providers;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
class ViewServiceProvider extends ServiceProvider
{
/**
* 注册任何应用服务
*
* @return void
*/
public function register()
{
//
}
/**
* 引导任何应用服务
*
* @return void
*/
public function boot()
{
View::share('public', config('field.public_url'));
View::composer(
['common.mallHeaderNav'],
'App\Http\ViewComposers\ClassificationViewComposer'
);
}
}
<?php
function test_helper() {
function test_helper()
{
return 'OK';
}
if (!function_exists('start_with')) {
function start_with($str, $pattern)
{
return strpos($str, $pattern) === 0;
}
}
if (!function_exists('generate_letters')) {
function generate_letters($upper = true)
{
$letters = [];
for ($i = 65; $i < 91; $i++) {
$letters[] = $upper ? strtoupper(chr($i)) : strtolower(chr($i));
}
return $letters;
}
}
/*
* 反爬虫用html标签替换数字,不包括“.”
* $number 数字串
*/
function numberToHtml($number){
$arr = [
['asfgdqwer','asfgdtyhg','asfgdpolk','asfgdpoqw'],
['asfgdrfdf','asfgderfd','asfgdwdsa','asfgdpoer'],
['asfgdasde','asfgdqwsz','asfgdrtgd','asfgdpovv'],
['asfgdwsxc','asfgdwsxz','asfgdrfvb','asfgdpoee'],
['asfgdqazs','asfgdqasd','asfgdqwag','asfgdpogh'],
['asfgdrtyh','asfgdyutr','asfgdeews','asfgdpotg'],
['asfgdpluj','asfgdikjf','asfgdesgj','asfgdpfff'],
['asfgdtrdb','asfgdiksf','asfgdsgkp','asfgdprty'],
['asfgdpehl','asfgdstgb','asfgderll','asfgdpokf'],
['asfgdpehg','asfgdstgf','asfgderlf','asfgdpogk']
];
if(empty($arr)){
return $number;
}
$len = strlen($number);
if($len>0){
$str = '';
for($i=0;$i<$len;$i++){
$num = substr($number, $i,1);
if(preg_match('/\d/', $num)){
$index = rand(0, 3);
$class = $arr[$num][$index];
$other_class = strRandom($class);
$num = '<font class="'.$class.$other_class.'"></font>';
}
$str .= $num;
}
return $str;
}else{
return $number;
}
}
File mode changed
File mode changed
......@@ -174,6 +174,7 @@ return [
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
App\Providers\ViewServiceProvider::class,
],
......
......@@ -7,5 +7,12 @@ return [
-1 => 'Closed',
0 => 'Pending',
1 => 'Replied',
],
//顶级分类和具体分类的映射,目前是写死的
'top_class_mapping' => [
'Actives' => [13396, 13782, 13359, 13287, 13482, 13488],
'Passives' => [13693, 13799, 13706, 13586, 13626, 13883],
'Modules & Devices & Products' => [13550, 13449, 13821, 13734, 13757, 13762],
]
];
......@@ -17,6 +17,7 @@ use Illuminate\Support\Facades\Route;
Route::middleware(['api'])->namespace('Api')->group(function () {
Route::POST('/auth/login', 'AuthApiController@login');
Route::POST('/auth/register', 'AuthApiController@register');
Route::POST('auth/send_email_code', 'AuthApiController@sendEmailCode');
});
......@@ -24,7 +25,6 @@ Route::middleware(['api', 'api.check'])->namespace('Api')->group(function () {
Route::GET('/auth/logout', 'AuthApiController@logout');
Route::POST('auth/reset_password', 'AuthApiController@resetPassword');
Route::POST('auth/send_email_code', 'AuthApiController@sendEmailCode');
Route::get('user/info', 'UserApiController@info');
Route::POST('user/update', 'UserApiController@update');
......@@ -43,7 +43,8 @@ Route::middleware(['api', 'api.check'])->namespace('Api')->group(function () {
Route::get('country/list', 'CountryApiController@list');
Route::POST('cart/addCart', 'CartApiController@addCart'); //添加购物车
Route::POST('cart/saveCart', 'CartApiController@saveCart'); //添加或者更新购物车
Route::POST('cart/cartLists', 'CartApiController@cartLists'); //购物车列表
});
<?php
/** @noinspection PhpUndefinedClassInspection */
/** @noinspection PhpFullyQualifiedNameUsageInspection */
<?php //57e58246c1892c9d4d68cdd025828591
/** @noinspection all */
namespace Facade\Ignition\Facades {
......@@ -1726,6 +1725,14 @@ namespace Illuminate\Support\Facades {
* @method static mixed macroCall(string $method, array $parameters)
* @see \Illuminate\Routing\Router::getPatterns
* @method static array getPatterns()
* @see Route::emailVerification
* @method static void emailVerification()
* @see Route::auth
* @method static void auth($options = [])
* @see Route::resetPassword
* @method static void resetPassword()
* @see Route::confirmPassword
* @method static void confirmPassword()
*/
class Route {}
......
<?php
/** @noinspection PhpUndefinedClassInspection */
/** @noinspection PhpFullyQualifiedNameUsageInspection */
<?php //eb887b72f4c195a7661d55cc5b0e6fb2
/** @noinspection all */
namespace Illuminate\Database\Eloquent {
/**
* @method $this onlyTrashed()
* @method int restore()
* @method $this withTrashed($withTrashed = true)
* @method $this withoutTrashed()
*/
class Builder {}
}
namespace Illuminate\Http {
/**
* @method bool hasValidSignature($absolute = true)
* @method array validate(array $rules, ...$params)
* @method array validateWithBag(string $errorBag, array $rules, ...$params)
* @method bool hasValidSignature($absolute = true)
*/
class Request {}
}
......@@ -15,10 +25,10 @@ namespace Illuminate\Http {
namespace Illuminate\Support\Facades {
/**
* @method void emailVerification()
* @method void auth($options = [])
* @method void resetPassword()
* @method void confirmPassword()
* @method void emailVerification()
* @method void resetPassword()
*/
class Route {}
}
\ No newline at end of file
<?php
/** @noinspection PhpUndefinedClassInspection */
/** @noinspection PhpFullyQualifiedNameUsageInspection */
<?php //5f7aad5b00d94544916e296bddb7d62f
/** @noinspection all */
namespace Illuminate\Database\Eloquent {
/**
* @method static $this onlyTrashed()
* @method static int restore()
* @method static $this withTrashed($withTrashed = true)
* @method static $this withoutTrashed()
*/
class Builder {}
}
namespace Illuminate\Http {
/**
* @method static bool hasValidSignature($absolute = true)
* @method static array validate(array $rules, ...$params)
* @method static array validateWithBag(string $errorBag, array $rules, ...$params)
* @method static bool hasValidSignature($absolute = true)
*/
class Request {}
}
......@@ -15,10 +25,10 @@ namespace Illuminate\Http {
namespace Illuminate\Support\Facades {
/**
* @method static void emailVerification()
* @method static void auth($options = [])
* @method static void resetPassword()
* @method static void confirmPassword()
* @method static void emailVerification()
* @method static void resetPassword()
*/
class Route {}
}
\ No newline at end of file
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