Cash.php 7.5 KB

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