|
|
@@ -5,21 +5,28 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import org.springblade.common.enums.CommonEnum;
|
|
|
import org.springblade.core.secure.BladeUser;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
import org.springblade.core.tool.utils.SpringUtil;
|
|
|
import org.springblade.salesPart.brand.service.IBrandDescService;
|
|
|
-import org.springblade.salesPart.corps.service.ICorpsAttnService;
|
|
|
-import org.springblade.salesPart.corps.service.ICorpsDescService;
|
|
|
import org.springblade.salesPart.entity.*;
|
|
|
+import org.springblade.salesPart.enums.FinalMap;
|
|
|
import org.springblade.salesPart.enums.ProductLaunchPriceSystem;
|
|
|
+import org.springblade.salesPart.recycling.entity.GreenRecyclingRecord;
|
|
|
import org.springblade.salesPart.stock.service.IStockDescService;
|
|
|
import org.springblade.salesPart.vo.ResourceWarehouseVo;
|
|
|
import org.springblade.salesPart.vo.WxAppGoodsImgVo;
|
|
|
import org.springblade.salesPart.vo.WxAppGoodsParamsVo;
|
|
|
import org.springblade.system.feign.ISysClient;
|
|
|
+import org.springblade.system.user.entity.User;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.Comparator;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -108,7 +115,7 @@ public class WxParamUtil {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public static void findGoodsImg(List<PjProductLaunch> pjProductLaunchList, List<WxAppGoodsImgVo> wxAppGoodsImgVoList, String priceSystemStr){
|
|
|
+ public static void findGoodsImg(List<PjProductLaunch> pjProductLaunchList, List<WxAppGoodsImgVo> wxAppGoodsImgVoList, String priceSystemStr) {
|
|
|
for (PjProductLaunch item : pjProductLaunchList) {
|
|
|
ProductLaunchPriceSystem priceSystem = ProductLaunchPriceSystem.fromValue(priceSystemStr);
|
|
|
priceSystem.setMallPrice(item);
|
|
|
@@ -124,7 +131,7 @@ public class WxParamUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static void findResourceWarehouseImg(List<ResourceWarehouseVo> resourceWarehouseVoList, List<WxAppGoodsImgVo> wxAppGoodsImgVoList, String priceSystemStr){
|
|
|
+ public static void findResourceWarehouseImg(List<ResourceWarehouseVo> resourceWarehouseVoList, List<WxAppGoodsImgVo> wxAppGoodsImgVoList, String priceSystemStr) {
|
|
|
PjProductLaunch pjProductLaunch = new PjProductLaunch();
|
|
|
for (ResourceWarehouseVo item : resourceWarehouseVoList) {
|
|
|
pjProductLaunch.setPriceOne(item.getPriceOne());
|
|
|
@@ -147,5 +154,143 @@ public class WxParamUtil {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据客户账期计算应结日期
|
|
|
+ *
|
|
|
+ * @param accountPeriod 账期
|
|
|
+ * @return 结账日期
|
|
|
+ */
|
|
|
+ public static Date getOrderDueDate(Integer accountPeriod) {
|
|
|
+ Date nowDate = new Date();
|
|
|
+ if (ObjectUtil.isNotEmpty(accountPeriod)) {
|
|
|
+ return nowDate;
|
|
|
+ }
|
|
|
+ long sevenDays = accountPeriod * 24 * 60 * 60 * 1000L;
|
|
|
+ return new Date(nowDate.getTime() + sevenDays);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 小程序支付获取支付类型
|
|
|
+ *
|
|
|
+ * @param ifLimitAmount 是否额度支付
|
|
|
+ * @param limitAmount 当前用户额度
|
|
|
+ * @param totalMoney 订单总金额
|
|
|
+ * @param isTlCashier 是否使用通联收银台
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ public static String wxPayGetPaymentType(String ifLimitAmount, BigDecimal limitAmount,
|
|
|
+ BigDecimal totalMoney, String isTlCashier) {
|
|
|
+ if (CommonEnum.ONE.info.equals(ifLimitAmount) && limitAmount.compareTo(totalMoney) >= 0) {
|
|
|
+ return CommonEnum.TWO.info;
|
|
|
+ }
|
|
|
+ return CommonEnum.ONE.info.equals(isTlCashier) ? isTlCashier : CommonEnum.ZERO.info;
|
|
|
+ }
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取订单基础信息
|
|
|
+ *
|
|
|
+ * @param corpsDesc 客户信息
|
|
|
+ * @param corpsAttn 用户信息
|
|
|
+ * @param bladeUser 用户信息
|
|
|
+ * @param srcOrdNo 来源订单号
|
|
|
+ * @param billNo 单据号
|
|
|
+ * @param deptId 部门id
|
|
|
+ * @param deptName 部门名称
|
|
|
+ * @param address 地址
|
|
|
+ * @return 基础order
|
|
|
+ */
|
|
|
+ public static PjOrder getBaseOrderByCorps(PjCorpsDesc corpsDesc, PjCorpsAttn corpsAttn, BladeUser bladeUser, String srcOrdNo,
|
|
|
+ String billNo, Long deptId, String deptName, String address) {
|
|
|
+ PjOrder order = new PjOrder();
|
|
|
+ //如果只有一个公司,订单编号和主编号一致
|
|
|
+ order.setOrdNo(srcOrdNo);
|
|
|
+ order.setBusinesDate(new Date());
|
|
|
+ order.setSrcOrdNo(billNo);
|
|
|
+ order.setCreateUser(bladeUser.getUserId());
|
|
|
+ //根据客户账期计算应结日期
|
|
|
+ order.setDueDate(WxParamUtil.getOrderDueDate(corpsDesc.getAccountPeriod()));
|
|
|
+ order.setCreateTime(new Date());
|
|
|
+ order.setCreateDept(deptId);
|
|
|
+ order.setTenantId(bladeUser.getTenantId());
|
|
|
+ order.setCustomerId(corpsDesc.getId());
|
|
|
+ order.setCustomerName(corpsDesc.getCname());
|
|
|
+ order.setSalerId(corpsDesc.getSalesmanId());
|
|
|
+ order.setSalerName(corpsDesc.getSalesmanName());
|
|
|
+ if (ObjectUtils.isNotNull(corpsDesc.getDeliveryWarehouseId())) {
|
|
|
+ order.setStorageId(corpsDesc.getDeliveryWarehouseId());
|
|
|
+ order.setStorageName(corpsDesc.getDeliveryWarehouseName());
|
|
|
+ }
|
|
|
+ order.setSalesCompanyId(deptId);
|
|
|
+ order.setSalesCompanyName(deptName);
|
|
|
+ order.setRecAddress(address);
|
|
|
+ order.setContacts(corpsAttn.getCname());
|
|
|
+ order.setPhone(corpsAttn.getTel());
|
|
|
+ return order;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据购物车信息创建订单明细信息
|
|
|
+ *
|
|
|
+ * @param item 购物车数据
|
|
|
+ * @param bladeUser 当前用户
|
|
|
+ * @param deptId 部门id
|
|
|
+ * @param billNo 单号
|
|
|
+ * @return 订单明细
|
|
|
+ */
|
|
|
+ public static PjOrderItems getBaseOrderItemsByShoppingCart(PjShoppingCart item, BladeUser bladeUser, Long deptId, String billNo) {
|
|
|
+ PjOrderItems orderItems = new PjOrderItems();
|
|
|
+ BeanUtils.copyProperties(item, orderItems);
|
|
|
+ orderItems.setId(null);
|
|
|
+ orderItems.setSendNum(FinalMap.ZERO_POINT_ZERO);
|
|
|
+ orderItems.setCreateUser(bladeUser.getUserId());
|
|
|
+ orderItems.setCreateDept(deptId);
|
|
|
+ orderItems.setCreateTime(new Date());
|
|
|
+ orderItems.setTenantId(bladeUser.getTenantId());
|
|
|
+ orderItems.setBillNo(billNo);
|
|
|
+ orderItems.setInventory(item.getInventory());
|
|
|
+ orderItems.setTotalAmount(orderItems.getGoodsNum().multiply(orderItems.getPrice()));
|
|
|
+ orderItems.setUrl(getGoodsImgUrlByShoppingCart(item.getFilesList()));
|
|
|
+ orderItems.setGoodsName(item.getGoodsName());
|
|
|
+ return orderItems;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private static String getGoodsImgUrlByShoppingCart(List<PjProductLaunchFiles> filesList) {
|
|
|
+ if (CollectionUtils.isEmpty(filesList)) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ return filesList.get(0).getUrl();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取订单运费
|
|
|
+ *
|
|
|
+ * @param orderItemCount 订单明细商品数量
|
|
|
+ * @param freight 运费
|
|
|
+ * @return 运费
|
|
|
+ */
|
|
|
+ public static BigDecimal getFreightByOrder(BigDecimal orderItemCount, String freight) {
|
|
|
+ if (orderItemCount.compareTo(FinalMap.ONE) != 0) {
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNull(freight)) {
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ return new BigDecimal(freight);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static GreenRecyclingRecord parseGreenRecyclingRecord(PjCorpsDesc corpsDesc, Long changeUserId,
|
|
|
+ BigDecimal srcRecoveredBalance, BigDecimal changeQuota, Integer changeType) {
|
|
|
+ GreenRecyclingRecord greenRecyclingRecord = new GreenRecyclingRecord();
|
|
|
+ greenRecyclingRecord.setCustomerId(corpsDesc.getId());
|
|
|
+ greenRecyclingRecord.setTenantId(corpsDesc.getTenantId());
|
|
|
+ greenRecyclingRecord.setAdjustedQuota(corpsDesc.getRecoveredBalance());
|
|
|
+ greenRecyclingRecord.setOriginalQuota(srcRecoveredBalance);
|
|
|
+ greenRecyclingRecord.setAdjustableQuota(changeQuota);
|
|
|
+ greenRecyclingRecord.setChangeUser(changeUserId);
|
|
|
+ greenRecyclingRecord.setChangeTime(LocalDateTime.now());
|
|
|
+ return greenRecyclingRecord;
|
|
|
+ }
|
|
|
}
|