Tixian.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. namespace Bill\Lib;
  3. use Dever;
  4. class Tixian
  5. {
  6. public function getInfo($type, $type_id, $admin_auth = false)
  7. {
  8. if ($type == 1) {
  9. if ($admin_auth) {
  10. return Dever::load("agent/lib/member.getOne", $type_id, "agent/member", true,true);
  11. } else {
  12. return Dever::load("agent/lib/member.getOne", $type_id, "agent/member", true);
  13. }
  14. }
  15. if ($type == 2) {
  16. $shop = Dever::db('shop/info')->find($type_id);
  17. return $shop['name'] . '<br />' . $shop['sid'];
  18. }
  19. if ($type == 3) {
  20. $user = Dever::db('passport/user')->find($type_id);
  21. return $user['username'] . '<br />' . $user['mobile'];
  22. }
  23. }
  24. public function up($mid, $ycash, $cash,$sign, $type = 1, $cash_id = false)
  25. {
  26. $state = false;
  27. if ($type == 1) {
  28. $member = Dever::db('agent/member')->find(array('id' => $mid, 'clear' => true));
  29. if ($member && $member['status'] <= 2) {
  30. $state = true;
  31. }
  32. $mcash = $member['cash'];
  33. }
  34. if ($type == 2) {
  35. $member = Dever::db('shop/info')->find(array('id' => $mid, 'clear' => true));
  36. if ($member) {
  37. $state = true;
  38. }
  39. $mcash = $member['price'];
  40. }
  41. if ($type == 3) {
  42. $member = Dever::db('passport/user')->find(array('id' => $mid, 'clear' => true));
  43. if ($member) {
  44. $state = true;
  45. }
  46. $mcash = $member['cash'];
  47. }
  48. if ($state) {
  49. $cash = -1*$cash;
  50. $ycash = -1*$ycash;
  51. $data['mid'] = $mid;
  52. $data['order_num'] = $this->getOrderId();
  53. $data['yue'] = $mcash + $ycash;
  54. $data['ycash'] = $ycash;
  55. $data['cash'] = $cash;
  56. $data['sign'] = $sign;
  57. $data['type'] = $type;
  58. if ($cash_id) {
  59. $data['cash_id'] = $cash_id;
  60. }
  61. $data['status'] = -1;
  62. return Dever::db('bill/tixian')->insert($data);
  63. }
  64. return false;
  65. }
  66. /**
  67. * 生成订单号
  68. *
  69. * @return mixed
  70. */
  71. public function getOrderId()
  72. {
  73. $where['order_num'] = Dever::order('C');
  74. $where['clear'] = true;
  75. $state = Dever::db('bill/cash')->one($where);
  76. if (!$state) {
  77. return $where['order_num'];
  78. } else {
  79. return $this->getOrderId();
  80. }
  81. }
  82. public function order_num($id){
  83. $info = Dever::db('bill/tixian')->find($id);
  84. $cdate = date('Y-m-d H:i',$info['cdate']);
  85. if ($info['operdate']) {
  86. $operdate = date('Y-m-d H:i',$info['operdate']);
  87. } else {
  88. $operdate = '-';
  89. }
  90. $html['name'] = $info['order_num'].'<br />'.$cdate.'<br />'.$operdate;
  91. $html['money'] = $info['ycash'].'<br />'.$info['cash'].'<br />'.$info['yue'];
  92. if ($info['type'] == 1) {
  93. $cash = Dever::db('bill/cash')->find($info['cash_id']);
  94. } elseif ($info['type'] == 2) {
  95. $cash = Dever::db('shop/record')->find($info['cash_id']);
  96. } elseif ($info['type'] == 3) {
  97. $cash = Dever::db('shop/user_money')->find($info['cash_id']);
  98. }
  99. if($cash['status']==1){
  100. $name = '待审核';
  101. }elseif($cash['status']==2){
  102. $name = '已审核';
  103. }elseif($cash['status']==3){
  104. $name = '已作废';
  105. }
  106. if($info['status']==-1){
  107. $status = '未审核待发放';
  108. }elseif($info['status']==1){
  109. $status = '已审核待发放';
  110. }elseif($info['status']==2){
  111. $status = '已发放';
  112. }elseif($info['status']==3){
  113. $status = '已作废';
  114. }
  115. $html['status'] = $name.'<br/>'.$status;
  116. return $html;
  117. }
  118. }