初始版本
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
package com.vverp.controller.api;
|
||||
|
||||
import com.vverp.util.DateUtil;
|
||||
import com.vverp.dto.PaymentApplyQuery;
|
||||
import com.vverp.entity.*;
|
||||
import com.vverp.moli.util.Filter;
|
||||
import com.vverp.moli.util.Page;
|
||||
import com.vverp.moli.util.Pageable;
|
||||
import com.vverp.moli.util.RespData;
|
||||
import com.vverp.service.*;
|
||||
import com.vverp.util.MapUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author dealsky
|
||||
* @date 2020/9/15 4:41 下午
|
||||
*/
|
||||
@RestController("apiPaymentApplyController")
|
||||
@RequestMapping("/api/paymentApply")
|
||||
public class PaymentApplyController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private PaymentApplyService paymentApplyService;
|
||||
|
||||
@Resource
|
||||
private AdminService adminService;
|
||||
|
||||
@Resource
|
||||
private PurchaseOrderService purchaseOrderService;
|
||||
|
||||
|
||||
@RequestMapping("/create")
|
||||
public RespData create(PaymentApply paymentApply) {
|
||||
Admin admin = adminService.getApp();
|
||||
paymentApply.setAdminId(admin.getId());
|
||||
return respDataWithHandle(() -> paymentApplyService.create(paymentApply));
|
||||
}
|
||||
|
||||
@RequestMapping("/createSeparate")
|
||||
public RespData createSeparate(PaymentApply paymentApply) {
|
||||
Admin admin = adminService.getApp();
|
||||
paymentApply.setAdminId(admin.getId());
|
||||
Department department = admin.getDepartment();
|
||||
if (department == null) {
|
||||
return RespData.error("部门为空");
|
||||
}
|
||||
paymentApply.setDepartmentId(department.getId());
|
||||
return respDataWithHandle(() -> paymentApplyService.selfCreate(paymentApply));
|
||||
}
|
||||
|
||||
@RequestMapping("/list")
|
||||
public RespData list(PaymentApplyQuery query, Pageable pageable, Boolean separate) {
|
||||
query.setContractRequired(!separate);
|
||||
query.setApprovalFailed(false);
|
||||
Page<PaymentApply> page = paymentApplyService.findPage(pageable, query);
|
||||
List<Map<String, Object>> list = getMapList(page.getContent());
|
||||
return RespData.success(new Page<>(list, page.getTotal(), page.getPageable()));
|
||||
}
|
||||
|
||||
@RequestMapping("/listAll")
|
||||
public RespData listAll(PaymentApplyQuery query) {
|
||||
List<PaymentApply> paymentApplyList = paymentApplyService.findList(query);
|
||||
List<Map<String, Object>> list = getMapList(paymentApplyList);
|
||||
return RespData.success(list);
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> getMapList(List<PaymentApply> paymentApplyList) {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (PaymentApply paymentApply : paymentApplyList) {
|
||||
Map<String, Object> map = MapUtils.beansToMap(paymentApply, Arrays.asList(
|
||||
"id", "companyName", "ownerName", "adminName", "amount", "status", "paymentType"
|
||||
));
|
||||
map.put("applyDate", DateUtil.formatDate(paymentApply.getApplyDate()));
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@RequestMapping("/view")
|
||||
public RespData separateList(Long id) {
|
||||
PaymentApply paymentApply = paymentApplyService.find(id);
|
||||
Map<String, Object> map = MapUtils.beansToMap(paymentApply, Arrays.asList(
|
||||
"id", "companyName", "ownerName", "adminName", "amount", "status", "paymentType", "type", "ownerId",
|
||||
"companyId", "departmentName", "bankName", "bankAccount", "remark", "amountCn", "receivePayment"
|
||||
));
|
||||
map.put("applyDate", DateUtil.formatDate(paymentApply.getApplyDate()));
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
@RequestMapping("/initInfo")
|
||||
public RespData initInfo(Long id, PaymentApply.Type type) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
||||
OrderBase orderBase = new OrderBase();
|
||||
|
||||
if (type.equals(PaymentApply.Type.purchaseOrder)) {
|
||||
orderBase = purchaseOrderService.find(id);
|
||||
map.put("bankType", "supplier");
|
||||
}
|
||||
|
||||
map.put("ownerId", orderBase.getOwnerId());
|
||||
map.put("ownerName", orderBase.getOwnerName());
|
||||
map.put("departmentId", orderBase.getDepartmentId());
|
||||
map.put("departmentName", orderBase.getDepartmentName());
|
||||
map.put("companyId", orderBase.getCompanyId());
|
||||
map.put("companyName", orderBase.getCompanyName());
|
||||
|
||||
return RespData.success(map);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user