Payment.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | A3Mall
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2020 http://www.a3-mall.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: xzncit <158373108@qq.com>
  8. // +----------------------------------------------------------------------
  9. namespace app\api\service;
  10. use app\common\models\Payment as PaymentModel;
  11. class Payment extends Service {
  12. /**
  13. * 获取支付方式
  14. * @param $data
  15. * @return array
  16. * @throws \think\db\exception\DataNotFoundException
  17. * @throws \think\db\exception\DbException
  18. * @throws \think\db\exception\ModelNotFoundException
  19. */
  20. public static function getList($data){
  21. $type = $data["type"]??"h5";
  22. $payType = $data["pay_type"]??"order";
  23. $in = [];
  24. $in[] = $type;
  25. if($payType == "order"){
  26. $in[] = "common";
  27. }
  28. $res = PaymentModel::where("status","0")->where("type","in",$in)->order("sort","DESC")->select()->toArray();
  29. $array = [];
  30. $style = [
  31. "wechat"=>["css"=>"iconfont iconweixin","text"=>'\ue673'],
  32. "alipay"=>["css"=>"iconfont iconumidd17","text"=>'\ue603'],
  33. "balance"=>["css"=>"iconfont iconxinbaniconshangchuan-","text"=>'\ue608']
  34. ];
  35. foreach($res as $value){
  36. $id = explode("-",$value["code"]);
  37. $array[] = [
  38. "name"=>$value["alias_name"],
  39. "id"=>$id[0],
  40. "class"=>$style[$id[0]]["css"],
  41. "text"=>$style[$id[0]]["text"]
  42. ];
  43. }
  44. return $array;
  45. }
  46. }