Predeposit.php 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891
  1. <?php
  2. namespace app\admin\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. use think\facade\Db;
  6. /**
  7. * ============================================================================
  8. * DSMall多用户商城
  9. * ============================================================================
  10. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  11. * 网站地址: http://www.csdeshang.com
  12. * ----------------------------------------------------------------------------
  13. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  14. * 不允许对程序代码以任何形式任何目的的再发布。
  15. * ============================================================================
  16. * 控制器
  17. */
  18. class Predeposit extends AdminControl {
  19. const EXPORT_SIZE = 1000;
  20. public function initialize() {
  21. parent::initialize();
  22. Lang::load(base_path() . 'admin/lang/'.config('lang.default_lang').'/predeposit.lang.php');
  23. }
  24. /*
  25. * 充值明细
  26. */
  27. public function pdrecharge_list() {
  28. $condition = array();
  29. $if_start_date = preg_match('/^20\d{2}-\d{2}-\d{2}$/', input('param.query_start_date'));
  30. $if_end_date = preg_match('/^20\d{2}-\d{2}-\d{2}$/', input('param.query_end_date'));
  31. $start_unixtime = $if_start_date ? strtotime(input('param.query_start_date')) : null;
  32. $end_unixtime = $if_end_date ? strtotime(input('param.query_end_date')) : null;
  33. if ($start_unixtime) {
  34. $condition[]=array('pdr_addtime','>=', $start_unixtime);
  35. }
  36. if ($end_unixtime) {
  37. $end_unixtime=$end_unixtime+86399;
  38. $condition[]=array('pdr_addtime','<=', $end_unixtime);
  39. }
  40. if (input('param.mname') != '') {
  41. $condition[]=array('pdr_member_name','like', "%" . input('param.mname') . "%");
  42. }
  43. if (input('param.paystate_search') != '') {
  44. $condition[]=array('pdr_payment_state','=',input('param.paystate_search'));
  45. }
  46. $predeposit_model = model('predeposit');
  47. $recharge_list = $predeposit_model->getPdRechargeList($condition, 20, '*', 'pdr_id desc');
  48. View::assign('recharge_list', $recharge_list);
  49. View::assign('show_page', $predeposit_model->page_info->render());
  50. View::assign('filtered', $condition ? 1 : 0); //是否有查询条件
  51. $this->setAdminCurItem('pdrecharge_list');
  52. return View::fetch();
  53. }
  54. /**
  55. * 充值编辑(更改成收到款)
  56. */
  57. public function recharge_edit() {
  58. $id = intval(input('param.id'));
  59. if ($id <= 0) {
  60. $this->error(lang('admin_predeposit_parameter_error'), 'Predeposit/pdrecharge_list');
  61. }
  62. //查询充值信息
  63. $predeposit_model = model('predeposit');
  64. $condition = array();
  65. $condition[] = array('pdr_id','=',$id);
  66. $condition[] = array('pdr_payment_state','=',0);
  67. $info = $predeposit_model->getPdRechargeInfo($condition);
  68. if (empty($info)) {
  69. $this->error(lang('admin_predeposit_record_error'), 'Predeposit/pdrecharge_list');
  70. }
  71. if (!request()->isPost()) {
  72. //显示支付接口列表
  73. $payment_list = model('payment')->getPaymentOpenList();
  74. //去掉预存款和货到付款
  75. foreach ($payment_list as $key => $value) {
  76. if ($value['payment_code'] == 'predeposit' || $value['payment_code'] == 'offline') {
  77. unset($payment_list[$key]);
  78. }
  79. }
  80. View::assign('payment_list', $payment_list);
  81. View::assign('info', $info);
  82. return View::fetch('recharge_edit');
  83. }
  84. //取支付方式信息
  85. $payment_model = model('payment');
  86. $condition = array();
  87. $condition[]=array('payment_code','=',input('post.payment_code'));
  88. $payment_info = $payment_model->getPaymentOpenInfo($condition);
  89. if (!$payment_info || $payment_info['payment_code'] == 'offline' || $payment_info['payment_code'] == 'offline') {
  90. $this->error(lang('payment_index_sys_not_support'));
  91. }
  92. $condition = array();
  93. $condition[] = array('pdr_sn','=',$info['pdr_sn']);
  94. $condition[] = array('pdr_payment_state','=',0);
  95. $update = array();
  96. $update['pdr_payment_state'] = 1;
  97. $update['pdr_paymenttime'] = strtotime(input('post.payment_time'));
  98. $update['pdr_payment_code'] = $payment_info['payment_code'];
  99. $update['pdr_trade_sn'] = input('post.trade_no');
  100. $update['pdr_admin'] = $this->admin_info['admin_name'];
  101. $log_msg = lang('admin_predeposit_recharge_edit_state') . ',' . lang('admin_predeposit_sn') . ':' . $info['pdr_sn'];
  102. Db::startTrans();
  103. try {
  104. //更改充值状态
  105. $state = $predeposit_model->editPdRecharge($update, $condition);
  106. if (!$state) {
  107. throw Exception(lang('predeposit_payment_pay_fail'));
  108. }
  109. //变更会员预存款
  110. $data = array();
  111. $data['member_id'] = $info['pdr_member_id'];
  112. $data['member_name'] = $info['pdr_member_name'];
  113. $data['amount'] = $info['pdr_amount'];
  114. $data['pdr_sn'] = $info['pdr_sn'];
  115. $data['admin_name'] = $this->admin_info['admin_name'];
  116. $predeposit_model->changePd('recharge', $data);
  117. Db::commit();
  118. $this->log($log_msg, 1);
  119. dsLayerOpenSuccess(lang('admin_predeposit_recharge_edit_success'));
  120. } catch (Exception $e) {
  121. Db::rollback();
  122. $this->log($log_msg, 0);
  123. $this->error($e->getMessage(), 'Predeposit/pdrecharge_list');
  124. }
  125. }
  126. /**
  127. * 充值查看
  128. */
  129. public function recharge_info() {
  130. $id = intval(input('param.id'));
  131. if ($id <= 0) {
  132. $this->error(lang('admin_predeposit_parameter_error'), 'Predeposit/pdrecharge_list');
  133. }
  134. //查询充值信息
  135. $predeposit_model = model('predeposit');
  136. $condition = array();
  137. $condition[] = array('pdr_id','=',$id);
  138. $info = $predeposit_model->getPdRechargeInfo($condition);
  139. if (empty($info)) {
  140. $this->error(lang('admin_predeposit_record_error'), 'Predeposit/pdrecharge_list');
  141. }
  142. View::assign('info', $info);
  143. return View::fetch('recharge_info');
  144. }
  145. /**
  146. * 充值删除
  147. */
  148. public function recharge_del() {
  149. $pdr_id = input('param.pdr_id');
  150. $pdr_id_array = ds_delete_param($pdr_id);
  151. if($pdr_id_array === FALSE){
  152. ds_json_encode('10001', lang('param_error'));
  153. }
  154. $predeposit_model = model('predeposit');
  155. $condition = array();
  156. $condition[] = array('pdr_id','in', $pdr_id_array);
  157. $condition[] = array('pdr_payment_state','=',0);
  158. $result = $predeposit_model->delPdRecharge($condition);
  159. if ($result) {
  160. ds_json_encode('10000', lang('ds_common_del_succ'));
  161. } else {
  162. ds_json_encode('10001', lang('ds_common_del_fail'));
  163. }
  164. }
  165. /*
  166. * 预存款明细
  167. */
  168. public function pdlog_list() {
  169. $condition = array();
  170. $stime = input('get.stime');
  171. $etime = input('get.etime');
  172. $if_start_date = preg_match('/^20\d{2}-\d{2}-\d{2}$/', $stime);
  173. $if_end_date = preg_match('/^20\d{2}-\d{2}-\d{2}$/', $etime);
  174. $start_unixtime = $if_start_date ? strtotime($stime) : null;
  175. $end_unixtime = $if_end_date ? strtotime($etime) : null;
  176. if ($start_unixtime) {
  177. $condition[]=array('lg_addtime','>=', $start_unixtime);
  178. }
  179. if ($end_unixtime) {
  180. $end_unixtime=$end_unixtime+86399;
  181. $condition[]=array('lg_addtime','<=', $end_unixtime);
  182. }
  183. $mname = input('get.mname');
  184. if (!empty($mname)) {
  185. $condition[] = array('lg_member_name','=',$mname);
  186. }
  187. $aname = input('get.aname');
  188. if (!empty($aname)) {
  189. $condition[] = array('lg_admin_name','=',$aname);
  190. }
  191. $predeposit_model = model('predeposit');
  192. $list_log = $predeposit_model->getPdLogList($condition, 10, '*', 'lg_id desc');
  193. View::assign('show_page', $predeposit_model->page_info->render());
  194. View::assign('list_log', $list_log);
  195. View::assign('filtered', $condition ? 1 : 0); //是否有查询条件
  196. $this->setAdminCurItem('pdlog_list');
  197. return View::fetch();
  198. }
  199. /*
  200. * 提现设置
  201. */
  202. public function pdcash_set(){
  203. $config_model = model('config');
  204. if(!request()->isPost()){
  205. $list_setting = rkcache('config', true);
  206. View::assign('list_setting',$list_setting);
  207. $this->setAdminCurItem('pdcash_set');
  208. return View::fetch();
  209. }else{
  210. $update_array=array(
  211. 'member_withdraw_min'=>abs(round(input('post.member_withdraw_min'),2)),
  212. 'member_withdraw_max'=>abs(round(input('post.member_withdraw_max'),2)),
  213. 'member_withdraw_cycle'=>abs(intval(input('post.member_withdraw_cycle'))),
  214. );
  215. $result = $config_model->editConfig($update_array);
  216. if ($result) {
  217. $this->log(lang('ds_update').lang('admin_predeposit_cashset'),1);
  218. $this->success(lang('ds_common_op_succ'), 'Predeposit/pdcash_set');
  219. }else{
  220. $this->log(lang('ds_update').lang('admin_predeposit_cashset'),0);
  221. }
  222. }
  223. }
  224. /*
  225. * 提现列表
  226. */
  227. public function pdcash_list() {
  228. $condition = array();
  229. $stime = input('get.stime');
  230. $etime = input('get.etime');
  231. $if_start_date = preg_match('/^20\d{2}-\d{2}-\d{2}$/', $stime);
  232. $if_end_date = preg_match('/^20\d{2}-\d{2}-\d{2}$/', $etime);
  233. $start_unixtime = $if_start_date ? strtotime($stime) : null;
  234. $end_unixtime = $if_end_date ? strtotime($etime) : null;
  235. if ($start_unixtime) {
  236. $condition[]=array('pdc_addtime','>=', $start_unixtime);
  237. }
  238. if ($end_unixtime) {
  239. $end_unixtime=$end_unixtime+86399;
  240. $condition[]=array('pdc_addtime','<=', $end_unixtime);
  241. }
  242. $mname = input('get.mname');
  243. if (!empty($mname)) {
  244. $condition[]=array('pdc_member_name','like', "%" . $mname . "%");
  245. }
  246. $pdc_bank_user = input('get.pdc_bank_user');
  247. if (!empty($pdc_bank_user)) {
  248. $condition[]=array('pdc_bank_user','like', "%" . $pdc_bank_user . "%");
  249. }
  250. $paystate_search = input('get.paystate_search');
  251. if ($paystate_search != '') {
  252. $condition[]=array('pdc_payment_state','=',$paystate_search);
  253. }
  254. $predeposit_model = model('predeposit');
  255. $predeposit_list = $predeposit_model->getPdcashList($condition, 20, '*', 'pdc_payment_state asc,pdc_id asc');
  256. View::assign('predeposit_list', $predeposit_list);
  257. View::assign('show_page', $predeposit_model->page_info->render());
  258. View::assign('filtered', $condition ? 1 : 0); //是否有查询条件
  259. $this->setAdminCurItem('pdcash_list');
  260. return View::fetch('pdcash_list');
  261. }
  262. /**
  263. * 删除提现记录
  264. */
  265. public function pdcash_del() {
  266. $pdc_id = intval(input('param.pdc_id'));
  267. if ($pdc_id <= 0) {
  268. ds_json_encode(10001, lang('param_error'));
  269. }
  270. $predeposit_model = model('predeposit');
  271. $condition = array();
  272. $condition[] = array('pdc_id','=',$pdc_id);
  273. $condition[] = array('pdc_payment_state','=',0);
  274. $info = $predeposit_model->getPdcashInfo($condition);
  275. if (!$info) {
  276. ds_json_encode(10001, lang('admin_predeposit_parameter_error'));
  277. }
  278. try {
  279. $result = $predeposit_model->delPdcash($condition);
  280. if (!$result) {
  281. ds_json_encode(10001, lang('admin_predeposit_cash_del_fail'));
  282. }
  283. //退还冻结的预存款
  284. $member_model = model('member');
  285. $member_info = $member_model->getMemberInfo(array('member_id' => $info['pdc_member_id']));
  286. //扣除冻结的预存款
  287. $admininfo = $this->getAdminInfo();
  288. $data = array();
  289. $data['member_id'] = $member_info['member_id'];
  290. $data['member_name'] = $member_info['member_name'];
  291. $data['amount'] = $info['pdc_amount'];
  292. $data['order_sn'] = $info['pdc_sn'];
  293. $data['admin_name'] = $admininfo['admin_name'];
  294. $predeposit_model->changePd('cash_del', $data);
  295. $predeposit_model->commit();
  296. ds_json_encode(10000, lang('admin_predeposit_cash_del_success'));
  297. } catch (Exception $e) {
  298. $predeposit_model->commit();
  299. ds_json_encode(10001, lang($e->getMessage()));
  300. }
  301. }
  302. /**
  303. * 更改提现为支付状态
  304. */
  305. public function pdcash_pay() {
  306. $id = intval(input('param.id'));
  307. if ($id <= 0) {
  308. $this->error(lang('admin_predeposit_parameter_error'),'Predeposit/pdcash_list');
  309. }
  310. $predeposit_model = model('predeposit');
  311. $condition = array();
  312. $condition[] = array('pdc_id','=',$id);
  313. $condition[] = array('pdc_payment_state','=',0);
  314. $info = $predeposit_model->getPdcashInfo($condition);
  315. if (!is_array($info) || count($info) < 0) {
  316. $this->error(lang('admin_predeposit_record_error'), 'Predeposit/pdcash_list');
  317. }
  318. //查询用户信息
  319. $member_model = model('member');
  320. $member_info = $member_model->getMemberInfo(array('member_id' => $info['pdc_member_id']));
  321. $update = array();
  322. $admininfo = $this->getAdminInfo();
  323. $update['pdc_payment_state'] = 1;
  324. $update['pdc_payment_admin'] = $admininfo['admin_name'];
  325. $update['pdc_payment_time'] = TIMESTAMP;
  326. $log_msg = lang('admin_predeposit_cash_edit_state') . ',' . lang('admin_predeposit_cs_sn') . ':' . $info['pdc_sn'];
  327. Db::startTrans();
  328. try {
  329. $result = $predeposit_model->editPdcash($update, $condition);
  330. if (!$result) {
  331. $this->error(lang('admin_predeposit_cash_edit_fail'));
  332. }
  333. //扣除冻结的预存款
  334. $data = array();
  335. $data['member_id'] = $member_info['member_id'];
  336. $data['member_name'] = $member_info['member_name'];
  337. $data['amount'] = $info['pdc_amount'];
  338. $data['order_sn'] = $info['pdc_sn'];
  339. $data['admin_name'] = $admininfo['admin_name'];
  340. $predeposit_model->changePd('cash_pay', $data);
  341. if($info['pdc_bank_type']=='alipay'){//如果是支付宝且开启了支付宝提现
  342. $logic_payment = model('payment', 'logic');
  343. $payment_code='alipay';
  344. $result = $logic_payment->getPaymentInfo($payment_code);
  345. if ($result['code']) {
  346. $payment_info = $result['data'];
  347. if($payment_info['payment_config']['alipay_trade_transfer_state'] == 1){
  348. $payment_api = new $payment_code($payment_info);
  349. $result = $payment_api->fund_transfer($info);
  350. if (!$result['code']) {
  351. throw new \think\Exception($result['msg'], 10006);
  352. }
  353. $result = $predeposit_model->editPdcash(array('pdc_payment_code'=>$payment_code,'pdc_trade_sn'=>$result['data']['pdc_trade_sn']), array('pdc_id'=>$id));
  354. if (!$result) {
  355. throw new \think\Exception(lang('admin_predeposit_cash_edit_fail'), 10006);
  356. }
  357. }
  358. }
  359. }elseif($info['pdc_bank_type']=='weixin'){//如果是微信且开启了微信提现
  360. $logic_payment = model('payment', 'logic');
  361. $payment_code='wxpay_native';
  362. $result = $logic_payment->getPaymentInfo($payment_code);
  363. if ($result['code']) {
  364. $payment_info = $result['data'];
  365. if($payment_info['payment_config']['wx_trade_transfer_state'] == 1){
  366. $payment_api = new $payment_code($payment_info);
  367. $result = $payment_api->fund_transfer($info);
  368. if (!$result['code']) {
  369. throw new \think\Exception($result['msg'], 10006);
  370. }
  371. $result = $predeposit_model->editPdcash(array('pdc_payment_code'=>$payment_code,'pdc_trade_sn'=>$result['data']['pdc_trade_sn']), array('pdc_id'=>$id));
  372. if (!$result) {
  373. throw new \think\Exception(lang('admin_predeposit_cash_edit_fail'), 10006);
  374. }
  375. }
  376. }
  377. }
  378. Db::commit();
  379. $this->log($log_msg, 1);
  380. dsLayerOpenSuccess(lang('admin_predeposit_cash_edit_success'));
  381. } catch (\Exception $e) {
  382. Db::rollback();
  383. $this->log($log_msg, 0);
  384. $this->error($e->getMessage(), 'Predeposit/pdcash_list');
  385. }
  386. }
  387. /**
  388. * 查看提现信息
  389. */
  390. public function pdcash_view() {
  391. $id = intval(input('param.id'));
  392. if ($id <= 0) {
  393. $this->error(lang('admin_predeposit_parameter_error'), 'Predeposit/pdcash_list');
  394. }
  395. $predeposit_model = model('predeposit');
  396. $condition = array();
  397. $condition[] = array('pdc_id','=',$id);
  398. $info = $predeposit_model->getPdcashInfo($condition);
  399. if (!is_array($info) || count($info) < 0) {
  400. $this->error(lang('admin_predeposit_record_error'), 'Predeposit/pdcash_list');
  401. }
  402. View::assign('info', $info);
  403. return View::fetch();
  404. }
  405. /*
  406. * 调节预存款
  407. */
  408. public function pd_add() {
  409. if (!(request()->isPost())) {
  410. $member_id = intval(input('get.member_id'));
  411. if($member_id>0){
  412. $condition = array();
  413. $condition[] = array('member_id','=',$member_id);
  414. $member = model('member')->getMemberInfo($condition);
  415. if(!empty($member)){
  416. View::assign('member_info',$member);
  417. }
  418. }
  419. return View::fetch();
  420. } else {
  421. $data = array(
  422. 'member_id' => input('post.member_id'),
  423. 'amount' => input('post.amount'),
  424. 'operatetype' => input('post.operatetype'),
  425. 'lg_desc' => input('post.lg_desc'),
  426. );
  427. $predeposit_validate = ds_validate('predeposit');
  428. if (!$predeposit_validate->scene('pd_add')->check($data)) {
  429. $this->error($predeposit_validate->getError());
  430. }
  431. $money = abs(floatval(input('post.amount')));
  432. $memo = trim(input('post.lg_desc'));
  433. if ($money <= 0) {
  434. $this->error(lang('amount_min'));
  435. }
  436. //查询会员信息
  437. $member_mod = model('member');
  438. $member_id = intval(input('post.member_id'));
  439. $operatetype = input('post.operatetype');
  440. $member_info = $member_mod->getMemberInfo(array('member_id' => $member_id));
  441. if (!is_array($member_info) || count($member_info) <= 0) {
  442. $this->error(lang('user_not_exist'), 'Predeposit/pd_add');
  443. }
  444. $available_predeposit = floatval($member_info['available_predeposit']);
  445. $freeze_predeposit = floatval($member_info['freeze_predeposit']);
  446. if ($operatetype == 2 && $money > $available_predeposit) {
  447. $this->error(lang('avaliable_predeposit_not_enough') . $available_predeposit, 'Predeposit/pd_add');
  448. }
  449. if ($operatetype == 3 && $money > $available_predeposit) {
  450. $this->error(lang('freezen_predeposit_not_enough') . $available_predeposit, 'Predeposit/pd_add');
  451. }
  452. if ($operatetype == 4 && $money > $freeze_predeposit) {
  453. $this->error(lang('recover_freezen_predeposit_not_enough') . $freeze_predeposit, 'Predeposit/pd_add');
  454. }
  455. $predeposit_model = model('predeposit');
  456. #生成对应订单号
  457. $order_sn = makePaySn($member_id);
  458. $admininfo = $this->getAdminInfo();
  459. $log_msg = "管理员【" . $admininfo['admin_name'] . "】操作会员【" . $member_info['member_name'] . "】预存款,金额为" . $money . ",编号为" . $order_sn;
  460. $admin_act = "sys_add_money";
  461. switch ($operatetype) {
  462. case 1:
  463. $admin_act = "sys_add_money";
  464. $log_msg = "管理员【" . $admininfo['admin_name'] . "】操作会员【" . $member_info['member_name'] . "】预存款【增加】,金额为" . $money . ",编号为" . $order_sn;
  465. break;
  466. case 2:
  467. $admin_act = "sys_del_money";
  468. $log_msg = "管理员【" . $admininfo['admin_name'] . "】操作会员【" . $member_info['member_name'] . "】预存款【减少】,金额为" . $money . ",编号为" . $order_sn;
  469. break;
  470. case 3:
  471. $admin_act = "sys_freeze_money";
  472. $log_msg = "管理员【" . $admininfo['admin_name'] . "】操作会员【" . $member_info['member_name'] . "】预存款【冻结】,金额为" . $money . ",编号为" . $order_sn;
  473. break;
  474. case 4:
  475. $admin_act = "sys_unfreeze_money";
  476. $log_msg = "管理员【" . $admininfo['admin_name'] . "】操作会员【" . $member_info['member_name'] . "】预存款【解冻】,金额为" . $money . ",编号为" . $order_sn;
  477. break;
  478. default:
  479. $this->error(lang('ds_common_op_fail'), 'Predeposit/pdlog_list');
  480. break;
  481. }
  482. try {
  483. Db::startTrans();
  484. //扣除冻结的预存款
  485. $data = array();
  486. $data['member_id'] = $member_info['member_id'];
  487. $data['member_name'] = $member_info['member_name'];
  488. $data['amount'] = $money;
  489. $data['order_sn'] = $order_sn;
  490. $data['admin_name'] = $admininfo['admin_name'];
  491. $data['pdr_sn'] = $order_sn;
  492. $data['lg_desc'] = $memo;
  493. $predeposit_model->changePd($admin_act, $data);
  494. Db::commit();
  495. $this->log($log_msg, 1);
  496. dsLayerOpenSuccess(lang('ds_common_op_succ'));
  497. } catch (Exception $e) {
  498. Db::rollback();
  499. $this->log($log_msg, 0);
  500. $this->error($e->getMessage(), 'Predeposit/pdlog_list');
  501. }
  502. }
  503. }
  504. //取得会员信息
  505. public function checkmember() {
  506. $name = input('post.name');
  507. if (!$name) {
  508. exit(json_encode(array('id' => 0)));
  509. die;
  510. }
  511. $obj_member = model('member');
  512. $member_info = $obj_member->getMemberInfo(array('member_name' => $name));
  513. if (is_array($member_info) && count($member_info) > 0) {
  514. exit(json_encode(array('id' => $member_info['member_id'], 'name' => $member_info['member_name'], 'available_predeposit' => $member_info['available_predeposit'], 'freeze_predeposit' => $member_info['freeze_predeposit'])));
  515. } else {
  516. exit(json_encode(array('id' => 0)));
  517. }
  518. }
  519. /**
  520. * 导出预存款充值记录
  521. *
  522. */
  523. public function export_step1() {
  524. $condition = array();
  525. $if_start_date = preg_match('/^20\d{2}-\d{2}-\d{2}$/', input('param.query_start_date'));
  526. $if_end_date = preg_match('/^20\d{2}-\d{2}-\d{2}$/', input('param.query_end_date'));
  527. $start_unixtime = $if_start_date ? strtotime(input('param.query_start_date')) : null;
  528. $end_unixtime = $if_end_date ? strtotime(input('param.query_end_date')) : null;
  529. if ($start_unixtime) {
  530. $condition[] = array('pdr_addtime','>=', $start_unixtime);
  531. }
  532. if ($end_unixtime) {
  533. $end_unixtime=$end_unixtime+86399;
  534. $condition[] = array('pdr_addtime','<=', $end_unixtime);
  535. }
  536. if (input('param.mname') != '') {
  537. $condition[]=array('pdr_member_name','like', "%" . input('param.mname') . "%");
  538. }
  539. if (input('param.paystate_search') != '') {
  540. $condition[]=array('pdr_payment_state','=',input('param.paystate_search'));
  541. }
  542. $predeposit_model = model('predeposit');
  543. if (!is_numeric(input('param.page'))) {
  544. $count = $predeposit_model->getPdRechargeCount($condition);
  545. $array = array();
  546. if ($count > self::EXPORT_SIZE) { //显示下载链接
  547. $page = ceil($count / self::EXPORT_SIZE);
  548. for ($i = 1; $i <= $page; $i++) {
  549. $limit1 = ($i - 1) * self::EXPORT_SIZE + 1;
  550. $limit2 = $i * self::EXPORT_SIZE > $count ? $count : $i * self::EXPORT_SIZE;
  551. $array[$i] = $limit1 . ' ~ ' . $limit2;
  552. }
  553. View::assign('export_list', $array);
  554. return View::fetch('/public/excel');
  555. } else { //如果数量小,直接下载
  556. $data = $predeposit_model->getPdRechargeList($condition, '', '*', 'pdr_id desc', self::EXPORT_SIZE);
  557. $rechargepaystate = array(0 => lang('admin_predeposit_rechargewaitpaying'), 1 => lang('admin_predeposit_rechargepaysuccess'));
  558. foreach ($data as $k => $v) {
  559. $data[$k]['pdr_payment_state'] = $rechargepaystate[$v['pdr_payment_state']];
  560. }
  561. $this->createExcel($data);
  562. }
  563. } else { //下载
  564. $limit1 = (input('param.page') - 1) * self::EXPORT_SIZE;
  565. $limit2 = self::EXPORT_SIZE;
  566. $data = $predeposit_model->getPdRechargeList($condition, $limit2, '*', 'pdr_id desc');
  567. $rechargepaystate = array(0 => lang('admin_predeposit_rechargewaitpaying'), 1 => lang('admin_predeposit_rechargepaysuccess'));
  568. foreach ($data as $k => $v) {
  569. $data[$k]['pdr_payment_state'] = $rechargepaystate[$v['pdr_payment_state']];
  570. }
  571. $this->createExcel($data);
  572. }
  573. }
  574. /**
  575. * 生成导出预存款充值excel
  576. *
  577. * @param array $data
  578. */
  579. private function createExcel($data = array()) {
  580. Lang::load(base_path() .'admin/lang/'.config('lang.default_lang').'/export.lang.php');
  581. $excel_obj = new \excel\Excel();
  582. $excel_data = array();
  583. //设置样式
  584. $excel_obj->setStyle(array('id' => 's_title', 'Font' => array('FontName' => '宋体', 'Size' => '12', 'Bold' => '1')));
  585. //header
  586. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_yc_no'));
  587. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_yc_member'));
  588. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_yc_ctime'));
  589. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_yc_ptime'));
  590. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_yc_pay'));
  591. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_yc_money'));
  592. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_yc_paystate'));
  593. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_yc_memberid'));
  594. foreach ((array) $data as $k => $v) {
  595. $tmp = array();
  596. $tmp[] = array('data' => $v['pdr_sn']);
  597. $tmp[] = array('data' => $v['pdr_member_name']);
  598. $tmp[] = array('data' => date('Y-m-d H:i:s', $v['pdr_addtime']));
  599. if (intval($v['pdr_paymenttime'])) {
  600. if (date('His', $v['pdr_paymenttime']) == 0) {
  601. $tmp[] = array('data' => date('Y-m-d', $v['pdr_paymenttime']));
  602. } else {
  603. $tmp[] = array('data' => date('Y-m-d H:i:s', $v['pdr_paymenttime']));
  604. }
  605. } else {
  606. $tmp[] = array('data' => '');
  607. }
  608. $tmp[] = array('data' => $v['pdr_payment_code']);
  609. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['pdr_amount']));
  610. $tmp[] = array('data' => $v['pdr_payment_state']);
  611. $tmp[] = array('data' => $v['pdr_member_id']);
  612. $excel_data[] = $tmp;
  613. }
  614. $excel_data = $excel_obj->charset($excel_data, CHARSET);
  615. $excel_obj->addArray($excel_data);
  616. $excel_obj->addWorksheet($excel_obj->charset(lang('exp_yc_yckcz'), CHARSET));
  617. $excel_obj->generateXML($excel_obj->charset(lang('exp_yc_yckcz'), CHARSET) . input('param.page') . '-' . date('Y-m-d-H', TIMESTAMP));
  618. }
  619. /**
  620. * 导出预存款提现记录
  621. *
  622. */
  623. public function export_cash_step1() {
  624. $condition = array();
  625. $stime = input('get.stime');
  626. $etime = input('get.etime');
  627. $if_start_date = preg_match('/^20\d{2}-\d{2}-\d{2}$/', $stime);
  628. $if_end_date = preg_match('/^20\d{2}-\d{2}-\d{2}$/', $etime);
  629. $start_unixtime = $if_start_date ? strtotime($stime) : null;
  630. $end_unixtime = $if_end_date ? strtotime($etime) : null;
  631. if ($start_unixtime) {
  632. $condition[] = array('pdc_addtime','>=', $start_unixtime);
  633. }
  634. if ($end_unixtime) {
  635. $end_unixtime=$end_unixtime+86399;
  636. $condition[] = array('pdc_addtime','<=', $end_unixtime);
  637. }
  638. $mname = input('get.mname');
  639. if (!empty($mname)) {
  640. $condition[]=array('pdc_member_name','like', "%" . $mname . "%");
  641. }
  642. $pdc_bank_user = input('get.pdc_bank_user');
  643. if (!empty($pdc_bank_user)) {
  644. $condition[]=array('pdc_bank_user','like', "%" . $pdc_bank_user . "%");
  645. }
  646. $paystate_search = input('get.paystate_search');
  647. if ($paystate_search != '') {
  648. $condition[]=array('pdc_payment_state','=',$paystate_search);
  649. }
  650. $predeposit_model = Model('predeposit');
  651. if (!is_numeric(input('param.page'))) {
  652. $count = $predeposit_model->getPdCashCount($condition);
  653. $array = array();
  654. if ($count > self::EXPORT_SIZE) { //显示下载链接
  655. $page = ceil($count / self::EXPORT_SIZE);
  656. for ($i = 1; $i <= $page; $i++) {
  657. $limit1 = ($i - 1) * self::EXPORT_SIZE + 1;
  658. $limit2 = $i * self::EXPORT_SIZE > $count ? $count : $i * self::EXPORT_SIZE;
  659. $array[$i] = $limit1 . ' ~ ' . $limit2;
  660. }
  661. View::assign('export_list', $array);
  662. return View::fetch('/public/excel');
  663. } else { //如果数量小,直接下载
  664. $data = $predeposit_model->getPdCashList($condition, '', '*', 'pdc_id desc', self::EXPORT_SIZE);
  665. $cashpaystate = array(0 => lang('admin_predeposit_rechargewaitpaying'), 1 => lang('admin_predeposit_rechargepaysuccess'));
  666. foreach ($data as $k => $v) {
  667. $data[$k]['pdc_payment_state'] = $cashpaystate[$v['pdc_payment_state']];
  668. }
  669. $this->createCashExcel($data);
  670. }
  671. } else { //下载
  672. $limit1 = (input('param.page') - 1) * self::EXPORT_SIZE;
  673. $limit2 = self::EXPORT_SIZE;
  674. $data = $predeposit_model->getPdCashList($condition, $limit2, '*', 'pdc_id desc');
  675. $cashpaystate = array(0 => lang('admin_predeposit_rechargewaitpaying'), 1 => lang('admin_predeposit_rechargepaysuccess'));
  676. foreach ($data as $k => $v) {
  677. $data[$k]['pdc_payment_state'] = $cashpaystate[$v['pdc_payment_state']];
  678. }
  679. $this->createCashExcel($data);
  680. }
  681. }
  682. /**
  683. * 生成导出预存款提现excel
  684. *
  685. * @param array $data
  686. */
  687. private function createCashExcel($data = array()) {
  688. Lang::load(base_path() .'admin/lang/'.config('lang.default_lang').'/export.lang.php');
  689. $excel_obj = new \excel\Excel();
  690. $excel_data = array();
  691. //设置样式
  692. $excel_obj->setStyle(array('id' => 's_title', 'Font' => array('FontName' => '宋体', 'Size' => '12', 'Bold' => '1')));
  693. //header
  694. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_tx_no'));
  695. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_tx_member'));
  696. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_tx_money'));
  697. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_tx_ctime'));
  698. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_tx_state'));
  699. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_tx_memberid'));
  700. foreach ((array) $data as $k => $v) {
  701. $tmp = array();
  702. $tmp[] = array('data' => $v['pdc_sn']);
  703. $tmp[] = array('data' => $v['pdc_member_name']);
  704. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['pdc_amount']));
  705. $tmp[] = array('data' => date('Y-m-d H:i:s', $v['pdc_addtime']));
  706. $tmp[] = array('data' => $v['pdc_payment_state']);
  707. $tmp[] = array('data' => $v['pdc_member_id']);
  708. $excel_data[] = $tmp;
  709. }
  710. $excel_data = $excel_obj->charset($excel_data, CHARSET);
  711. $excel_obj->addArray($excel_data);
  712. $excel_obj->addWorksheet($excel_obj->charset(lang('exp_tx_title'), CHARSET));
  713. $excel_obj->generateXML($excel_obj->charset(lang('exp_tx_title'), CHARSET) . input('param.page') . '-' . date('Y-m-d-H', TIMESTAMP));
  714. }
  715. /**
  716. * 预存款明细信息导出
  717. */
  718. public function export_mx_step1() {
  719. $condition = array();
  720. $stime = input('get.stime');
  721. $etime = input('get.etime');
  722. $if_start_date = preg_match('/^20\d{2}-\d{2}-\d{2}$/', $stime);
  723. $if_end_date = preg_match('/^20\d{2}-\d{2}-\d{2}$/', $etime);
  724. $start_unixtime = $if_start_date ? strtotime($stime) : null;
  725. $end_unixtime = $if_end_date ? strtotime($etime) : null;
  726. if ($start_unixtime) {
  727. $condition[] = array('lg_addtime','>=',$start_unixtime);
  728. }
  729. if ($end_unixtime) {
  730. $end_unixtime=$end_unixtime+86399;
  731. $condition[] = array('lg_addtime','<=',$end_unixtime);
  732. }
  733. $mname = input('get.mname');
  734. if (!empty($mname)) {
  735. $condition[] = array('lg_member_name','=',$mname);
  736. }
  737. $aname = input('get.aname');
  738. if (!empty($aname)) {
  739. $condition[] = array('lg_admin_name','=',$aname);
  740. }
  741. $predeposit_model = model('predeposit');
  742. if (!is_numeric(input('param.page'))) {
  743. $count = $predeposit_model->getPdLogCount($condition);
  744. $array = array();
  745. if ($count > self::EXPORT_SIZE) { //显示下载链接
  746. $page = ceil($count / self::EXPORT_SIZE);
  747. for ($i = 1; $i <= $page; $i++) {
  748. $limit1 = ($i - 1) * self::EXPORT_SIZE + 1;
  749. $limit2 = $i * self::EXPORT_SIZE > $count ? $count : $i * self::EXPORT_SIZE;
  750. $array[$i] = $limit1 . ' ~ ' . $limit2;
  751. }
  752. View::assign('export_list', $array);
  753. return View::fetch('/public/excel');
  754. } else { //如果数量小,直接下载
  755. $data = $predeposit_model->getPdLogList($condition, '', '*', 'lg_id desc', self::EXPORT_SIZE);
  756. $this->createmxExcel($data);
  757. }
  758. } else { //下载
  759. $limit1 = (input('param.page') - 1) * self::EXPORT_SIZE;
  760. $limit2 = self::EXPORT_SIZE;
  761. $data = $predeposit_model->getPdLogList($condition, $limit2, '*', 'lg_id desc');
  762. $this->createmxExcel($data);
  763. }
  764. }
  765. /**
  766. * 导出预存款明细excel
  767. *
  768. * @param array $data
  769. */
  770. private function createmxExcel($data = array()) {
  771. Lang::load(base_path() .'admin/lang/'.config('lang.default_lang').'/export.lang.php');
  772. $excel_obj = new \excel\Excel();
  773. $excel_data = array();
  774. //设置样式
  775. $excel_obj->setStyle(array('id' => 's_title', 'Font' => array('FontName' => '宋体', 'Size' => '12', 'Bold' => '1')));
  776. //header
  777. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_mx_member'));
  778. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_mx_ctime'));
  779. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_mx_av_money'));
  780. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_mx_freeze_money'));
  781. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_mx_system'));
  782. $excel_data[0][] = array('styleid' => 's_title', 'data' => lang('exp_mx_mshu'));
  783. foreach ((array) $data as $k => $v) {
  784. $tmp = array();
  785. $tmp[] = array('data' => $v['lg_member_name']);
  786. $tmp[] = array('data' => date('Y-m-d H:i:s', $v['lg_addtime']));
  787. if (floatval($v['lg_av_amount']) == 0) {
  788. $tmp[] = array('data' => '');
  789. } else {
  790. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['lg_av_amount']));
  791. }
  792. if (floatval($v['lg_freeze_amount']) == 0) {
  793. $tmp[] = array('data' => '');
  794. } else {
  795. $tmp[] = array('format' => 'Number', 'data' => ds_price_format($v['lg_freeze_amount']));
  796. }
  797. $tmp[] = array('data' => $v['lg_admin_name']);
  798. $tmp[] = array('data' => $v['lg_desc']);
  799. $excel_data[] = $tmp;
  800. }
  801. $excel_data = $excel_obj->charset($excel_data, CHARSET);
  802. $excel_obj->addArray($excel_data);
  803. $excel_obj->addWorksheet($excel_obj->charset(lang('exp_mx_rz'), CHARSET));
  804. $excel_obj->generateXML($excel_obj->charset(lang('exp_mx_rz'), CHARSET) . input('param.page') . '-' . date('Y-m-d-H', TIMESTAMP));
  805. }
  806. /**
  807. * 获取卖家栏目列表,针对控制器下的栏目
  808. */
  809. protected function getAdminItemList() {
  810. $menu_array = array(
  811. array(
  812. 'name' => 'pdrecharge_list',
  813. 'text' => lang('pdrecharge_list'),
  814. 'url' => (string)url('Predeposit/pdrecharge_list')
  815. ),
  816. array(
  817. 'name' => 'pdcash_set',
  818. 'text' => lang('admin_predeposit_cashset'),
  819. 'url' => (string)url('Predeposit/pdcash_set')
  820. ),
  821. array(
  822. 'name' => 'pdcash_list',
  823. 'text' => lang('admin_predeposit_cashmanage'),
  824. 'url' => (string)url('Predeposit/pdcash_list')
  825. ),
  826. array(
  827. 'name' => 'pdlog_list',
  828. 'text' => lang('pdlog_list'),
  829. 'url' => (string)url('Predeposit/pdlog_list')
  830. ),
  831. array(
  832. 'name' => 'pd_add',
  833. 'text' => lang('pd_add'),
  834. 'url' => "javascript:dsLayerOpen('".(string)url('Predeposit/pd_add')."','".lang('pd_add')."')"
  835. ),
  836. );
  837. return $menu_array;
  838. }
  839. }
  840. ?>