RefundDetailVC.m 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. //
  2. // RefundDetailVC.m
  3. // yunbaolive
  4. //
  5. // Created by ybRRR on 2020/2/20.
  6. // Copyright © 2020 cat. All rights reserved.
  7. //
  8. #import "RefundDetailVC.h"
  9. #import "RefundHeadView.h"
  10. #import "RefuseRefundVC.h"
  11. #import "RefundDetailModel.h"
  12. #import "JCHATConversationViewController.h"
  13. @interface RefundDetailVC ()
  14. {
  15. UIScrollView *backScroll;
  16. }
  17. @property (nonatomic, strong)RefundHeadView *headView;
  18. @property (nonatomic, strong)UIView *historyView;
  19. @property (nonatomic, strong)UIView *infoView;
  20. @property (nonatomic, strong)UIImageView *orderImg;
  21. @property (nonatomic, strong)UILabel *orderTitleLb;
  22. @property (nonatomic, strong)UILabel *orderContentLb;
  23. @property (nonatomic, strong)UILabel *orderPriceLb;
  24. @property (nonatomic, strong)UILabel *orderCountLb;
  25. @property (nonatomic, strong)RefundDetailModel *model;
  26. @end
  27. @implementation RefundDetailVC
  28. #pragma mark------卖家获取退款详情----------
  29. -(void)reqestRefundInfo{
  30. NSString *url = [purl stringByAppendingFormat:@"?service=Seller.getGoodsOrderRefundInfo"];
  31. NSDictionary *signdic = @{@"uid":[Config getOwnID],@"token":[Config getOwnToken],@"orderid":self.orderModel.idStr,@"time":[NSNumber numberWithLong: (long)[[NSDate date] timeIntervalSince1970]]};
  32. NSString *sign = [PublicObj sortString:signdic];
  33. NSDictionary *dic = @{
  34. @"uid":[Config getOwnID],
  35. @"token":[Config getOwnToken],
  36. @"orderid":self.orderModel.idStr,
  37. @"time":[NSNumber numberWithLong: (long)[[NSDate date] timeIntervalSince1970]],
  38. @"sign":sign
  39. };
  40. [YBNetworking postWithUrl:@"Seller.getGoodsOrderRefundInfo" Dic:dic Suc:^(int code, id info, NSString *msg) {
  41. if (code ==0) {
  42. NSDictionary *infos = [info firstObject];
  43. self.model = [RefundDetailModel modelWithDic:infos];
  44. //头部视图
  45. [backScroll addSubview:self.headView];
  46. [backScroll addSubview:self.historyView];
  47. [backScroll addSubview:self.infoView];
  48. backScroll.contentSize = CGSizeMake(_window_width, self.headView.height+self.historyView.height+self.infoView.height);
  49. }else{
  50. [MBProgressHUD showError:msg];
  51. }
  52. } Fail:^(id fail) {
  53. }];
  54. }
  55. - (UIStatusBarStyle)preferredStatusBarStyle {
  56. if (@available(iOS 13.0,*)) {
  57. return UIStatusBarStyleDarkContent;
  58. }
  59. return UIStatusBarStyleDefault;
  60. }
  61. - (void)viewDidLoad {
  62. [super viewDidLoad];
  63. self.titleL.text = YZMsg(@"退款详情");
  64. self.subNavi.backgroundColor = UIColor.whiteColor;
  65. self.titleL.textColor = UIColor.blackColor;
  66. [self.leftBtn setImage:[UIImage imageNamed:@"pub_back_black"] forState:0];
  67. self.naviLine.hidden = NO;
  68. self.naviLine.backgroundColor = RGB(245, 245, 245);
  69. backScroll = [[UIScrollView alloc]init];
  70. backScroll.frame = CGRectMake(0, 64+statusbarHeight, _window_width, _window_height-64-statusbarHeight);
  71. backScroll.backgroundColor = UIColor.whiteColor;
  72. [self.view addSubview:backScroll];
  73. [self reqestRefundInfo];
  74. }
  75. -(void)agreeRefundOrder{
  76. NSDictionary *signdic = @{@"uid":[Config getOwnID],@"token":[Config getOwnToken],@"orderid":self.orderModel.idStr,@"time":[NSNumber numberWithLong: (long)[[NSDate date] timeIntervalSince1970]]};
  77. NSString *sign = [PublicObj sortString:signdic];
  78. NSDictionary *dic = @{
  79. @"uid":[Config getOwnID],
  80. @"token":[Config getOwnToken],
  81. @"orderid":self.orderModel.idStr,
  82. @"type":@"1",
  83. @"reasonid":@"",
  84. @"refuse_desc":@"",
  85. @"time":[NSNumber numberWithLong: (long)[[NSDate date] timeIntervalSince1970]],
  86. @"sign":sign
  87. };
  88. [YBNetworking postWithUrl:@"seller.setGoodsOrderRefund" Dic:dic Suc:^(int code, id info, NSString *msg) {
  89. if (code ==0) {
  90. [MBProgressHUD showError:msg];
  91. [[YBBaseAppDelegate sharedAppDelegate]popViewController:YES];
  92. }else{
  93. [MBProgressHUD showError:msg];
  94. }
  95. } Fail:^(id fail) {
  96. }];
  97. }
  98. -(RefundHeadView *)headView{
  99. YBWeakSelf;
  100. if (!_headView) {
  101. _headView = [[RefundHeadView alloc]initWithFrame:CGRectMake(0, 0, _window_width, 120)];
  102. [_headView setRefundData:self.model];
  103. _headView.clickEvent = ^(NSString * _Nonnull btnTitle) {
  104. if ([btnTitle isEqual:YZMsg(@"同意")]) {
  105. [weakSelf agreeRefundOrder];
  106. }else if ([btnTitle isEqual:YZMsg(@"拒绝")]){
  107. [weakSelf refushClick];
  108. }
  109. };
  110. }
  111. return _headView;
  112. }
  113. -(UIView *)historyView{
  114. if (!_historyView) {
  115. _historyView = [[UIView alloc]init];
  116. _historyView.backgroundColor = UIColor.whiteColor;
  117. _historyView.frame = CGRectMake(0, _headView.bottom+5, _window_width, 50);
  118. [backScroll addSubview:_historyView];
  119. UILabel *titlelb = [[UILabel alloc]init];
  120. titlelb.frame = CGRectMake(12, 50/2-10, 80+100, 20);
  121. titlelb.text = YZMsg(@"协商历史");
  122. titlelb.font = [UIFont systemFontOfSize:14];
  123. titlelb.textColor = [UIColor blackColor];
  124. [_historyView addSubview:titlelb];
  125. UIImageView *rightImg = [[UIImageView alloc]init];
  126. rightImg.frame =CGRectMake(_window_width-30, 50/2-8, 16, 16);
  127. rightImg.image = [UIImage imageNamed:@"shop_right"];
  128. [_historyView addSubview:rightImg];
  129. UIButton *historyBtn = [UIButton buttonWithType:0];
  130. historyBtn.frame = CGRectMake(0, 0, _historyView.width, _historyView.height);
  131. [historyBtn addTarget:self action:@selector(historyRefundClick) forControlEvents:UIControlEventTouchUpInside];
  132. [_historyView addSubview:historyBtn];
  133. }
  134. return _historyView;
  135. }
  136. -(UIView *)infoView{
  137. if (!_infoView) {
  138. _infoView = [[UIView alloc]initWithFrame:CGRectMake(0, _historyView.bottom+5, _window_width, 450)];
  139. _infoView.backgroundColor = UIColor.whiteColor;
  140. UILabel *lb = [[UILabel alloc]initWithFrame:CGRectMake(12, 10, 80, 20)];
  141. lb.text = YZMsg(@"退款信息");
  142. lb.font = [UIFont systemFontOfSize:14];
  143. lb.textColor = [UIColor blackColor];
  144. [_infoView addSubview:lb];
  145. _orderImg = [[UIImageView alloc]init];
  146. _orderImg.frame = CGRectMake(12, lb.bottom+5, 90, 90);
  147. _orderImg.backgroundColor = [UIColor lightGrayColor];
  148. _orderImg.layer.cornerRadius = 5;
  149. _orderImg.layer.masksToBounds = YES;
  150. _orderImg.contentMode = UIViewContentModeScaleAspectFill;
  151. [_orderImg sd_setImageWithURL:[NSURL URLWithString:self.model.spec_thumb_format]];
  152. [_infoView addSubview:_orderImg];
  153. _orderTitleLb = [[UILabel alloc]init];
  154. _orderTitleLb.textColor = [UIColor blackColor];
  155. _orderTitleLb.font = [UIFont systemFontOfSize:14];
  156. _orderTitleLb.text = self.model.goods_name;
  157. [_infoView addSubview:_orderTitleLb];
  158. [_orderTitleLb mas_makeConstraints:^(MASConstraintMaker *make) {
  159. make.left.equalTo(_orderImg.mas_right).offset(5);
  160. make.top.equalTo(_orderImg).offset(8);
  161. make.height.mas_equalTo(18);
  162. }];
  163. _orderPriceLb = [[UILabel alloc]init];
  164. _orderPriceLb.textColor = [UIColor blackColor];
  165. _orderPriceLb.font = [UIFont systemFontOfSize:14];
  166. _orderPriceLb.text =[NSString stringWithFormat:@"%@%@",YZMsg(@"¥"),self.model.price];// @"¥188.00";
  167. _orderPriceLb.textAlignment = NSTextAlignmentRight;
  168. [_infoView addSubview:_orderPriceLb];
  169. [_orderPriceLb mas_makeConstraints:^(MASConstraintMaker *make) {
  170. make.right.equalTo(_infoView).offset(-10);
  171. make.centerY.height.equalTo(_orderTitleLb);
  172. }];
  173. _orderContentLb = [[UILabel alloc]init];
  174. _orderContentLb.textColor = Normal_TextColor;
  175. _orderContentLb.font = [UIFont systemFontOfSize:14];
  176. _orderContentLb.text =self.model.spec_name;// @"麻辣鲜香味";
  177. [_infoView addSubview:_orderContentLb];
  178. [_orderContentLb mas_makeConstraints:^(MASConstraintMaker *make) {
  179. make.left.equalTo(_orderTitleLb);
  180. make.top.equalTo(_orderTitleLb.mas_bottom).offset(5);
  181. make.height.equalTo(_orderTitleLb);
  182. }];
  183. _orderCountLb = [[UILabel alloc]init];
  184. _orderCountLb.textColor = Normal_TextColor;
  185. _orderCountLb.font = [UIFont systemFontOfSize:14];
  186. _orderCountLb.text =[NSString stringWithFormat:@"%@%@",YZMsg(@"x"), self.model.nums];// @"x1";
  187. _orderCountLb.textAlignment = NSTextAlignmentRight;
  188. [_infoView addSubview:_orderCountLb];
  189. [_orderCountLb mas_makeConstraints:^(MASConstraintMaker *make) {
  190. make.right.equalTo(_infoView).offset(-10);
  191. make.centerY.height.equalTo(_orderContentLb);
  192. }];
  193. [PublicObj lineViewWithFrame:CGRectMake(0, _orderImg.bottom+5, _window_width, 5) andColor:RGB(245, 245, 245) andView:_infoView];
  194. NSArray *arr = @[YZMsg(@"买家昵称:"),YZMsg(@"订单状态:"),YZMsg(@"退款方式:"),YZMsg(@"退款金额:"),YZMsg(@"退款原因:"),YZMsg(@"申请时间:"),YZMsg(@"退款单号:"),YZMsg(@"问题描述:")];
  195. for (int i = 0;i < arr.count ; i++) {
  196. UILabel *lb = [[UILabel alloc]init];
  197. lb.font = [UIFont systemFontOfSize:14];
  198. lb.textColor = Normal_TextColor;
  199. lb.text = arr[i];
  200. [_infoView addSubview:lb];
  201. [lb mas_makeConstraints:^(MASConstraintMaker *make) {
  202. make.left.equalTo(_infoView).offset(12);
  203. make.top.equalTo(_orderImg.mas_bottom).offset(15+i*30);
  204. make.height.mas_equalTo(20);
  205. }];
  206. UILabel *infoLb = [[UILabel alloc]init];
  207. infoLb.font = [UIFont systemFontOfSize:14];
  208. if (i > 0 && i < 4) {
  209. infoLb.textColor = Pink_Cor;
  210. }else{
  211. infoLb.textColor = [UIColor grayColor];
  212. }
  213. [_infoView addSubview:infoLb];
  214. if (i == 7) {
  215. [infoLb mas_makeConstraints:^(MASConstraintMaker *make) {
  216. make.left.equalTo(lb.mas_right).offset(5);
  217. make.top.equalTo(lb.mas_top).offset(-2);
  218. make.width.mas_equalTo(_window_width-100);
  219. }];
  220. }else{
  221. [infoLb mas_makeConstraints:^(MASConstraintMaker *make) {
  222. make.left.equalTo(lb.mas_right).offset(5);
  223. make.top.equalTo(lb.mas_top);
  224. make.width.mas_equalTo(_window_width-100);
  225. }];
  226. }
  227. switch (i) {
  228. case 0:
  229. infoLb.text = self.model.user_nickname;
  230. break;
  231. case 1:
  232. infoLb.text = self.model.status_name;
  233. break;
  234. case 2:{
  235. //(退款类型 0 仅退款 1 退货退款)
  236. NSString *typeStr;
  237. if ([self.model.type isEqual:@"0"]) {
  238. typeStr =YZMsg(@"仅退款");
  239. }else{
  240. typeStr =YZMsg(@"退货退款");
  241. }
  242. infoLb.text = typeStr;
  243. }
  244. break;
  245. case 3:
  246. infoLb.text = [NSString stringWithFormat:@"¥%@",self.model.total];
  247. break;
  248. case 4:
  249. infoLb.text = self.model.reason;
  250. break;
  251. case 5:
  252. infoLb.text = self.model.addtime;
  253. break;
  254. case 6:
  255. infoLb.text = self.model.orderno;
  256. break;
  257. case 7:{
  258. infoLb.text = self.model.refund_status_content;
  259. infoLb.lineBreakMode = NSLineBreakByWordWrapping;
  260. infoLb.numberOfLines = 0;
  261. CGFloat textHeight = [PublicObj heightOfString:self.model.refund_status_content andFont:[UIFont systemFontOfSize:14] andWidth:_window_width-100];
  262. [infoLb mas_updateConstraints:^(MASConstraintMaker *make) {
  263. make.height.mas_equalTo(10+textHeight);
  264. }];
  265. _infoView.size = CGSizeMake(_window_width, 450+textHeight);
  266. }
  267. break;
  268. default:
  269. break;
  270. }
  271. }
  272. // [_infoView layoutIfNeeded];
  273. CGFloat textHeight = [PublicObj heightOfString:self.model.refund_status_content andFont:[UIFont systemFontOfSize:14] andWidth:_window_width-100];
  274. [PublicObj lineViewWithFrame:CGRectMake(0, (_orderImg.bottom+25)+arr.count*30+textHeight, _window_width, 1) andColor:RGB(245, 245, 245) andView:_infoView];
  275. UIButton *kefuBtn = [UIButton buttonWithType:0];
  276. [kefuBtn setBackgroundColor: UIColor.whiteColor];
  277. [kefuBtn setImage:[UIImage imageNamed:@"联系客服"] forState:0];
  278. [kefuBtn setTitle:YZMsg(@"联系买家") forState:0];
  279. [kefuBtn setTitleColor:[UIColor blackColor] forState:0];
  280. kefuBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  281. [kefuBtn addTarget:self action:@selector(kefuBtnClick) forControlEvents:UIControlEventTouchUpInside];
  282. [kefuBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 10, 0, 0 )];
  283. [_infoView addSubview:kefuBtn];
  284. [kefuBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  285. make.left.equalTo(_infoView);
  286. make.top.equalTo(_orderImg.mas_bottom).offset(30+arr.count*30+textHeight);
  287. make.width.equalTo(_infoView).multipliedBy(0.5);
  288. make.height.mas_equalTo(40);
  289. }];
  290. UIButton *callBtn = [UIButton buttonWithType:0];
  291. [callBtn setBackgroundColor: UIColor.whiteColor];
  292. [callBtn setImage:[UIImage imageNamed:@"拨打电话"] forState:0];
  293. [callBtn setTitle:YZMsg(@"拨打电话") forState:0];
  294. [callBtn setTitleColor:[UIColor blackColor] forState:0];
  295. callBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  296. [callBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 10, 0, 0 )];
  297. [callBtn addTarget:self action:@selector(callBtnClick) forControlEvents:UIControlEventTouchUpInside];
  298. [_infoView addSubview:callBtn];
  299. [callBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  300. make.left.equalTo(kefuBtn.mas_right);
  301. make.top.equalTo(kefuBtn);
  302. make.width.equalTo(_infoView).multipliedBy(0.5);
  303. make.height.mas_equalTo(40);
  304. }];
  305. [PublicObj lineViewWithFrame:CGRectMake(_window_width/2, (_orderImg.bottom+25)+arr.count*30+textHeight, 1, 50) andColor:RGB(245, 245, 245) andView:_infoView];
  306. }
  307. return _infoView;
  308. }
  309. -(void)refushClick{
  310. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:nil message:YZMsg(@"选择拒绝前请先尝试与买家进行充分沟通") preferredStyle:UIAlertControllerStyleAlert];
  311. UIAlertAction *goAction = [UIAlertAction actionWithTitle:YZMsg(@"继续") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  312. RefuseRefundVC *refuse = [[RefuseRefundVC alloc]init];
  313. refuse.orderId = self.orderModel.idStr;
  314. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:refuse animated:YES];
  315. }];
  316. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:YZMsg(@"取消") style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  317. }];
  318. [alertControl addAction:goAction];
  319. [alertControl addAction:cancelAction];
  320. [goAction setValue:[UIColor grayColor] forKey:@"_titleTextColor"];
  321. [cancelAction setValue:Normal_Color forKey:@"_titleTextColor"];
  322. [self.navigationController presentViewController:alertControl animated:YES completion:nil];
  323. }
  324. //查看协商历史
  325. -(void)historyRefundClick{
  326. NSString *url =[NSString stringWithFormat:@"%@/appapi/goodsorderrefund/index",h5url];
  327. PubH5 *h5VC = [[PubH5 alloc]init];
  328. h5VC.url = [self addurl:url addModel:self.model];;
  329. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:h5VC animated:YES];
  330. }
  331. //所有h5需要拼接uid和token
  332. -(NSString *)addurl:(NSString *)url addModel:(RefundDetailModel *)models{
  333. return [url stringByAppendingFormat:@"&uid=%@&token=%@&orderid=%@&user_type=seller",[Config getOwnID],[Config getOwnToken],self.orderModel.idStr];
  334. }
  335. //联系买家
  336. -(void)kefuBtnClick{
  337. NSDictionary *userDic = @{
  338. @"id":self.model.refund_uid,
  339. @"user_nickname":self.model.user_nickname,
  340. @"avatar":self.model.shop_avatar,
  341. };
  342. [[YBMessageManager shareManager] chatWithUser:userDic];
  343. }
  344. -(void)callBtnClick{
  345. NSString *phone =[NSString stringWithFormat:@"tel://%@",self.model.order_phone] ;
  346. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phone]];
  347. }
  348. @end