public function handle($data) { parent::handle($data); # handle the wechat message LogUtil::info(['channel weconnect event' => $data], 'channel-webhook'); if (empty($data)) { throw new BadRequestHttpException(Yii::t('channel', 'parameter_format_error')); } $data = $data['data']; $requiredParameters = ['outTradeNo', 'tradeNo', 'tradeStatus']; ValidatorUtil::fieldsRequired($data, $requiredParameters); $tradePayment = TradePayment::findOne(['orderNumber' => $data['outTradeNo']]); LogUtil::info(['tradePayment' => $tradePayment->toArray()], 'channel-webhook'); if (empty($tradePayment)) { throw new InvalidParameterException(Yii::t('common', 'data_error')); } $memberId = $tradePayment['user']['memberId']; $couponId = $tradePayment['couponId']; LogUtil::info(['memberId' => $memberId, 'couponId' => $couponId], 'channel-webhook'); if ($data['tradeStatus'] == 'PAY_SUCCESS') { $tradePayment->status = TradePayment::STATUS_PAID; $tradePayment->realAmount = intval($data['totalFee']) / 100; // Make coupon used if (!empty($couponId)) { Yii::$app->service->coupon->makeUsed($memberId, $couponId); } } else { if ($data['tradeStatus'] == 'PAY_ERROR') { $tradePayment->status = TradePayment::STATUS_FAILED; } } $tradePayment->paymentTime = MongodbUtil::msTimetamp2MongoDate($data['paymentTime']); $tradePayment->transactionId = $data['tradeNo']; return $tradePayment->save(true, ['paymentTime', 'status', 'transactionId', 'realAmount']); }
public function handle($data) { parent::handle($data); LogUtil::info(['data' => $data], 'test'); }
public function handle($data) { parent::handle($data); }