|
|
@@ -16,6 +16,7 @@ import com.zhongzheng.modules.alioss.bo.OssRequest;
|
|
|
import com.zhongzheng.modules.alioss.service.OssService;
|
|
|
import com.zhongzheng.modules.grade.domain.ClassGradeUser;
|
|
|
import com.zhongzheng.modules.grade.service.impl.UserPeriodServiceImpl;
|
|
|
+import com.zhongzheng.modules.order.bo.TopOrderInvoiceBack;
|
|
|
import com.zhongzheng.modules.order.domain.OrderGoodsRefund;
|
|
|
import com.zhongzheng.modules.order.domain.OrderInvoice;
|
|
|
import com.zhongzheng.modules.order.service.IOrderInvoiceOrderService;
|
|
|
@@ -39,8 +40,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.pagehelper.Page;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.net.HttpURLConnection;
|
|
|
+import java.net.URL;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -125,43 +131,46 @@ public class TopNuoMplatformLogServiceImpl extends ServiceImpl<TopNuoMplatformLo
|
|
|
add.setStatus(0);
|
|
|
add.setCreateTime(DateUtils.getNowTime());
|
|
|
add.setUpdateTime(DateUtils.getNowTime());
|
|
|
- if(this.save(add)){
|
|
|
- try{
|
|
|
- Long id = add.getId();
|
|
|
- Map<String,String> params = new HashMap<>();
|
|
|
- params.put("content",bo.getContent());
|
|
|
- String result = nuonuoService.openMplatform(params);
|
|
|
- TopNuoMplatformLog update = new TopNuoMplatformLog();
|
|
|
- update.setId(id);
|
|
|
- update.setResult(result);
|
|
|
- JSONObject jsonObject = (JSONObject) JSONObject.parse(result);
|
|
|
- String code = String.valueOf(jsonObject.get("code"));
|
|
|
- String describe = String.valueOf(jsonObject.get("describe"));
|
|
|
- update.setResultCode(code);
|
|
|
- Map<String,String> rs = new HashMap<>();
|
|
|
- if("E0000".equals(code)){
|
|
|
- JSONObject resultObject = jsonObject.getJSONObject("result");
|
|
|
- String invoiceSerialNum = String.valueOf(resultObject.get("invoiceSerialNum"));
|
|
|
- update.setInvoiceSerialNum(invoiceSerialNum);
|
|
|
- update.setStatus(1);
|
|
|
- rs.put("invoiceSerialNum",invoiceSerialNum);
|
|
|
- update.setUpdateTime(DateUtils.getNowTime());
|
|
|
- updateById(update);
|
|
|
-
|
|
|
- rs.put("code",code);
|
|
|
- rs.put("describe",describe);
|
|
|
- return rs;
|
|
|
- }else{
|
|
|
- update.setStatus(-1);
|
|
|
- update.setUpdateTime(DateUtils.getNowTime());
|
|
|
- updateById(update);
|
|
|
- throw new CustomException(result);
|
|
|
- }
|
|
|
- }catch (Exception e){
|
|
|
- throw new CustomException("开票失败");
|
|
|
- }
|
|
|
- }
|
|
|
- throw new CustomException("新增失败");
|
|
|
+ this.save(add);
|
|
|
+ return new HashMap<>();
|
|
|
+ //诺税通服务已暂停
|
|
|
+// if(this.save(add)){
|
|
|
+// try{
|
|
|
+// Long id = add.getId();
|
|
|
+// Map<String,String> params = new HashMap<>();
|
|
|
+// params.put("content",bo.getContent());
|
|
|
+// String result = nuonuoService.openMplatform(params);
|
|
|
+// TopNuoMplatformLog update = new TopNuoMplatformLog();
|
|
|
+// update.setId(id);
|
|
|
+// update.setResult(result);
|
|
|
+// JSONObject jsonObject = (JSONObject) JSONObject.parse(result);
|
|
|
+// String code = String.valueOf(jsonObject.get("code"));
|
|
|
+// String describe = String.valueOf(jsonObject.get("describe"));
|
|
|
+// update.setResultCode(code);
|
|
|
+// Map<String,String> rs = new HashMap<>();
|
|
|
+// if("E0000".equals(code)){
|
|
|
+// JSONObject resultObject = jsonObject.getJSONObject("result");
|
|
|
+// String invoiceSerialNum = String.valueOf(resultObject.get("invoiceSerialNum"));
|
|
|
+// update.setInvoiceSerialNum(invoiceSerialNum);
|
|
|
+// update.setStatus(1);
|
|
|
+// rs.put("invoiceSerialNum",invoiceSerialNum);
|
|
|
+// update.setUpdateTime(DateUtils.getNowTime());
|
|
|
+// updateById(update);
|
|
|
+//
|
|
|
+// rs.put("code",code);
|
|
|
+// rs.put("describe",describe);
|
|
|
+// return rs;
|
|
|
+// }else{
|
|
|
+// update.setStatus(-1);
|
|
|
+// update.setUpdateTime(DateUtils.getNowTime());
|
|
|
+// updateById(update);
|
|
|
+// throw new CustomException(result);
|
|
|
+// }
|
|
|
+// }catch (Exception e){
|
|
|
+// throw new CustomException("开票失败");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// throw new CustomException("新增失败");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -312,4 +321,97 @@ public class TopNuoMplatformLogServiceImpl extends ServiceImpl<TopNuoMplatformLo
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean orderInvoiceBack(TopOrderInvoiceBack bo) {
|
|
|
+ if (CollectionUtils.isEmpty(bo.getOrderNos())){
|
|
|
+ throw new CustomException("发票ID不能为空");
|
|
|
+ }
|
|
|
+ switch (bo.getStatus()){
|
|
|
+ case 0://关闭
|
|
|
+ List<TopNuoMplatformLog> list = list(new LambdaQueryWrapper<TopNuoMplatformLog>()
|
|
|
+ .in(TopNuoMplatformLog::getOrderNo, bo.getOrderNos()));
|
|
|
+ List<String> orderNos = new ArrayList<>();
|
|
|
+ list.stream().forEach(x -> {
|
|
|
+ String orderNoList = x.getOrderNoList();
|
|
|
+ orderNos.addAll(Arrays.asList(orderNoList.split(",")));
|
|
|
+ });
|
|
|
+ //更新发票状态
|
|
|
+ iTopOldOrderService.update(new LambdaUpdateWrapper<TopOldOrder>()
|
|
|
+ .in(TopOldOrder::getOrderSn,orderNos)
|
|
|
+ .set(TopOldOrder::getInvoiceStatus,2));
|
|
|
+ update(new LambdaUpdateWrapper<TopNuoMplatformLog>()
|
|
|
+ .in(TopNuoMplatformLog::getOrderNo,bo.getOrderNos())
|
|
|
+ .set(TopNuoMplatformLog::getStatus,0));
|
|
|
+ break;
|
|
|
+ case 1://已开票
|
|
|
+ //下载发票上传oss
|
|
|
+ try {
|
|
|
+
|
|
|
+ // 编码中文文件名
|
|
|
+ String invoiceUrl = bo.getInvoiceUrl();
|
|
|
+ String pathurl = invoiceUrl.substring(0,invoiceUrl.lastIndexOf("/")+1);
|
|
|
+ String fileName = invoiceUrl.substring(invoiceUrl.lastIndexOf("/") + 1);
|
|
|
+ String encodedFileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8.toString());
|
|
|
+ String pdfUrl = pathurl + encodedFileName;
|
|
|
+
|
|
|
+ URL url = new URL(pdfUrl);
|
|
|
+
|
|
|
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
|
+ connection.setRequestMethod("GET");
|
|
|
+ connection.setRequestProperty("User-Agent", "Mozilla/5.0");
|
|
|
+ connection.setRequestProperty("Accept", "application/pdf");
|
|
|
+
|
|
|
+
|
|
|
+ // 检查响应码(200表示成功)
|
|
|
+ int responseCode = connection.getResponseCode();
|
|
|
+ String path = "";
|
|
|
+ if (responseCode == HttpURLConnection.HTTP_OK) {
|
|
|
+ path = ossService.uploadInputStream(connection.getInputStream(), 11);
|
|
|
+ }else {
|
|
|
+ throw new CustomException("文件下载异常");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<TopNuoMplatformLog> listLog = list(new LambdaQueryWrapper<TopNuoMplatformLog>()
|
|
|
+ .in(TopNuoMplatformLog::getOrderNo, bo.getOrderNos()));
|
|
|
+ List<String> orderNoList = new ArrayList<>();
|
|
|
+ listLog.stream().forEach(x -> {
|
|
|
+ orderNoList.addAll(Arrays.asList(x.getOrderNoList().split(",")));
|
|
|
+ });
|
|
|
+ //更新发票状态
|
|
|
+ iTopOldOrderService.update(new LambdaUpdateWrapper<TopOldOrder>()
|
|
|
+ .in(TopOldOrder::getOrderSn,orderNoList)
|
|
|
+ .set(TopOldOrder::getInvoiceStatus,1));
|
|
|
+ //填充发票信息
|
|
|
+ update(new LambdaUpdateWrapper<TopNuoMplatformLog>()
|
|
|
+ .in(TopNuoMplatformLog::getOrderNo,bo.getOrderNos())
|
|
|
+ .set(TopNuoMplatformLog::getOssPdfUrl,path)
|
|
|
+ .set(TopNuoMplatformLog::getUpdateTime,DateUtils.getNowTime())
|
|
|
+ .set(TopNuoMplatformLog::getStatus,2));
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new CustomException("文件下载异常");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 2://线下已开票
|
|
|
+ List<TopNuoMplatformLog> listLog = list(new LambdaQueryWrapper<TopNuoMplatformLog>()
|
|
|
+ .in(TopNuoMplatformLog::getOrderNo, bo.getOrderNos()));
|
|
|
+ List<String> orderNoList = new ArrayList<>();
|
|
|
+ listLog.stream().forEach(x -> {
|
|
|
+ orderNoList.addAll(Arrays.asList(x.getOrderNoList().split(",")));
|
|
|
+ });
|
|
|
+ //更新发票状态
|
|
|
+ iTopOldOrderService.update(new LambdaUpdateWrapper<TopOldOrder>()
|
|
|
+ .in(TopOldOrder::getOrderSn,orderNoList)
|
|
|
+ .set(TopOldOrder::getInvoiceStatus,3));
|
|
|
+ //填充发票信息
|
|
|
+ update(new LambdaUpdateWrapper<TopNuoMplatformLog>()
|
|
|
+ .in(TopNuoMplatformLog::getOrderNo,bo.getOrderNos())
|
|
|
+ .set(TopNuoMplatformLog::getUpdateTime,DateUtils.getNowTime())
|
|
|
+ .set(TopNuoMplatformLog::getStatus,2));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|