'ID', 'mall_id' => 'Mall ID', 'mch_id' => 'Mch ID', 'goods_id' => '商品id', 'content' => '内容', 'status' => '状态[0禁用 1启用 -1删除]', 'created_at' => '创建时间', 'updated_at' => '修改时间', ]; } public static function setData(array $params) { try { if (!empty($params['mall_id'])&&!empty($params['mch_id'])&&!empty($params['goods_id'])) { $model = self::findOne(['mall_id' => $params['mall_id'], 'mch_id' => $params['mch_id'], 'goods_id' => $params['goods_id'], 'status' => [StatusEnum::ENABLED]]); if (empty($model)) { $model = new self(); $model->loadDefaultValues(); } } else { $model = new self(); $model->loadDefaultValues(); } if (!$model->load($params, '') || !$model->save()) { throw new \Exception($model->getErrorMessage()); } return $model; } catch (\Exception $e) { self::$static_error = $e->getMessage() . $e->getLine() . $e->getFile(); return false; } } /** * 商品是否参与渠道分红 * * @param int $mallId * @param int $mchId * @param int $goodsId * * @return bool */ public static function isParticipateAgent(int $mallId, int $mchId, int $goodsId) { $content = MchGoodsModel::find() ->where([ 'mch_id' => $mchId, 'mall_id' => $mallId, 'goods_id' => $goodsId, 'status' => StatusEnum::ENABLED ]) ->select('content') ->scalar(); $content = json_decode($content, true); $agent = json_decode($content['Agent'], true); return !isset($agent['distribution_setting']['is_participate']) || !empty($agent['distribution_setting']['is_participate']); } }