bd.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace WY\app\controller\derpay;
  3. use WY\app\libs\Controller;
  4. use WY\app\model\Handleorder;
  5. use WY\app\model\Pushorder;
  6. if (!defined('WY_ROOT')) {
  7. exit;
  8. }
  9. class bd extends CheckAdmin
  10. {
  11. public function index()
  12. {
  13. $data = array('title' => '订单补发');
  14. $this->put('bd.php', $data);
  15. }
  16. public function save()
  17. {
  18. $orderid = $this->req->post('orderid');
  19. $price = $this->req->post('price');
  20. if ($orderid && $price) {
  21. $handle = new Handleorder($orderid, $price);
  22. $handle->updateUncard();
  23. }
  24. echo json_encode(array('status' => 1, 'msg' => '订单补发成功'));
  25. }
  26. public function notify()
  27. {
  28. $fdate = $this->req->post('fdate');
  29. $tdate = $this->req->post('tdate');
  30. $userid = $this->req->post('userid');
  31. if ($userid == '') {
  32. echo json_encode(array('status' => 0, 'msg' => '商户ID不能为空'));
  33. exit;
  34. }
  35. $cons = 'is_state=? and is_notify=?';
  36. $consArr = array(1, 1);
  37. if ($userid) {
  38. $cons .= $cons ? ' and ' : '';
  39. $cons .= 'userid=?';
  40. $consArr[] = $userid;
  41. }
  42. if ($fdate) {
  43. $cons .= $cons ? ' and ' : '';
  44. $cons .= 'addtime>=?';
  45. $consArr[] = strtotime($fdate);
  46. }
  47. if ($fdate) {
  48. $cons .= $cons ? ' and ' : '';
  49. $cons .= 'addtime<=?';
  50. $consArr[] = strtotime($tdate . ' 23:59:59');
  51. }
  52. $nums = 0;
  53. if ($cons) {
  54. $orders = $this->model()->select('orderid')->from('orders')->where(array('fields' => $cons, 'values' => $consArr))->fetchAll();
  55. if ($orders) {
  56. $nums = count($orders);
  57. foreach ($orders as $key => $val) {
  58. $push = new Pushorder($val['orderid']);
  59. $push->notify();
  60. }
  61. }
  62. }
  63. echo json_encode(array('status' => 1, 'msg' => '批量通知完成,共通知' . $nums . '个订单'));
  64. }
  65. }