Procházet zdrojové kódy

申请退款流程--finished

Chris před 6 roky
rodič
revize
a697a85bf3

+ 4 - 0
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -327,6 +327,7 @@
 		BD20F1D82283D2AA00677D8E /* ShoppingCartModule.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BD20F1D72283D2AA00677D8E /* ShoppingCartModule.xcassets */; };
 		BD29A92E228F99780018CFC3 /* OrderCommentParameterModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD29A92D228F99780018CFC3 /* OrderCommentParameterModel.swift */; };
 		BD3474F522857B85000908C5 /* CommonPayHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD3474F422857B85000908C5 /* CommonPayHeader.swift */; };
+		BD6EDF48229007EA009A20FE /* OrderApplyRefundModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD6EDF47229007EA009A20FE /* OrderApplyRefundModel.swift */; };
 		BD7AB83622841A8B0030646A /* ShoppingCartPayOrderItemCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD7AB83522841A8B0030646A /* ShoppingCartPayOrderItemCell.swift */; };
 		BD7AB838228420310030646A /* ShoppingCartPayOrderHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD7AB837228420310030646A /* ShoppingCartPayOrderHeader.swift */; };
 		BD7AB83A2284288D0030646A /* ShoppingCartPayOrderFooter.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD7AB8392284288D0030646A /* ShoppingCartPayOrderFooter.swift */; };
@@ -720,6 +721,7 @@
 		BD20F1D72283D2AA00677D8E /* ShoppingCartModule.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = ShoppingCartModule.xcassets; sourceTree = "<group>"; };
 		BD29A92D228F99780018CFC3 /* OrderCommentParameterModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderCommentParameterModel.swift; sourceTree = "<group>"; };
 		BD3474F422857B85000908C5 /* CommonPayHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonPayHeader.swift; sourceTree = "<group>"; };
+		BD6EDF47229007EA009A20FE /* OrderApplyRefundModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderApplyRefundModel.swift; sourceTree = "<group>"; };
 		BD7AB83522841A8B0030646A /* ShoppingCartPayOrderItemCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingCartPayOrderItemCell.swift; sourceTree = "<group>"; };
 		BD7AB837228420310030646A /* ShoppingCartPayOrderHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingCartPayOrderHeader.swift; sourceTree = "<group>"; };
 		BD7AB8392284288D0030646A /* ShoppingCartPayOrderFooter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingCartPayOrderFooter.swift; sourceTree = "<group>"; };
@@ -2813,6 +2815,7 @@
 				BD1DC6CA228D157000B89C57 /* OrderCreateBackModel.swift */,
 				BD1DC6CC228D160D00B89C57 /* OrderPurchaseModel.swift */,
 				A7FF159B228D9E3C00A85748 /* OrderRefundDetailModel.swift */,
+				BD6EDF47229007EA009A20FE /* OrderApplyRefundModel.swift */,
 			);
 			path = OrderModel;
 			sourceTree = "<group>";
@@ -3617,6 +3620,7 @@
 				A77F2C9C2231FDCF001BD3F6 /* BaseView.swift in Sources */,
 				A7A98E2F228017E2005306E9 /* SwiftMoyaNetWorkServiceCMS.swift in Sources */,
 				A7284A522252EE9A000BAEC4 /* RootModel.swift in Sources */,
+				BD6EDF48229007EA009A20FE /* OrderApplyRefundModel.swift in Sources */,
 				A72A7388223396CB00B21995 /* ApiMacro.swift in Sources */,
 				A72A72B922321DE000B21995 /* Extension+Array.swift in Sources */,
 				A70B2C492288416F00B2449F /* ProductDetailHotSellCollectionViewCell.swift in Sources */,

+ 25 - 9
RainbowPlanet/RainbowPlanet/Modules/OrderModule/OrderApplyRefund/View/OrderApplyRefundPhotoCell.swift

