GhsBalanceChangeController.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace hd\controllers;
  3. use bizHd\ghs\classes\GhsBalanceChangeClass;
  4. use bizHd\ghs\classes\GhsClass;
  5. use common\components\util;
  6. use Yii;
  7. /**
  8. * 花店端供货商余额变动
  9. * 小程序登录态与 H5 扫码付款(salt)共用 list 接口
  10. */
  11. class GhsBalanceChangeController extends BaseController
  12. {
  13. /** H5 付款页未登录也可查明细,依赖 salt 校验归属 */
  14. public $guestAccess = ['list'];
  15. /**
  16. * 余额变动明细列表
  17. * 无 salt:校验当前店铺是否拥有该供货商;有 salt:与 get-ghs-data 一致按 salt 放行(H5 访客)
  18. */
  19. public function actionList()
  20. {
  21. $get = Yii::$app->request->get();
  22. $ghsId = $get['ghsId'] ?? 0;
  23. $salt = $get['salt'] ?? '';
  24. $ghs = GhsClass::getById($ghsId, true);
  25. if (empty($ghs)) {
  26. util::fail('无法查看');
  27. }
  28. if (empty($salt)) {
  29. GhsClass::valid($ghs, $this->shopId);
  30. } else {
  31. // 扫码付款链接携带 salt,与小程序余额明细共用同一套数据
  32. if ($ghs->salt != $salt) {
  33. util::fail('无法查看');
  34. }
  35. }
  36. $where = [];
  37. $where['ghsId'] = $ghsId;
  38. $list = GhsBalanceChangeClass::getChangeList($where);
  39. util::success($list);
  40. }
  41. }