'ID', 'mall_id' => '商城ID', 'user_id' => '用户ID', 'goods_id' => '购买过的商品id', 'finish_order_money' => '完成订单支付总金额,单位:元', 'month' => '月份,如:202207', 'is_settlement' => '是否已结算[0=否,1=是]', 'status' => '状态[-1:删除;0:禁用;1启用]', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } /** * 保存数据 * @Author: lun * @DateTime: 2022/7/10 0010 16:24 * @Copyright: copyright (c) 2021 广东七件事集团 * @param $params * @return bool */ public static function setData($params) { try { $month = date('Ym', time()); $model = self::findOne(['mall_id' => $params['mall_id'], 'user_id' => $params['user_id'], 'goods_id' => $params['goods_id'], 'month' => $month, 'status' => StatusEnum::ENABLED]); if (empty($model)) { $model = new self(); $model->mall_id = $params['mall_id']; $model->user_id = $params['user_id']; $model->goods_id = $params['goods_id']; $model->month = $month; $model->loadDefaultValues(); } if (!empty($params['goods_price'])) $model->finish_order_money += $params['goods_price']; if (!$model->save()) throw new Exception($model->getErrorMessage()); return true; } catch (\Exception $e) { self::setStaticError($e->getMessage()); return false; } } }