MyCommisionController.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * 企业微信号"我的提成"控制器
  4. * @author 2015-12-09
  5. */
  6. class MyCommisionController extends CController {
  7. public $layout = 'qyindex';
  8. /**
  9. * 我的提成首页,默认显示本月数据
  10. */
  11. public function actionIndex() {
  12. // 环境判断
  13. // if (ENVIRONMENT == 'product') {
  14. if (false) {
  15. if (isset($_COOKIE['weixin_userid']) && isset($_COOKIE['weixin_userid_signature'])) {
  16. $signature = md5($_COOKIE['weixin_userid'].'wozhua=9527');
  17. if ($signature == $_COOKIE['weixin_userid_signature']) {
  18. $userid = $_COOKIE['weixin_userid'];
  19. } else {
  20. $this->render('error', ['msg' => '未查询到用户']);die;
  21. }
  22. } else {
  23. $this->redirect('https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxedb2ce71dfee8aa5&redirect_uri= api.yiguanjia.me%2Findex.php%3Fr%3Do2o%2FmyCommision%2FcheckUserid&response_type=code&scope=snsapi_base&state=5e2b4706179f774e94903e1213d2222e#wechat_redirect');
  24. }
  25. } else {
  26. $userid = Yii::app()->request->getParam('weixin_userid', '');
  27. }
  28. $tech = TechInfo::getByUserid($userid);
  29. if (!$tech) {
  30. $this->render('error', ['msg' => '未查询到用户']);die;
  31. }
  32. $username = $tech->name;
  33. $user = $tech->_id;
  34. $timelist = O2oApp::getTimeList();
  35. $info = array(
  36. 'userid' => $userid,
  37. 'username' => $username,
  38. 'user' => $user,
  39. 'timelist' => $timelist,
  40. );
  41. $data = array_merge($info);
  42. $this->render('index', $data);
  43. }
  44. /**
  45. * 获取userid保存至cookie
  46. */
  47. public function actionCheckUserid() {
  48. $check = O2oApp::checkURI(24);
  49. if (!$check['success']) {
  50. $this->render('error', $check);die;
  51. } else {
  52. $userid = $check['userid'];
  53. }
  54. setcookie('weixin_userid', $userid);
  55. setcookie('weixin_userid_signature', md5($userid.'wozhua=9527'));
  56. $this->redirect(['index']);
  57. }
  58. public function actionList() {
  59. $start = Yii::app()->request->getParam('start', 0);
  60. $end = Yii::app()->request->getParam('end', 0);
  61. $userid = Yii::app()->request->getParam('userid', '');
  62. $start = strtotime($start);
  63. $end = $end == 0 ? strtotime('+1 month', $start) : $end;
  64. $o2oApp = new O2oApp($userid);
  65. $commisionData = $o2oApp->getCommision($start, $end, true);
  66. echo json_encode($commisionData);
  67. }
  68. public function actionInfo() {
  69. $order = Yii::app()->request->getParam('order', '');
  70. $user = Yii::app()->request->getParam('user', '');
  71. $type = intval(Yii::app()->request->getParam('type', 0));
  72. $this->layout = 'qyinfo';
  73. $data = array(
  74. 'order' => $order,
  75. 'user' => $user
  76. );
  77. if ($type == 0) {
  78. $this->render('info_order', $data);
  79. } else {
  80. $this->render('info_append', $data);
  81. }
  82. }
  83. }