Skip to content

Commit

Permalink
Merge pull request #167 from ginnosgroup/Develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
venwyhk committed Aug 2, 2020
2 parents 9fcdacf + e141145 commit 56580ec
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.zhinanzhen.b.controller;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
Expand Down Expand Up @@ -36,8 +37,11 @@

import com.ikasoa.core.utils.StringUtil;

import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.WorkbookSettings;
import jxl.read.biff.BiffException;
import jxl.write.Label;
import jxl.write.WritableCellFormat;
import jxl.write.WritableSheet;
Expand All @@ -62,6 +66,8 @@ public class CommissionOrderController extends BaseCommissionOrderController {

@Resource
ServiceOrderService serviceOrderService;

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

@RequestMapping(value = "/upload_img", method = RequestMethod.POST)
@ResponseBody
Expand Down Expand Up @@ -766,6 +772,59 @@ public Response<List<CommissionOrderListDTO>> list(@RequestParam(value = "maraId
}
}

@RequestMapping(value = "/upload", method = RequestMethod.POST)
@ResponseBody
public Response<Integer> upload(@RequestParam MultipartFile file, HttpServletRequest request,
HttpServletResponse response) throws IllegalStateException, IOException {
super.setPostHeader(response);
String message = "";
int n = 0;
Response<String> r = super.upload2(file, request.getSession(), "/tmp/");
try (InputStream is = new FileInputStream(r.getData())) {
jxl.Workbook wb = jxl.Workbook.getWorkbook(is);
Sheet sheet = wb.getSheet(0);
for (int i = 1; i < sheet.getRows(); i++) {
Cell[] cells = sheet.getRow(i);
String _id = cells[0].getContents();
String _schoolPaymentAmount = cells[21].getContents();
String _schoolPaymentDate = cells[22].getContents();
String _invoiceNumber = cells[23].getContents();
String _zyDate = cells[23].getContents();
String _sureExpectAmount = cells[26].getContents();
String _bonus = cells[27].getContents();
String _bonusDate = cells[28].getContents();
try {
CommissionOrderListDTO commissionOrderListDto = commissionOrderService
.getCommissionOrderById(Integer.parseInt(_id));
if (commissionOrderListDto == null) {
message += "[" + _id + "]佣金订单不存在;";
continue;
}
if (!CommissionStateEnum.DJY.toString()
.equalsIgnoreCase(commissionOrderListDto.getCommissionState())
&& !CommissionStateEnum.DZY.toString()
.equalsIgnoreCase(commissionOrderListDto.getCommissionState())) {
message += "[" + _id + "]佣金订单状态不是待结佣或待追佣;";
continue;
}
Response<CommissionOrderDTO> _r = updateOne(Integer.parseInt(_id),
Double.parseDouble(_schoolPaymentAmount), sdf.format(_schoolPaymentDate), _invoiceNumber,
sdf.format(_zyDate), Double.parseDouble(_sureExpectAmount), Double.parseDouble(_bonus),
sdf.format(_bonusDate), true);
if (_r.getCode() > 0)
message += "[" + _id + "]" + _r.getMessage() + ";";
else
n++;
} catch (NumberFormatException | ServiceException e) {
message += "[" + _id + "]" + e.getMessage() + ";";
}
}
} catch (BiffException | IOException e) {
return new Response<Integer>(1, "上传失败:" + e.getMessage(), 0);
}
return new Response<Integer>(0, message, n);
}

@RequestMapping(value = "/down", method = RequestMethod.GET)
@ResponseBody
public void down(@RequestParam(value = "maraId", required = false) Integer maraId,
Expand Down Expand Up @@ -858,7 +917,6 @@ public void down(@RequestParam(value = "maraId", required = false) Integer maraI
WritableCellFormat cellFormat = new WritableCellFormat();

int i = 1;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
for (CommissionOrderListDTO commissionOrderListDto : commissionOrderList) {
sheet.addCell(new Label(0, i, commissionOrderListDto.getId() + "", cellFormat));
sheet.addCell(new Label(1, i, sdf.format(commissionOrderListDto.getGmtCreate()), cellFormat));
Expand Down
52 changes: 48 additions & 4 deletions src/main/java/org/zhinanzhen/b/controller/VisaController.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.zhinanzhen.b.controller;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
Expand Down Expand Up @@ -33,14 +34,14 @@

import com.ikasoa.core.utils.StringUtil;

import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.WorkbookSettings;
import jxl.read.biff.BiffException;
import jxl.write.Label;
import jxl.write.WritableCellFormat;
import jxl.write.WritableSheet;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Controller
@CrossOrigin(origins = "*", maxAge = 3600)
Expand All @@ -52,6 +53,8 @@ public class VisaController extends BaseCommissionOrderController {

@Resource
ServiceOrderService serviceOrderService;

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

@RequestMapping(value = "/upload_img", method = RequestMethod.POST)
@ResponseBody
Expand Down Expand Up @@ -556,6 +559,48 @@ public Response<List<VisaDTO>> listVisa(@RequestParam(value = "keyword", require
return new Response<List<VisaDTO>>(1, e.getMessage(), null);
}
}

@RequestMapping(value = "/upload", method = RequestMethod.POST)
@ResponseBody
public Response<Integer> upload(@RequestParam MultipartFile file, HttpServletRequest request,
HttpServletResponse response) throws IllegalStateException, IOException {
super.setPostHeader(response);
String message = "";
int n = 0;
Response<String> r = super.upload2(file, request.getSession(), "/tmp/");
try (InputStream is = new FileInputStream(r.getData())) {
jxl.Workbook wb = jxl.Workbook.getWorkbook(is);
Sheet sheet = wb.getSheet(0);
for (int i = 1; i < sheet.getRows(); i++) {
Cell[] cells = sheet.getRow(i);
String _id = cells[0].getContents();
String _bonus = cells[11].getContents();
String _bonusDate = cells[12].getContents();
try {
VisaDTO visaDto = visaService.getVisaById(Integer.parseInt(_id));
if (visaDto == null) {
message += "[" + _id + "]佣金订单不存在;";
continue;
}
if (!CommissionStateEnum.DJY.toString().equals(visaDto.getCommissionState())) {
message += "[" + _id + "]佣金订单状态不是待结佣;";
continue;
}
Response<VisaDTO> _r = updateOne(Integer.parseInt(_id), null, Double.parseDouble(_bonus),
sdf.format(_bonusDate), true);
if (_r.getCode() > 0)
message += "[" + _id + "]" + _r.getMessage() + ";";
else
n++;
} catch (NumberFormatException | ServiceException e) {
message += "[" + _id + "]" + e.getMessage() + ";";
}
}
} catch (BiffException | IOException e) {
return new Response<Integer>(1, "上传失败:" + e.getMessage(), 0);
}
return new Response<Integer>(0, message, n);
}

@RequestMapping(value = "/down", method = RequestMethod.GET)
@ResponseBody
Expand Down Expand Up @@ -645,7 +690,6 @@ public void down(@RequestParam(value = "keyword", required = false) String keywo
WritableCellFormat cellFormat = new WritableCellFormat();

int i = 1;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
for (VisaDTO visaDto : list) {
sheet.addCell(new Label(0, i, visaDto.getId() + "", cellFormat));
sheet.addCell(new Label(1, i, sdf.format(visaDto.getGmtCreate()), cellFormat));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public int countCommissionOrder(Integer maraId, Integer adviserId, Integer offic
throws ServiceException {
return commissionOrderDao.countCommissionOrder(maraId, adviserId, officialId, userId, name, phone,
wechatUsername, schoolId, isSettle, stateList, commissionStateList, startKjApprovalDate,
endKjApprovalDate, isYzyAndYjy);
theDateTo23_59_59(endKjApprovalDate), isYzyAndYjy);
}

@Override
Expand All @@ -145,7 +145,8 @@ public List<CommissionOrderListDTO> listCommissionOrder(Integer maraId, Integer
try {
commissionOrderListDoList = commissionOrderDao.listCommissionOrder(maraId, adviserId, officialId, userId,
name, phone, wechatUsername, schoolId, isSettle, stateList, commissionStateList,
startKjApprovalDate, endKjApprovalDate, isYzyAndYjy, pageNum * pageSize, pageSize);
startKjApprovalDate, theDateTo23_59_59(endKjApprovalDate), isYzyAndYjy, pageNum * pageSize,
pageSize);
if (commissionOrderListDoList == null)
return null;
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ private void schoolSetting7(SchoolSettingDO schoolSetting, Date startDate, Date
// co.getId() + "学校设置计算=学校设置金额[" + subjectSettingDo.getPrice() + "]=" + co.getCommission());
if (parameters != null) {
co.setCommission(co.getAmount() - Double.parseDouble(parameters.trim()));
System.out.println(co.getId() + "学校设置计算=本次收款金额[\" + co.getAmount() + \"]-学校设置金额[" + Double.parseDouble(parameters.trim()) + "]="
System.out.println(co.getId() + "学校设置计算=本次收款金额[" + co.getAmount() + "]-学校设置金额[" + Double.parseDouble(parameters.trim()) + "]="
+ co.getCommission());
} else {
co.setCommission(co.getAmount()); // 正常情况下是不会执行到这里的
Expand Down

0 comments on commit 56580ec

Please sign in to comment.