|
|
@@ -2,8 +2,10 @@
|
|
|
namespace app\api\logic;
|
|
|
|
|
|
use app\common\logic\BaseLogic;
|
|
|
+use app\common\model\external\ExternalPlatformGoods;
|
|
|
use app\common\model\goods\Goods;
|
|
|
use app\common\model\goods_category\GoodsCategory;
|
|
|
+use app\common\model\works\ServiceWork;
|
|
|
use think\facade\Db;
|
|
|
|
|
|
|
|
|
@@ -23,9 +25,20 @@ class GoodsLogic extends BaseLogic
|
|
|
* @author whitef
|
|
|
* @date 2022/9/20 17:09
|
|
|
*/
|
|
|
- public static function detail($id,$type){
|
|
|
+ public static function detail($id,$type,$userId = 0,$service_work_id = 0){
|
|
|
+ $where = [];
|
|
|
if($type == 'category'){
|
|
|
- $goods = Goods::where(['goods_category_id'=>$id,'user_id'=>0,'is_agent'=>0,'is_activity'=>0,'platform_value'=>0])->visible([
|
|
|
+ $where[] = ['goods_category_id','=',$id];
|
|
|
+ $where[] = ['user_id','=',0];
|
|
|
+ $where[] = ['is_agent','=',0];
|
|
|
+ $where[] = ['is_activity','=',0];
|
|
|
+ if($service_work_id > 0){
|
|
|
+ $platform_value = ServiceWork::where('id',$service_work_id)->value('external_platform_id');
|
|
|
+ $where[] = ['platform_value','=',$platform_value];
|
|
|
+ }else{
|
|
|
+ $where[] = ['platform_value','=',0];
|
|
|
+ }
|
|
|
+ $goods = Goods::where($where)->visible([
|
|
|
'id','goods_image','goods_name','goods_banners','good_unit','sell_num','base_service_fee',
|
|
|
'service_total','service_fee','service_image','fee_schedule','warranty_period','goods_payment_type','goods_category_id'
|
|
|
])->select()->toArray();
|
|
|
@@ -40,6 +53,9 @@ class GoodsLogic extends BaseLogic
|
|
|
if(!empty($goods)){
|
|
|
$data = [];
|
|
|
foreach ($goods as $key => $value) {
|
|
|
+ if($service_work_id > 0){
|
|
|
+ $value['service_fee'] = self::getPlatformServiceFee($platform_value,$value['id'])?:$value['service_fee'];
|
|
|
+ }
|
|
|
if($value['goods_payment_type'] == '2'){
|
|
|
$coupon = ($value['service_total']-$value['service_fee'])>0?'立减'.$value['service_total']-$value['service_fee']:'';
|
|
|
}
|
|
|
@@ -191,4 +207,13 @@ class GoodsLogic extends BaseLogic
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public static function getPlatformServiceFee($platform_value,$goods_id)
|
|
|
+ {
|
|
|
+ return ExternalPlatformGoods::where('external_platform_id',$platform_value)->where('goods_id',$goods_id)->value('service_fee');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|