255], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => '商城id', 'user_id' => '补货代理商用户id', 'trade_id' => '支付流水记录 id', 'pay_money' => '支付金额', 'order_no' => '补货订单编号', 'trade_no' => '支付流水号', 'is_pay' => '是否支付', 'goods_id' => '商品id', 'num' => '补货商品数量', 'status' => '状态[-1:删除;0:禁用;1启用]', 'created_at' => 'Created At', 'updated_at' => 'Updated At', 'reward_unit_price' => 'Reward Unit Price', ]; } public function getUser() { return $this->hasOne(User::class, ['id' => 'user_id'])->select(['id', 'nickname', 'avatar_url', 'mobile']); } public function getGoods() { return $this->hasOne(Goods::class, ['id' => 'goods_id'])->select(['id', 'goods_name', 'cover_pic']); } public static function setData(int $mall_id, array $data) { if (!empty($data['id'])) { $model = self::findOne(['mall_id' => $mall_id, 'status' => StatusEnum::ENABLED, 'id' => $data['id']]); if (empty($model)) { self::$static_error = '数据异常'; return false; } } else { $model = new self(); $model->loadDefaultValues(); $model->mall_id = $mall_id; } foreach ($data as $key => $val) { $model->$key = $val; } // dd($model); if (!$model->save()) { self::$static_error = '保存数据失败:' . $model->getErrorMessage(); return false; } return $model; } public static function check($params): bool { $order_no_arr = $params['order_no_arr']; $payment_order_list = $params['payment_order_list']; $counts = self::find()->where(['order_no'=>$order_no_arr,'is_pay'=>0])->count(); if ($counts != count($payment_order_list)) { self::$static_error = '补货订单不一致'; return false; } return true; } }