vrorder_helper.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. require_once(BASE_HELPER_PATH . '/mcard/mcard.php');
  3. require_once(BASE_HELPER_PATH . '/mtopcard/mtopcard.php');
  4. class vrorder_helper
  5. {
  6. //提供给商家管理后台.
  7. public static function extend_order_info($order)
  8. {
  9. global $config;
  10. $handlers = $config['vgoods_handlers'];
  11. $goods_id = $order['goods_id'];
  12. if(array_key_exists($goods_id,$handlers))
  13. {
  14. $handler = $handlers[$goods_id];
  15. if($handler['type'] == 'oil_card' || $handler['type'] == 'phone_card') {
  16. $mod_card = Model('card_key');
  17. $item = $mod_card->where(['order_id' => $order['order_id']])->find();
  18. if(!empty($item))
  19. {
  20. $ret = [];
  21. $ret['接收卡'] = $item['receive_card_no'];
  22. if($handler['type'] == 'oil_card') {
  23. $extra_info = json_decode($order['extra_info'],true);
  24. $ret['绑定手机号'] = $extra_info['input']['phone_no'] ?? '';
  25. }
  26. $ret['卡类别'] = mtopcard\scard_type($item['receive_card_type']);
  27. $ret['卡号'] = $item['card_no'];
  28. $ret['卡密'] = $item['card_key'];
  29. return $ret;
  30. }
  31. }
  32. elseif($handler['type'] == 'member_card') {
  33. return [];
  34. }
  35. else {
  36. return [];
  37. }
  38. }
  39. else {
  40. return [];
  41. }
  42. }
  43. //取消虚拟订单时的状态
  44. public static function unfreeze_extra($order)
  45. {
  46. global $config;
  47. $handlers = $config['vgoods_handlers'];
  48. $goods_id = $order['goods_id'];
  49. if(array_key_exists($goods_id,$handlers))
  50. {
  51. $handler = $handlers[$goods_id];
  52. if($handler['type'] == 'oil_card' || $handler['type'] == 'phone_card')
  53. {
  54. $mod_card = Model('card_key');
  55. $item = $mod_card->where(['order_id' => $order['order_id']])->find();
  56. if(!empty($item)) {
  57. $card_id = $item['card_id'];
  58. $mod_card->reuse($card_id);
  59. }
  60. }
  61. }
  62. }
  63. }