一键设置代理价格
This commit is contained in:
@@ -9,6 +9,7 @@ use app\agent\model\Product as PoductModel;
|
||||
use app\agent\model\ProductPackage as PoductPackageModel;
|
||||
use app\agent\model\AgentPrice as AgentPriceModel;
|
||||
use app\agent\model\AgentScore as AgentScoreModel;
|
||||
use app\agent\model\ProductPriceDiscount as ProductPriceDiscountModel;
|
||||
|
||||
class Agent extends Controller
|
||||
{
|
||||
@@ -140,6 +141,60 @@ class Agent extends Controller
|
||||
echo json_encode($retuen_data);
|
||||
}
|
||||
|
||||
//按照折扣设置最低价
|
||||
public function setPriceDiscount()
|
||||
{
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
$price_model = new AgentPriceModel;
|
||||
$discount = new ProductPriceDiscountModel;
|
||||
$package_model = new PoductPackageModel;
|
||||
$product_model = new PoductModel;
|
||||
|
||||
$discount_list = $discount->getList(['SchemeId'=>$data['schemeId']]);
|
||||
$package_list = [];
|
||||
$pack_list = $package_model->getList();
|
||||
foreach ($pack_list as $info){
|
||||
$package_list[$info['Id']] = $info;
|
||||
}
|
||||
|
||||
$product_list = [];
|
||||
$p_list = $product_model->getList();
|
||||
foreach ($p_list as $info){
|
||||
$product_list[$info['Id']] = $info;
|
||||
}
|
||||
|
||||
foreach ($discount_list as $info){
|
||||
$update_data = [
|
||||
'product_id' => $info['ProductId'],
|
||||
'package_id' => $info['PackageId'],
|
||||
'agent_id' => $data['userId'],
|
||||
'price' => $package_list[$info['PackageId']]['Price'] * $info['BuyPriceDiscount']/100,
|
||||
'refund' => $product_list[$info['ProductId']]['RefundDayPrice'] * $info['RefundDayPriceDiscount']/100,
|
||||
];
|
||||
|
||||
$where = [
|
||||
'package_id' => $info['PackageId'],
|
||||
'agent_id' => $data['userId'],
|
||||
];
|
||||
|
||||
$agent_price = $price_model->getOne($where);
|
||||
|
||||
// die;
|
||||
|
||||
if(empty($agent_price)){
|
||||
$price_model->add($update_data);
|
||||
} else {
|
||||
$price_model->updateOne($where,$update_data);
|
||||
}
|
||||
}
|
||||
|
||||
$retuen_data = [
|
||||
'Code' => 10000,
|
||||
'Message' => '',
|
||||
];
|
||||
echo json_encode($retuen_data);
|
||||
}
|
||||
|
||||
//是否启用修改后的价格
|
||||
public function setPriceStatus()
|
||||
{
|
||||
|
||||
10
app/agent/model/ProductPriceDiscount.php
Normal file
10
app/agent/model/ProductPriceDiscount.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
use fastphp\base\Model;
|
||||
|
||||
class ProductPriceDiscount extends Model
|
||||
{
|
||||
protected $table = 'product_price_discount';
|
||||
}
|
||||
Reference in New Issue
Block a user