<?php

use App\Base\Base;
use App\Services\Marketing\MarketingGoodsService;
use App\Exception\custom\DistributorException;
use Helpers\Aes;
class MarketingGoodsController extends Base
{
    
    /**
     * 获取全部生效营销活动商品列表
     *
     */
    public function marketing_goods_listAction()
    {
        $params = $this->params;

        $list = MarketingGoodsService::marketingGoodsList($params);
        $this->success($list);
    }

    public function generate_share_goodsAction()
    {
        $params = $this->params;
        $userId = !empty($params['user_id']) ? $params['user_id'] : '';
        $marketingId = !empty($params['marketing_id']) ? $params['marketing_id'] : '';
        $goodsSkuId = !empty($params['goods_sku_id']) ? $params['goods_sku_id'] : '';
        $content = $userId .'_' .$marketingId . '_' .$goodsSkuId;
       

        if (empty($userId)) {
             throw new DistributorException(['cus'=>14]);
        }

        if (empty($marketingId)) {
             throw new DistributorException(['cus'=>15]);
        }

        if (empty($goodsSkuId)) {
             throw new DistributorException(['cus'=>16]);
        }

        $goodsShareId = Aes::encrypt($content); 
        $data['goods_share_id'] = $goodsShareId;
        $data['share_img_url'] = '';
        $result = ['result' => $data];
        $this->success($result);
    }
    
 

}