|
@@ -72,13 +72,14 @@ class KMProductModel: ObservableObject {
|
|
*/
|
|
*/
|
|
var dmgLastGetProductPriceInfos: KMMemberProductResult?
|
|
var dmgLastGetProductPriceInfos: KMMemberProductResult?
|
|
|
|
|
|
- // MARK: DMG Public Method
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
- @abstract 获取服务器架上所有商品 (得到的价格是原始价格)
|
|
|
|
- @param
|
|
|
|
|
|
+ DMG 版本 已经登录用户 最后一次价格价格获取
|
|
*/
|
|
*/
|
|
- func getDMGProductDatas() -> Void {
|
|
|
|
|
|
+ var dmgLastGetBatchProductPriceInfos: KMMemberProductResult?
|
|
|
|
+
|
|
|
|
+ // MARK: DMG Public Method
|
|
|
|
+
|
|
|
|
+ func checkConnectionAvailable() -> Void {
|
|
if KMMemberCenterManager.manager.isConnectionAvailable() == false {
|
|
if KMMemberCenterManager.manager.isConnectionAvailable() == false {
|
|
let alert = NSAlert()
|
|
let alert = NSAlert()
|
|
alert.alertStyle = .critical
|
|
alert.alertStyle = .critical
|
|
@@ -88,12 +89,26 @@ class KMProductModel: ObservableObject {
|
|
alert.runModal()
|
|
alert.runModal()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ @abstract 获取服务器架上所有商品 (得到的价格是原始价格)
|
|
|
|
+ @param
|
|
|
|
+ */
|
|
|
|
+ func getDMGProductDatas() -> Void {
|
|
|
|
+ checkConnectionAvailable()
|
|
|
|
|
|
KMMemberCenterManager.manager.getListingProducts(isEducation: 0) { [weak self] success, result in
|
|
KMMemberCenterManager.manager.getListingProducts(isEducation: 0) { [weak self] success, result in
|
|
guard let productsArrays : KMMemberProductResult = result else { return }
|
|
guard let productsArrays : KMMemberProductResult = result else { return }
|
|
self?.dmgProductDatas = productsArrays
|
|
self?.dmgProductDatas = productsArrays
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if KMMemberInfo.shared.isLogin {
|
|
|
|
+ getDMGProductPriceInfosForMember(productId: "SP2024102100002", isEducation: 0) { [weak self] success, result in
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -101,20 +116,40 @@ class KMProductModel: ObservableObject {
|
|
@param
|
|
@param
|
|
*/
|
|
*/
|
|
func getDMGProductPriceInfosForMember(productId: String, isEducation: Int, _ complete: @escaping KMMemberProductComplete) {
|
|
func getDMGProductPriceInfosForMember(productId: String, isEducation: Int, _ complete: @escaping KMMemberProductComplete) {
|
|
- if KMMemberCenterManager.manager.isConnectionAvailable() == false {
|
|
|
|
- let alert = NSAlert()
|
|
|
|
- alert.alertStyle = .critical
|
|
|
|
- alert.messageText = NSLocalizedString("Error Information", comment: "")
|
|
|
|
- alert.informativeText = NSLocalizedString("Please make sure your internet connection is available.", comment: "")
|
|
|
|
- alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
|
|
|
|
- alert.runModal()
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
|
|
+ checkConnectionAvailable()
|
|
//暂时无教育优惠,先固定传 0
|
|
//暂时无教育优惠,先固定传 0
|
|
KMMemberCenterManager.manager.getProductPriceForBuy(productId: productId, isEducation: 0, userId:KMMemberInfo.shared.userID) { [weak self] success, result in
|
|
KMMemberCenterManager.manager.getProductPriceForBuy(productId: productId, isEducation: 0, userId:KMMemberInfo.shared.userID) { [weak self] success, result in
|
|
- guard let productsArrays : KMMemberProductResult = result else { return }
|
|
|
|
- self?.dmgLastGetProductPriceInfos = productsArrays
|
|
|
|
- complete(true, productsArrays)
|
|
|
|
|
|
+ if success {
|
|
|
|
+ guard let productsArrays : KMMemberProductResult = result else {
|
|
|
|
+ complete(false, result)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ self?.dmgLastGetProductPriceInfos = productsArrays
|
|
|
|
+ complete(true, productsArrays)
|
|
|
|
+ } else {
|
|
|
|
+ complete(false, result)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ @abstract 获取批量阶段购买价格(建立订单时需要用到)
|
|
|
|
+ @param
|
|
|
|
+ */
|
|
|
|
+ func getDMGBatchProductPriceInfosForMember(productId: String, num: Int, _ complete: @escaping KMMemberProductComplete) {
|
|
|
|
+ checkConnectionAvailable()
|
|
|
|
+ //暂时无教育优惠,先固定传 0
|
|
|
|
+ KMMemberCenterManager.manager.getBatchProductPrice(productId: productId, num: 0) { [weak self] success, result in
|
|
|
|
+ if success {
|
|
|
|
+ guard let productsArrays : KMMemberProductResult = result else {
|
|
|
|
+ complete(false, result)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ self?.dmgLastGetBatchProductPriceInfos = productsArrays
|
|
|
|
+ complete(true, productsArrays)
|
|
|
|
+ } else {
|
|
|
|
+ complete(false, result)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|