bug
This commit is contained in:
parent
eb6f43a713
commit
a92a25fb28
@ -292,7 +292,7 @@
|
||||
},
|
||||
total:0,
|
||||
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
@ -248,7 +248,7 @@ public class FyPayServiceImpl implements FyPayService {
|
||||
if ("CVR".equals(type)) {
|
||||
payStates = "paid";
|
||||
receiveParameter.setType("2");
|
||||
if (goodsOrder.getUserId()!=null){
|
||||
if (ObjectUtil.isNotEmpty(goodsOrder) && ObjectUtil.isNotEmpty(goodsOrder.getUserId())){
|
||||
receiveParameter.setUserId(goodsOrder.getUserId());
|
||||
}
|
||||
// if (!ObjectUtil.isEmpty(map1.get("orderId"))) {
|
||||
@ -386,6 +386,7 @@ public class FyPayServiceImpl implements FyPayService {
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
return resMap;
|
||||
@ -516,13 +517,17 @@ public class FyPayServiceImpl implements FyPayService {
|
||||
String insCd = map1.get("insCd");
|
||||
String mchntCd = map1.get("mchntCd");
|
||||
Map<String, String> map = Builder.buildFuiou24();
|
||||
map.put("mchnt_order_no",orderNo);
|
||||
map.put("order_type",payType);
|
||||
map.put("total_amt", allAmount);
|
||||
map.put("refund_amt", allAmount);
|
||||
map.put("version", "1.0");
|
||||
map.put("ins_cd", insCd);
|
||||
map.put("mchnt_cd", mchntCd);
|
||||
map.put("term_id", "88888888");
|
||||
map.put("mchnt_order_no",orderNo);
|
||||
map.put("random_str", "orderNo");
|
||||
map.put("order_type",payType);
|
||||
map.put("refund_order_no", refundOrderNo);
|
||||
map.put("refund_amt", allAmount);
|
||||
map.put("total_amt", allAmount);
|
||||
|
||||
|
||||
|
||||
// 请求报文
|
||||
|
@ -17,4 +17,8 @@ public interface LJGoodsMapper extends BaseMapper<LJGoods> {
|
||||
public IPage<LJGoods> selectLJGoodsList(Page page, @Param("goods") LJGoods goods);
|
||||
|
||||
|
||||
|
||||
int subtractGoodesStockByLock(@Param("id") Integer id, @Param("stock") Integer stock);
|
||||
|
||||
|
||||
}
|
||||
|
@ -40,4 +40,12 @@
|
||||
order by sort
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<update id="subtractGoodesStockByLock">
|
||||
update mt_goods set
|
||||
stock = stock - #{stock}
|
||||
where id = #{id}
|
||||
|
||||
</update>
|
||||
|
||||
</mapper>
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fuint.business.convenienceSore.dto.LJGoodsDto;
|
||||
import com.fuint.business.convenienceSore.entity.LJGoods;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -79,4 +80,6 @@ public interface LJGoodsService extends IService<LJGoods> {
|
||||
* @return
|
||||
*/
|
||||
boolean editGoodsInventory(LJGoodsDto goods);
|
||||
|
||||
boolean subtractGoodesStockByLock(@Param("id") Integer id, @Param("stock") Integer stock);
|
||||
}
|
||||
|
@ -16,8 +16,10 @@ import com.fuint.business.convenienceSore.service.LJGoodsService;
|
||||
import com.fuint.business.convenienceSore.service.StockStatisticService;
|
||||
import com.fuint.business.convenienceSore.service.StockTrackService;
|
||||
import com.fuint.common.dto.AccountInfo;
|
||||
import com.fuint.common.util.RedisLock;
|
||||
import com.fuint.common.util.StringUtils;
|
||||
import com.fuint.common.util.TokenUtil;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -25,10 +27,12 @@ import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 商品信息 业务层
|
||||
@ -256,4 +260,29 @@ public class LJGoodsServiceImpl extends ServiceImpl<LJGoodsMapper, LJGoods> impl
|
||||
int i = trackService.insertStockTrack(stockTrack);
|
||||
return i>0;
|
||||
}
|
||||
|
||||
@Resource
|
||||
RedisLock redisLock;
|
||||
/**
|
||||
* 减少商品库存
|
||||
* @param goods
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean subtractGoodesStockByLock(@Param("id") Integer id, @Param("stock") Integer stock) {
|
||||
// 根据油罐id加锁 同一时间只能
|
||||
String lockKey = "integralGift-"+id;
|
||||
Boolean isLock = redisLock.tryLock(lockKey,500,5000, TimeUnit.MILLISECONDS);
|
||||
if (isLock) {
|
||||
LJGoods ljGoods = baseMapper.selectById(id);
|
||||
if (stock.compareTo(ljGoods.getStock())>0) {
|
||||
throw new RuntimeException("“"+ ljGoods.getName() +"”商品库存不足,无法进行减少!");
|
||||
}
|
||||
baseMapper.subtractGoodesStockByLock(id,stock);
|
||||
redisLock.unlock(lockKey);
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -63,7 +63,9 @@ public class IntegralGift extends BaseEntity {
|
||||
* 礼品剩余库存
|
||||
*/
|
||||
private Integer remainingInventory;
|
||||
|
||||
/**
|
||||
* 使用的库存
|
||||
*/
|
||||
private Integer usedInventory;
|
||||
/**
|
||||
* 商家卡券
|
||||
|
@ -86,5 +86,7 @@ public interface IntegralGiftMapper {
|
||||
|
||||
int updateInventory(@Param("id") Integer id,@Param("editInventory") Integer editInventory,@Param("updateBy") Integer updateBy);
|
||||
|
||||
int updateInventoryByLock(@Param("id") Integer id,@Param("editInventory") Integer editInventory);
|
||||
|
||||
}
|
||||
|
||||
|
@ -411,5 +411,15 @@
|
||||
where id =#{id}
|
||||
</update>
|
||||
|
||||
|
||||
<update id="updateInventoryByLock">
|
||||
update integral_gift
|
||||
set
|
||||
remaining_inventory = remaining_inventory - #{editInventory}, -- 剩余库存
|
||||
total_inventory = used_inventory + #{editInventory}, -- 使用库存
|
||||
update_time = NOW()
|
||||
where id =#{id}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
||||
|
@ -70,4 +70,7 @@ public interface IntegralGiftService {
|
||||
*/
|
||||
boolean updateInventory(@Param("id") Integer id,@Param("editInventory") Integer editInventory);
|
||||
|
||||
boolean updateInventoryByLock(@Param("id") Integer id,@Param("editInventory") Integer editInventory);
|
||||
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import com.fuint.business.integral.service.IntegralGiftService;
|
||||
import com.fuint.business.integral.service.IntegralOrdersService;
|
||||
import com.fuint.business.integral.vo.IntegralGiftVO;
|
||||
import com.fuint.common.dto.AccountInfo;
|
||||
import com.fuint.common.util.RedisLock;
|
||||
import com.fuint.common.util.TokenUtil;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -16,6 +17,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* (IntegralGift)表服务实现类
|
||||
@ -119,4 +121,26 @@ public class IntegralGiftServiceImpl implements IntegralGiftService {
|
||||
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
|
||||
return this.integralGiftDao.updateInventory(id,editInventory,nowAccountInfo.getStaffId()) > 0;
|
||||
}
|
||||
@Resource
|
||||
RedisLock redisLock;
|
||||
/**
|
||||
* 处理积分商品库存(库存减少)
|
||||
*/
|
||||
@Override
|
||||
public boolean updateInventoryByLock(@Param("id") Integer id,@Param("editInventory") Integer editInventory) {
|
||||
// 根据油罐id加锁 同一时间只能
|
||||
String lockKey = "integralGift-"+id;
|
||||
Boolean isLock = redisLock.tryLock(lockKey,500,5000, TimeUnit.MILLISECONDS);
|
||||
if (isLock) {
|
||||
redisLock.unlock(lockKey);
|
||||
|
||||
IntegralGift integralGift = integralGiftDao.queryById(id);
|
||||
if (editInventory.compareTo(integralGift.getRemainingInventory())>0) {
|
||||
throw new RuntimeException("该积分商品库存不足!");
|
||||
}else {
|
||||
integralGiftDao.updateInventoryByLock(id, editInventory);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -376,6 +376,9 @@ public class IntegralOrdersServiceImpl implements IntegralOrdersService {
|
||||
ljGoodsService.editGoodsInventory(goods);
|
||||
}
|
||||
|
||||
// 处理积分库存
|
||||
integralGiftService.updateInventoryByLock(integralOrders.getGiftId(),integralOrders.getExchangeQuantity());
|
||||
|
||||
}
|
||||
|
||||
// 用户积分余额变动
|
||||
|
@ -49,6 +49,7 @@ public class CardValueRecordController extends BaseController {
|
||||
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
|
||||
cardValueRecord.setStoreId(nowAccountInfo.getStoreId());
|
||||
Page page = new Page(pageNo, pageSize);
|
||||
page.setDesc("create_time");
|
||||
return getSuccessResult(this.cardValueRecordService.page(page, new QueryWrapper<>(cardValueRecord)));
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
and combined_result.recordName = #{cardValueRecord.recordName}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY createTime
|
||||
ORDER BY create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectFuleRecord"
|
||||
@ -51,7 +51,7 @@
|
||||
and combined_result.recordName = #{cardValueRecord.recordName}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY createTime
|
||||
ORDER BY create_time desc
|
||||
</select>
|
||||
|
||||
|
||||
|
@ -49,7 +49,7 @@ public interface CardValueRecordService extends IService<CardValueRecord> {
|
||||
|
||||
CardValueRecord checkTheStatusOfYourPayment(Integer id);
|
||||
|
||||
boolean editPayStatus(Integer id, String payStatus);
|
||||
boolean editPayStatus(@Param("id") Integer id,@Param("payStates") String payStates);
|
||||
|
||||
|
||||
IPage<CardValueRecordDTO> selectCardRecord(@Param("page") Page page, CardValueRecordDTO cardValueRecord);
|
||||
|
@ -61,4 +61,14 @@ public class AllOrderInfoController extends BaseController {
|
||||
return getSuccessResult(allOrderInfoService.getOrderNum(storeId));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/refund")
|
||||
public ResponseObject refund(@RequestBody Map<String,String> map){
|
||||
return getSuccessResult(allOrderInfoService.refund(map));
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import com.fuint.business.order.entity.AllOrderInfo;
|
||||
import com.fuint.business.order.vo.AllOrderInfoVo;
|
||||
import com.fuint.business.order.vo.CardBalanceChangeVo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface AllOrderInfoService {
|
||||
|
||||
/**
|
||||
@ -52,6 +54,9 @@ public interface AllOrderInfoService {
|
||||
public int updateAllOrderInfoByOrderNo(String orderNo,String status);
|
||||
|
||||
|
||||
public int refund(Map<String,String> map);
|
||||
|
||||
|
||||
public int getOrderNum(Integer StoreId);
|
||||
|
||||
|
||||
|
@ -5,12 +5,16 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fuint.api.fuyou.entity.Const;
|
||||
import com.fuint.api.fuyou.entity.MerchantConfig;
|
||||
import com.fuint.api.fuyou.service.FyPayService;
|
||||
import com.fuint.api.fuyou.service.MerchantConfigService;
|
||||
import com.fuint.business.order.entity.AllOrderInfo;
|
||||
import com.fuint.business.order.mapper.AllOrderInfoMapper;
|
||||
import com.fuint.business.order.service.AllOrderInfoService;
|
||||
import com.fuint.business.order.service.OilOrderService;
|
||||
import com.fuint.business.order.vo.AllOrderInfoVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -21,6 +25,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper,AllOrderInfo> implements AllOrderInfoService {
|
||||
|
||||
@Autowired
|
||||
@ -91,4 +96,40 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper,AllO
|
||||
// 调用统计方法
|
||||
return baseMapper.selectCount(queryWrapper);
|
||||
}
|
||||
|
||||
@Resource
|
||||
private FyPayService fyPayService;
|
||||
|
||||
@Override
|
||||
public int refund(Map<String, String> map) {
|
||||
Map<String, String> refund = null;
|
||||
try {
|
||||
|
||||
// 根据订单号查询订单
|
||||
AllOrderInfo allOrderInfo = selectAllOrderInfoByOrderNo(map.get("orderNo"));
|
||||
map.put("orderNo",allOrderInfo.getOrderNo());
|
||||
map.put("payType",allOrderInfo.getPayType());
|
||||
map.put("allAmount",allOrderInfo.getPayMoney().toString());
|
||||
|
||||
|
||||
MerchantConfig merchantConfig = merchantConfigService.selectMeChByIdIsUse(allOrderInfo.getStoreId());
|
||||
// 机构号
|
||||
map.put("insCd", merchantConfig.getInsCd());
|
||||
// 商户号
|
||||
map.put("mchntCd", merchantConfig.getMchntCd());
|
||||
// 生成退款id
|
||||
// map.put("refundOrderNo", "ref_" + allOrderInfo.getOrderNo());
|
||||
map.put("refundOrderNo", allOrderInfo.getOrderNo());
|
||||
|
||||
|
||||
|
||||
|
||||
refund = fyPayService.refund(map);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("退款失败");
|
||||
}
|
||||
log.info("refund{}",refund);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -130,11 +130,21 @@ public class OilInventoryOrderController extends BaseController {
|
||||
return getSuccessResult(this.oilInventoryOrderService.audit(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 盘点废除
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("abolition")
|
||||
public ResponseObject abolition(Integer id) {
|
||||
return getSuccessResult(this.oilInventoryOrderService.abolition(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断入库
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("storage")
|
||||
public ResponseObject storage(Integer id) {
|
||||
return getSuccessResult(this.oilInventoryOrderService.storage(id));
|
||||
|
@ -86,7 +86,7 @@ public interface OilTankMapper {
|
||||
* @return 影响行数
|
||||
*/
|
||||
int update(OilTank oilTank);
|
||||
int addStoredQuantityByLock(@Param("tankId") Integer tankId,@Param("changeNum") Double changeNum);
|
||||
int addStoredQuantityByLock(@Param("tankId") Integer tankId,@Param("changeNum") Double changeNum,Double totalAmount,Double discountedPrice);
|
||||
|
||||
int subtractStoredQuantityByLock(@Param("tankId") Integer tankId,@Param("changeNum") Double changeNum);
|
||||
|
||||
|
@ -414,6 +414,12 @@
|
||||
<update id="addStoredQuantityByLock">
|
||||
update oil_tank set
|
||||
stored_quantity = stored_quantity+#{changeNum},
|
||||
<if test="totalAmount != null and totalAmount != ''">
|
||||
total_price = total_price + #{totalAmount},
|
||||
</if>
|
||||
<if test="discountedPrice != null and discountedPrice != ''">
|
||||
discounted_price = #{discountedPrice}
|
||||
</if>
|
||||
update_time = NOW()
|
||||
where id = #{tankId}
|
||||
</update>
|
||||
|
@ -229,11 +229,15 @@ public class OilInventoryOrderServiceImpl implements OilInventoryOrderService {
|
||||
String oilIntake = "盘点入库";
|
||||
int audit = iljStaffService.auditPrem(oilIntake);
|
||||
if (audit>0) {
|
||||
// 1.查询所有的数据
|
||||
// 查询所有的数据
|
||||
OilInventoryOrder oilInventoryOrder = new OilInventoryOrder();
|
||||
oilInventoryOrder.setInventoryId(id);
|
||||
List<OilInventoryOrderVO> allList = oilInventoryOrderDao.getAllList2(oilInventoryOrder);
|
||||
for (OilInventoryOrderVO oilInventoryOrderVO : allList) {
|
||||
|
||||
// 判断盘点的油品是否超过油罐的最大容量
|
||||
|
||||
|
||||
OilTank oilTank = new OilTank();
|
||||
oilTank.setId(oilInventoryOrderVO.getTankId());
|
||||
oilTank.setStoredQuantity(oilInventoryOrderVO.getInventoryVolume());
|
||||
@ -247,13 +251,7 @@ public class OilInventoryOrderServiceImpl implements OilInventoryOrderService {
|
||||
|
||||
|
||||
// 插入到库存跟踪
|
||||
OilTracking oilTracking = new OilTracking();
|
||||
oilTracking.setStoreId(nowAccountInfo.getStoreId());
|
||||
oilTracking.setCreateBy(nowAccountInfo.getStaffId().toString());
|
||||
oilTracking.setDocument(oilIntake);
|
||||
oilTracking.setQuantityChange(oilInventoryOrderVO.getInventoryVolume());
|
||||
oilTracking.setTankId(oilInventoryOrderVO.getTankId());
|
||||
oilTracking.setOrderNumber(oilInventoryOrderVO.getInventoryNumber());
|
||||
OilTracking oilTracking = getOilTracking(oilInventoryOrderVO, nowAccountInfo, oilIntake);
|
||||
oilTrackingMapper.insert(oilTracking);
|
||||
}
|
||||
|
||||
@ -268,6 +266,17 @@ public class OilInventoryOrderServiceImpl implements OilInventoryOrderService {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static OilTracking getOilTracking(OilInventoryOrderVO oilInventoryOrderVO, AccountInfo nowAccountInfo, String oilIntake) {
|
||||
OilTracking oilTracking = new OilTracking();
|
||||
oilTracking.setStoreId(nowAccountInfo.getStoreId());
|
||||
oilTracking.setCreateBy(nowAccountInfo.getStaffId().toString());
|
||||
oilTracking.setDocument(oilIntake);
|
||||
oilTracking.setQuantityChange(oilInventoryOrderVO.getInventoryVolume());
|
||||
oilTracking.setTankId(oilInventoryOrderVO.getTankId());
|
||||
oilTracking.setOrderNumber(oilInventoryOrderVO.getInventoryNumber());
|
||||
return oilTracking;
|
||||
}
|
||||
|
||||
// 修改审核人
|
||||
public boolean edit(Integer id){
|
||||
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
|
||||
|
@ -213,23 +213,21 @@ public class OilPurchaseOrderServiceImpl implements OilPurchaseOrderService {
|
||||
List<OilPurchaseOrderVO> allList = oilPurchaseOrderDao.getAllList(oilPurchase);
|
||||
for (OilPurchaseOrderVO oilPurchaseOrderVO : allList) {
|
||||
|
||||
|
||||
|
||||
oilTankService.addStoredQuantityByLock(oilPurchaseOrderVO.getTankId(),oilPurchaseOrderVO.getPurchaseVolume(),oilPurchaseOrderVO.getTotalAmount());
|
||||
|
||||
OilTank oilTank = new OilTank();
|
||||
oilTank.setId(oilPurchaseOrderVO.getTankId());
|
||||
oilTank.setStoredQuantity(oilPurchaseOrderVO.getPurchaseVolume());
|
||||
oilTank.setTotalPrice(oilPurchaseOrderVO.getTotalAmount());
|
||||
// oilTank.setDiscountedPrice(oilPurchaseOrderVO.getDiscountedPrice());
|
||||
|
||||
// 单价计算
|
||||
OilTank oilTankSum = oilTankMapper.queryById(oilPurchaseOrderVO.getTankId());
|
||||
BigDecimal totalSum= new BigDecimal(oilPurchaseOrderVO.getTotalAmount().toString()).add(new BigDecimal(oilTankSum.getTotalPrice().toString()));
|
||||
BigDecimal volSum= new BigDecimal(oilPurchaseOrderVO.getPurchaseVolume().toString()).add(new BigDecimal(oilTankSum.getStoredQuantity().toString()));
|
||||
BigDecimal disPrice = totalSum.divide(volSum, 2, RoundingMode.HALF_UP);
|
||||
oilTank.setDiscountedPrice(disPrice.doubleValue());
|
||||
oilTankMapper.accumulate(oilTank);
|
||||
//
|
||||
// OilTank oilTank = new OilTank();
|
||||
// oilTank.setId(oilPurchaseOrderVO.getTankId());
|
||||
// oilTank.setStoredQuantity(oilPurchaseOrderVO.getPurchaseVolume());
|
||||
// oilTank.setTotalPrice(oilPurchaseOrderVO.getTotalAmount());
|
||||
//// oilTank.setDiscountedPrice(oilPurchaseOrderVO.getDiscountedPrice());
|
||||
//
|
||||
// // 单价计算
|
||||
// OilTank oilTankSum = oilTankMapper.queryById(oilPurchaseOrderVO.getTankId());
|
||||
// BigDecimal totalSum= new BigDecimal(oilPurchaseOrderVO.getTotalAmount().toString()).add(new BigDecimal(oilTankSum.getTotalPrice().toString()));
|
||||
// BigDecimal volSum= new BigDecimal(oilPurchaseOrderVO.getPurchaseVolume().toString()).add(new BigDecimal(oilTankSum.getStoredQuantity().toString()));
|
||||
// BigDecimal disPrice = totalSum.divide(volSum, 2, RoundingMode.HALF_UP);
|
||||
// oilTank.setDiscountedPrice(disPrice.doubleValue());
|
||||
// oilTankMapper.accumulate(oilTank);
|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.fuint.business.petrolStationManagement.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fuint.business.petrolStationManagement.entity.OilTank;
|
||||
@ -129,11 +130,11 @@ public class OilTankServiceImpl implements OilTankService {
|
||||
public OilTank addStoredQuantityByLock(Integer tankId, Double changeNum, Double totalAmount) {
|
||||
// 根据油罐id加锁 同一时间只能
|
||||
String lockKey = "oilTank-"+tankId;
|
||||
Boolean isLock = redisLock.tryLock(lockKey,5000,5000, TimeUnit.MILLISECONDS);
|
||||
Boolean isLock = redisLock.tryLock(lockKey,500,5000, TimeUnit.MILLISECONDS);
|
||||
if (isLock) {
|
||||
// 判断存油数量是否足够
|
||||
OilTank oilTank = oilTankDao.queryById(tankId);
|
||||
// 计算总数
|
||||
// 计算总升数
|
||||
BigDecimal changeNumBigDecimal = new BigDecimal(changeNum.toString());
|
||||
BigDecimal storedQuantityBigDecimal = changeNumBigDecimal.subtract(new BigDecimal(oilTank.getStoredQuantity().toString()));
|
||||
|
||||
@ -141,8 +142,18 @@ public class OilTankServiceImpl implements OilTankService {
|
||||
redisLock.unlock(lockKey);
|
||||
throw new RuntimeException("“"+ oilTank.getTankName() +"”油罐中容量不足,无法进行增加!");
|
||||
}
|
||||
// todo 计算单价,和总价格
|
||||
this.oilTankDao.addStoredQuantityByLock(tankId, changeNum);
|
||||
|
||||
Double discountedPrice = null;
|
||||
if (ObjectUtil.isNotEmpty(totalAmount)) {
|
||||
// 计算总价格
|
||||
BigDecimal totalAmountBigDecimal = new BigDecimal(totalAmount.toString());
|
||||
BigDecimal totalPriceBigDecimal = totalAmountBigDecimal.subtract(new BigDecimal(oilTank.getTotalPrice().toString()));
|
||||
// 计算单价
|
||||
BigDecimal discountedPriceBigDecimal = totalPriceBigDecimal.divide(storedQuantityBigDecimal,2);
|
||||
discountedPrice = Double.valueOf(discountedPriceBigDecimal.toString());
|
||||
}
|
||||
|
||||
this.oilTankDao.addStoredQuantityByLock(tankId, changeNum, totalAmount, discountedPrice);
|
||||
redisLock.unlock(lockKey);
|
||||
}
|
||||
return this.queryById(tankId);
|
||||
|
10
fuintCashierWeb/src/api/cashier/refund.js
Normal file
10
fuintCashierWeb/src/api/cashier/refund.js
Normal file
@ -0,0 +1,10 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 退款
|
||||
export function refundApi(data) {
|
||||
return request({
|
||||
url: '/business/allOrderInfo/refund',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
@ -616,13 +616,13 @@ import {getUserInfoMobile, getUserVoMobile, getUserVoName} from "@/api/cashier/u
|
||||
})
|
||||
},
|
||||
// 重置
|
||||
reset() {
|
||||
async reset() {
|
||||
this.shoppingCart=[]
|
||||
this.markPurchasesAll = 0
|
||||
this.allPoints=0
|
||||
this.allAmout=0
|
||||
this.allMoneyRatio=0
|
||||
this.getGift();
|
||||
await this.getGift();
|
||||
|
||||
// this.paymentType = ''
|
||||
this.resetMember()
|
||||
@ -914,7 +914,7 @@ import {getUserInfoMobile, getUserVoMobile, getUserVoName} from "@/api/cashier/u
|
||||
this.openConfirm = false
|
||||
this.openRecharge = false
|
||||
|
||||
|
||||
this.reset()
|
||||
this.dialogVisiblej = false
|
||||
this.authCode = '';
|
||||
},
|
||||
|
@ -251,7 +251,7 @@
|
||||
</div>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogRefund = false">取 消</el-button>
|
||||
<el-button type="primary" @click="dialogRefund = false">确 定</el-button>
|
||||
<el-button type="primary" @click="refundConfirmed()">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
@ -264,6 +264,7 @@ import {oilOrderList, oilOrders} from "@/api/cashier/oilorder";
|
||||
import {getOilNameList} from "@/api/cashier/oilnumgun";
|
||||
import {getOrderGoods} from "@/api/cashier/goodsorder";
|
||||
import {exportExcelCashierApi} from "@/api/order/exportExcel";
|
||||
import {refundApi} from "@/api/cashier/refund";
|
||||
|
||||
export default {
|
||||
name: "order_Cashier",
|
||||
@ -360,6 +361,21 @@ import {exportExcelCashierApi} from "@/api/order/exportExcel";
|
||||
this.cashierOrder = response.data
|
||||
})
|
||||
},
|
||||
|
||||
refundConfirmed() {
|
||||
this.dialogRefund = false;
|
||||
// 退款确定
|
||||
// cashierOrder
|
||||
console.log("cashierOrder",this.cashierOrder)
|
||||
let map={
|
||||
orderNo: this.cashierOrder.orderNo,
|
||||
storeId: this.cashierOrder.storeId,
|
||||
type: "cashierOrder"
|
||||
}
|
||||
refundApi(map).then(res=>{
|
||||
|
||||
})
|
||||
},
|
||||
// 获取油号名称
|
||||
getName(oilNameList,id){
|
||||
let name = ""
|
||||
|
@ -215,7 +215,7 @@
|
||||
</div>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogRefund = false">取 消</el-button>
|
||||
<el-button type="primary" @click="dialogRefund = false">确 定</el-button>
|
||||
<el-button type="primary" @click="refundConfirmed()">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
@ -225,6 +225,7 @@
|
||||
import {cardValueRecordInfo, listCardValueRecord, orderStatisticsApi} from "@/api/cashier/cardvaluerecord";
|
||||
import {getDicts} from "@/api/dict/data";
|
||||
import {queryStaffs} from "@/api/cashier/staff";
|
||||
import {refundApi} from "@/api/cashier/refund";
|
||||
|
||||
export default {
|
||||
name: "order_Cashier",
|
||||
@ -296,6 +297,21 @@ export default {
|
||||
this.oilOrder = response.data
|
||||
})
|
||||
},
|
||||
|
||||
refundConfirmed() {
|
||||
this.dialogRefund = false;
|
||||
// 退款确定
|
||||
// cashierOrder
|
||||
console.log("oilOrder",this.oilOrder)
|
||||
let map={
|
||||
orderNo: this.oilOrder.paymentNo,
|
||||
storeId: this.oilOrder.storeId,
|
||||
type: "oilOrder"
|
||||
}
|
||||
refundApi(map).then(res=>{
|
||||
|
||||
})
|
||||
},
|
||||
getType(list,val){
|
||||
let name = "";
|
||||
list.forEach(item => {
|
||||
|
Loading…
Reference in New Issue
Block a user