@@ -15,7 +15,15 @@ class OrderApplyRefundPhotoCell: UITableViewCell {
     typealias ChoosePicBlock = () -> Void
     var choosePicBlock : ChoosePicBlock?
     
-    var imgCount: Int? = 0
+    typealias DelPicTransBlock = (_ idxRow:Int?) -> Void
+    var delPicTransBlock : DelPicTransBlock?
+    
+    var imgCount: Int = 0
+    var goodsImageArr: Array<UIImage>? {
+        didSet {
+            imgCount = self.goodsImageArr?.count ?? 0
+        }
+    }
     
     class func cellWith(tableView:UITableView,indexPath:IndexPath) -> OrderApplyRefundPhotoCell {
         let ID = "OrderApplyRefundPhotoCell"
@@ -136,22 +144,31 @@ extension OrderApplyRefundPhotoCell: UICollectionViewDelegateFlowLayout,UICollec
     }
     
     func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
-        if imgCount! < maxImageCount {
-            return imgCount!+1
+        if imgCount < maxImageCount {
+            return imgCount+1
         } else {
             return maxImageCount
         }
     }
     
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
-        if imgCount! < maxImageCount && indexPath.row == imgCount {
+        if imgCount < maxImageCount && indexPath.row == imgCount {
             // 添加图片
             let cell = OrderCommentDefaultCollectionCell.cellWith(collectionView: collectionView, indexPath: indexPath)
             return cell
         } else {
             // 展示图片
-            let cell = OrderCommentAddImgCollectionCell.cellWith(collectionView: collectionView, indexPath: indexPath)
-            return cell
+            let pCell = OrderCommentAddImgCollectionCell.cellWith(collectionView: collectionView, indexPath: indexPath)
+            if indexPath.row < imgCount {
+                pCell.showImage = self.goodsImageArr![indexPath.row]
+            }
+            pCell.delPicBlock = {
+                [weak self] (idxRow) in
+                if let delPicTransBlock = self?.delPicTransBlock {
+                    delPicTransBlock(idxRow)
+                }
+            }
+            return pCell
         }
     }
     
@@ -164,9 +181,8 @@ extension OrderApplyRefundPhotoCell: UICollectionViewDelegateFlowLayout,UICollec
     }
     
     func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
