Commit f29461ec by 杨树贤

Merge branch 'master' of http://git.ichunt.net/semour/semour_web

parents b4fa5f8b 345c39d9
...@@ -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;
......
...@@ -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,12 +41,12 @@ class CartService ...@@ -41,12 +41,12 @@ 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"]= \Arr::get($digikeyArr,"raw_goods_id","");
$temp["raw_goods_packing"]= $digikeyArr["pack"]; $temp["raw_goods_packing"]= \Arr::get($digikeyArr,"pack","");
$temp["raw_brand_name"]= $digikeyArr["raw_brand_name"]; $temp["raw_brand_name"]= \Arr::get($digikeyArr,"raw_brand_name","");
} }
//购买时价格 //购买时价格
...@@ -112,93 +112,11 @@ class CartService ...@@ -112,93 +112,11 @@ class CartService
return $te; return $te;
}catch (\Exception $e){ }catch (\Exception $e){
$con->rollback(); $con->rollback();
# throw new InvalidRequestException($e->getMessage().$e->getLine()); throw new InvalidRequestException($e->getMessage().$e->getLine());
return false; return false;
} }
} }
//添加或者更新购物车(批量)
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,12 +169,12 @@ class CartService ...@@ -251,12 +169,12 @@ 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"]= \Arr::get($digikeyArr,"raw_goods_id","");
$temp["raw_goods_packing"]= $digikeyArr["pack"]; $temp["raw_goods_packing"]= \Arr::get($digikeyArr,"pack","");
$temp["raw_brand_name"]= $digikeyArr["raw_brand_name"]; $temp["raw_brand_name"]= \Arr::get($digikeyArr,"raw_brand_name","");
} }
$temp["buy_number"] = $skuInfo["stock"] > $v['buy_number'] ? $v['buy_number'] : $skuInfo["stock"]; //购买数量 $temp["buy_number"] = $skuInfo["stock"] > $v['buy_number'] ? $v['buy_number'] : $skuInfo["stock"]; //购买数量
...@@ -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对应基石标准品牌列表的英文简称,无则取英文名称、都无则取品牌名称
...@@ -179,9 +180,9 @@ class OrderService ...@@ -179,9 +180,9 @@ class OrderService
"purchase_name"=>"", //采购员 "purchase_name"=>"", //采购员
"contract_remark"=>"", //合同备注 6个汉子 "contract_remark"=>"", //合同备注 6个汉子
"tax_rate"=>0, //税率 "tax_rate"=>0, //税率
"raw_goods_sn"=>\Arr::get($cartInfo,"raw_goods_sn",0), //DGK原始编码 "raw_goods_sn"=>\Arr::get($cartInfo,"raw_goods_sn",""), //DGK原始编码
"raw_goods_packing"=>\Arr::get($cartInfo,"raw_goods_packing",0), //DGK原始包装 "raw_goods_packing"=>\Arr::get($cartInfo,"raw_goods_packing",""), //DGK原始包装
"raw_brand_name"=>\Arr::get($cartInfo,"raw_brand_name",0), //DGK原始品牌名称 "raw_brand_name"=>\Arr::get($cartInfo,"raw_brand_name",""), //DGK原始品牌名称
"discount_amount"=>0, //折扣金额 "discount_amount"=>0, //折扣金额
"other_amount"=>0, //其它费用金额 "other_amount"=>0, //其它费用金额
"remarks"=>$v["remark"], //客户备注 "remarks"=>$v["remark"], //客户备注
...@@ -309,7 +310,8 @@ class OrderService ...@@ -309,7 +310,8 @@ class OrderService
$priceArr = array_column($priceInfo,"price","price_type"); $priceArr = array_column($priceInfo,"price","price_type");
# $sub_total = OrderPriceModel::getOrderSubTotal($order_id); # $sub_total = OrderPriceModel::getOrderSubTotal($order_id);
$payment_surcharge_paypal = round($merchandise_total*0.046+0.5,2); $shipping = \Arr::get($priceArr,3,0); //运费
$payment_surcharge_paypal = round(($merchandise_total+$shipping)*0.046+0.5,2);
$ts =[ $ts =[
"order_id"=>$order_id, "order_id"=>$order_id,
...@@ -322,7 +324,7 @@ class OrderService ...@@ -322,7 +324,7 @@ class OrderService
"email"=>\Arr::get($receiveAddress,"email"), "email"=>\Arr::get($receiveAddress,"email"),
"phone"=>\Arr::get($receiveAddress,"phone"), "phone"=>\Arr::get($receiveAddress,"phone"),
"shipping_address"=>\Arr::get($receiveAddress,"detail_address"), "shipping_address"=>\Arr::get($receiveAddress,"detail_address"),
"shipping"=>\Arr::get($priceArr,3,0), //运费 "shipping"=>$shipping, //运费
"payment_surcharge_paypal"=>$payment_surcharge_paypal, //paypal 支付手续费 "payment_surcharge_paypal"=>$payment_surcharge_paypal, //paypal 支付手续费
"payment_surcharge_ttl"=>35, //ttl 支付手续费 "payment_surcharge_ttl"=>35, //ttl 支付手续费
"merchandise_total"=>$merchandise_total, //商品总额 "merchandise_total"=>$merchandise_total, //商品总额
...@@ -397,7 +399,7 @@ class OrderService ...@@ -397,7 +399,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");
}
} }
...@@ -117,14 +117,15 @@ ...@@ -117,14 +117,15 @@
</div> </div>
<div class="row"> <div class="row">
<div class="input-group-auth">
<p class="labelp"><span>*</span>LAST NAME</p>
<input type="text" class="last_name3 verify" verifyTip='{"type":"null","text":"LAST NAME"}'>
</div>
<div class="input-group-auth ml30"> <div class="input-group-auth ml30">
<p class="labelp"><span>*</span>FIRST NAME</p> <p class="labelp"><span>*</span>FIRST NAME</p>
<input type="text" class="first_name3 verify" verifyTip='{"type":"null","text":"FIRST NAME"}'> <input type="text" class="first_name3 verify" verifyTip='{"type":"null","text":"FIRST NAME"}'>
</div> </div>
<div class="input-group-auth">
<p class="labelp"><span>*</span>LAST NAME</p>
<input type="text" class="last_name3 verify" verifyTip='{"type":"null","text":"LAST NAME"}'>
</div>
</div> </div>
<div class="row"> <div class="row">
<div class="input-group-auth"> <div class="input-group-auth">
......
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
</div> </div>
</div> </div>
<div class="create createcarbtn">Place Order</div> <div class="create createcarbtn">Place Order</div>
@if(Auth::check()) @if(!Auth::check())
<div class="lgtips"> <div class="lgtips">
Already Registered? <a href="/login?referer={{\Illuminate\Support\Facades\URL::current()}}">Log In</a> Already Registered? <a href="/login?referer={{\Illuminate\Support\Facades\URL::current()}}">Log In</a>
</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