| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace common\expand\alipay\order\notice\validate;
- use common\expand\alipay\AlipayValidateInterface;
- use common\models\order\Order;
- use Yii;
- class NoticeValidate implements AlipayValidateInterface
- {
- protected $data = [];
- public function __construct(array $data)
- {
- $this->data = $data;
- }
- /**
- * @return bool|array
- */
- public function valid()
- {
- if (empty($this->data['id'])) {
- Yii::error(sprintf("%s ID不能为空", __CLASS__));
- return false;
- }
- $mall_id = Order::find()->where(['id' => $this->data['id']])->select('mall_id')->scalar();
- if (!$mall_id) {
- Yii::error(sprintf("%s 订单不存在 %d", __CLASS__, $this->data['id']));
- return false;
- }
- // 判断是否有支付宝小程序
- $app_id = Yii::$app->services->setting->mall->get($mall_id, "alipay_mini.app_id");
- if (!$app_id) {
- Yii::error(sprintf("%s 不支持支付宝小程序 %d", __CLASS__, $mall_id));
- return false;
- }
- // 判断是否有开启通知
- if (!Yii::$app->services->setting->mall->get($mall_id, "notice_alipay.{$this->data['step_key']}")) {
- Yii::error(sprintf("%s 未开启通知 %d %s", __CLASS__, $mall_id, $this->data['step_key']));
- return false;
- }
- return array_merge($this->data, [
- 'mall_id' => $mall_id,
- 'ali_mini_app_id' => $app_id,
- ]);
- }
- }
|