|
|
@@ -43,6 +43,10 @@ class GoodsLogic extends BaseLogic
|
|
|
{
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
+ if((!$params['type'] || !$params['rate']) && $params['goods_status']==1){
|
|
|
+ throw new Exception('商品规格的绩效未配置,不允许上架');
|
|
|
+ }
|
|
|
+
|
|
|
$params['goods_category_id'] = end($params['goods_category_ids']);
|
|
|
if ($params['is_type'] == 1) {
|
|
|
$params['is_agent'] = 1;
|
|
|
@@ -54,7 +58,7 @@ class GoodsLogic extends BaseLogic
|
|
|
$params['is_agent'] = 0;
|
|
|
$params['is_activity'] = 0;
|
|
|
}
|
|
|
- Goods::create([
|
|
|
+ $goods = Goods::create([
|
|
|
'goods_category_ids' => $params['goods_category_ids'],
|
|
|
'category_type' => GoodsCategory::where('id',$params['goods_category_id'])->value('category_type'),
|
|
|
'goods_category_id' => $params['goods_category_id'],
|
|
|
@@ -86,8 +90,34 @@ class GoodsLogic extends BaseLogic
|
|
|
'is_activity' => $params['is_activity'] ??0,
|
|
|
'property_activity_id' => $params['property_activity_id'] ??0,
|
|
|
'labels' => (isset($params['labels']) && $params['labels'])?implode(',',$params['labels']):'',
|
|
|
+ 'activity_service_fee' => $params['activity_service_fee'] ??'',
|
|
|
]);
|
|
|
|
|
|
+ //更新绩效规则
|
|
|
+ if(in_array($params['type'],[0,1,2])){
|
|
|
+ // 0-1
|
|
|
+ if($params['rate']>1){
|
|
|
+ throw new Exception('商品绩效比率不能大于1');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(in_array($params['type'],[3])){
|
|
|
+ // ≥1
|
|
|
+ if($params['rate']<1){
|
|
|
+ throw new Exception('金额不能小于1');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $rule = PerformanceRules::where(['goods_id'=>$goods->id])->findOrEmpty();
|
|
|
+ if(!$rule->isEmpty()){
|
|
|
+ $rule->type = $params['type'];
|
|
|
+ $rule->rate = $params['rate'];
|
|
|
+ }else{
|
|
|
+ $rule = new PerformanceRules();
|
|
|
+ $rule->goods_id = $goods->id;
|
|
|
+ $rule->type = $params['type'];
|
|
|
+ $rule->rate = $params['rate'];
|
|
|
+ }
|
|
|
+ $rule->save();
|
|
|
+
|
|
|
Db::commit();
|
|
|
return true;
|
|
|
} catch (\Exception $e) {
|
|
|
@@ -157,6 +187,7 @@ class GoodsLogic extends BaseLogic
|
|
|
'is_activity' => $params['is_activity'] ??0,
|
|
|
'property_activity_id' => $params['property_activity_id'] ??0,
|
|
|
'labels' => (isset($params['labels']) && $params['labels'])?implode(',',$params['labels']):'',
|
|
|
+ 'activity_service_fee' => $params['activity_service_fee'] ??'',
|
|
|
]);
|
|
|
|
|
|
//更新绩效规则
|