ScanPayClass.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace bizGhs\order\classes;
  3. use common\components\dict;
  4. use common\components\util;
  5. use bizGhs\base\classes\BaseClass;
  6. class ScanPayClass extends BaseClass
  7. {
  8. public static $baseFile = '\bizGhs\order\models\ScanPay';
  9. public static function getPayList($where)
  10. {
  11. return self::getList('*', $where, 'addTime DESC,id DESC');
  12. }
  13. public static function getDetail($id, $mainId)
  14. {
  15. $order = self::getById($id, true);
  16. if (empty($order)) {
  17. util::fail('没有找到流水');
  18. }
  19. if ($order->mainId != $mainId) {
  20. util::fail('没有权限');
  21. }
  22. $actPrice = $order->actPrice ?? 0;
  23. $tkPrice = $order->tkPrice ?? 0;
  24. $canRefundPrice = bcsub($actPrice, $tkPrice, 2);
  25. if ($canRefundPrice < 0) {
  26. $canRefundPrice = 0;
  27. }
  28. $refundList = ScanPayRefundClass::getAllByCondition(['scanPayId' => $id], 'id DESC', '*');
  29. $payWay = $order->payWay ?? 0;
  30. $payWayMap = dict::getDict('payWay');
  31. $payWayName = '未知';
  32. if ($payWay == ($payWayMap['wxPay'] ?? 0)) {
  33. $payWayName = '微信';
  34. } elseif ($payWay == ($payWayMap['alipay'] ?? 1)) {
  35. $payWayName = '支付宝';
  36. }
  37. return [
  38. 'info' => $order,
  39. 'refundList' => $refundList ?: [],
  40. 'canRefundPrice' => floatval($canRefundPrice),
  41. 'payWayName' => $payWayName,
  42. ];
  43. }
  44. }