|
@@ -326,76 +326,76 @@ public class CmPayShopController extends BaseController {
|
|
//子订单的成本方式第一次填写以后就不能修改了
|
|
//子订单的成本方式第一次填写以后就不能修改了
|
|
// 固定成本
|
|
// 固定成本
|
|
//if ("1".equals(costType)) {
|
|
//if ("1".equals(costType)) {
|
|
- // List<CmReturnedPurchaseProduct> rL = cmReturnedPurchaseProductService.findReturnedByShopOrderID(Integer.parseInt(shopOrderID));
|
|
|
|
- for (NewOrderProduct product : newOrderProducts) {
|
|
|
|
- Integer orderProductID = product.getOrderProductID();
|
|
|
|
- Double costPrice = product.getCostPrice() == null ? 0d : product.getCostPrice();
|
|
|
|
- Double organizeCostPrice = product.getOrganizeCostPrice() == null ? 0d : product.getOrganizeCostPrice();
|
|
|
|
- Double cmCostPrice = product.getCmCostPrice() == null ? 0d : product.getCmCostPrice();
|
|
|
|
- if (soZeroCostFlag && costPrice > 0) {
|
|
|
|
- soZeroCostFlag = false;
|
|
|
|
- }
|
|
|
|
- // 在订单商品含税的情况下, 成本计算税费
|
|
|
|
- if ("0".equals(product.getIncludedTax()) && null != product.getSupplierTaxRate() && product.getSupplierTaxRate() > 0d) {
|
|
|
|
- costPrice = MathUtil.add(costPrice, MathUtil.div(MathUtil.mul(costPrice, product.getSupplierTaxRate()), 100)).doubleValue();
|
|
|
|
- }
|
|
|
|
- // product.setSingleShouldPayTotalTax(MathUtil.div(MathUtil.mul(MathUtil.div(product.getCostPrice(), MathUtil.div(MathUtil.add(product.getTaxRate(), 100),100)), product.getSupplierTaxRate()), 100).doubleValue());
|
|
|
|
- Double singleShouldPayTotalTax = product.getSingleShouldPayTotalTax() == null ? 0d : product.getSingleShouldPayTotalTax();
|
|
|
|
- Double supplierTaxRate = product.getSupplierTaxRate() == null ? 0d : product.getSupplierTaxRate();
|
|
|
|
- // 获取已被退款的商品数量
|
|
|
|
- Integer returnNum = newOrderProductDao.CountReturnedPurchaseProduct(Integer.parseInt(shopOrderID), orderProductID);
|
|
|
|
- returnNum = returnNum == null ? 0 : returnNum;
|
|
|
|
- NewOrderProduct orderProduct = newOrderProductService.get(String.valueOf(orderProductID));
|
|
|
|
- // 修改前
|
|
|
|
- if (StringUtils.isEmpty(dbcostType)) {
|
|
|
|
- CmChangePayShopProduct cmChangePayShopProduct = new CmChangePayShopProduct();
|
|
|
|
- cmChangePayShopProduct.setRecondType("1");
|
|
|
|
- cmChangePayShopProduct.setChangeType("1");
|
|
|
|
- cmChangePayShopProduct.setChangePayShopId(Integer.parseInt(cmChangePayShopRecondId));
|
|
|
|
- cmChangePayShopProduct.setOrderProductId(orderProductID);
|
|
|
|
- cmChangePayShopProduct.setOrderProductName(product.getName());
|
|
|
|
- // 同步使用机构税率 作为供应商税率
|
|
|
|
- cmChangePayShopProduct.setSupplierTaxRate(product.getTaxRate());
|
|
|
|
- cmChangePayShopProduct.setCostPrice(orderProduct.getNewCostPrice());
|
|
|
|
- cmChangePayShopProduct.setOrganizeCostPrice(orderProduct.getOrganizeCostPrice());
|
|
|
|
- cmChangePayShopProduct.setCmCostPrice(orderProduct.getCmCostPrice());
|
|
|
|
- cmChangePayShopProduct.setSingleShouldPayTotalTax(orderProduct.getSingleShouldPayTotalTax());
|
|
|
|
- cmChangePayShopProductService.save(cmChangePayShopProduct);
|
|
|
|
- }
|
|
|
|
- // 成本
|
|
|
|
- orderProduct.setCostPrice(costPrice);
|
|
|
|
- // 成本 不含税
|
|
|
|
- orderProduct.setCostPriceTax(product.getCostPrice() == null ? 0d : product.getCostPrice());
|
|
|
|
- orderProduct.setOrganizeCostPrice(organizeCostPrice);
|
|
|
|
- orderProduct.setCmCostPrice(cmCostPrice);
|
|
|
|
- // 同步使用机构税率 作为供应商税率
|
|
|
|
- orderProduct.setSupplierTaxRate(supplierTaxRate);
|
|
|
|
- orderProduct.setTaxRate(product.getTaxRate());
|
|
|
|
- orderProduct.setSingleShouldPayTotalTax(singleShouldPayTotalTax);
|
|
|
|
- orderProducts.add(orderProduct);
|
|
|
|
- int num = orderProduct.getNum() == null ? 0 : orderProduct.getNum();
|
|
|
|
- int presentNum = orderProduct.getPresentNum() == null ? 0 : orderProduct.getPresentNum();
|
|
|
|
- totalCostFee += (num + presentNum - returnNum) * costPrice;
|
|
|
|
- orderProduct.setShouldPayTotalTax(singleShouldPayTotalTax * (num + presentNum - returnNum));
|
|
|
|
- totalTaxesFee += singleShouldPayTotalTax * (num + presentNum - returnNum);
|
|
|
|
- // 修改后
|
|
|
|
|
|
+ // List<CmReturnedPurchaseProduct> rL = cmReturnedPurchaseProductService.findReturnedByShopOrderID(Integer.parseInt(shopOrderID));
|
|
|
|
+ for (NewOrderProduct product : newOrderProducts) {
|
|
|
|
+ Integer orderProductID = product.getOrderProductID();
|
|
|
|
+ Double costPrice = product.getCostPrice() == null ? 0d : product.getCostPrice();
|
|
|
|
+ Double organizeCostPrice = product.getOrganizeCostPrice() == null ? 0d : product.getOrganizeCostPrice();
|
|
|
|
+ Double cmCostPrice = product.getCmCostPrice() == null ? 0d : product.getCmCostPrice();
|
|
|
|
+ if (soZeroCostFlag && costPrice > 0) {
|
|
|
|
+ soZeroCostFlag = false;
|
|
|
|
+ }
|
|
|
|
+ // 在订单商品含税的情况下, 成本计算税费
|
|
|
|
+ if ("0".equals(product.getIncludedTax()) && null != product.getSupplierTaxRate() && product.getSupplierTaxRate() > 0d) {
|
|
|
|
+ costPrice = MathUtil.add(costPrice, MathUtil.div(MathUtil.mul(costPrice, product.getSupplierTaxRate()), 100)).doubleValue();
|
|
|
|
+ }
|
|
|
|
+ // product.setSingleShouldPayTotalTax(MathUtil.div(MathUtil.mul(MathUtil.div(product.getCostPrice(), MathUtil.div(MathUtil.add(product.getTaxRate(), 100),100)), product.getSupplierTaxRate()), 100).doubleValue());
|
|
|
|
+ Double singleShouldPayTotalTax = product.getSingleShouldPayTotalTax() == null ? 0d : product.getSingleShouldPayTotalTax();
|
|
|
|
+ Double supplierTaxRate = product.getSupplierTaxRate() == null ? 0d : product.getSupplierTaxRate();
|
|
|
|
+ // 获取已被退款的商品数量
|
|
|
|
+ Integer returnNum = newOrderProductDao.CountReturnedPurchaseProduct(Integer.parseInt(shopOrderID), orderProductID);
|
|
|
|
+ returnNum = returnNum == null ? 0 : returnNum;
|
|
|
|
+ NewOrderProduct orderProduct = newOrderProductService.get(String.valueOf(orderProductID));
|
|
|
|
+ // 修改前
|
|
|
|
+ if (StringUtils.isEmpty(dbcostType)) {
|
|
CmChangePayShopProduct cmChangePayShopProduct = new CmChangePayShopProduct();
|
|
CmChangePayShopProduct cmChangePayShopProduct = new CmChangePayShopProduct();
|
|
- cmChangePayShopProduct.setRecondType("2");
|
|
|
|
- cmChangePayShopProduct.setChangeType(costType);
|
|
|
|
- cmChangePayShopProduct.setChangePayShopId(Integer.parseInt(cmChangePayShopRecondId2));
|
|
|
|
|
|
+ cmChangePayShopProduct.setRecondType("1");
|
|
|
|
+ cmChangePayShopProduct.setChangeType("1");
|
|
|
|
+ cmChangePayShopProduct.setChangePayShopId(Integer.parseInt(cmChangePayShopRecondId));
|
|
cmChangePayShopProduct.setOrderProductId(orderProductID);
|
|
cmChangePayShopProduct.setOrderProductId(orderProductID);
|
|
cmChangePayShopProduct.setOrderProductName(product.getName());
|
|
cmChangePayShopProduct.setOrderProductName(product.getName());
|
|
- cmChangePayShopProduct.setSupplierTaxRate(supplierTaxRate);
|
|
|
|
- cmChangePayShopProduct.setCostPrice(product.getCostPrice());
|
|
|
|
- cmChangePayShopProduct.setOrganizeCostPrice(product.getOrganizeCostPrice());
|
|
|
|
- cmChangePayShopProduct.setCmCostPrice(product.getCmCostPrice());
|
|
|
|
- cmChangePayShopProduct.setSingleShouldPayTotalTax(product.getSingleShouldPayTotalTax());
|
|
|
|
|
|
+ // 同步使用机构税率 作为供应商税率
|
|
|
|
+ cmChangePayShopProduct.setSupplierTaxRate(product.getTaxRate());
|
|
|
|
+ cmChangePayShopProduct.setCostPrice(orderProduct.getNewCostPrice());
|
|
|
|
+ cmChangePayShopProduct.setOrganizeCostPrice(orderProduct.getOrganizeCostPrice());
|
|
|
|
+ cmChangePayShopProduct.setCmCostPrice(orderProduct.getCmCostPrice());
|
|
|
|
+ cmChangePayShopProduct.setSingleShouldPayTotalTax(orderProduct.getSingleShouldPayTotalTax());
|
|
cmChangePayShopProductService.save(cmChangePayShopProduct);
|
|
cmChangePayShopProductService.save(cmChangePayShopProduct);
|
|
}
|
|
}
|
|
- //总税费
|
|
|
|
- shopOrder.setShopTaxFee(totalTaxesFee);
|
|
|
|
- //商品费
|
|
|
|
- shopOrder.setShopProductAmount(totalCostFee);
|
|
|
|
|
|
+ // 成本
|
|
|
|
+ orderProduct.setCostPrice(costPrice);
|
|
|
|
+ // 成本 不含税
|
|
|
|
+ orderProduct.setCostPriceTax(product.getCostPrice() == null ? 0d : product.getCostPrice());
|
|
|
|
+ orderProduct.setOrganizeCostPrice(organizeCostPrice);
|
|
|
|
+ orderProduct.setCmCostPrice(cmCostPrice);
|
|
|
|
+ // 同步使用机构税率 作为供应商税率
|
|
|
|
+ orderProduct.setSupplierTaxRate(supplierTaxRate);
|
|
|
|
+ orderProduct.setTaxRate(product.getTaxRate());
|
|
|
|
+ orderProduct.setSingleShouldPayTotalTax(singleShouldPayTotalTax);
|
|
|
|
+ orderProducts.add(orderProduct);
|
|
|
|
+ int num = orderProduct.getNum() == null ? 0 : orderProduct.getNum();
|
|
|
|
+ int presentNum = orderProduct.getPresentNum() == null ? 0 : orderProduct.getPresentNum();
|
|
|
|
+ totalCostFee += (num + presentNum - returnNum) * costPrice;
|
|
|
|
+ orderProduct.setShouldPayTotalTax(singleShouldPayTotalTax * (num + presentNum - returnNum));
|
|
|
|
+ totalTaxesFee += singleShouldPayTotalTax * (num + presentNum - returnNum);
|
|
|
|
+ // 修改后
|
|
|
|
+ CmChangePayShopProduct cmChangePayShopProduct = new CmChangePayShopProduct();
|
|
|
|
+ cmChangePayShopProduct.setRecondType("2");
|
|
|
|
+ cmChangePayShopProduct.setChangeType(costType);
|
|
|
|
+ cmChangePayShopProduct.setChangePayShopId(Integer.parseInt(cmChangePayShopRecondId2));
|
|
|
|
+ cmChangePayShopProduct.setOrderProductId(orderProductID);
|
|
|
|
+ cmChangePayShopProduct.setOrderProductName(product.getName());
|
|
|
|
+ cmChangePayShopProduct.setSupplierTaxRate(supplierTaxRate);
|
|
|
|
+ cmChangePayShopProduct.setCostPrice(product.getCostPrice());
|
|
|
|
+ cmChangePayShopProduct.setOrganizeCostPrice(product.getOrganizeCostPrice());
|
|
|
|
+ cmChangePayShopProduct.setCmCostPrice(product.getCmCostPrice());
|
|
|
|
+ cmChangePayShopProduct.setSingleShouldPayTotalTax(product.getSingleShouldPayTotalTax());
|
|
|
|
+ cmChangePayShopProductService.save(cmChangePayShopProduct);
|
|
|
|
+ }
|
|
|
|
+ //总税费
|
|
|
|
+ shopOrder.setShopTaxFee(totalTaxesFee);
|
|
|
|
+ //商品费
|
|
|
|
+ shopOrder.setShopProductAmount(totalCostFee);
|
|
//}
|
|
//}
|
|
// 比例成本
|
|
// 比例成本
|
|
/*if ("2".equals(costType)) {
|
|
/*if ("2".equals(costType)) {
|
|
@@ -487,53 +487,55 @@ public class CmPayShopController extends BaseController {
|
|
// shopOrder.setShopProductAmount(productAmount * proportional / 100); //商品费
|
|
// shopOrder.setShopProductAmount(productAmount * proportional / 100); //商品费
|
|
|
|
|
|
}*/
|
|
}*/
|
|
- shopOrder.setPayStatus(soZeroCostFlag ? "3" : "1");
|
|
|
|
- shopOrder.setZeroCostFlag(soZeroCostFlag ? 1 : 0);
|
|
|
|
- //当子订单0成本时,若主订单中其他子订单(除了运费子订单)都为0成本,设主订单为已付款,否则设为部分付款
|
|
|
|
- NewOrder newOrder = newOrderService.get(shopOrder.getOrderID().toString());
|
|
|
|
- if (soZeroCostFlag) {
|
|
|
|
- AtomicReference<Boolean> zeroCostFlag = new AtomicReference<>(true);
|
|
|
|
- AtomicReference<Boolean> freightFlag = new AtomicReference<>(false);
|
|
|
|
- newOrder.getNewShopOrders().forEach(item -> {
|
|
|
|
- if (item.getShopID().equals(998)) {
|
|
|
|
- freightFlag.set(true);
|
|
|
|
- } else if (!item.getShopOrderID().equals(shopOrder.getShopOrderID()) && 0 == item.getZeroCostFlag()) {
|
|
|
|
- zeroCostFlag.set(false);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- //如果含有运费子订单且其他子订单都为0成本,将运费子订单置为已付款
|
|
|
|
- if (freightFlag.get() && zeroCostFlag.get()) {
|
|
|
|
- newOrder.getNewShopOrders().forEach(item -> {
|
|
|
|
- if (item.getShopID().equals(998)) {
|
|
|
|
- item.setPayStatus("3");
|
|
|
|
- //更新运费子订单
|
|
|
|
- newShopOrderService.updatePayStatus(item);
|
|
|
|
- cmPayShopService.payFreightShopOrder(item);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- if (zeroCostFlag.get()) {
|
|
|
|
- newOrder.setPayStatus("3");
|
|
|
|
- newOrder.setZeroCostFlag(1);
|
|
|
|
- } else {
|
|
|
|
- newOrder.setPayStatus("2");
|
|
|
|
- newOrder.setZeroCostFlag(0);
|
|
|
|
- }
|
|
|
|
- newOrderService.updatePayStatus(newOrder);
|
|
|
|
- }
|
|
|
|
|
|
+// shopOrder.setPayStatus(soZeroCostFlag ? "3" : "1");
|
|
|
|
+// shopOrder.setZeroCostFlag(soZeroCostFlag ? 1 : 0);
|
|
|
|
+// //当子订单0成本时,若主订单中其他子订单(除了运费子订单)都为0成本,设主订单为已付款,否则设为部分付款
|
|
|
|
+// NewOrder newOrder = newOrderService.get(shopOrder.getOrderID().toString());
|
|
|
|
+// if (soZeroCostFlag) {
|
|
|
|
+// AtomicReference<Boolean> zeroCostFlag = new AtomicReference<>(true);
|
|
|
|
+// AtomicReference<Boolean> freightFlag = new AtomicReference<>(false);
|
|
|
|
+// newOrder.getNewShopOrders().forEach(item -> {
|
|
|
|
+// if (item.getShopID().equals(998)) {
|
|
|
|
+// freightFlag.set(true);
|
|
|
|
+// } else if (!item.getShopOrderID().equals(shopOrder.getShopOrderID()) && 0 == item.getZeroCostFlag()) {
|
|
|
|
+// zeroCostFlag.set(false);
|
|
|
|
+// }
|
|
|
|
+// });
|
|
|
|
+// //如果含有运费子订单且其他子订单都为0成本,将运费子订单置为已付款
|
|
|
|
+// if (freightFlag.get() && zeroCostFlag.get()) {
|
|
|
|
+// newOrder.getNewShopOrders().forEach(item -> {
|
|
|
|
+// if (item.getShopID().equals(998)) {
|
|
|
|
+// item.setPayStatus("3");
|
|
|
|
+// //更新运费子订单
|
|
|
|
+// newShopOrderService.updatePayStatus(item);
|
|
|
|
+// cmPayShopService.payFreightShopOrder(item);
|
|
|
|
+//
|
|
|
|
+// }
|
|
|
|
+// });
|
|
|
|
+// }
|
|
|
|
+// if (zeroCostFlag.get()) {
|
|
|
|
+// newOrder.setPayStatus("3");
|
|
|
|
+// newOrder.setZeroCostFlag(1);
|
|
|
|
+// } else {
|
|
|
|
+// newOrder.setPayStatus("2");
|
|
|
|
+// newOrder.setZeroCostFlag(0);
|
|
|
|
+// }
|
|
|
|
+// newOrderService.updatePayStatus(newOrder);
|
|
|
|
+// }
|
|
|
|
+ shopOrder.setRebateFee(newShopOrder.getRebateOrder());
|
|
shopOrder.setSupplierFreight(freight); //运费
|
|
shopOrder.setSupplierFreight(freight); //运费
|
|
shopOrder.setShopOtherFee(thirdPartyFee); //付第三方
|
|
shopOrder.setShopOtherFee(thirdPartyFee); //付第三方
|
|
shopOrder.setCostType(costType);
|
|
shopOrder.setCostType(costType);
|
|
shopOrder.setModifyShouldPayNote(modifyShouldPayNote); //备注
|
|
shopOrder.setModifyShouldPayNote(modifyShouldPayNote); //备注
|
|
shopOrder.setModifyShouldPayUserID(UserUtils.getUser().getId()); //修改人的用户id
|
|
shopOrder.setModifyShouldPayUserID(UserUtils.getUser().getId()); //修改人的用户id
|
|
shopOrder.setModifyShouldPayDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); //修改时间
|
|
shopOrder.setModifyShouldPayDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); //修改时间
|
|
- double shouldPayShopAmount = shopOrder.getShopProductAmount() + shopOrder.getSupplierFreight(); // + shopOrder.getShopTaxFee();
|
|
|
|
|
|
+ double supplierFreight = null == shopOrder.getSupplierFreight() ? 0 : shopOrder.getSupplierFreight();
|
|
|
|
+ double shouldPayShopAmount = shopOrder.getShopProductAmount() + supplierFreight; // + shopOrder.getShopTaxFee();
|
|
if (shopOrder.getPayedShopAmount() != null && shouldPayShopAmount == shopOrder.getPayedShopAmount()) {
|
|
if (shopOrder.getPayedShopAmount() != null && shouldPayShopAmount == shopOrder.getPayedShopAmount()) {
|
|
shopOrder.setPayStatus("3");
|
|
shopOrder.setPayStatus("3");
|
|
}
|
|
}
|
|
// 付供应商 - 优惠券 - 促销满减优惠
|
|
// 付供应商 - 优惠券 - 促销满减优惠
|
|
- shopOrder.setShouldPayShopAmount(MathUtil.sub(shouldPayShopAmount , MathUtil.add(shopOrder.getCouponAmount(), shopOrder.getPromotionFullReduction())).doubleValue());
|
|
|
|
|
|
+ shopOrder.setShouldPayShopAmount(MathUtil.sub(shouldPayShopAmount, MathUtil.add(shopOrder.getCouponAmount(), shopOrder.getPromotionFullReduction())).doubleValue());
|
|
newShopOrderService.modifyPayShopAmount(shopOrder, orderProducts);
|
|
newShopOrderService.modifyPayShopAmount(shopOrder, orderProducts);
|
|
return "redirect:" + Global.getAdminPath() + "/shopOrder/payOrderList";
|
|
return "redirect:" + Global.getAdminPath() + "/shopOrder/payOrderList";
|
|
}
|
|
}
|
|
@@ -688,7 +690,7 @@ public class CmPayShopController extends BaseController {
|
|
int weekIdx = instance.get(Calendar.DAY_OF_WEEK) - 1;
|
|
int weekIdx = instance.get(Calendar.DAY_OF_WEEK) - 1;
|
|
String format = new SimpleDateFormat("HH:mm:ss").format(new Date());
|
|
String format = new SimpleDateFormat("HH:mm:ss").format(new Date());
|
|
Integer substring = Integer.valueOf(format.substring(0, 2));
|
|
Integer substring = Integer.valueOf(format.substring(0, 2));
|
|
- ids.forEach(i->{
|
|
|
|
|
|
+ ids.forEach(i -> {
|
|
//当前时间周五下午到周日都返回1不能结算,其他时间看够不够24小时
|
|
//当前时间周五下午到周日都返回1不能结算,其他时间看够不够24小时
|
|
if ((5 == weekIdx && substring > 14) || 6 == weekIdx || 7 == weekIdx) {
|
|
if ((5 == weekIdx && substring > 14) || 6 == weekIdx || 7 == weekIdx) {
|
|
flag.set(1);
|
|
flag.set(1);
|