commit
1ebc282e1b
@ -28,6 +28,6 @@ class IndexController extends BaseAdminController
|
||||
public function demo2()
|
||||
{
|
||||
$res=DemoLogic::test();
|
||||
return $this->success('成功',$res);
|
||||
return $this->success('成功');
|
||||
}
|
||||
}
|
@ -85,11 +85,6 @@ class BeforehandOrderCartInfoController extends BaseAdminController
|
||||
}
|
||||
}
|
||||
$find->source_order_info = array_values($json);
|
||||
$productPrice = StoreProduct::where('id',$res['product_id'])->value('price');
|
||||
$procurementOrder = BeforehandOrder::where('id', $find['order_id'])->find();
|
||||
$procurementOrder->total_price = bcsub($procurementOrder->total_price, bcmul($productPrice, $res['cart_num'], 2), 2);
|
||||
$procurementOrder->pay_price = $procurementOrder->total_price;
|
||||
$procurementOrder->save();
|
||||
}
|
||||
if ($find->need_num <= 0) {
|
||||
$find->delete_time = time();
|
||||
|
@ -45,8 +45,6 @@ class StoreCategoryLists extends BaseAdminDataLists implements ListsSearchInterf
|
||||
public function lists(): array
|
||||
{
|
||||
$userGroups = UserShip::field('id,title')->select()->toArray();
|
||||
$userGroups[] = ['id' => 100001, 'title' => '供货价'];
|
||||
$userGroups[] = ['id' => 100002, 'title' => '零售价'];
|
||||
return StoreCategory::where($this->searchWhere)
|
||||
->field(['id', 'pid', 'name', 'data', 'pic', 'sort', 'price_rate'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
@ -56,13 +54,21 @@ class StoreCategoryLists extends BaseAdminDataLists implements ListsSearchInterf
|
||||
$item['price_rate'] = $userGroups;
|
||||
} else {
|
||||
$priceRate = reset_index($item['price_rate'], 'id');
|
||||
unset($priceRate[100003], $priceRate[100004]);
|
||||
$temp = [];
|
||||
foreach ($userGroups as $userGroup) {
|
||||
if (!isset($priceRate[$userGroup['id']])) {
|
||||
$userGroup['rate'] = 0;
|
||||
$priceRate[] = $userGroup;
|
||||
if ($userGroup['id'] == 21 && !empty($priceRate[100001]) && empty($userGroup['rate'])) {
|
||||
$userGroup['rate'] = $priceRate[100001]['rate'];
|
||||
unset($priceRate[100001]);
|
||||
} elseif ($userGroup['id'] == 22 && !empty($priceRate[100002]) && empty($userGroup['rate'])) {
|
||||
$userGroup['rate'] = $priceRate[100002]['rate'];
|
||||
unset($priceRate[100002]);
|
||||
} else {
|
||||
$userGroup['rate'] = $priceRate[$userGroup['id']]['rate'] ?? 0;
|
||||
}
|
||||
$temp[] = $userGroup;
|
||||
}
|
||||
$item['price_rate'] = array_values($priceRate);
|
||||
$item['price_rate'] = $temp;
|
||||
}
|
||||
$item['is_children'] = StoreCategory::where('pid', $item->id)->count(); // 判断是否有子分类
|
||||
return $item->toArray();
|
||||
|
@ -183,10 +183,10 @@ class PurchaseProductOfferLogic extends BaseLogic
|
||||
'expiration_date' => $params['expiration_date'],
|
||||
]);
|
||||
// $find = StoreProductPrice::where(['offer_id' => $params['id']])->find();
|
||||
$product = StoreProduct::where('id', $offer['product_id'])->withTrashed()->field('id,store_name,top_cate_id,two_cate_id')->find();
|
||||
$product = StoreProduct::where('id', $offer['product_id'])->withTrashed()->field('id,store_name,top_cate_id,two_cate_id,cate_id')->find();
|
||||
$unit_name=StoreProductUnit::where('id', $offer['unit'])->value('name');
|
||||
$order = BeforehandOrder::where('id', $params['bhoid'])->find();
|
||||
$order->pay_price = bcadd($offer['total_price'], $order->pay_price, 2);
|
||||
$order->pay_price = PurchaseProductOffer::where('order_id', $order['id'])->sum('total_price');
|
||||
$order->total_price = $order->pay_price;
|
||||
$order->save();
|
||||
self::setProductGroupPrice($params, $product);
|
||||
@ -364,13 +364,13 @@ class PurchaseProductOfferLogic extends BaseLogic
|
||||
'update_time' => time(),
|
||||
'status' => 0,
|
||||
];
|
||||
$productCatePriceRate = StoreCategory::where('id', $product['top_cate_id'])->value('price_rate');
|
||||
$productCatePriceRate = self::getProductCatePriceRate($product);
|
||||
if (!empty($productCatePriceRate)) {
|
||||
$storeProductGroupPrice = StoreProductGroupPrice::where('product_id', $product['id'])->select()->toArray();
|
||||
$storeProductGroupPrice = reset_index($storeProductGroupPrice, 'group_id');
|
||||
$purchase=0;
|
||||
foreach ($productCatePriceRate as $k => $v) {
|
||||
if ($v['id'] == 100001) {
|
||||
if ($v['id'] == 100001 || $v['id'] == 21) {
|
||||
//供货
|
||||
$data['purchase_lv'] = bcdiv($v['rate'], 100, 2);
|
||||
$data['purchase'] = bcmul($params['purchase'], bcadd($data['purchase_lv'], 1, 2), 2);
|
||||
@ -384,7 +384,7 @@ class PurchaseProductOfferLogic extends BaseLogic
|
||||
$data['cost_lv'] = bcdiv($v['rate'], 100, 2);
|
||||
$data['cost'] = bcmul($purchase, bcadd($data['cost_lv'], 1, 2), 2);
|
||||
continue;
|
||||
}elseif ($v['id'] == 100002 &&$purchase>0) {
|
||||
}elseif (($v['id'] == 100002 || $v['id'] == 22) &&$purchase>0) {
|
||||
//零售
|
||||
$data['price_lv'] = bcdiv($v['rate'], 100, 2);
|
||||
$data['price'] = bcmul($purchase, bcadd($data['price_lv'], 1, 2), 1);
|
||||
@ -400,7 +400,7 @@ class PurchaseProductOfferLogic extends BaseLogic
|
||||
}
|
||||
continue;
|
||||
}
|
||||
$baseRate = 100 + $v['rate'];
|
||||
$baseRate = ($v['id'] == 100001 || $v['id'] == 21) ? 100 : 100 + $v['rate'];
|
||||
if($purchase>0){
|
||||
$item = [
|
||||
'product_id' => $product['id'],
|
||||
@ -427,4 +427,18 @@ class PurchaseProductOfferLogic extends BaseLogic
|
||||
StoreProductPrice::create($data);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getProductCatePriceRate($product)
|
||||
{
|
||||
$productCatePriceRate = StoreCategory::where('id', $product['cate_id'])->value('price_rate');
|
||||
if (!empty($productCatePriceRate)) {
|
||||
return $productCatePriceRate;
|
||||
}
|
||||
$productCatePriceRate = StoreCategory::where('id', $product['two_cate_id'])->value('price_rate');
|
||||
if (!empty($productCatePriceRate)) {
|
||||
return $productCatePriceRate;
|
||||
}
|
||||
return StoreCategory::where('id', $product['top_cate_id'])->value('price_rate');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,12 +29,17 @@ class StoreCategoryLogic extends BaseLogic
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$priceRate = [];
|
||||
foreach ($params['price_rate'] as $v) {
|
||||
$priceRate[$v['id']] = $v;
|
||||
}
|
||||
StoreCategory::create([
|
||||
'pid' => $params['pid'],
|
||||
'name' => $params['name'],
|
||||
'data' => $params['data'],
|
||||
'pic' => $params['pic'],
|
||||
'sort' => $params['sort']
|
||||
'sort' => $params['sort'],
|
||||
'price_rate' => array_values($priceRate)
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
@ -57,13 +62,17 @@ class StoreCategoryLogic extends BaseLogic
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$priceRate = [];
|
||||
foreach ($params['price_rate'] as $v) {
|
||||
$priceRate[$v['id']] = $v;
|
||||
}
|
||||
StoreCategory::where('id', $params['id'])->update([
|
||||
'pid' => $params['pid'],
|
||||
'name' => $params['name'],
|
||||
'data' => $params['data'],
|
||||
'pic' => $params['pic'],
|
||||
'sort' => $params['sort'],
|
||||
'price_rate' => $params['price_rate']
|
||||
'price_rate' => array_values($priceRate)
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
|
@ -106,8 +106,6 @@ class StoreProductGroupPriceLogic extends BaseLogic
|
||||
$arr=StoreProductGroupPrice::where('product_id',$params['product_id'])->select()->toArray();
|
||||
$purchase=StoreProduct::where('id',$params['product_id'])->value('purchase');
|
||||
$arr_two=UserShip::where('id','>',0)->select()->toArray();
|
||||
$arr_two[] = ['id' => 100001, 'title' => '供货价'];
|
||||
$arr_two[] = ['id' => 100002, 'title' => '零售价'];
|
||||
foreach ($arr_two as $k=>$v){
|
||||
$arr_two[$k]['purchase']=$purchase;
|
||||
$arr_two[$k]['product_id']=$params['product_id'];
|
||||
|
Loading…
x
Reference in New Issue
Block a user