parent
3c7642ff56
commit
8b2f35f92c
@ -0,0 +1,113 @@ |
|||||||
|
package com.bweb.controller; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.hai.common.exception.ErrorCode; |
||||||
|
import com.hai.common.exception.ErrorHelp; |
||||||
|
import com.hai.common.exception.SysCode; |
||||||
|
import com.hai.common.security.UserCenter; |
||||||
|
import com.hai.common.utils.ResponseMsgUtil; |
||||||
|
import com.hai.entity.HighGasOilPrice; |
||||||
|
import com.hai.entity.HighMerchantStore; |
||||||
|
import com.hai.entity.HighTyAgentPrice; |
||||||
|
import com.hai.model.ResponseData; |
||||||
|
import com.hai.service.HighGasOilPriceService; |
||||||
|
import com.hai.service.HighMerchantStoreService; |
||||||
|
import com.hai.service.HighTyAgentPriceService; |
||||||
|
import io.swagger.annotations.Api; |
||||||
|
import io.swagger.annotations.ApiOperation; |
||||||
|
import org.apache.commons.lang3.StringUtils; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
import org.springframework.stereotype.Controller; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
@Controller |
||||||
|
@RequestMapping(value = "/tyAgentPrice") |
||||||
|
@Api(value = "订单接口") |
||||||
|
public class HighTyAgentPriceController { |
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(HighTyAgentPriceController.class); |
||||||
|
|
||||||
|
@Resource |
||||||
|
private HighTyAgentPriceService tyAgentPriceService; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private HighMerchantStoreService merchantStoreService; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private HighGasOilPriceService gasOilPriceService; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private UserCenter userCenter; |
||||||
|
|
||||||
|
@RequestMapping(value = "/editPrice", method = RequestMethod.POST) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "编辑价格") |
||||||
|
public ResponseData editPrice(@RequestBody JSONObject body) { |
||||||
|
try { |
||||||
|
|
||||||
|
if (body.getLong("tyAgentOilStationId") == null |
||||||
|
|| StringUtils.isBlank(body.getString("oilNoName")) |
||||||
|
|| StringUtils.isBlank(body.getString("oilNo")) |
||||||
|
|| body.getBigDecimal("priceRate") == null) { |
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); |
||||||
|
} |
||||||
|
|
||||||
|
// 查询油站
|
||||||
|
HighTyAgentPrice agentOilStation = tyAgentPriceService.getDetail(body.getLong("tyAgentOilStationId"), body.getString("oilNo")); |
||||||
|
if (agentOilStation == null) { |
||||||
|
agentOilStation = new HighTyAgentPrice(); |
||||||
|
agentOilStation.setTyAgentOilStationId(body.getLong("tyAgentOilStationId")); |
||||||
|
agentOilStation.setOilNoName(body.getString("oilNoName")); |
||||||
|
agentOilStation.setOilNo(body.getString("oilNo")); |
||||||
|
agentOilStation.setPriceRate(body.getBigDecimal("priceRate")); |
||||||
|
} else { |
||||||
|
agentOilStation.setPriceRate(body.getBigDecimal("priceRate")); |
||||||
|
} |
||||||
|
|
||||||
|
tyAgentPriceService.editTyAgentPrice(agentOilStation); |
||||||
|
|
||||||
|
return ResponseMsgUtil.success("操作成功"); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.error("HighTyAgentPriceController --> editPrice() error!", e); |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@RequestMapping(value = "/getOilStationPrice", method = RequestMethod.GET) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "油站价格") |
||||||
|
public ResponseData getOilStationPrice(@RequestParam(name = "oilStationId", required = true) Long oilStationId) { |
||||||
|
try { |
||||||
|
|
||||||
|
List<HighGasOilPrice> oilPriceList = gasOilPriceService.getGasOilPriceByStore(oilStationId); |
||||||
|
|
||||||
|
List<Map<String, Object>> oilPriceMapList = new ArrayList<>(); |
||||||
|
Map<String, Object> oilPriceMap; |
||||||
|
|
||||||
|
for (HighGasOilPrice price : oilPriceList) { |
||||||
|
oilPriceMap = new HashMap<>(); |
||||||
|
oilPriceMap.put("oilStationId", oilStationId); |
||||||
|
oilPriceMap.put("oilNo", price.getOilNo()); |
||||||
|
oilPriceMap.put("oilNoName", price.getOilNoName()); |
||||||
|
|
||||||
|
oilPriceMapList.add(oilPriceMap); |
||||||
|
HighTyAgentPrice tyAgentPrice = tyAgentPriceService.getDetail(oilStationId, price.getOilNo().toString()); |
||||||
|
} |
||||||
|
|
||||||
|
return ResponseMsgUtil.success(oilPriceList); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.error("HighTyAgentPriceController --> getOilStationPrice() error!", e); |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
package com.hai.service; |
||||||
|
|
||||||
|
import com.hai.entity.HighTyAgentPrice; |
||||||
|
|
||||||
|
/** |
||||||
|
* 加油价格 |
||||||
|
* @author hurui |
||||||
|
*/ |
||||||
|
public interface HighTyAgentPriceService { |
||||||
|
|
||||||
|
/** |
||||||
|
* 编辑价格 |
||||||
|
* @param tyAgentPrice |
||||||
|
*/ |
||||||
|
void editTyAgentPrice(HighTyAgentPrice tyAgentPrice); |
||||||
|
|
||||||
|
/** |
||||||
|
* 根据代理油站id 查询详情 |
||||||
|
* @param tyAgentOilStationId |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
HighTyAgentPrice getDetail(Long tyAgentOilStationId, String oilNo); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,45 @@ |
|||||||
|
package com.hai.service.impl; |
||||||
|
|
||||||
|
import com.hai.dao.HighTyAgentPriceMapper; |
||||||
|
import com.hai.entity.HighTyAgentPrice; |
||||||
|
import com.hai.entity.HighTyAgentPriceExample; |
||||||
|
import com.hai.service.HighTyAgentPriceService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@Service("highTyAgentPriceService") |
||||||
|
public class HighTyAgentPriceServiceImpl implements HighTyAgentPriceService { |
||||||
|
|
||||||
|
@Resource |
||||||
|
private HighTyAgentPriceMapper tyAgentPriceMapper; |
||||||
|
|
||||||
|
@Override |
||||||
|
public void editTyAgentPrice(HighTyAgentPrice tyAgentPrice) { |
||||||
|
if (tyAgentPrice.getId() == null) { |
||||||
|
tyAgentPrice.setCreateTime(new Date()); |
||||||
|
tyAgentPrice.setUpdateTime(new Date()); |
||||||
|
tyAgentPrice.setStatus(1); |
||||||
|
tyAgentPriceMapper.insert(tyAgentPrice); |
||||||
|
} else { |
||||||
|
tyAgentPrice.setUpdateTime(new Date()); |
||||||
|
tyAgentPriceMapper.updateByPrimaryKey(tyAgentPrice); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public HighTyAgentPrice getDetail(Long tyAgentOilStationId, String oilNo) { |
||||||
|
HighTyAgentPriceExample example = new HighTyAgentPriceExample(); |
||||||
|
example.createCriteria() |
||||||
|
.andStatusEqualTo(1) |
||||||
|
.andTyAgentOilStationIdEqualTo(tyAgentOilStationId) |
||||||
|
.andOilNoEqualTo(oilNo); |
||||||
|
List<HighTyAgentPrice> list = tyAgentPriceMapper.selectByExample(example); |
||||||
|
if (list.size() > 0) { |
||||||
|
return list.get(0); |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue