20], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => '商城ID', 'goods_id' => '商品id', 'redpack_wallet_type' => '红包类型[frozen_redpack:冻结红包,redpack:激活红包]', 'is_enable' => '是否开启:0:否,1是', 'is_percent' => '是否百分比:0:否(固定金额),1是', 'give' => '赠送红包金额', 'deduct_type' => '商品抵扣类型[1:单件抵扣,2:多件抵扣]', 'deduct_money' => '商品抵扣金额', 'is_deduct_percent' => '抵扣是否百分比[0=否,1=是]', 'status' => '状态[-1:删除;0:禁用;1启用]', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } /** * 保存设置 * @Author: lun * @DateTime: 2022/3/23 0023 14:26 * @Copyright: copyright (c) 2021 广东七件事集团 * @param $mall_id * @param $goods_id * @param $list * @return bool */ public static function setGoodsSetting($mall_id, $goods_id, $list) { try { foreach ($list as $item) { $model = self::findOne(['mall_id' => $mall_id, 'goods_id' => $goods_id, 'redpack_wallet_type' => $item['redpack_wallet_type'], 'status' => StatusEnum::ENABLED]); if (empty($model)) { $model = new self(); $model->mall_id = $mall_id; $model->goods_id = $goods_id; $model->loadDefaultValues(); } if (!$model->load($item, '') || !$model->save()) throw new Exception($model->getErrorMessage()); } return true; } catch (\Exception $e) { self::setStaticError('商品红包设置失败:' . $e->getMessage()); return false; } } }