feat: 添加对店铺配置的校验功能
This commit is contained in:
parent
1648d48c15
commit
4fd112b900
@ -4,6 +4,7 @@ namespace app\admin\logic\store_order_cart_info;
|
||||
|
||||
use app\admin\logic\statistic\TradeStatisticLogic;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
@ -29,10 +30,18 @@ class StoreOrderCartInfoLogic extends BaseLogic
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
|
||||
$cart_info = StoreOrderCartInfo::where('oid', $params['oid'])->find();
|
||||
if($cart_info['is_pay']==1){
|
||||
throw new BusinessException('已支付订单无法追加');
|
||||
}
|
||||
$value=DictData::where('type_value','vendors_store')->column('value');
|
||||
if(!$value){
|
||||
throw new BusinessException('请先配置店铺');
|
||||
}
|
||||
if(!in_array($cart_info['store_id'],$value)){
|
||||
throw new BusinessException('该订单不属于可设置店铺');
|
||||
}
|
||||
foreach($params['product_arr'] as $k=>$v){
|
||||
$find=StoreProduct::where('id',$v['product_id'])->find();
|
||||
|
||||
@ -97,6 +106,13 @@ class StoreOrderCartInfoLogic extends BaseLogic
|
||||
if($find['is_pay']==1){
|
||||
throw new BusinessException('已支付订单无法编辑');
|
||||
}
|
||||
$value=DictData::where('type_value','vendors_store')->column('value');
|
||||
if(!$value){
|
||||
throw new BusinessException('请先配置店铺');
|
||||
}
|
||||
if(!in_array($find['store_id'],$value)){
|
||||
throw new BusinessException('该订单不属于可设置店铺');
|
||||
}
|
||||
$find->cart_num = $params['cart_num'];
|
||||
$find->total_price = bcmul($params['cart_num'], $find->price, 2);
|
||||
$find->save();
|
||||
@ -128,6 +144,13 @@ class StoreOrderCartInfoLogic extends BaseLogic
|
||||
if($find['is_pay']==1){
|
||||
throw new BusinessException('已支付订单无法删除');
|
||||
}
|
||||
$value=DictData::where('type_value','vendors_store')->column('value');
|
||||
if(!$value){
|
||||
throw new BusinessException('请先配置店铺');
|
||||
}
|
||||
if(!in_array($find['store_id'],$value)){
|
||||
throw new BusinessException('该订单不属于可设置店铺');
|
||||
}
|
||||
$find->delete_time=time();
|
||||
$find->save();
|
||||
$total_price = StoreOrderCartInfo::where('oid', $find['oid'])->sum('total_price');
|
||||
|
Loading…
x
Reference in New Issue
Block a user