| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace common\helpers;
- use common\enums\PayTypeEnum;
- use common\models\common\PaymentTradeGroupOrder;
- use common\models\common\PaymentTradeOrder;
- class PaymentTypeHelper
- {
- /**
- * 获取订单支付方式
- * @param string $order_no
- * @param int $payment_type
- * @return array
- */
- public static function getPaymentTypes(string $order_no, int $payment_type)
- {
- $pay_types = PayTypeEnum::getMap();
- $payment_types = [];
- if ($payment_type == PayTypeEnum::MIXED) {
- /**
- * @var $each PaymentTradeGroupOrder
- */
- foreach (PaymentTradeGroupOrder::find()->where(['order_no' => $order_no])->each() as $each) {
- $payment_types[] = [
- 'title' => $pay_types[$each->pay_type] ?? '未知支付',
- 'pay_money' => bcmul($each->pay_fee, 1, 2)
- ];
- }
- } else {
- $payment_types[] = [
- 'title' => $pay_types[$payment_type] ?? '未知支付',
- 'pay_money' => bcmul((float) PaymentTradeOrder::find()->where(['order_no' => $order_no])
- ->select('pay_fee')->scalar(), 1, 2)
- ];
- }
- return $payment_types;
- }
- }
|