feat: 修改了用户船运和商品列表API逻辑,调整了用户船运特权价格计算方式,并优化了代码结构。
This commit is contained in:
parent
0db6af6783
commit
10fcdd0749
app
api
common/logic
@ -66,7 +66,7 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
|
||||
$off_activity = Config::where('name', 'off_activity')->value('value');
|
||||
$user_ship = User::where('id', $userId)->value('user_ship');
|
||||
$field='product_id,image,price,cost,store_name,unit,delete_time,vip_price';
|
||||
if (in_array($user_ship, [4, 5, 6, 7])) {
|
||||
if (in_array($user_ship, [4, 6, 7])) {
|
||||
$field='product_id,image,cost price,cost,store_name,unit,delete_time,vip_price';
|
||||
}
|
||||
$this->user_ship=$user_ship;
|
||||
@ -76,11 +76,13 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
|
||||
->field($field)
|
||||
->withTrashed()
|
||||
->find();
|
||||
|
||||
if ($find) {
|
||||
if($off_activity==1){
|
||||
$this->activity_price = bcadd(bcmul($find['cost'],$item['cart_num'], 2), $this->activity_price, 2);
|
||||
}
|
||||
if ($off_activity == 0 && $user_ship == 5 && $item['top_cate_id'] == 15189) {
|
||||
$find['price']=$find['cost'];
|
||||
}
|
||||
$item['goods_total_price'] = bcmul($item['cart_num'], $find['price'], 2);
|
||||
$this->total_price = bcadd($this->total_price, $item['goods_total_price'], 2);
|
||||
$item['imgs'] = $find['image'];
|
||||
|
@ -79,23 +79,23 @@ class ProductLists extends BaseApiDataLists implements ListsSearchInterface, Lis
|
||||
} else {
|
||||
$order = [$field => $order];
|
||||
}
|
||||
$fields = 'id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock';
|
||||
$fields = 'id,product_id,top_cate_id,cate_id,store_name,cost,store_id,vip_price,purchase,price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock';
|
||||
$off_activity = Config::where('name', 'off_activity')->value('value');
|
||||
if($off_activity==1){
|
||||
$tag='赠10%品牌礼品券';
|
||||
}else{
|
||||
$tag='';
|
||||
if ($off_activity == 1) {
|
||||
$tag = '赠10%品牌礼品券';
|
||||
} else {
|
||||
$tag = '';
|
||||
}
|
||||
$uid=0;
|
||||
if($this->request->get('uid',0)>0){
|
||||
$uid=$this->request->get('uid',0);
|
||||
}elseif( $this->userId > 0){
|
||||
$uid=$this->userId;
|
||||
$uid = 0;
|
||||
if ($this->request->get('uid', 0) > 0) {
|
||||
$uid = $this->request->get('uid', 0);
|
||||
} elseif ($this->userId > 0) {
|
||||
$uid = $this->userId;
|
||||
}
|
||||
if ($uid>0) {
|
||||
if ($uid > 0) {
|
||||
$user_ship = User::where('id', $uid)->value('user_ship');
|
||||
if (in_array($user_ship, [4, 5, 6, 7])) {
|
||||
$fields = 'id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,cost price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock';
|
||||
if (in_array($user_ship, [4, 6, 7])) {
|
||||
$fields = 'id,product_id,top_cate_id,cate_id,store_name,cost,store_id,vip_price,purchase,cost price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock';
|
||||
}
|
||||
}
|
||||
$this->off_activity = $off_activity;
|
||||
@ -106,9 +106,11 @@ class ProductLists extends BaseApiDataLists implements ListsSearchInterface, Lis
|
||||
->with(['className', 'unitName'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order($order)
|
||||
// ->page($this->limitOffset +1,$this->limitLength)
|
||||
->select()->each(function ($item) use($tag){
|
||||
$item['tag']=$tag;
|
||||
->select()->each(function ($item) use ($tag, $off_activity, $user_ship) {
|
||||
if ($off_activity == 0 && $user_ship == 5 && $item['top_cate_id'] == 15189) {
|
||||
$item['price'] = $item['cost'];
|
||||
}
|
||||
$item['tag'] = $tag;
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
|
@ -108,11 +108,14 @@ class OrderLogic extends BaseLogic
|
||||
}
|
||||
unset($cart_select[$k]['id']);
|
||||
$cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价
|
||||
if ($off_activity == 1 || ($user != null && in_array($user['user_ship'], [4, 5, 6, 7]))) {
|
||||
if ($off_activity == 1 || ($user != null && in_array($user['user_ship'], [4, 6, 7]))) {
|
||||
$price = $find['cost'];
|
||||
} else {
|
||||
$price = $find['price'];
|
||||
}
|
||||
if($off_activity==0 && $user['user_ship']==5 && $find['top_cate_id']==15189){
|
||||
$price=$find['cost'];
|
||||
}
|
||||
$cart_select[$k]['price'] = $price;
|
||||
$cart_select[$k]['cost'] = $find['cost'];
|
||||
$cart_select[$k]['vip'] = 0;
|
||||
|
@ -62,7 +62,7 @@ class UserSignLogic extends BaseLogic
|
||||
return false;
|
||||
}
|
||||
$count = UserRecharge::where(['uid'=>$order->uid,'paid'=>YesNoEnum::YES])->count();
|
||||
if ($count ==1 && $user_ship>0) {
|
||||
if ($count ==1 && in_array($user_ship,[1,2,3])) {
|
||||
//首充
|
||||
$write = self::write($order, $total_vip, 0, 1, 9);
|
||||
self::write_log($write, $total_vip, 0, 7);
|
||||
|
Loading…
x
Reference in New Issue
Block a user