更改部分商城接口

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

@ -6,6 +6,42 @@ class _MarketApi {
_Category category = _Category(); _Category category = _Category();
_Home home = _Home(); _Home home = _Home();
_Rotation rotation = _Rotation(); _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 { class _Collection {

@ -1,5 +1,11 @@
import 'package:json_annotation/json_annotation.dart';
part 'collection_goods_model.g.dart';
@JsonSerializable()
class CollectionGoodsModel { class CollectionGoodsModel {
int? id; int id;
int? goodsPushId;
String? skuName; String? skuName;
String? mainPhoto; String? mainPhoto;
int? status; int? status;
@ -7,38 +13,18 @@ class CollectionGoodsModel {
double? sellPrice; double? sellPrice;
double? discountPrice; double? discountPrice;
int? kind; int? kind;
factory CollectionGoodsModel.fromJson(Map<String, dynamic> json) =>
_$CollectionGoodsModelFromJson(json);
CollectionGoodsModel( CollectionGoodsModel({
{this.id, required this.id,
this.skuName, this.goodsPushId,
this.mainPhoto, this.skuName,
this.status, this.mainPhoto,
this.shopStatus, this.status,
this.sellPrice, this.shopStatus,
this.discountPrice, this.sellPrice,
this.kind}); 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;
}
} }

@ -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 int? shopStatus;
final double? sellPrice; final double? sellPrice;
final double? discountPrice; final double? discountPrice;
// (1.0.)
final int stockStatus;
final String? unit; final String? unit;
// 0= 1= 2= , // 0= 1= 2= ,
@ -37,6 +39,7 @@ class ShopCarListModel {
this.shopStatus, this.shopStatus,
this.sellPrice, this.sellPrice,
this.discountPrice, this.discountPrice,
required this.stockStatus,
this.unit, this.unit,
this.kind, this.kind,
this.weight, this.weight,

@ -15,6 +15,7 @@ ShopCarListModel _$ShopCarListModelFromJson(Map<String, dynamic> json) =>
shopStatus: json['shopStatus'] as int?, shopStatus: json['shopStatus'] as int?,
sellPrice: (json['sellPrice'] as num?)?.toDouble(), sellPrice: (json['sellPrice'] as num?)?.toDouble(),
discountPrice: (json['discountPrice'] as num?)?.toDouble(), discountPrice: (json['discountPrice'] as num?)?.toDouble(),
stockStatus: json['stockStatus'] as int,
unit: json['unit'] as String?, unit: json['unit'] as String?,
kind: json['kind'] as int?, kind: json['kind'] as int?,
weight: (json['weight'] as num?)?.toDouble(), weight: (json['weight'] as num?)?.toDouble(),

@ -1,4 +1,5 @@
import 'package:aku_new_community/constants/api.dart'; 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/board_model.dart';
import 'package:aku_new_community/model/community/swiper_model.dart'; import 'package:aku_new_community/model/community/swiper_model.dart';
import 'package:aku_new_community/model/user/adress_model.dart'; import 'package:aku_new_community/model/user/adress_model.dart';
@ -11,7 +12,7 @@ class Userfunc {
/// ///
static Future<List<AddressModel>> getMyAddress() async { static Future<List<AddressModel>> getMyAddress() async {
BaseModel model = await NetUtil().get( BaseModel model = await NetUtil().get(
API.user.myAddressList, SARSAPI.market.address.myAddress,
); );
if (model.data!.length == 0) return []; if (model.data!.length == 0) return [];
return (model.data as List).map((e) => AddressModel.fromJson(e)).toList(); 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, static Future<bool> insertAddress(String name, String tel, int? location,
String addressDetail, int? isDefault) async { String addressDetail, int? isDefault) async {
BaseModel model = await NetUtil().post(API.user.insertAddress, BaseModel model = await NetUtil().post(SARSAPI.market.address.insert,
params: { params: {
'name': name, 'name': name,
'tel': tel, 'tel': tel,
@ -41,7 +42,7 @@ class Userfunc {
/// ///
static Future<bool> updateAddress(int id, String name, String tel, static Future<bool> updateAddress(int id, String name, String tel,
int? location, String addressDetail, int? isDefault) async { 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: { params: {
'id': id, 'id': id,
'name': name, 'name': name,
@ -62,8 +63,8 @@ class Userfunc {
/// ///
static Future<bool> deleteAddress(int addressId) async { static Future<bool> deleteAddress(int addressId) async {
BaseModel model = await NetUtil().post(API.user.deleteAddress, BaseModel model = await NetUtil().post(SARSAPI.market.address.delete,
params: {'addressId': addressId}, showMessage: false); params: {'id': addressId}, showMessage: false);
if (model.success) { if (model.success) {
BotToast.showText(text: '删除成功'); BotToast.showText(text: '删除成功');
return true; return true;
@ -75,8 +76,8 @@ class Userfunc {
/// ///
static Future<bool> setIsDefaultAddress(int addressId) async { static Future<bool> setIsDefaultAddress(int addressId) async {
BaseModel model = await NetUtil().post(API.user.settingDefaultAddress, BaseModel model = await NetUtil().post(SARSAPI.market.address.setDefault,
params: {'addressId': addressId}, showMessage: false); params: {'id': addressId}, showMessage: false);
if (model.success) { if (model.success) {
BotToast.showText(text: '设置成功'); BotToast.showText(text: '设置成功');
return true; return true;

@ -4,6 +4,7 @@ import 'dart:io';
import 'package:aku_new_community/constants/api.dart'; import 'package:aku_new_community/constants/api.dart';
import 'package:aku_new_community/constants/application_objects.dart'; import 'package:aku_new_community/constants/application_objects.dart';
import 'package:aku_new_community/constants/config.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/common/real_time_weather_model.dart';
import 'package:aku_new_community/model/community/hot_topic_model.dart'; import 'package:aku_new_community/model/community/hot_topic_model.dart';
import 'package:aku_new_community/model/message/message_center_model.dart'; import 'package:aku_new_community/model/message/message_center_model.dart';
@ -310,9 +311,7 @@ class AppProvider extends ChangeNotifier {
/// ///
Future getMyAddress() async { Future getMyAddress() async {
BaseModel model = await NetUtil().get( BaseModel model = await NetUtil().get(SARSAPI.market.address.myAddress);
API.user.myAddressList,
);
if (model.data!.length == 0) if (model.data!.length == 0)
return []; return [];
else { 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/models/collection/collection_goods_model.dart';
import 'package:aku_new_community/utils/network/base_model.dart'; import 'package:aku_new_community/utils/network/base_model.dart';
import 'package:aku_new_community/utils/network/net_util.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 { class CollectionFunc {
/// ///
static Future collection(int jcookGoodsId) async { static Future collection(int jcookGoodsId) async {
await NetUtil().get(API.market.addCollection, await NetUtil().get(SARSAPI.market.collection.changeCollection,
params: {"jcookGoodsId": jcookGoodsId}, showMessage: true); params: {"appGoodsPushId": jcookGoodsId}, showMessage: true);
} }
/// ///
static Future<List<CollectionGoodsModel>> getCollectionList() async { 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) { if (baseModel.success == true && baseModel.data != null) {
return (baseModel.data as List) return (baseModel.data as List)
.map((e) => CollectionGoodsModel.fromJson(e)) .map((e) => CollectionGoodsModel.fromJson(e))

@ -62,7 +62,7 @@ class _OrderCardState extends State<OrderCard> {
super.initState(); super.initState();
widget.model.myOrderListVoList!.forEach((element) { widget.model.myOrderListVoList!.forEach((element) {
_goodsList.add(SettlementGoodsDTO( _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(); super.initState();
widget.orderModel.myOrderListVoList!.forEach((element) { widget.orderModel.myOrderListVoList!.forEach((element) {
_goodsList.add(SettlementGoodsDTO( _goodsList.add(SettlementGoodsDTO(
jcookGoodsId: element.jcookGoodsId, num: element.num)); appGoodsPushId: element.jcookGoodsId, num: element.num));
}); });
if (widget.orderModel.tradeStatus == 0) { if (widget.orderModel.tradeStatus == 0) {
timer = Timer.periodic(Duration(seconds: 1), (Timer t) => _checkTime()); 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/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/good_detail_model.dart';
import 'package:aku_new_community/models/market/order/order_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'; import 'package:aku_new_community/models/search/search_goods_model.dart';
@ -53,8 +54,8 @@ class SearchFunc {
/// ///
static Future<GoodDetailModel> getGoodDetail(int shopId) async { static Future<GoodDetailModel> getGoodDetail(int shopId) async {
BaseModel model = await NetUtil().get( BaseModel model = await NetUtil().get(
API.market.findGoodsDetail, SARSAPI.market.good.goodDetail,
params: {'shopId': shopId}, params: {'appGoodsPushId': shopId},
); );
if (model.data == null) return GoodDetailModel.fail(); if (model.data == null) return GoodDetailModel.fail();
return GoodDetailModel.fromJson(model.data); return GoodDetailModel.fromJson(model.data);
@ -72,8 +73,8 @@ class SearchFunc {
/// ///
static Future<String> addGoodsCar(int jcookGoodsId) async { static Future<String> addGoodsCar(int jcookGoodsId) async {
BaseModel model = await NetUtil().post(API.market.insertShoppingCart, BaseModel model = await NetUtil().post(SARSAPI.market.shopCart.insert,
params: {'jcookGoodsId': jcookGoodsId}, showMessage: true); params: {'appGoodsPushId': jcookGoodsId}, showMessage: true);
if (model.msg == null) return ''; if (model.msg == null) return '';
return model.msg as String; return model.msg as String;
} }

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

@ -1,6 +1,7 @@
import 'package:aku_new_community/base/base_style.dart'; import 'package:aku_new_community/base/base_style.dart';
import 'package:aku_new_community/const/resource.dart'; import 'package:aku_new_community/const/resource.dart';
import 'package:aku_new_community/constants/api.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/order/create_order_model.dart';
import 'package:aku_new_community/model/user/adress_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'; 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(); _controllers.clear();
widget.models.forEach((element) { widget.models.forEach((element) {
_controllers.add(TextEditingController(text: element.num.toString())); _controllers.add(TextEditingController(text: element.num.toString()));
_goodsList _goodsList.add(
.add(SettlementGoodsDTO(jcookGoodsId: element.id, num: element.num)); SettlementGoodsDTO(appGoodsPushId: element.id, num: element.num));
}); });
if (appProvider.addressModel != null) { if (appProvider.addressModel != null) {
@ -72,7 +73,7 @@ class _SubmitOrderPageState extends State<SubmitOrderPage> {
Future<bool> createOrder( Future<bool> createOrder(
int addressId, List<SettlementGoodsDTO> goodsList) async { int addressId, List<SettlementGoodsDTO> goodsList) async {
BaseModel model = await NetUtil().post( BaseModel model = await NetUtil().post(
API.market.shopCarSettlement, SARSAPI.market.shopCart.settlement,
params: { params: {
'addressId': addressId, 'addressId': addressId,
'settlementGoodsDTOList': goodsList.map((v) => v.toJson()).toList() 'settlementGoodsDTOList': goodsList.map((v) => v.toJson()).toList()
@ -726,8 +727,8 @@ class _SubmitOrderPageState extends State<SubmitOrderPage> {
Future<bool> changeNum(int jcookGoodsId, int num) async { Future<bool> changeNum(int jcookGoodsId, int num) async {
var cancel = BotToast.showLoading(); var cancel = BotToast.showLoading();
var base = await NetUtil().post(API.market.shopCarChangeNum, var base = await NetUtil().post(SARSAPI.market.shopCart.updateNum,
params: {'jcookGoodsId': jcookGoodsId, 'num': num}); params: {'appGoodsPushId': jcookGoodsId, 'num': num});
if (!(base.success)) { if (!(base.success)) {
BotToast.showText(text: base.msg); BotToast.showText(text: base.msg);
} }

@ -1,5 +1,6 @@
import 'package:aku_new_community/base/base_style.dart'; import 'package:aku_new_community/base/base_style.dart';
import 'package:aku_new_community/constants/api.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/gen/assets.gen.dart';
import 'package:aku_new_community/model/order/create_order_model.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/model/user/adress_model.dart';
@ -53,7 +54,7 @@ class _SubmitOrderNormalPageState extends State<SubmitOrderNormalPage> {
_controllers = TextEditingController(text: '1'); _controllers = TextEditingController(text: '1');
_goodsList _goodsList
.add(SettlementGoodsDTO(jcookGoodsId: widget.goodModel.id, num: 1)); .add(SettlementGoodsDTO(appGoodsPushId: widget.goodModel.id, num: 1));
if (appProvider.addressModel != null) { if (appProvider.addressModel != null) {
_addressModel = appProvider.addressModel!; _addressModel = appProvider.addressModel!;
@ -72,7 +73,7 @@ class _SubmitOrderNormalPageState extends State<SubmitOrderNormalPage> {
Future<bool> createOrder( Future<bool> createOrder(
int addressId, List<SettlementGoodsDTO> goodsList) async { int addressId, List<SettlementGoodsDTO> goodsList) async {
BaseModel model = await NetUtil().post( BaseModel model = await NetUtil().post(
API.market.shopCarSettlement, SARSAPI.market.shopCart.settlement,
params: { params: {
'addressId': addressId, 'addressId': addressId,
'settlementGoodsDTOList': goodsList.map((v) => v.toJson()).toList() 'settlementGoodsDTOList': goodsList.map((v) => v.toJson()).toList()
@ -758,8 +759,8 @@ class _SubmitOrderNormalPageState extends State<SubmitOrderNormalPage> {
Future<bool> changeNum(int jcookGoodsId, int num) async { Future<bool> changeNum(int jcookGoodsId, int num) async {
var cancel = BotToast.showLoading(); var cancel = BotToast.showLoading();
var base = await NetUtil().post(API.market.shopCarChangeNum, var base = await NetUtil().post(SARSAPI.market.shopCart.updateNum,
params: {'jcookGoodsId': jcookGoodsId, 'num': num}); params: {'appGoodsPushId': jcookGoodsId, 'num': num});
if (!(base.success)) { if (!(base.success)) {
BotToast.showText(text: base.msg); BotToast.showText(text: base.msg);
} }

@ -1,6 +1,6 @@
import 'package:aku_new_community/base/base_style.dart'; import 'package:aku_new_community/base/base_style.dart';
import 'package:aku_new_community/const/resource.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/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/search/submit_order_page.dart';
import 'package:aku_new_community/ui/market/shop_car/shop_car_func.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, controller: _refreshController,
header: MaterialHeader(), header: MaterialHeader(),
onRefresh: () async { onRefresh: () async {
var base = await NetUtil().get(API.market.shopCarList); var base =
await NetUtil().get(SARSAPI.market.shopCart.myCart);
if (base.success) { if (base.success) {
_models = (base.data as List) _models = (base.data as List)
.map((e) => ShopCarListModel.fromJson(e)) .map((e) => ShopCarListModel.fromJson(e))
.toList(); .toList();
// _controllers.forEach((element) {
// element.dispose();
// });
// _controllers.clear();
if (_first) { if (_first) {
_models.forEach((element) { _models.forEach((element) {
_controllers.add(TextEditingController( _controllers.add(TextEditingController(
@ -248,9 +245,9 @@ class _ShopCarPageState extends State<ShopCarPage> {
if (result == true) { if (result == true) {
BaseModel model = await NetUtil().post( BaseModel model = await NetUtil().post(
API.market.shopCarDelete, SARSAPI.market.shopCart.delete,
params: { params: {
'jcookGoodsIds': _selectIndex.map((e) => _models[e].id).toList() 'appGoodsPushIds': _selectIndex.map((e) => _models[e].id).toList()
}, },
showMessage: true, showMessage: true,
); );
@ -607,8 +604,8 @@ class _ShopCarPageState extends State<ShopCarPage> {
Future<bool> changeNum(int jcookGoodsId, int num) async { Future<bool> changeNum(int jcookGoodsId, int num) async {
var cancel = BotToast.showLoading(); var cancel = BotToast.showLoading();
var base = await NetUtil().post(API.market.shopCarChangeNum, var base = await NetUtil().post(SARSAPI.market.shopCart.updateNum,
params: {'jcookGoodsId': jcookGoodsId, 'num': num}); params: {'appGoodsPushId': jcookGoodsId, 'num': num});
if (!(base.success)) { if (!(base.success)) {
BotToast.showText(text: base.msg); BotToast.showText(text: base.msg);
} }
@ -634,9 +631,9 @@ class _ShopCarPageState extends State<ShopCarPage> {
if (result == true) { if (result == true) {
BaseModel model = await NetUtil().post( BaseModel model = await NetUtil().post(
API.market.shopCarDelete, SARSAPI.market.shopCart.delete,
params: { params: {
'jcookGoodsIds': _selectIndex.map((e) => _models[e].id).toList() 'appGoodsPushIds': _selectIndex.map((e) => _models[e].id).toList()
}, },
showMessage: true, showMessage: true,
); );

Loading…
Cancel
Save