|
@@ -6,9 +6,8 @@ use App\Models\Product;
|
|
|
use App\Models\Product\Skus as ProductSkus;
|
|
|
use App\Http\Requests\Api\Orders as Request;
|
|
|
use App\Models\Business;
|
|
|
-use App\Models\City;
|
|
|
use App\Models\Custom;
|
|
|
-use App\Models\CustomAddr;
|
|
|
+use App\Models\StudentAddr;
|
|
|
use App\Models\CustomCoupon;
|
|
|
use App\Models\CustomScore;
|
|
|
use App\Models\OrdersAddr;
|
|
@@ -35,7 +34,7 @@ class Orders extends Api{
|
|
|
* 创建订单 /api/orders/create
|
|
|
*
|
|
|
* */
|
|
|
- public function create(Request $request,Custom $Custom,City $City,Model $Model,WorkTag $WorkTag,OrdersAddr $OrdersAddr,OrdersProduct $OrdersProduct,Product $Product,ProductSkus $ProductSkus,CustomCoupon $CustomCoupon,ShopCart $ShopCart,CustomAddr $CustomAddr,CustomScore $CustomScore,PromoProduct $PromoProduct){
|
|
|
+ public function create(Request $request,Custom $Custom,Model $Model,WorkTag $WorkTag,OrdersAddr $OrdersAddr,OrdersProduct $OrdersProduct,Product $Product,ProductSkus $ProductSkus,CustomCoupon $CustomCoupon,ShopCart $ShopCart,StudentAddr $StudentAddr,CustomScore $CustomScore,PromoProduct $PromoProduct){
|
|
|
// 接口验签
|
|
|
// $this->verify_sign();
|
|
|
// 验证参数
|
|
@@ -54,24 +53,22 @@ class Orders extends Api{
|
|
|
// 如果不存在数据
|
|
|
if( empty($buyList) ) return json_send(['code'=>'error','msg'=>'没有需下单的产品','data'=>['error'=>'产品列表为空']]);
|
|
|
// 选择地址
|
|
|
- $addr = $CustomAddr->getOne($addrId);
|
|
|
+ $addr = $StudentAddr->getOne($addrId);
|
|
|
// 如果不存在数据
|
|
|
if( !$addr ) return json_send(['code'=>'error','msg'=>'地址有误,请核对','data'=>['error'=>'没有找到对应的地址']]);
|
|
|
// 重组数据
|
|
|
- $addr = ['contact_name'=>$addr['contact_name'],'contact_shop'=>$addr['contact_shop'],'contact_phone'=>$addr['contact_phone'],'contact_province'=>$addr['contact_province'],'contact_city'=>$addr['contact_city'],'contact_area'=>$addr['contact_area'],'contact_addr'=>$addr['contact_addr']];
|
|
|
+ $addr = [
|
|
|
+ 'contact_area'=>$addr['contact_area'],
|
|
|
+ 'contact_school'=>$addr['contact_school'],
|
|
|
+ 'contact_grade'=>$addr['contact_grade'],
|
|
|
+ 'contact_class'=>$addr['contact_class'],
|
|
|
+ 'contact_name'=>$addr['contact_name'],
|
|
|
+ 'contact_phone'=>$addr['contact_phone'],
|
|
|
+ ];
|
|
|
// 获取客户城市ID
|
|
|
$custom = $Custom->getOne($uid);
|
|
|
// 如果不存在的话
|
|
|
if( !$custom ) return json_send(['code'=>'no_login','msg'=>'用户不存在,请重新登录','data'=>['error'=>'用户不存在,请重新登录']]);
|
|
|
- // 如果不存在的话
|
|
|
- if( !$custom['city_id'] ) return json_send(['code'=>'error','msg'=>'请选择所在城市后下单','data'=>['error'=>'请选择所在城市后下单']]);
|
|
|
- // 获取城市ID
|
|
|
- $cityId = $custom['city_id'];
|
|
|
- $cityName = $City->getOne($cityId,'name');
|
|
|
- $pid = $City->getOne($cityId,'pid');
|
|
|
- $province = $City->getOne($pid,'name');
|
|
|
- // 判断选择的城市名称是不是一致
|
|
|
- if( $cityName != $addr['contact_city'] ) return json_send(['code'=>'error','msg'=>'收货地址请选择'.$province.'/'.$cityName,'data'=>['error'=>'收货地址需与您所选城市一致']]);
|
|
|
// 商品购买数量
|
|
|
$buyNum = [];
|
|
|
// 循环购买信息
|
|
@@ -188,7 +185,7 @@ class Orders extends Api{
|
|
|
// 获取优惠券赠品信息
|
|
|
$rebateProduct = $couponRebate['rebate_product'];
|
|
|
/*活动优惠数据*/
|
|
|
- $promoList = $PromoProduct->getRebatePrice(array_column($buyList,'product_id'),$uid,$productPrice,$cityId,$tags);
|
|
|
+ $promoList = $PromoProduct->getRebatePrice(array_column($buyList,'product_id'),$productPrice,$tags);
|
|
|
$promoProductPrice = $promoList['product_price'];
|
|
|
$promoRebateProduct = $promoList['rebate_product'];
|
|
|
//订单支付总价
|
|
@@ -617,7 +614,7 @@ class Orders extends Api{
|
|
|
* 创建拼团订单 /api/orders/create_regiment
|
|
|
*
|
|
|
* */
|
|
|
- public function create_regiment(Request $request,Custom $Custom,City $City,Model $Model,WorkTag $WorkTag,OrdersAddr $OrdersAddr,OrdersProduct $OrdersProduct,Product $Product,ProductSkus $ProductSkus,CustomCoupon $CustomCoupon,ShopCart $ShopCart,CustomAddr $CustomAddr,CustomScore $CustomScore){
|
|
|
+ public function create_regiment(Request $request,Custom $Custom,Model $Model,WorkTag $WorkTag,OrdersAddr $OrdersAddr,OrdersProduct $OrdersProduct,Product $Product,ProductSkus $ProductSkus,CustomCoupon $CustomCoupon,ShopCart $ShopCart,StudentAddr $StudentAddr,CustomScore $CustomScore){
|
|
|
// 接口验签
|
|
|
// $this->verify_sign();
|
|
|
// 验证参数
|
|
@@ -625,9 +622,7 @@ class Orders extends Api{
|
|
|
// 检查登录
|
|
|
$uid = $this->checkLogin();
|
|
|
// 接收参数
|
|
|
- $isCart = request('is_cart',0);
|
|
|
$productList = request('product_list','[]');
|
|
|
- $customCouponId = request('custom_coupon_id',0);
|
|
|
$addrId = request('addr_id',0);
|
|
|
$regimentId = request('regiment_id',0);
|
|
|
$regimentActiveId = request('regiment_active_id',0);
|
|
@@ -642,24 +637,22 @@ class Orders extends Api{
|
|
|
if( empty($buyList) ) return json_send(['code'=>'error','msg'=>'没有需下单的产品','data'=>['error'=>'产品列表为空']]);
|
|
|
$time = time();
|
|
|
// 选择地址
|
|
|
- $addr = $CustomAddr->getOne($addrId);
|
|
|
- // 如果不存在数据
|
|
|
- if( !$addr ) return json_send(['code'=>'error','msg'=>'地址有误,请核对','data'=>['error'=>'没有找到对应的地址']]);
|
|
|
- // 重组数据
|
|
|
- $addr = ['contact_name'=>$addr['contact_name'],'contact_shop'=>$addr['contact_shop'],'contact_phone'=>$addr['contact_phone'],'contact_province'=>$addr['contact_province'],'contact_city'=>$addr['contact_city'],'contact_area'=>$addr['contact_area'],'contact_addr'=>$addr['contact_addr']];
|
|
|
+ $addr = $StudentAddr->getOne($addrId);
|
|
|
+ // 如果不存在数据
|
|
|
+ if( !$addr ) return json_send(['code'=>'error','msg'=>'地址有误,请核对','data'=>['error'=>'没有找到对应的地址']]);
|
|
|
+ // 重组数据
|
|
|
+ $addr = [
|
|
|
+ 'contact_area'=>$addr['contact_area'],
|
|
|
+ 'contact_school'=>$addr['contact_school'],
|
|
|
+ 'contact_grade'=>$addr['contact_grade'],
|
|
|
+ 'contact_class'=>$addr['contact_class'],
|
|
|
+ 'contact_name'=>$addr['contact_name'],
|
|
|
+ 'contact_phone'=>$addr['contact_phone'],
|
|
|
+ ];
|
|
|
// 获取客户城市ID
|
|
|
$custom = $Custom->getOne($uid);
|
|
|
// 如果不存在的话
|
|
|
if( !$custom ) return json_send(['code'=>'no_login','msg'=>'用户不存在,请重新登录','data'=>['error'=>'用户不存在,请重新登录']]);
|
|
|
- // 如果不存在的话
|
|
|
- if( !$custom['city_id'] ) return json_send(['code'=>'error','msg'=>'请选择所在城市后下单','data'=>['error'=>'请选择所在城市后下单']]);
|
|
|
- // 获取城市ID
|
|
|
- $cityId = $custom['city_id'];
|
|
|
- $cityName = $City->getOne($cityId,'name');
|
|
|
- $pid = $City->getOne($cityId,'pid');
|
|
|
- $province = $City->getOne($pid,'name');
|
|
|
- // 判断选择的城市名称是不是一致
|
|
|
- if( $cityName != $addr['contact_city'] ) return json_send(['code'=>'error','msg'=>'收货地址请选择'.$province.'/'.$cityName,'data'=>['error'=>'收货地址需与您所选城市一致']]);
|
|
|
//获取团活动信息
|
|
|
$regimentActiveInfo = RegimentActive::query()
|
|
|
->where([['id','=',$regimentActiveId],['status','=',1],['start_time','<=',$time],['end_time','>=',$time]])
|