Cash.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <?php
  2. namespace Bill\Lib;
  3. use Dever;
  4. class Cash
  5. {
  6. public function up($mid, $type, $cash, $role, $type_id, $desc, $status)
  7. {
  8. $member = Dever::db('agent/member')->find(array('id' => $mid, 'clear' => true));
  9. if ($member['status'] <= 2) {
  10. $where['mid'] = $mid;
  11. if ($type == 11) {
  12. $cash = -1*$cash;
  13. }
  14. $where['type'] = $type;
  15. $where['type_id'] = $type_id;
  16. $where['clear'] = true;
  17. $info = Dever::db('bill/cash')->find($where);
  18. if (!$info) {
  19. $data = $where;
  20. $data['order_num'] = $this->getOrderId();
  21. $data['yue'] = $member['cash'] + $cash;
  22. $data['cash'] = $cash;
  23. $data['role'] = $role;
  24. $data['desc'] = $desc;
  25. $data['status'] = $status;
  26. if ($status == 2) {
  27. $data['operdate'] = time();
  28. }
  29. return Dever::db('bill/cash')->insert($data);
  30. }
  31. return $info['id'];
  32. }
  33. return false;
  34. }
  35. /**
  36. * 生成订单号
  37. *
  38. * @return mixed
  39. */
  40. public function getOrderId()
  41. {
  42. $where['order_num'] = Dever::order('C');
  43. $state = Dever::db('bill/cash')->one($where);
  44. if (!$state) {
  45. return $where['order_num'];
  46. } else {
  47. return $this->getOrderId();
  48. }
  49. }
  50. # 展示详情
  51. public function show()
  52. {
  53. $id = Dever::input('id');
  54. $config = Dever::db('bill/cash')->config['set'];
  55. $info = Dever::db('bill/cash')->one($id);
  56. $status = $config['status'][$info['status']];
  57. $type = $config['type'][$info['type']];
  58. $member = Dever::db('agent/member')->find($info['mid']);
  59. $role = Dever::db('setting/role')->one($member['role']);
  60. $level = Dever::db('setting/level')->one($member['level_id']);
  61. if ($member['shop_id']) {
  62. $shop = Dever::db('shop/info')->one($member['shop_id']);
  63. } else {
  64. $shop['id'] = -1;
  65. $shop['name'] = '无';
  66. }
  67. $cdate = date('Y-m-d H:i', $info['cdate']);
  68. if ($info['operdate']) {
  69. $opertime = date('Y-m-d H:i', $info['operdate']);
  70. } else {
  71. $opertime = '';
  72. }
  73. $result = array();
  74. $result['代理商信息'] = array
  75. (
  76. 'type' => 'info',
  77. 'content' => array
  78. (
  79. array
  80. (
  81. array('代理商', $member['name'] . ' ' . $member['mobile']),
  82. array('代理角色', $role['name'] . ($level ? '('.$level['name'].')' : '')),
  83. array('所属店铺', $shop['name']),
  84. ),
  85. array
  86. (
  87. array('资金余额', '¥' . $member['cash'] . '元'),
  88. array('直推业绩', '¥' . $member['sell'] . '元'),
  89. array('团队业绩', '¥' . $member['group_sell'] . '元'),
  90. ),
  91. ),
  92. );
  93. $result['交易信息'] = array
  94. (
  95. 'type' => 'info',
  96. 'content' => array
  97. (
  98. array
  99. (
  100. array('流水号', $info['order_num']),
  101. array('交易时间', $cdate),
  102. array('交易类型', $type),
  103. ),
  104. array
  105. (
  106. array('交易金额', '¥' . $info['cash'] . '元'),
  107. array('交易后账户余额', '¥' . $info['yue'] . '元'),
  108. array('交易说明', $info['desc']),
  109. ),
  110. )
  111. );
  112. $result['审核信息'] = array
  113. (
  114. 'type' => 'info',
  115. 'content' => array
  116. (
  117. array
  118. (
  119. array('审核时间', $opertime),
  120. array('审核状态', $status),
  121. array('备注', $info['audit_desc']),
  122. ),
  123. )
  124. );
  125. # 提现信息
  126. $button = array();
  127. if ($info['status'] == 1) {
  128. $button[] = array
  129. (
  130. 'type' => 'edit',
  131. 'link' => Dever::url('project/database/update?project=bill&table=cash&where_id='.$info['id'].'&col=audit,audit_desc&oper_save_jump=cash&oper_table=cash&oper_parent=cash', 'manage'),
  132. 'name' => '审核',
  133. );
  134. }
  135. if ($info['type'] == 11) {
  136. $tixian = Dever::db('bill/tixian')->find($info['type_id']);
  137. if ($tixian) {
  138. if ($info['status'] == 2 && $tixian['status'] == 1) {
  139. $button[] = array
  140. (
  141. 'type' => 'edit',
  142. 'link' => Dever::url('project/database/update?project=bill&table=tixian&where_id='.$tixian['id'].'&col=audit,audit_desc,pic&oper_save_jump=tixian&oper_table=tixian&oper_parent=tixian', 'manage'),
  143. 'name' => '发放',
  144. );
  145. }
  146. $bank = Dever::db('setting/bank')->find($tixian['bank']);
  147. $result['提现信息'] = array
  148. (
  149. 'type' => 'info',
  150. 'content' => array
  151. (
  152. array
  153. (
  154. array('银行名称', $bank['name']),
  155. array('开户行', $tixian['bankname']),
  156. ),
  157. array
  158. (
  159. array('姓名', $tixian['name']),
  160. array('卡号', $tixian['card']),
  161. ),
  162. )
  163. );
  164. if ($tixian['status'] == 2) {
  165. if ($tixian['operdate']) {
  166. $opertime = date('Y-m-d H:i', $tixian['operdate']);
  167. } else {
  168. $opertime = '';
  169. }
  170. $pic = '';
  171. if ($tixian['pic']) {
  172. $temp = explode(',', $tixian['pic']);
  173. foreach ($temp as $k => $v) {
  174. $pic .= '<a href="'.Dever::pic($v).'" target="_blank"><img src="'.Dever::pic($v).'" width="150" /></a>';
  175. }
  176. }
  177. $result['发放信息'] = array
  178. (
  179. 'type' => 'info',
  180. 'content' => array
  181. (
  182. array
  183. (
  184. array('发放时间', $opertime),
  185. array('备注', $tixian['audit_desc']),
  186. ),
  187. array
  188. (
  189. array('凭证', $pic),
  190. ),
  191. )
  192. );
  193. }
  194. }
  195. }
  196. $head = array
  197. (
  198. 'name' => '基本信息',
  199. 'btn' => $button,
  200. );
  201. $html = Dever::show($head, $result);
  202. return $html;
  203. }
  204. }