Commit b9773d19 by 肖康

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

parents 09bea32a 7af39ae3
...@@ -71,7 +71,7 @@ class AuthApiController extends Controller ...@@ -71,7 +71,7 @@ class AuthApiController extends Controller
} }
return $this->setError('Login failure'); return $this->setError('The account or password is incorrect');
} }
public function logout(Request $request) public function logout(Request $request)
...@@ -192,18 +192,27 @@ class AuthApiController extends Controller ...@@ -192,18 +192,27 @@ class AuthApiController extends Controller
return $this->setError($validator->errors()->first()); return $this->setError($validator->errors()->first());
} }
$info = UserModel::where('email', $email)->first(); $info = UserModel::where('email', $email)->first();
$msg = '';
switch ($type) { switch ($type) {
case 'register': case 'register':
if ($info) { if ($info) {
return $this->setError('This email had been registered'); return $this->setError('This email had been registered');
} }
$msg = 'You are registering an account with us.';
break; break;
case 'forget_password' : case 'forget_password' :
$msg = 'You are trying to reset your password.';
$existEmail = UserModel::where('email', $email)->exists();
if (!$existEmail) {
return $this->setError('This email is not registered');
}
break;
case 'update_email': case 'update_email':
$existEmail = UserModel::where('email', $email)->exists(); $existEmail = UserModel::where('email', $email)->exists();
if (!$existEmail) { if (!$existEmail) {
return $this->setError('This email is not registered'); return $this->setError('This email is not registered');
} }
$msg = 'You are modifying your email address.';
break; break;
} }
...@@ -216,10 +225,8 @@ class AuthApiController extends Controller ...@@ -216,10 +225,8 @@ class AuthApiController extends Controller
} }
Redis::set($redisKey, $code); Redis::set($redisKey, $code);
Redis::expire($redisKey, 120); Redis::expire($redisKey, 120);
$subject = config('mail.from.name');
// return $this->setSuccessData($code); // return $this->setSuccessData($code);
Mail::to($email)->send(new SendCode($type, $code)); Mail::to($email)->send(new SendCode($code, $msg));
//错误处理 //错误处理
if (count(Mail::failures())) { if (count(Mail::failures())) {
return $this->setError('Email code send failed'); return $this->setError('Email code send failed');
......
...@@ -37,27 +37,6 @@ class CartApiController extends Controller ...@@ -37,27 +37,6 @@ class CartApiController extends Controller
return !$result ? $this->setError('Add cart failed , please contact administrator'):$this->setSuccess('success',ApiCode::API_CODE_SUCCESS,$result); return !$result ? $this->setError('Add cart failed , please contact administrator'):$this->setSuccess('success',ApiCode::API_CODE_SUCCESS,$result);
} }
//批量添加购物车, items: {"goods_id":1166788996788323407,"goods_number":2}
public function saveCartBatch(Request $request)
{
$validator = Validator::make($request->all(), [
'items' => 'required|string',
], [
'items.min' => 'items must be at least 1 characters long.'
]);
if ($validator->fails()) {
return $this->setError($validator->errors()->first());
}
$data = $request->only([
'items',
'data',
]);
$result = CartService::saveCart($data, $request->user->id,$request->user->gid);
return !$result ? $this->setError('Add cart failed , please contact administrator'):$this->setSuccess('Add inquiry success');
}
//购物车列表 //购物车列表
public function cartLists(Request $request){ public function cartLists(Request $request){
$result = CartService::cartLists($request->user->id,$request->user->gid,$request->input("cart_ids",0)); $result = CartService::cartLists($request->user->id,$request->user->gid,$request->input("cart_ids",0));
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Http\Services\AutoAssignCustomerService; use App\Http\Services\AutoAssignCustomerService;
use App\Http\Services\ThirdService;
use App\Http\Services\UserService; use App\Http\Services\UserService;
use Illuminate\Http\Request; use Illuminate\Http\Request;
......
...@@ -28,7 +28,7 @@ class BrandService ...@@ -28,7 +28,7 @@ class BrandService
} }
return $standardBrandCache; return $standardBrandCache;
} }
return []; return [];
} }
...@@ -70,9 +70,12 @@ class BrandService ...@@ -70,9 +70,12 @@ class BrandService
public static function getStandardBrandInfo($brandId) public static function getStandardBrandInfo($brandId)
{ {
$standardBrand = Redis::hget('standard_brand', $brandId); $standardBrandData = \Http::get(config('website.footstone_url') . '/open/getStandardBrandInfo?brand_id=' . $brandId)->json();
$standardBrand = json_decode($standardBrand, true); if (isset($standardBrandData['code']) && $standardBrandData['code'] == 0) {
return $standardBrand; $standardBrand = $standardBrandData['data'];
return $standardBrand;
}
return [];
} }
} }
...@@ -26,7 +26,7 @@ class CartService ...@@ -26,7 +26,7 @@ class CartService
$con->beginTransaction(); $con->beginTransaction();
$redis = Redis::connection(); $redis = Redis::connection();
$goodsInfoArr = ThirdService::getGoodsInfo([$goods_id]); $goodsInfoArr = ThirdService::getSemourData("goods_info",$goods_id);
$temp = [ $temp = [
'goods_id' => $goods_id, 'goods_id' => $goods_id,
...@@ -41,7 +41,7 @@ class CartService ...@@ -41,7 +41,7 @@ class CartService
} }
$skuInfo = $goodsInfoArr[$goods_id]; //sku库存 $skuInfo = $goodsInfoArr[$goods_id]; //sku库存
$digikeyInfo = $redis->hget("sku_raw_map",$goods_id); //digikey 编码 $digikeyInfo = ThirdService::getSemourData("sku_raw_map",$goods_id); //digikey 编码
if ($digikeyInfo){ if ($digikeyInfo){
$digikeyArr = json_decode($digikeyInfo,true); $digikeyArr = json_decode($digikeyInfo,true);
$temp["raw_goods_sn"]= $digikeyArr["raw_goods_id"]; $temp["raw_goods_sn"]= $digikeyArr["raw_goods_id"];
...@@ -117,88 +117,6 @@ class CartService ...@@ -117,88 +117,6 @@ class CartService
} }
} }
//添加或者更新购物车(批量)
public static function saveCartBatch($data,$user_id="",$gid="")
{
try{
$con = DB::connection();
$con->beginTransaction();
$vs = json_decode(\Arr::get($data, 'items', []),true);
$redis = Redis::connection();
$goodsInfoArr = ThirdService::getGoodsInfo(array_column($vs,"goods_id"));
foreach ($vs as $v) {
$goods_id = $v['goods_id'];
$temp = [
'goods_id' => $v['goods_id'],
'update_time' => time(),
];
if ($user_id){
$temp["user_id"] = $user_id;
}else{
$temp["gid"] = $gid;
}
$skuInfo = $goodsInfoArr[$goods_id]; //sku库存
$digikeyInfo = $redis->hget("sku_raw_map",$goods_id); //digikey 编码
if ($digikeyInfo){
$digikeyArr = json_decode($digikeyInfo,true);
$temp["raw_goods_sn"]= $digikeyArr["raw_goods_id"];
$temp["raw_goods_packing"]= $digikeyArr["pack"];
$temp["raw_brand_name"]= $digikeyArr["raw_brand_name"];
}
//购买时价格
$buy_price = 0;
$ladder_price = data_get($skuInfo,"ladder_price");
if ($ladder_price){ //购买价格
foreach ($ladder_price as $a=>$b){
if ($v["buy_number"] >= $b["purchases"]){
$buy_price = $b["price_us"];
}else{
break;
}
}
}
$temp["buy_price"] = $buy_price;
$checkHas = CartModel::where(["user_id"=>$user_id,"goods_id"=>$goods_id,"status"=>1])->first();
if ($checkHas){ //存在累计库存
$temp["buy_number"] = $skuInfo["stock"] > ($v['buy_number']+$checkHas["buy_number"]) ? $v['buy_number']+$checkHas["buy_number"] : $skuInfo["stock"];
$temp["update_time"] = time();
$temp["status"] = $v["buy_number"] > 0 ? CartModel::status_yes:CartModel::status_no;
$flag = CartModel::where(["cart_id"=>$checkHas["cart_id"]])->update($temp);
if (!$flag){
throw new Exception("error update",1003);
}
}else{ //不存在插入购物车
$temp["buy_number"] = $skuInfo["stock"] > $v['buy_number'] ? $v['buy_number'] : $skuInfo["stock"];
$temp["status"] = $v["buy_number"] > 0 ? CartModel::status_yes:CartModel::status_no;
$temp["create_time"] = time();
$temp["update_time"] = time();
$flag = CartModel::insertGetId($temp);
if (!$flag){
throw new Exception("error add",1003);
}
}
}
$con->commit();
return true;
}catch (\Exception $e){
$con->rollback();
#throw new InvalidRequestException($e->getMessage().$e->getLine());
return false;
}
}
/* /*
* 刷新购物车并且返回列表 * 刷新购物车并且返回列表
...@@ -232,7 +150,7 @@ class CartService ...@@ -232,7 +150,7 @@ class CartService
$con->beginTransaction(); $con->beginTransaction();
$redis = Redis::connection(); $redis = Redis::connection();
$goodsInfoArr = ThirdService::getGoodsInfo(array_column($result,"goods_id")); $goodsInfoArr = ThirdService::getSemourData("goods_info",implode(",",array_column($result,"goods_id")));
$cartList = []; $cartList = [];
...@@ -251,7 +169,7 @@ class CartService ...@@ -251,7 +169,7 @@ class CartService
} }
$skuInfo = $goodsInfoArr[$goods_id]; //sku库存 $skuInfo = $goodsInfoArr[$goods_id]; //sku库存
$digikeyInfo = $redis->hget("sku_raw_map",$goods_id); //digikey 编码 $digikeyInfo = ThirdService::getSemourData("sku_raw_map",$goods_id); //digikey 编码
if ($digikeyInfo){ if ($digikeyInfo){
$digikeyArr = json_decode($digikeyInfo,true); $digikeyArr = json_decode($digikeyInfo,true);
$temp["raw_goods_sn"]= $digikeyArr["raw_goods_id"]; $temp["raw_goods_sn"]= $digikeyArr["raw_goods_id"];
...@@ -350,7 +268,7 @@ class CartService ...@@ -350,7 +268,7 @@ class CartService
//猎芯联营采购员 ,添加供应商采购员渠道不得为空 //猎芯联营采购员 ,添加供应商采购员渠道不得为空
$info['purchase_name'] = ''; $info['purchase_name'] = '';
if ($info['canal'] != ""){ if ($info['canal'] != ""){
$pur_name = $redis->hget('search_supplier_canaltopurchase',$info['canal']); $pur_name = ThirdService::getSemourData('search_supplier_canaltopurchase',$info['canal']);
$info['purchase_name'] = $pur_name; $info['purchase_name'] = $pur_name;
} }
//货区去掉工作日 //货区去掉工作日
...@@ -362,7 +280,7 @@ class CartService ...@@ -362,7 +280,7 @@ class CartService
#查询英文品牌缩写 #查询英文品牌缩写
$standard_brand_id = \Arr::get(\Arr::get($info,"standard_brand"),"standard_brand_id"); $standard_brand_id = \Arr::get(\Arr::get($info,"standard_brand"),"standard_brand_id");
$standardBrandInfo = $redis->hget("standard_brand",$standard_brand_id); $standardBrandInfo = ThirdService::getSemourData("standard_brand",$standard_brand_id);
if ($standardBrandInfo){ if ($standardBrandInfo){
$standardBrandInfoArr = json_decode($standardBrandInfo,true); $standardBrandInfoArr = json_decode($standardBrandInfo,true);
#深贸商城的品牌字段需展示该SKU对应基石标准品牌列表的英文简称,无则取英文名称、都无则取品牌名称 #深贸商城的品牌字段需展示该SKU对应基石标准品牌列表的英文简称,无则取英文名称、都无则取品牌名称
......
...@@ -125,7 +125,8 @@ class OrderService ...@@ -125,7 +125,8 @@ class OrderService
throw new InvalidRequestException("error:order address"); throw new InvalidRequestException("error:order address");
} }
#订单明细 #订单明细
$goodsInfoArr = ThirdService::getGoodsInfo(array_column($items,"goods_id")); //商品详情 $goodsInfoArr = ThirdService::getSemourData("goods_info",implode(",",array_column($items,"goods_id")));
$orderItems = []; //订单商品明细 $orderItems = []; //订单商品明细
$orderAmount = 0; $orderAmount = 0;
foreach ($items as $v) { foreach ($items as $v) {
...@@ -142,7 +143,7 @@ class OrderService ...@@ -142,7 +143,7 @@ class OrderService
#查询英文品牌缩写 #查询英文品牌缩写
$brandName = $skuInfo["brand_name"]; $brandName = $skuInfo["brand_name"];
$standard_brand_id = \Arr::get($standard_brand,"standard_brand_id",0); $standard_brand_id = \Arr::get($standard_brand,"standard_brand_id",0);
$standardBrandInfo = $redis->hget("standard_brand",$standard_brand_id); $standardBrandInfo = ThirdService::getSemourData("standard_brand",$standard_brand_id);
if ($standardBrandInfo){ if ($standardBrandInfo){
$standardBrandInfoArr = json_decode($standardBrandInfo,true); $standardBrandInfoArr = json_decode($standardBrandInfo,true);
#深贸商城的品牌字段需展示该SKU对应基石标准品牌列表的英文简称,无则取英文名称、都无则取品牌名称 #深贸商城的品牌字段需展示该SKU对应基石标准品牌列表的英文简称,无则取英文名称、都无则取品牌名称
...@@ -397,7 +398,7 @@ class OrderService ...@@ -397,7 +398,7 @@ class OrderService
->get() ->get()
->keyBy("order_address_type")->toArray(); //地址信息,1收货信息 2账单邮寄信息 ->keyBy("order_address_type")->toArray(); //地址信息,1收货信息 2账单邮寄信息
$goodsInfoArr = ThirdService::getGoodsInfo(array_column($items,"goods_id")); //商品详情 $goodsInfoArr = ThirdService::getSemourData("goods_info",implode(",",array_column($items,"goods_id"))); //商品详情
$itemsTemp = []; $itemsTemp = [];
$merchandise_total = 0; //商品总额 $merchandise_total = 0; //商品总额
foreach ($items as $k=>$v){ foreach ($items as $k=>$v){
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace App\Http\Services; namespace App\Http\Services;
use App\Exceptions\InvalidRequestException; use App\Exceptions\InvalidRequestException;
use App\Http\ApiHelper\ApiCode;
use App\Http\Models\Order\OrderModel; use App\Http\Models\Order\OrderModel;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
...@@ -34,4 +35,20 @@ class ThirdService ...@@ -34,4 +35,20 @@ class ThirdService
return $res['data']; return $res['data'];
} }
/*
*
* getSemourData("sku_raw_map","1163833797285826826")
*
* 深茂获取相关数据
* hget("sku_raw_map",$goods_id); //digikey 编码
* hget("standard_brand",$standard_brand_id); //获取标准品牌
* synchronization //获取商品详情
*/
public static function getSemourData($types,$k){
$response = Http::asForm()->post(env('FOOTSTONE_URL', '') ."/open/getSemourData", ["k"=>$k,"types"=>$types]);
$data = json_decode($response->body(),true);
return \Arr::get($data,"data");
}
} }
...@@ -19,6 +19,7 @@ class UserAddressService ...@@ -19,6 +19,7 @@ class UserAddressService
$address['user_id'] = $user->id; $address['user_id'] = $user->id;
$address['create_time'] = time(); $address['create_time'] = time();
$address['consignee'] = $address['first_name'] . ' ' . $address['last_name'];
//如果没有默认地址,那么就设置为默认地址 //如果没有默认地址,那么就设置为默认地址
$hasDefaultAddress = UserAddressModel::where('user_id', $user->id)->where('is_default', 1)->exists(); $hasDefaultAddress = UserAddressModel::where('user_id', $user->id)->where('is_default', 1)->exists();
if (!$hasDefaultAddress) { if (!$hasDefaultAddress) {
......
...@@ -11,18 +11,18 @@ class SendCode extends Mailable ...@@ -11,18 +11,18 @@ class SendCode extends Mailable
{ {
use Queueable, SerializesModels; use Queueable, SerializesModels;
public $type;
public $code; public $code;
public $msg;
/** /**
* Create a new message instance. * Create a new message instance.
* *
* @return void * @return void
*/ */
public function __construct($type,$code) public function __construct($code, $msg)
{ {
$this->type = $type;
$this->code = $code; $this->code = $code;
$this->msg = $msg;
} }
/** /**
......
...@@ -10,33 +10,14 @@ ...@@ -10,33 +10,14 @@
<div> <div>
<img style="width: 25%;" src="https://img.ichunt.com/images/ichunt/202211/22/c0a944d0d89fde3ba67477369eac1bb2.png"> <img style="width: 25%;" src="https://img.ichunt.com/images/ichunt/202211/22/c0a944d0d89fde3ba67477369eac1bb2.png">
</div> </div>
@if($type=='register')
<div style="margin-top: 50px"> <div style="margin-top: 50px">
<p>Hi!</p> <p>Hi!</p>
<p>You are registering an account with us.</p> <p>{{$msg}}</p>
<p>You can enter this code on SEMOUR website:</p> <p>You can enter this code on SEMOUR website:</p>
<span style="font-size: 20px"><strong>{{$code}}</strong></span> <span style="font-size: 20px"><strong>{{$code}}</strong></span>
<p>If this was not you, please let us know at INFO@semour.com</p> <p>If this was not you, please let us know at INFO@semour.com</p>
</div> </div>
@endif
@if($type=='update_email')
<div style="margin-top: 50px">
<p>Hi!</p>
<p>You are modifying your email address.</p>
<p>You can enter this code on SEMOUR website:</p>
<span style="font-size: 20px"><strong>{{$code}}</strong></span>
<p>If this was not you, please let us know at INFO@semour.com</p>
</div>
@endif
@if($type=='reset_password')
<div style="margin-top: 50px">
<p>Hi!</p>
<p>You are trying to reset your password.</p>
<p>You can enter this code on SEMOUR website:</p>
<span style="font-size: 20px"><strong>{{$code}}</strong></span>
<p>If this was not you, please let us know at INFO@semour.com</p>
</div>
@endif
</div> </div>
</body> </body>
......
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