feat: 修改商品列表和订单逻辑,根据配置计算价格和抵扣金额
This commit is contained in:
parent
4a3ba92035
commit
17697bf361
@ -10,6 +10,7 @@ use app\common\model\store_branch_product\StoreBranchProduct;
|
|||||||
use app\common\model\store_product\StoreProduct;
|
use app\common\model\store_product\StoreProduct;
|
||||||
use app\common\lists\ListsSearchInterface;
|
use app\common\lists\ListsSearchInterface;
|
||||||
use app\common\model\cate\Cate;
|
use app\common\model\cate\Cate;
|
||||||
|
use app\common\model\Config;
|
||||||
//use app\common\model\goods\GoodsLabel;
|
//use app\common\model\goods\GoodsLabel;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
|
||||||
@ -102,11 +103,16 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
|
|||||||
$this->searchWhere[] = ['cate_id','=',$class_all];
|
$this->searchWhere[] = ['cate_id','=',$class_all];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$off_activity=Config::where('name','off_activity')->value('value');
|
||||||
|
if($off_activity==1){
|
||||||
|
$field='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';
|
||||||
|
}else{
|
||||||
|
$field='id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,price,bar_code,image,sales,store_info,delete_time,unit,batch';
|
||||||
|
}
|
||||||
$this->searchWhere[] = ['status', '=', 1];
|
$this->searchWhere[] = ['status', '=', 1];
|
||||||
$this->searchWhere[] = ['stock', '>', 0];
|
$this->searchWhere[] = ['stock', '>', 0];
|
||||||
return StoreBranchProduct::where($this->searchWhere)
|
return StoreBranchProduct::where($this->searchWhere)
|
||||||
->field(['id', 'product_id', 'cate_id', 'store_name', 'cost', 'store_id','vip_price','purchase', 'price', 'bar_code', 'image', 'sales', 'store_info', 'delete_time', 'unit', 'batch'])
|
->field($field)
|
||||||
->with(['className', 'unitName'])
|
->with(['className', 'unitName'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order($this->sortOrder)
|
->order($this->sortOrder)
|
||||||
|
@ -10,6 +10,7 @@ use app\common\logic\BaseLogic;
|
|||||||
use app\common\logic\CapitalFlowLogic;
|
use app\common\logic\CapitalFlowLogic;
|
||||||
use app\common\logic\PayNotifyLogic;
|
use app\common\logic\PayNotifyLogic;
|
||||||
use app\common\logic\StoreFinanceFlowLogic;
|
use app\common\logic\StoreFinanceFlowLogic;
|
||||||
|
use app\common\model\Config;
|
||||||
use app\common\model\dict\DictData;
|
use app\common\model\dict\DictData;
|
||||||
use app\common\model\dict\DictType;
|
use app\common\model\dict\DictType;
|
||||||
use app\common\model\order\Cart;
|
use app\common\model\order\Cart;
|
||||||
@ -73,9 +74,14 @@ class OrderLogic extends BaseLogic
|
|||||||
self::$activity_price = 0; //活动减少
|
self::$activity_price = 0; //活动减少
|
||||||
self::$store_price = 0; //门店零售价
|
self::$store_price = 0; //门店零售价
|
||||||
/** 计算价格 */
|
/** 计算价格 */
|
||||||
|
$off_activity=Config::where('name','off_activity')->value('value');
|
||||||
|
if($off_activity==1){
|
||||||
|
$field='id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id';
|
||||||
|
}else{
|
||||||
|
$field='id branch_product_id,store_name,image,unit,cost price,vip_price,cost,purchase,product_id';
|
||||||
|
}
|
||||||
foreach ($cart_select as $k => $v) {
|
foreach ($cart_select as $k => $v) {
|
||||||
$find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field('id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id')->withTrashed()->find();
|
$find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field($field)->withTrashed()->find();
|
||||||
if (!$find) {
|
if (!$find) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -86,18 +92,20 @@ class OrderLogic extends BaseLogic
|
|||||||
$cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价
|
$cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价
|
||||||
$cart_select[$k]['deduction_price'] =self::$activity_price;//抵扣金额
|
$cart_select[$k]['deduction_price'] =self::$activity_price;//抵扣金额
|
||||||
$cart_select[$k]['vip'] = 0;
|
$cart_select[$k]['vip'] = 0;
|
||||||
if ($user && $user['user_ship'] == 1) {
|
if($off_activity!=1){
|
||||||
//更新 会员为1的时候原价减去会员价
|
if ($user && $user['user_ship'] == 1) {
|
||||||
$deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$v['cart_num'],2);
|
//更新 会员为1的时候原价减去会员价
|
||||||
$cart_select[$k]['deduction_price'] =$deduction_price_count;
|
$deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$v['cart_num'],2);
|
||||||
self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2);
|
$cart_select[$k]['deduction_price'] =$deduction_price_count;
|
||||||
$cart_select[$k]['vip'] =1;
|
self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2);
|
||||||
}
|
$cart_select[$k]['vip'] =1;
|
||||||
if ($user && $user['user_ship'] == 4) {
|
}
|
||||||
//更新 为4商户的时候减去商户价格
|
if ($user && $user['user_ship'] == 4) {
|
||||||
$deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$v['cart_num'],2);
|
//更新 为4商户的时候减去商户价格
|
||||||
$cart_select[$k]['deduction_price'] =$deduction_price_count;
|
$deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$v['cart_num'],2);
|
||||||
self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2);
|
$cart_select[$k]['deduction_price'] =$deduction_price_count;
|
||||||
|
self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//利润
|
//利润
|
||||||
|
Loading…
x
Reference in New Issue
Block a user