-        if imgCount! < maxImageCount && indexPath.row == imgCount {
-            // 添加图片
-            print("点击添加图片")
+        if imgCount < maxImageCount && indexPath.row == imgCount {
+            // 添加图片            
             if let choosePicBlock = self.choosePicBlock {
                 choosePicBlock()
             }

+ 59 - 10
RainbowPlanet/RainbowPlanet/Modules/OrderModule/OrderApplyRefund/ViewController/OrderApplyRefundController.swift

@@ -29,7 +29,8 @@ class OrderApplyRefundController: BaseViewController {
     // 选中の退款原因
     var selRefundReason: String? = ""
     
-    
+    // 上传图片数组
+    var goodsImageArr = Array<UIImage>()
     
     override func viewDidLoad() {
         super.viewDidLoad()
@@ -48,7 +49,7 @@ class OrderApplyRefundController: BaseViewController {
         commitButton.backgroundColor = kFFA42FColor
         self.view.addSubview(commitButton)
         commitButton.rx.tap.subscribe(onNext: { [weak self] (data) in
-            self?.orderPurchaseRefundApi()
+            self?.applyOrderRefund()
             
         }).disposed(by: disposeBag)
         commitButton.snp.makeConstraints { (make) in
@@ -159,10 +160,42 @@ extension OrderApplyRefundController : UITableViewDelegate, UITableViewDataSourc
             noteCell.orderModel = orderDetailModel
             return noteCell
         case 4:
-            let photoCell = OrderApplyRefundPhotoCell.cellWith(tableView: tableView, indexPath: indexPath)            
+            let photoCell = OrderApplyRefundPhotoCell.cellWith(tableView: tableView, indexPath: indexPath)
+            photoCell.goodsImageArr = self.goodsImageArr
             photoCell.frame = tableView.bounds
             photoCell.layoutIfNeeded()
             photoCell.reloadData()
+            photoCell.choosePicBlock = {
+                [weak self] in
+                // 添加图片
+                UIAlertController.showConfirmActionSheet(camera: { (action) in
+                    PhotoAndCameraManager.shared().authorizeCamera()
+                    PhotoAndCameraManager.shared().photoAndCameraManagerImageBlock = { [weak self] (image) in
+                        if self?.goodsImageArr.count ?? 0 < 3 {
+                            self?.goodsImageArr.append(image)
+                            self?.tableView.reloadData()
+                        } else {
+                            print("------超过最大数量")
+                        }
+                        
+                    }
+                }) { (action) in
+                    PhotoAndCameraManager.shared().authorizePhoto()
+                    PhotoAndCameraManager.shared().photoAndCameraManagerImageBlock = { [weak self] (image) in
+                        if self?.goodsImageArr.count ?? 0 < 3 {
+                            self?.goodsImageArr.append(image)
+                            self?.tableView.reloadData()
+                        } else {
+                            print("------超过最大数量")
+                        }
+                    }
+                }
+            }
+            photoCell.delPicTransBlock = {
+                [weak self] (idxRow) in
+                self?.goodsImageArr.remove(at: idxRow!)
+                self?.tableView.reloadData()
+            }
             return photoCell
         default:
             return UITableViewCell()
@@ -235,7 +268,7 @@ extension OrderApplyRefundController {
     }
     
     // 申请退款
-    func orderPurchaseRefundApi() {
+    func applyOrderRefund() {
         
         if productArr?.isEmpty ?? true {
             SwiftProgressHUD.shared().showText("请选择退款商品")
@@ -247,6 +280,11 @@ extension OrderApplyRefundController {
             return
         }
         
+        if productArr?.count == 0 {
+            SwiftProgressHUD.shared().showText("请拍照上传问题")
+            return
+        }
+        
         // 子订单id参数
         var subIdArr: Array<Int> = []
         for productMdl in productArr ?? [] {
@@ -256,12 +294,23 @@ extension OrderApplyRefundController {
         }
         let detailJsonStr = JSON(subIdArr).description
         
-        
-        
-//        SwiftMoyaNetWorkServiceOrder.shared().orderPurchaseRefundApi(purchaseId: Int(orderDetailModel!.purchaseNo!)!, mobile: orderDetailModel!.mobile!, refundReason: selRefundReason!, refund_remark: orderDetailModel!.remark ?? "", detail: detailJsonStr, imgs: <#T##String#>) { (data) -> (Void) in
-//            print(data)
-//        }
-        
+        // 多图上传
+        SwiftMoyaNetWorkServiceConfig.shared().configUploadMultiImgApi(imageArray: goodsImageArr) { [weak self] (imgUrlArr) -> (Void) in
+            let imgJsonStr = JSON(imgUrlArr).description
+            
+            self?.orderPurchaseRefundApi(purchaseId: (self?.orderDetailModel!.purchaseNo)!, mobile: (self?.orderDetailModel!.mobile!)!, refundReason: (self?.selRefundReason!)!, refund_remark: self?.orderDetailModel!.remark ?? "", detail: detailJsonStr, imgs: imgJsonStr)
+        }
+    }
+    
+    func orderPurchaseRefundApi(purchaseId:String = "",mobile:String = "",refundReason:String = "",refund_remark:String = "",detail:String = "",imgs:String = "") {
+        SwiftMoyaNetWorkServiceOrder.shared().orderPurchaseRefundApi(purchaseId: purchaseId, mobile: mobile, refundReason: refundReason, refund_remark: refund_remark, detail: detail, imgs: imgs) { (orderApplyRefundModel) -> (Void) in
+            let applyRefundMdl = orderApplyRefundModel as! OrderApplyRefundModel
+            
+            let vc = OrderRefunddetailsViewController()
+            vc.refundNo = applyRefundMdl.refundNo
+            self.navigationController?.pushViewController(vc, animated: true)
+            
+        }
     }
     
 }

+ 30 - 0
RainbowPlanet/RainbowPlanet/Service/Model/OrderModel/OrderApplyRefundModel.swift

@@ -0,0 +1,30 @@
+//
+//  OrderApplyRefundModel.swift
+//  RainbowPlanet
+//
+//  Created by Christopher on 2019/5/18.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//  申请退款のModel
+
+import Foundation
+import ObjectMapper
+
+
+class OrderApplyRefundModel : NSObject, Mappable{
+    
+    var refundNo : String?
+    
+    
+    class func newInstance(map: Map) -> Mappable?{
+        return OrderApplyRefundModel()
+    }
+    required init?(map: Map){}
+    private override init(){}
+    
+    func mapping(map: Map)
+    {
+        refundNo <- map["refund_no"]
+        
+    }
+    
+}

+ 2 - 3
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceConfig/SwiftMoyaNetWorkServiceConfig.swift

@@ -109,10 +109,9 @@ class SwiftMoyaNetWorkServiceConfig: NSObject {
             multipartData.append(formData)
         }
         SwiftProgressHUD.shared().showWait()
-        SwiftMoyaNetWorkManager.shared().request(target: MultiTarget(SwiftMoyaServiceConfigApi.configUploadMultiImg(parameters: parameters, dataArray: multipartData))) { (data) in
+        SwiftMoyaNetWorkManager.shared().requestArray(target: MultiTarget(SwiftMoyaServiceConfigApi.configUploadMultiImg(parameters: parameters, dataArray: multipartData))) { (imgUrlArr) in
             SwiftProgressHUD.shared().hide()
-            let rootModel = data as! RootModel
-            print(rootModel)
+            completion(imgUrlArr)
         }
     }
             

+ 3 - 3
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceOrder/SwiftMoyaNetWorkServiceOrder.swift

@@ -139,7 +139,7 @@ class SwiftMoyaNetWorkServiceOrder: NSObject {
     ///   - detail: 子订单id(json字符串
     ///   - imgs: 图库(json字符串)
     ///   - completion: 回调
-    func orderPurchaseRefundApi(purchaseId:Int = 0,mobile:String = "",refundReason:String = "",refund_remark:String = "",detail:String = "",imgs:String = "",completion: @escaping apiCallBack) {
+    func orderPurchaseRefundApi(purchaseId:String = "",mobile:String = "",refundReason:String = "",refund_remark:String = "",detail:String = "",imgs:String = "",completion: @escaping apiCallBack) {
         var parameters = Dictionary<String,Any>()
         parameters.updateValue(purchaseId, forKey: "purchase_id")
         parameters.updateValue(mobile, forKey: "mobile")
@@ -148,9 +148,9 @@ class SwiftMoyaNetWorkServiceOrder: NSObject {
         parameters.updateValue(detail, forKey: "detail")
         parameters.updateValue(imgs, forKey: "imgs")
         SwiftProgressHUD.shared().showWait()
-        SwiftMoyaNetWorkManager.shared().request(OrderRefundDetailModel.self,target: MultiTarget(SwiftMoyaServiceOrderApi.orderPurchaseRefund(parameters: parameters))) { (orderRefundDetailModel) in
+        SwiftMoyaNetWorkManager.shared().request(OrderApplyRefundModel.self,target: MultiTarget(SwiftMoyaServiceOrderApi.orderPurchaseRefund(parameters: parameters))) { (orderApplyRefundModel) in
             SwiftProgressHUD.shared().hide()
-            completion(orderRefundDetailModel)
+            completion(orderApplyRefundModel)
         }
     }