智莺生活APP的阿里百川 Flutter 插件
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

albc_tools.dart 1.8 KiB

2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. ///
  2. /// @Description: 工具类
  3. /// @Author: wuxing
  4. /// @Date: 2019-09-06 22:51:22
  5. /// @LastEditors: wuxing
  6. /// @LastEditTime: 2019-09-06 22:52:48
  7. ///
  8. import 'alibc_const_key.dart';
  9. import 'alibc_model.dart';
  10. class AlibcTools {
  11. // -------------------------------------------//
  12. // --------这里是工具类,不要从这获取-------------//
  13. // -------------------------------------------//
  14. // 获取返回数据
  15. static TradeResult getTradeResult(Map result) {
  16. // 如果失败
  17. if (result[AlibcConstKey.errorCode] != "0") {
  18. return TradeResult(
  19. result[AlibcConstKey.errorCode],
  20. result[AlibcConstKey.errorMessage],
  21. );
  22. }
  23. // 判断类型
  24. if (result[AlibcConstKey.data]["type"] ==
  25. TradeResultType.AlibcTradeResultTypePaySuccess) {
  26. // 付款成功
  27. return TradeResult(
  28. result[AlibcConstKey.errorCode], result[AlibcConstKey.errorMessage],
  29. type: TradeResultType.AlibcTradeResultTypePaySuccess,
  30. payResult: PayResult(
  31. result[AlibcConstKey.data]["paySuccessOrders"],
  32. result[AlibcConstKey.data]["payFailedOrders"],
  33. ));
  34. } else {
  35. // 添加购物车成功
  36. return TradeResult(
  37. result[AlibcConstKey.errorCode],
  38. result[AlibcConstKey.errorMessage],
  39. type: TradeResultType.AlibcTradeResultTypeAddCard,
  40. );
  41. }
  42. }
  43. // 设置淘宝客数据
  44. static Map? getTaokeMap(TaokeParams? taokeParams) {
  45. Map? taoKe;
  46. if (taokeParams != null) {
  47. taoKe = {
  48. "adzoneId": taokeParams.adzoneId ?? "",
  49. "pid": taokeParams.pid ?? "",
  50. "unionId": taokeParams.unionId ?? "",
  51. "subPid": taokeParams.subPid ?? "",
  52. "extParams": taokeParams.extParams ?? {}
  53. };
  54. }
  55. return taoKe;
  56. }
  57. }