更改部分商城接口

pull/1/head
张萌 3 years ago
parent 596ed6d4bb
commit e182005713

@ -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 {

@ -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<String, dynamic> json) =>
_$CollectionGoodsModelFromJson(json);
CollectionGoodsModel(
{this.id,
this.skuName,
this.mainPhoto,
this.status,
this.shopStatus,
this.sellPrice,
this.discountPrice,
this.kind});
CollectionGoodsModel.fromJson(Map<String, dynamic> 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<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
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,
});
}

@ -0,0 +1,21 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'collection_goods_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
CollectionGoodsModel _$CollectionGoodsModelFromJson(
Map<String, dynamic> 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?,
);

@ -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,

@ -15,6 +15,7 @@ ShopCarListModel _$ShopCarListModelFromJson(Map<String, dynamic> 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(),

@ -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<List<AddressModel>> 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<bool> 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<bool> 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<bool> 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<bool> 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;

@ -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 {

@ -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<List<CollectionGoodsModel>> 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))

@ -62,7 +62,7 @@ class _OrderCardState extends State<OrderCard> {
super.initState();
widget.model.myOrderListVoList!.forEach((element) {
_goodsList.add(SettlementGoodsDTO(
jcookGoodsId: element.jcookGoodsId, num: element.num));
appGoodsPushId: element.jcookGoodsId, num: element.num));
});
}

@ -172,7 +172,7 @@ class _OrderDetailPageState extends State<OrderDetailPage> {
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());

@ -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<GoodDetailModel> 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<String> 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;
}

@ -1,20 +1,20 @@
class SettlementGoodsDTO {
int? jcookGoodsId;
int? appGoodsPushId;
int? num;
SettlementGoodsDTO({
this.jcookGoodsId,
this.appGoodsPushId,
this.num,
});
SettlementGoodsDTO.fromJson(Map<String, dynamic> json) {
jcookGoodsId = json['jcookGoodsId'];
appGoodsPushId = json['jcookGoodsId'];
num = json['num'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['jcookGoodsId'] = this.jcookGoodsId;
data['jcookGoodsId'] = this.appGoodsPushId;
data['num'] = this.num;
return data;

@ -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<SubmitOrderPage> {
_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<SubmitOrderPage> {
Future<bool> createOrder(
int addressId, List<SettlementGoodsDTO> 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<SubmitOrderPage> {
Future<bool> 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);
}

@ -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<SubmitOrderNormalPage> {
_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<SubmitOrderNormalPage> {
Future<bool> createOrder(
int addressId, List<SettlementGoodsDTO> 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<SubmitOrderNormalPage> {
Future<bool> 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);
}

@ -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<ShopCarPage> {
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<ShopCarPage> {
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<ShopCarPage> {
Future<bool> 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<ShopCarPage> {
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,
);

Loading…
Cancel
Save