Yspay.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace Shop\Lib;
  3. use Dever;
  4. class Yspay
  5. {
  6. #生成订单号
  7. public function getOrderId()
  8. {
  9. $where['order_num'] = Dever::order('SD');
  10. $where['clear'] = true;
  11. $state = Dever::db('shop/yspay_tixian_log')->one($where);
  12. if (!$state) {
  13. return $where['order_num'];
  14. } else {
  15. return $this->getOrderId();
  16. }
  17. }
  18. public function insert($id, $name, $data)
  19. {
  20. $shop_id = Dever::param('shop_id',$data);
  21. $cash = Dever::param('cash',$data);
  22. $desc = Dever::param('desc',$data);
  23. $account = Dever::db('shop/yspay_account')->one(array('shop_id' => $shop_id));
  24. if (!$account) {
  25. Dever::alert('账户不存在');
  26. }
  27. if ($cash <= 0) {
  28. Dever::alert('提现金额不能小于0');
  29. }
  30. $cash = $cash * 100;
  31. if ($cash > $account['cash']) {
  32. Dever::alert('账户余额不足');
  33. }
  34. }
  35. public function update($id, $name, $data)
  36. {
  37. $shop_id = Dever::param('shop_id',$data);
  38. $cash = Dever::param('cash',$data);
  39. $desc = Dever::param('desc',$data);
  40. $account = Dever::db('shop/yspay_account')->one(array('shop_id' => $shop_id));
  41. if (!$account) {
  42. Dever::alert('账户不存在');
  43. }
  44. if ($cash <= 0) {
  45. Dever::alert('提现金额不能小于0');
  46. }
  47. $cash = $cash * 100;
  48. if ($cash > $account['cash']) {
  49. Dever::alert('账户余额不足');
  50. }
  51. $order_num = $this->getOrderId();
  52. $account['desc'] = $desc;
  53. $account['mtype'] = 2;
  54. Dever::load('shop/yspay')->action($account['mid'], $order_num, -1, 2, $cash, $account);
  55. }
  56. }