StaffReflect.Class.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /**
  3. * 提成提现
  4. * Created by PhpStorm.
  5. * User: wxj
  6. * Date: 2019/10/31
  7. * Time: 15:02
  8. */
  9. namespace JinDouYun\Controller\Department;
  10. use JinDouYun\Dao\Department\DStaffReflect;
  11. use Mall\Framework\Core\ErrorCode;
  12. use Mall\Framework\Core\ResultWrapper;
  13. use Mall\Framework\Core\StatusCode;
  14. use JinDouYun\Cache\ShopCache;
  15. use JinDouYun\Controller\BaseController;
  16. use JinDouYun\Cache\TempSaveCache;
  17. class StaffReflect extends BaseController
  18. {
  19. private $obj;
  20. private $objShopCache;
  21. private $objTempSaveCache;
  22. public function __construct($isCheckAcl = true, $isMustLogin = true)
  23. {
  24. parent::__construct($isCheckAcl, $isMustLogin);
  25. $this->objShopCache = new ShopCache();
  26. $this->objTempSaveCache = new TempSaveCache();
  27. }
  28. /**
  29. * 列表
  30. */
  31. public function list()
  32. {
  33. $params = $this->request->params();
  34. $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
  35. $limit = $pageParams['limit'];
  36. $offset = $pageParams['offset'];
  37. $selectParams['a.en_id'] = $this->onlineEnterpriseId;
  38. if (isset($params['auditStatus']) and !empty($params['auditStatus'])) {
  39. $selectParams['a.auditStatus'] = $params['auditStatus'];
  40. }
  41. if (isset($params['staffId']) and !empty($params['staffId'])) {
  42. $selectParams['a.staffId'] = $params['staffId'];
  43. }
  44. if (isset($params['reflectStatus']) and !empty($params['reflectStatus'])) {
  45. $selectParams['a.reflectStatus'] = $params['reflectStatus'];
  46. }
  47. if (isset($params['reflectType']) and !empty($params['reflectType'])) {
  48. $selectParams['reflectType'] = $params['reflectType'];
  49. }
  50. if (isset($params['end']) and !empty($params['end']) && isset($params['start']) and !empty($params['start'])) {
  51. $selectParams[] = ['a.createTime', '>=', $params['start']];
  52. $selectParams[] = ['a.createTime', '<=', $params['end']];
  53. }
  54. $db = new DStaffReflect('default');
  55. $join = 'Left join qianniao_staff_'.$this->onlineEnterpriseId.' as b on a.staffId = b.id';
  56. $list = $db->select($selectParams, 'a.*,b.staffName', 'a.id DESC', $limit, $offset, [], true, false, $join);
  57. if ($list){
  58. foreach ($list as &$item) {
  59. $item['reflectInfo'] = json_decode($item['reflectInfo']);
  60. }
  61. }
  62. $count = $db->count($selectParams);
  63. $pageData = [
  64. 'pageIndex' => $params['page'],
  65. 'pageSize' => $params['pageSize'],
  66. 'pageTotal' => $count,
  67. ];
  68. parent::sendOutput($list, 0, $pageData);
  69. }
  70. /**
  71. * 打款审核
  72. * @return void
  73. */
  74. public function updateStatus()
  75. {
  76. $parma = $this->request->getRawJson();
  77. if (empty($parma['id'])) $this->sendOutput('id参数为空', ErrorCode::$paramError);
  78. if (empty($parma['status'])) $this->sendOutput('status参数为空', ErrorCode::$paramError);
  79. $db = new DStaffReflect('default');
  80. $data = $db->get(['id' => $parma['id']]);
  81. if (empty($data)) $this->sendOutput('提现记录不存在', ErrorCode::$paramError);
  82. if ($parma['status'] == 1){
  83. if ($data['auditStatus'] == 2) $this->sendOutput('提现已审核', ErrorCode::$paramError);
  84. $res = $db->update(['auditStatus' => 2]);
  85. }elseif ($parma['status'] == 2){
  86. $res = $db->update(['reflectStatus' => 3]);
  87. }elseif ($parma['status'] == 3){
  88. if ($data['reflectStatus'] == 5) $this->sendOutput('提现已打款', ErrorCode::$paramError);
  89. if ($data['auditStatus'] != 2) $this->sendOutput('订单未审核', ErrorCode::$paramError);
  90. $res = $db->update(['reflectStatus' => 5]);
  91. }
  92. if ($res) parent::sendOutput('成功');
  93. parent::sendOutput('失败', ErrorCode::$paramError);
  94. }
  95. }