智莺生活APP的阿里百川 Flutter 插件
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

63 rindas
1.7 KiB

  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. }