diff --git a/lib/constants/market_api.dart b/lib/constants/market_api.dart index 2caa9523..94a0cf5d 100644 --- a/lib/constants/market_api.dart +++ b/lib/constants/market_api.dart @@ -6,6 +6,42 @@ class _MarketApi { _Category category = _Category(); _Home home = _Home(); _Rotation rotation = _Rotation(); + _ShopCart shopCart = _ShopCart(); + _Address address = _Address(); +} + +class _ShopCart { + ///加入购物车 + String get insert => '/app/user/shop/cart/insertShoppingCart'; + + ///我的购物车 + String get myCart => '/app/user/shop/cart/myShoppingCart'; + + ///更改购物车商品数量 + String get updateNum => '/app/user/shop/cart/updateShoppingCartNum'; + + ///删除购物车商品 + String get delete => '/app/user/shop/cart/deleteShoppingCart'; + + ///购物车结算 + String get settlement => '/app/user/shop/cart/settlement'; +} + +class _Address { + ///添加收货地址 + String get insert => '/app/user/shop/address/insert'; + + ///修改收货地址 + String get update => '/app/user/shop/address/update'; + + ///我的收货地址 + String get myAddress => '/app/user/shop/address/myAddress'; + + ///删除收货地址 + String get delete => '/app/user/shop/address/delete'; + + ///设置默认收货地址 + String get setDefault => '/app/user/shop/address/settingDefaultAddress'; } class _Collection { diff --git a/lib/models/collection/collection_goods_model.dart b/lib/models/collection/collection_goods_model.dart index 8351f767..f3e465ea 100644 --- a/lib/models/collection/collection_goods_model.dart +++ b/lib/models/collection/collection_goods_model.dart @@ -1,5 +1,11 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'collection_goods_model.g.dart'; + +@JsonSerializable() class CollectionGoodsModel { - int? id; + int id; + int? goodsPushId; String? skuName; String? mainPhoto; int? status; @@ -7,38 +13,18 @@ class CollectionGoodsModel { double? sellPrice; double? discountPrice; int? kind; + factory CollectionGoodsModel.fromJson(Map json) => + _$CollectionGoodsModelFromJson(json); - CollectionGoodsModel( - {this.id, - this.skuName, - this.mainPhoto, - this.status, - this.shopStatus, - this.sellPrice, - this.discountPrice, - this.kind}); - - CollectionGoodsModel.fromJson(Map json) { - id = json['id']; - skuName = json['skuName']; - mainPhoto = json['mainPhoto']; - status = json['status']; - shopStatus = json['shopStatus']; - sellPrice = json['sellPrice']; - discountPrice = json['discountPrice']; - kind = json['kind']; - } - - Map toJson() { - final Map data = new Map(); - data['id'] = this.id; - data['skuName'] = this.skuName; - data['mainPhoto'] = this.mainPhoto; - data['status'] = this.status; - data['shopStatus'] = this.shopStatus; - data['sellPrice'] = this.sellPrice; - data['discountPrice'] = this.discountPrice; - data['kind'] = this.kind; - return data; - } + CollectionGoodsModel({ + required this.id, + this.goodsPushId, + this.skuName, + this.mainPhoto, + this.status, + this.shopStatus, + this.sellPrice, + this.discountPrice, + this.kind, + }); } diff --git a/lib/models/collection/collection_goods_model.g.dart b/lib/models/collection/collection_goods_model.g.dart new file mode 100644 index 00000000..cc2371af --- /dev/null +++ b/lib/models/collection/collection_goods_model.g.dart @@ -0,0 +1,21 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'collection_goods_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +CollectionGoodsModel _$CollectionGoodsModelFromJson( + Map json) => + CollectionGoodsModel( + id: json['id'] as int, + goodsPushId: json['goodsPushId'] as int?, + skuName: json['skuName'] as String?, + mainPhoto: json['mainPhoto'] as String?, + status: json['status'] as int?, + shopStatus: json['shopStatus'] as int?, + sellPrice: (json['sellPrice'] as num?)?.toDouble(), + discountPrice: (json['discountPrice'] as num?)?.toDouble(), + kind: json['kind'] as int?, + ); diff --git a/lib/models/market/shop_car/shop_car_list_model.dart b/lib/models/market/shop_car/shop_car_list_model.dart index db8faf23..c0da9cc8 100644 --- a/lib/models/market/shop_car/shop_car_list_model.dart +++ b/lib/models/market/shop_car/shop_car_list_model.dart @@ -16,6 +16,8 @@ class ShopCarListModel { final int? shopStatus; final double? sellPrice; final double? discountPrice; + // 库存状态(1.有货,0.无货) + final int stockStatus; final String? unit; // 0=未知 1=自营 2=其 他,商品类别 @@ -37,6 +39,7 @@ class ShopCarListModel { this.shopStatus, this.sellPrice, this.discountPrice, + required this.stockStatus, this.unit, this.kind, this.weight, diff --git a/lib/models/market/shop_car/shop_car_list_model.g.dart b/lib/models/market/shop_car/shop_car_list_model.g.dart index e460ff88..c727fecb 100644 --- a/lib/models/market/shop_car/shop_car_list_model.g.dart +++ b/lib/models/market/shop_car/shop_car_list_model.g.dart @@ -15,6 +15,7 @@ ShopCarListModel _$ShopCarListModelFromJson(Map json) => shopStatus: json['shopStatus'] as int?, sellPrice: (json['sellPrice'] as num?)?.toDouble(), discountPrice: (json['discountPrice'] as num?)?.toDouble(), + stockStatus: json['stockStatus'] as int, unit: json['unit'] as String?, kind: json['kind'] as int?, weight: (json['weight'] as num?)?.toDouble(), diff --git a/lib/pages/personal/user_func.dart b/lib/pages/personal/user_func.dart index ec58be11..dd14f4d3 100644 --- a/lib/pages/personal/user_func.dart +++ b/lib/pages/personal/user_func.dart @@ -1,4 +1,5 @@ import 'package:aku_new_community/constants/api.dart'; +import 'package:aku_new_community/constants/sars_api.dart'; import 'package:aku_new_community/model/community/board_model.dart'; import 'package:aku_new_community/model/community/swiper_model.dart'; import 'package:aku_new_community/model/user/adress_model.dart'; @@ -11,7 +12,7 @@ class Userfunc { ///查询我的收货地址列表 static Future> getMyAddress() async { BaseModel model = await NetUtil().get( - API.user.myAddressList, + SARSAPI.market.address.myAddress, ); if (model.data!.length == 0) return []; return (model.data as List).map((e) => AddressModel.fromJson(e)).toList(); @@ -20,7 +21,7 @@ class Userfunc { ///添加收货地址 static Future insertAddress(String name, String tel, int? location, String addressDetail, int? isDefault) async { - BaseModel model = await NetUtil().post(API.user.insertAddress, + BaseModel model = await NetUtil().post(SARSAPI.market.address.insert, params: { 'name': name, 'tel': tel, @@ -41,7 +42,7 @@ class Userfunc { ///修改收货地址 static Future updateAddress(int id, String name, String tel, int? location, String addressDetail, int? isDefault) async { - BaseModel model = await NetUtil().post(API.user.updateAddress, + BaseModel model = await NetUtil().post(SARSAPI.market.address.update, params: { 'id': id, 'name': name, @@ -62,8 +63,8 @@ class Userfunc { ///删除收货地址 static Future deleteAddress(int addressId) async { - BaseModel model = await NetUtil().post(API.user.deleteAddress, - params: {'addressId': addressId}, showMessage: false); + BaseModel model = await NetUtil().post(SARSAPI.market.address.delete, + params: {'id': addressId}, showMessage: false); if (model.success) { BotToast.showText(text: '删除成功'); return true; @@ -75,8 +76,8 @@ class Userfunc { ///设置默认收货地址 static Future setIsDefaultAddress(int addressId) async { - BaseModel model = await NetUtil().post(API.user.settingDefaultAddress, - params: {'addressId': addressId}, showMessage: false); + BaseModel model = await NetUtil().post(SARSAPI.market.address.setDefault, + params: {'id': addressId}, showMessage: false); if (model.success) { BotToast.showText(text: '设置成功'); return true; diff --git a/lib/provider/app_provider.dart b/lib/provider/app_provider.dart index 9f525815..8159729e 100644 --- a/lib/provider/app_provider.dart +++ b/lib/provider/app_provider.dart @@ -4,6 +4,7 @@ import 'dart:io'; import 'package:aku_new_community/constants/api.dart'; import 'package:aku_new_community/constants/application_objects.dart'; import 'package:aku_new_community/constants/config.dart'; +import 'package:aku_new_community/constants/sars_api.dart'; import 'package:aku_new_community/model/common/real_time_weather_model.dart'; import 'package:aku_new_community/model/community/hot_topic_model.dart'; import 'package:aku_new_community/model/message/message_center_model.dart'; @@ -310,9 +311,7 @@ class AppProvider extends ChangeNotifier { ///保存默认收货地址 Future getMyAddress() async { - BaseModel model = await NetUtil().get( - API.user.myAddressList, - ); + BaseModel model = await NetUtil().get(SARSAPI.market.address.myAddress); if (model.data!.length == 0) return []; else { diff --git a/lib/ui/market/collection/collection_func.dart b/lib/ui/market/collection/collection_func.dart index 920e66db..4e576b1f 100644 --- a/lib/ui/market/collection/collection_func.dart +++ b/lib/ui/market/collection/collection_func.dart @@ -1,4 +1,4 @@ -import 'package:aku_new_community/constants/api.dart'; +import 'package:aku_new_community/constants/sars_api.dart'; import 'package:aku_new_community/models/collection/collection_goods_model.dart'; import 'package:aku_new_community/utils/network/base_model.dart'; import 'package:aku_new_community/utils/network/net_util.dart'; @@ -6,13 +6,14 @@ import 'package:aku_new_community/utils/network/net_util.dart'; class CollectionFunc { ///加入和取消收藏 static Future collection(int jcookGoodsId) async { - await NetUtil().get(API.market.addCollection, - params: {"jcookGoodsId": jcookGoodsId}, showMessage: true); + await NetUtil().get(SARSAPI.market.collection.changeCollection, + params: {"appGoodsPushId": jcookGoodsId}, showMessage: true); } /// 获取此供应商热度最高的商品 static Future> getCollectionList() async { - BaseModel baseModel = await NetUtil().get(API.market.collectionList); + BaseModel baseModel = + await NetUtil().get(SARSAPI.market.collection.myCollection); if (baseModel.success == true && baseModel.data != null) { return (baseModel.data as List) .map((e) => CollectionGoodsModel.fromJson(e)) diff --git a/lib/ui/market/order/order_card.dart b/lib/ui/market/order/order_card.dart index a5b6f5ee..e19354ec 100644 --- a/lib/ui/market/order/order_card.dart +++ b/lib/ui/market/order/order_card.dart @@ -62,7 +62,7 @@ class _OrderCardState extends State { super.initState(); widget.model.myOrderListVoList!.forEach((element) { _goodsList.add(SettlementGoodsDTO( - jcookGoodsId: element.jcookGoodsId, num: element.num)); + appGoodsPushId: element.jcookGoodsId, num: element.num)); }); } diff --git a/lib/ui/market/order/order_detail_page.dart b/lib/ui/market/order/order_detail_page.dart index 96dd1a8c..da550dc6 100644 --- a/lib/ui/market/order/order_detail_page.dart +++ b/lib/ui/market/order/order_detail_page.dart @@ -172,7 +172,7 @@ class _OrderDetailPageState extends State { super.initState(); widget.orderModel.myOrderListVoList!.forEach((element) { _goodsList.add(SettlementGoodsDTO( - jcookGoodsId: element.jcookGoodsId, num: element.num)); + appGoodsPushId: element.jcookGoodsId, num: element.num)); }); if (widget.orderModel.tradeStatus == 0) { timer = Timer.periodic(Duration(seconds: 1), (Timer t) => _checkTime()); diff --git a/lib/ui/market/search/search_func.dart b/lib/ui/market/search/search_func.dart index f91e6aba..628508f6 100644 --- a/lib/ui/market/search/search_func.dart +++ b/lib/ui/market/search/search_func.dart @@ -1,4 +1,5 @@ import 'package:aku_new_community/constants/api.dart'; +import 'package:aku_new_community/constants/sars_api.dart'; import 'package:aku_new_community/models/market/good_detail_model.dart'; import 'package:aku_new_community/models/market/order/order_detail_model.dart'; import 'package:aku_new_community/models/search/search_goods_model.dart'; @@ -53,8 +54,8 @@ class SearchFunc { ///查询商品详情 static Future getGoodDetail(int shopId) async { BaseModel model = await NetUtil().get( - API.market.findGoodsDetail, - params: {'shopId': shopId}, + SARSAPI.market.good.goodDetail, + params: {'appGoodsPushId': shopId}, ); if (model.data == null) return GoodDetailModel.fail(); return GoodDetailModel.fromJson(model.data); @@ -72,8 +73,8 @@ class SearchFunc { ///加入购物车 static Future addGoodsCar(int jcookGoodsId) async { - BaseModel model = await NetUtil().post(API.market.insertShoppingCart, - params: {'jcookGoodsId': jcookGoodsId}, showMessage: true); + BaseModel model = await NetUtil().post(SARSAPI.market.shopCart.insert, + params: {'appGoodsPushId': jcookGoodsId}, showMessage: true); if (model.msg == null) return ''; return model.msg as String; } diff --git a/lib/ui/market/search/settlementGoodsDTO.dart b/lib/ui/market/search/settlementGoodsDTO.dart index d0aabc7d..9b5c2224 100644 --- a/lib/ui/market/search/settlementGoodsDTO.dart +++ b/lib/ui/market/search/settlementGoodsDTO.dart @@ -1,20 +1,20 @@ class SettlementGoodsDTO { - int? jcookGoodsId; + int? appGoodsPushId; int? num; SettlementGoodsDTO({ - this.jcookGoodsId, + this.appGoodsPushId, this.num, }); SettlementGoodsDTO.fromJson(Map json) { - jcookGoodsId = json['jcookGoodsId']; + appGoodsPushId = json['jcookGoodsId']; num = json['num']; } Map toJson() { final Map data = new Map(); - data['jcookGoodsId'] = this.jcookGoodsId; + data['jcookGoodsId'] = this.appGoodsPushId; data['num'] = this.num; return data; diff --git a/lib/ui/market/search/submit_order_page.dart b/lib/ui/market/search/submit_order_page.dart index accf9f64..a2d2dbac 100644 --- a/lib/ui/market/search/submit_order_page.dart +++ b/lib/ui/market/search/submit_order_page.dart @@ -1,6 +1,7 @@ import 'package:aku_new_community/base/base_style.dart'; import 'package:aku_new_community/const/resource.dart'; import 'package:aku_new_community/constants/api.dart'; +import 'package:aku_new_community/constants/sars_api.dart'; import 'package:aku_new_community/model/order/create_order_model.dart'; import 'package:aku_new_community/model/user/adress_model.dart'; import 'package:aku_new_community/models/market/shop_car/shop_car_list_model.dart'; @@ -52,8 +53,8 @@ class _SubmitOrderPageState extends State { _controllers.clear(); widget.models.forEach((element) { _controllers.add(TextEditingController(text: element.num.toString())); - _goodsList - .add(SettlementGoodsDTO(jcookGoodsId: element.id, num: element.num)); + _goodsList.add( + SettlementGoodsDTO(appGoodsPushId: element.id, num: element.num)); }); if (appProvider.addressModel != null) { @@ -72,7 +73,7 @@ class _SubmitOrderPageState extends State { Future createOrder( int addressId, List goodsList) async { BaseModel model = await NetUtil().post( - API.market.shopCarSettlement, + SARSAPI.market.shopCart.settlement, params: { 'addressId': addressId, 'settlementGoodsDTOList': goodsList.map((v) => v.toJson()).toList() @@ -726,8 +727,8 @@ class _SubmitOrderPageState extends State { Future changeNum(int jcookGoodsId, int num) async { var cancel = BotToast.showLoading(); - var base = await NetUtil().post(API.market.shopCarChangeNum, - params: {'jcookGoodsId': jcookGoodsId, 'num': num}); + var base = await NetUtil().post(SARSAPI.market.shopCart.updateNum, + params: {'appGoodsPushId': jcookGoodsId, 'num': num}); if (!(base.success)) { BotToast.showText(text: base.msg); } diff --git a/lib/ui/market/search/submit_order_page_normal.dart b/lib/ui/market/search/submit_order_page_normal.dart index 1cd43293..0be59a17 100644 --- a/lib/ui/market/search/submit_order_page_normal.dart +++ b/lib/ui/market/search/submit_order_page_normal.dart @@ -1,5 +1,6 @@ import 'package:aku_new_community/base/base_style.dart'; import 'package:aku_new_community/constants/api.dart'; +import 'package:aku_new_community/constants/sars_api.dart'; import 'package:aku_new_community/gen/assets.gen.dart'; import 'package:aku_new_community/model/order/create_order_model.dart'; import 'package:aku_new_community/model/user/adress_model.dart'; @@ -53,7 +54,7 @@ class _SubmitOrderNormalPageState extends State { _controllers = TextEditingController(text: '1'); _goodsList - .add(SettlementGoodsDTO(jcookGoodsId: widget.goodModel.id, num: 1)); + .add(SettlementGoodsDTO(appGoodsPushId: widget.goodModel.id, num: 1)); if (appProvider.addressModel != null) { _addressModel = appProvider.addressModel!; @@ -72,7 +73,7 @@ class _SubmitOrderNormalPageState extends State { Future createOrder( int addressId, List goodsList) async { BaseModel model = await NetUtil().post( - API.market.shopCarSettlement, + SARSAPI.market.shopCart.settlement, params: { 'addressId': addressId, 'settlementGoodsDTOList': goodsList.map((v) => v.toJson()).toList() @@ -758,8 +759,8 @@ class _SubmitOrderNormalPageState extends State { Future changeNum(int jcookGoodsId, int num) async { var cancel = BotToast.showLoading(); - var base = await NetUtil().post(API.market.shopCarChangeNum, - params: {'jcookGoodsId': jcookGoodsId, 'num': num}); + var base = await NetUtil().post(SARSAPI.market.shopCart.updateNum, + params: {'appGoodsPushId': jcookGoodsId, 'num': num}); if (!(base.success)) { BotToast.showText(text: base.msg); } diff --git a/lib/ui/market/shop_car/shop_car_page.dart b/lib/ui/market/shop_car/shop_car_page.dart index f8e1e837..aa44b379 100644 --- a/lib/ui/market/shop_car/shop_car_page.dart +++ b/lib/ui/market/shop_car/shop_car_page.dart @@ -1,6 +1,6 @@ import 'package:aku_new_community/base/base_style.dart'; import 'package:aku_new_community/const/resource.dart'; -import 'package:aku_new_community/constants/api.dart'; +import 'package:aku_new_community/constants/sars_api.dart'; import 'package:aku_new_community/models/market/shop_car/shop_car_list_model.dart'; import 'package:aku_new_community/ui/market/search/submit_order_page.dart'; import 'package:aku_new_community/ui/market/shop_car/shop_car_func.dart'; @@ -92,15 +92,12 @@ class _ShopCarPageState extends State { controller: _refreshController, header: MaterialHeader(), onRefresh: () async { - var base = await NetUtil().get(API.market.shopCarList); + var base = + await NetUtil().get(SARSAPI.market.shopCart.myCart); if (base.success) { _models = (base.data as List) .map((e) => ShopCarListModel.fromJson(e)) .toList(); - // _controllers.forEach((element) { - // element.dispose(); - // }); - // _controllers.clear(); if (_first) { _models.forEach((element) { _controllers.add(TextEditingController( @@ -248,9 +245,9 @@ class _ShopCarPageState extends State { if (result == true) { BaseModel model = await NetUtil().post( - API.market.shopCarDelete, + SARSAPI.market.shopCart.delete, params: { - 'jcookGoodsIds': _selectIndex.map((e) => _models[e].id).toList() + 'appGoodsPushIds': _selectIndex.map((e) => _models[e].id).toList() }, showMessage: true, ); @@ -607,8 +604,8 @@ class _ShopCarPageState extends State { Future changeNum(int jcookGoodsId, int num) async { var cancel = BotToast.showLoading(); - var base = await NetUtil().post(API.market.shopCarChangeNum, - params: {'jcookGoodsId': jcookGoodsId, 'num': num}); + var base = await NetUtil().post(SARSAPI.market.shopCart.updateNum, + params: {'appGoodsPushId': jcookGoodsId, 'num': num}); if (!(base.success)) { BotToast.showText(text: base.msg); } @@ -634,9 +631,9 @@ class _ShopCarPageState extends State { if (result == true) { BaseModel model = await NetUtil().post( - API.market.shopCarDelete, + SARSAPI.market.shopCart.delete, params: { - 'jcookGoodsIds': _selectIndex.map((e) => _models[e].id).toList() + 'appGoodsPushIds': _selectIndex.map((e) => _models[e].id).toList() }, showMessage: true, );