parent
e31ee1efef
commit
eaf7871b10
@ -0,0 +1,284 @@ |
||||
package com.bweb.controller; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.bweb.config.SysConst; |
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
import com.hfkj.common.QRCodeGenerator; |
||||
import com.hfkj.common.exception.ErrorCode; |
||||
import com.hfkj.common.exception.ErrorHelp; |
||||
import com.hfkj.common.exception.SysCode; |
||||
import com.hfkj.common.security.AESEncodeUtil; |
||||
import com.hfkj.common.security.SessionObject; |
||||
import com.hfkj.common.security.UserCenter; |
||||
import com.hfkj.common.utils.DateUtil; |
||||
import com.hfkj.common.utils.IDGenerator; |
||||
import com.hfkj.common.utils.ResponseMsgUtil; |
||||
import com.hfkj.config.CommonSysConst; |
||||
import com.hfkj.entity.BsGasStaff; |
||||
import com.hfkj.entity.BsMerchant; |
||||
import com.hfkj.model.ResponseData; |
||||
import com.hfkj.model.SecUserSessionObject; |
||||
import com.hfkj.service.BsMerchantService; |
||||
import com.hfkj.service.CommonService; |
||||
import com.hfkj.service.gas.BsGasStaffService; |
||||
import com.hfkj.sysenum.SecUserObjectTypeEnum; |
||||
import com.hfkj.sysenum.gas.GasStaffStatus; |
||||
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.net.URLEncoder; |
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
@Controller |
||||
@RequestMapping(value = "/gasStaff") |
||||
@Api(value = "加油站员工管理") |
||||
public class BsGasStaffController { |
||||
|
||||
private static Logger log = LoggerFactory.getLogger(BsGasStaffController.class); |
||||
|
||||
@Resource |
||||
private BsGasStaffService gasStaffService; |
||||
@Resource |
||||
private BsMerchantService merchantService; |
||||
@Resource |
||||
private CommonService commonService; |
||||
@Resource |
||||
private UserCenter userCenter; |
||||
|
||||
@RequestMapping(value="/addGasStaff",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "增加员工") |
||||
public ResponseData addStaff(@RequestBody JSONObject body) { |
||||
try { |
||||
SecUserSessionObject userInfoModel = userCenter.getSessionModel(SecUserSessionObject.class); |
||||
if (userInfoModel == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_LOGIN_NOT, ""); |
||||
} |
||||
if (!userInfoModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type2.getCode())) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.ROLE_NOT_PERMISSIONS, ""); |
||||
} |
||||
if (StringUtils.isBlank(body.getString("name")) |
||||
|| StringUtils.isBlank(body.getString("telephone")) |
||||
|| StringUtils.isBlank(body.getString("positionType"))) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
BsGasStaff gasStaff = new BsGasStaff(); |
||||
gasStaff.setMerId(userInfoModel.getAccount().getObjectId()); |
||||
gasStaff.setAvatar(body.getString("avatar")); |
||||
gasStaff.setName(body.getString("name")); |
||||
gasStaff.setTelephone(body.getString("telephone")); |
||||
gasStaff.setPositionType(body.getInteger("positionType")); |
||||
gasStaff.setPositionName(commonService.getDictionaryCodeName("GAS_STAFF_POSITION_TYPE", body.getString("positionType"))); |
||||
gasStaffService.addStaff(gasStaff); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighGasStaffController -> addStaff() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/updateGasStaff",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "修改员工") |
||||
public ResponseData updateGasStaff(@RequestBody JSONObject body) { |
||||
try { |
||||
if (body.getLong("id") == null |
||||
|| StringUtils.isBlank(body.getString("name")) |
||||
|| StringUtils.isBlank(body.getString("telephone")) |
||||
|| StringUtils.isBlank(body.getString("positionType")) |
||||
) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
// 查询员工信息
|
||||
BsGasStaff gasStaff = gasStaffService.getStaffDetailById(body.getLong("id")); |
||||
if (gasStaff == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到员工信息"); |
||||
} |
||||
gasStaff.setAvatar(body.getString("avatar")); |
||||
gasStaff.setName(body.getString("name")); |
||||
gasStaff.setTelephone(body.getString("telephone")); |
||||
gasStaff.setPositionType(body.getInteger("positionType")); |
||||
gasStaff.setPositionName(commonService.getDictionaryCodeName("GAS_STAFF_POSITION_TYPE", body.getString("positionType"))); |
||||
gasStaffService.updateStaff(gasStaff); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighGasStaffController -> updateGasStaff() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/queryQrCode",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询二维码") |
||||
public ResponseData queryQrCode(@RequestBody JSONObject body) { |
||||
try { |
||||
if (body.getLong("gasStaffId") == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
// 查询员工信息
|
||||
BsGasStaff gasStaff = gasStaffService.getStaffDetailById(body.getLong("gasStaffId")); |
||||
if (gasStaff == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到员工信息"); |
||||
} |
||||
|
||||
if (StringUtils.isBlank(gasStaff.getQrCodeImgUrl())) { |
||||
// 查询加油站
|
||||
BsMerchant merchantStore = merchantService.getMerchant(gasStaff.getMerId()); |
||||
if (merchantStore == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到加油站信息"); |
||||
} |
||||
// 员工ID签名
|
||||
String signId = AESEncodeUtil.aesEncrypt(gasStaff.getId().toString()); |
||||
|
||||
// 生成二维码
|
||||
String param = "/hsgH5?accountId=0000021"; |
||||
String qrCodeImgUrl = DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(1) +".jpg"; |
||||
QRCodeGenerator.generateQRCodeImage(param, 350, 350, SysConst.getSysConfig().getFileUrl()+"/gasStaff/"+qrCodeImgUrl); |
||||
|
||||
gasStaff.setQrCodeImgUrl(qrCodeImgUrl); |
||||
gasStaffService.updateStaff(gasStaff); |
||||
} |
||||
|
||||
return ResponseMsgUtil.success(gasStaff.getQrCodeImgUrl()); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighGasStaffController -> queryQrCode() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/disabled",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "禁用员工") |
||||
public ResponseData disabled(@RequestBody JSONObject body) { |
||||
try { |
||||
if (body.getLong("staffId") == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
// 查询油站员工
|
||||
BsGasStaff gasStaff = gasStaffService.getStaffDetailById(body.getLong("staffId")); |
||||
if (gasStaff == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到员工"); |
||||
} |
||||
gasStaff.setStatus(GasStaffStatus.status2.getStatus()); |
||||
gasStaffService.editData(gasStaff); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighGasStaffController -> disabled() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/recover",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "恢复正常") |
||||
public ResponseData recover(@RequestBody JSONObject body) { |
||||
try { |
||||
if (body.getLong("staffId") == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
// 查询油站员工
|
||||
BsGasStaff gasStaff = gasStaffService.getStaffDetailById(body.getLong("staffId")); |
||||
if (gasStaff == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到员工"); |
||||
} |
||||
gasStaff.setStatus(GasStaffStatus.status1.getStatus()); |
||||
gasStaffService.editData(gasStaff); |
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighGasStaffController -> delStaff() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/delStaff",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "删除员工") |
||||
public ResponseData delStaff(@RequestBody JSONObject body) { |
||||
try { |
||||
|
||||
if (body.getLong("staffId") == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
gasStaffService.delStaff(body.getLong("staffId")); |
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighGasStaffController -> delStaff() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/getStaffDetail",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询员工详情") |
||||
public ResponseData getStaffDetail(@RequestParam(name = "staffId", required = true) Long staffId) { |
||||
try { |
||||
|
||||
return ResponseMsgUtil.success(gasStaffService.getStaffDetailById(staffId)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighGasStaffController -> getStaffDetail() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
|
||||
@RequestMapping(value="/getStaffList",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询员工列表") |
||||
public ResponseData getStaffList(@RequestParam(name = "merchantStoreId", required = false) Long merchantStoreId, |
||||
@RequestParam(name = "name", required = false) String name, |
||||
@RequestParam(name = "telephone", required = false) String telephone, |
||||
@RequestParam(name = "positionType", required = false) Integer positionType, |
||||
@RequestParam(name = "status", required = false) Integer status, |
||||
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(name = "pageSize", required = true) Integer pageSize) { |
||||
try { |
||||
SecUserSessionObject userInfoModel = userCenter.getSessionModel(SecUserSessionObject.class); |
||||
if (userInfoModel == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_LOGIN_NOT, ""); |
||||
} |
||||
Map<String,Object> param = new HashMap<>(); |
||||
if (userInfoModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type1.getCode())) { |
||||
param.put("merchantStoreId", merchantStoreId); |
||||
} else if (userInfoModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type2.getCode())) { |
||||
param.put("merchantStoreId", userInfoModel.getAccount().getObjectId()); |
||||
} else { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.ROLE_NOT_PERMISSIONS, ""); |
||||
} |
||||
param.put("name", name); |
||||
param.put("telephone", telephone); |
||||
param.put("positionType", positionType); |
||||
param.put("status", status); |
||||
|
||||
PageHelper.startPage(pageNum,pageSize); |
||||
return ResponseMsgUtil.success(new PageInfo<>(gasStaffService.getStaffList(param))); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighGasStaffController -> getStaffList() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,79 @@ |
||||
package com.cweb.controller; |
||||
|
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
import com.hfkj.common.utils.ResponseMsgUtil; |
||||
import com.hfkj.model.ResponseData; |
||||
import com.hfkj.service.gas.BsGasService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
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.math.BigDecimal; |
||||
|
||||
@Controller |
||||
@RequestMapping(value = "/gas") |
||||
@Api(value = "油站管理") |
||||
public class BsGasController { |
||||
private static Logger log = LoggerFactory.getLogger(BsGasController.class); |
||||
|
||||
@Resource |
||||
private BsGasService gasService; |
||||
|
||||
@RequestMapping(value="/oilPriceCompute",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "油价计算") |
||||
public ResponseData oilPriceCompute(@RequestParam(name = "isTyAgent", required = false) Boolean isTyAgent, |
||||
@RequestParam(name = "refuelPrice", required = true) BigDecimal refuelPrice, |
||||
@RequestParam(name = "merNo", required = true) String merNo, |
||||
@RequestParam(name = "oilNo", required = true) String oilNo) { |
||||
try { |
||||
|
||||
return ResponseMsgUtil.success(gasService.refuelPriceCompute(refuelPrice,merNo,oilNo,isTyAgent)); |
||||
|
||||
} catch (Exception e) { |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/queryGasList",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询加油站列表") |
||||
public ResponseData queryGasList(@RequestParam(name = "isTyAgent", required = false) Boolean isTyAgent, |
||||
@RequestParam(name = "gasName", required = false) String gasName, |
||||
@RequestParam(name = "distanceLimit", required = false) Integer distanceLimit, |
||||
@RequestParam(name = "oilNo", required = true) String oilNo, |
||||
@RequestParam(name = "longitude", required = true) String longitude, |
||||
@RequestParam(name = "latitude", required = true) String latitude, |
||||
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(name = "pageSize", required = true) Integer pageSize |
||||
) { |
||||
try { |
||||
|
||||
PageHelper.startPage(pageNum,pageSize); |
||||
return ResponseMsgUtil.success(new PageInfo<>(gasService.getGasList(longitude,latitude,oilNo,gasName,distanceLimit))); |
||||
|
||||
} catch (Exception e) { |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/queryGasDetail",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询加油站详情") |
||||
public ResponseData queryGasDetail(@RequestParam(name = "merNo", required = true) String merNo, |
||||
@RequestParam(name = "isTyAgent", required = false) Boolean isTyAgent) { |
||||
try { |
||||
|
||||
return ResponseMsgUtil.success(gasService.getGasDetail(merNo)); |
||||
|
||||
} catch (Exception e) { |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,133 @@ |
||||
package com.hfkj.dao; |
||||
|
||||
import com.hfkj.entity.BsGasStaff; |
||||
import com.hfkj.entity.BsGasStaffExample; |
||||
import java.util.List; |
||||
import org.apache.ibatis.annotations.Delete; |
||||
import org.apache.ibatis.annotations.DeleteProvider; |
||||
import org.apache.ibatis.annotations.Insert; |
||||
import org.apache.ibatis.annotations.InsertProvider; |
||||
import org.apache.ibatis.annotations.Options; |
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.apache.ibatis.annotations.Result; |
||||
import org.apache.ibatis.annotations.Results; |
||||
import org.apache.ibatis.annotations.Select; |
||||
import org.apache.ibatis.annotations.SelectProvider; |
||||
import org.apache.ibatis.annotations.Update; |
||||
import org.apache.ibatis.annotations.UpdateProvider; |
||||
import org.apache.ibatis.type.JdbcType; |
||||
import org.springframework.stereotype.Repository; |
||||
|
||||
/** |
||||
* |
||||
* 代码由工具生成,请勿修改!!! |
||||
* 如果需要扩展请在其父类进行扩展 |
||||
* |
||||
**/ |
||||
@Repository |
||||
public interface BsGasStaffMapper extends BsGasStaffMapperExt { |
||||
@SelectProvider(type=BsGasStaffSqlProvider.class, method="countByExample") |
||||
long countByExample(BsGasStaffExample example); |
||||
|
||||
@DeleteProvider(type=BsGasStaffSqlProvider.class, method="deleteByExample") |
||||
int deleteByExample(BsGasStaffExample example); |
||||
|
||||
@Delete({ |
||||
"delete from bs_gas_staff", |
||||
"where id = #{id,jdbcType=BIGINT}" |
||||
}) |
||||
int deleteByPrimaryKey(Long id); |
||||
|
||||
@Insert({ |
||||
"insert into bs_gas_staff (mer_id, avatar, ", |
||||
"`name`, telephone, ", |
||||
"position_type, position_name, ", |
||||
"qr_code_img_url, `status`, ", |
||||
"create_time, update_time, ", |
||||
"ext_1, ext_2, ext_3)", |
||||
"values (#{merId,jdbcType=BIGINT}, #{avatar,jdbcType=VARCHAR}, ", |
||||
"#{name,jdbcType=VARCHAR}, #{telephone,jdbcType=VARCHAR}, ", |
||||
"#{positionType,jdbcType=INTEGER}, #{positionName,jdbcType=VARCHAR}, ", |
||||
"#{qrCodeImgUrl,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ", |
||||
"#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ", |
||||
"#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" |
||||
}) |
||||
@Options(useGeneratedKeys=true,keyProperty="id") |
||||
int insert(BsGasStaff record); |
||||
|
||||
@InsertProvider(type=BsGasStaffSqlProvider.class, method="insertSelective") |
||||
@Options(useGeneratedKeys=true,keyProperty="id") |
||||
int insertSelective(BsGasStaff record); |
||||
|
||||
@SelectProvider(type=BsGasStaffSqlProvider.class, method="selectByExample") |
||||
@Results({ |
||||
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), |
||||
@Result(column="mer_id", property="merId", jdbcType=JdbcType.BIGINT), |
||||
@Result(column="avatar", property="avatar", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="name", property="name", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="telephone", property="telephone", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="position_type", property="positionType", jdbcType=JdbcType.INTEGER), |
||||
@Result(column="position_name", property="positionName", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="qr_code_img_url", property="qrCodeImgUrl", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER), |
||||
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), |
||||
@Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), |
||||
@Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) |
||||
}) |
||||
List<BsGasStaff> selectByExample(BsGasStaffExample example); |
||||
|
||||
@Select({ |
||||
"select", |
||||
"id, mer_id, avatar, `name`, telephone, position_type, position_name, qr_code_img_url, ", |
||||
"`status`, create_time, update_time, ext_1, ext_2, ext_3", |
||||
"from bs_gas_staff", |
||||
"where id = #{id,jdbcType=BIGINT}" |
||||
}) |
||||
@Results({ |
||||
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), |
||||
@Result(column="mer_id", property="merId", jdbcType=JdbcType.BIGINT), |
||||
@Result(column="avatar", property="avatar", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="name", property="name", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="telephone", property="telephone", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="position_type", property="positionType", jdbcType=JdbcType.INTEGER), |
||||
@Result(column="position_name", property="positionName", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="qr_code_img_url", property="qrCodeImgUrl", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER), |
||||
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), |
||||
@Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), |
||||
@Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) |
||||
}) |
||||
BsGasStaff selectByPrimaryKey(Long id); |
||||
|
||||
@UpdateProvider(type=BsGasStaffSqlProvider.class, method="updateByExampleSelective") |
||||
int updateByExampleSelective(@Param("record") BsGasStaff record, @Param("example") BsGasStaffExample example); |
||||
|
||||
@UpdateProvider(type=BsGasStaffSqlProvider.class, method="updateByExample") |
||||
int updateByExample(@Param("record") BsGasStaff record, @Param("example") BsGasStaffExample example); |
||||
|
||||
@UpdateProvider(type=BsGasStaffSqlProvider.class, method="updateByPrimaryKeySelective") |
||||
int updateByPrimaryKeySelective(BsGasStaff record); |
||||
|
||||
@Update({ |
||||
"update bs_gas_staff", |
||||
"set mer_id = #{merId,jdbcType=BIGINT},", |
||||
"avatar = #{avatar,jdbcType=VARCHAR},", |
||||
"`name` = #{name,jdbcType=VARCHAR},", |
||||
"telephone = #{telephone,jdbcType=VARCHAR},", |
||||
"position_type = #{positionType,jdbcType=INTEGER},", |
||||
"position_name = #{positionName,jdbcType=VARCHAR},", |
||||
"qr_code_img_url = #{qrCodeImgUrl,jdbcType=VARCHAR},", |
||||
"`status` = #{status,jdbcType=INTEGER},", |
||||
"create_time = #{createTime,jdbcType=TIMESTAMP},", |
||||
"update_time = #{updateTime,jdbcType=TIMESTAMP},", |
||||
"ext_1 = #{ext1,jdbcType=VARCHAR},", |
||||
"ext_2 = #{ext2,jdbcType=VARCHAR},", |
||||
"ext_3 = #{ext3,jdbcType=VARCHAR}", |
||||
"where id = #{id,jdbcType=BIGINT}" |
||||
}) |
||||
int updateByPrimaryKey(BsGasStaff record); |
||||
} |
@ -0,0 +1,7 @@ |
||||
package com.hfkj.dao; |
||||
|
||||
/** |
||||
* mapper扩展类 |
||||
*/ |
||||
public interface BsGasStaffMapperExt { |
||||
} |
@ -0,0 +1,360 @@ |
||||
package com.hfkj.dao; |
||||
|
||||
import com.hfkj.entity.BsGasStaff; |
||||
import com.hfkj.entity.BsGasStaffExample.Criteria; |
||||
import com.hfkj.entity.BsGasStaffExample.Criterion; |
||||
import com.hfkj.entity.BsGasStaffExample; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import org.apache.ibatis.jdbc.SQL; |
||||
|
||||
public class BsGasStaffSqlProvider { |
||||
|
||||
public String countByExample(BsGasStaffExample example) { |
||||
SQL sql = new SQL(); |
||||
sql.SELECT("count(*)").FROM("bs_gas_staff"); |
||||
applyWhere(sql, example, false); |
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String deleteByExample(BsGasStaffExample example) { |
||||
SQL sql = new SQL(); |
||||
sql.DELETE_FROM("bs_gas_staff"); |
||||
applyWhere(sql, example, false); |
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String insertSelective(BsGasStaff record) { |
||||
SQL sql = new SQL(); |
||||
sql.INSERT_INTO("bs_gas_staff"); |
||||
|
||||
if (record.getMerId() != null) { |
||||
sql.VALUES("mer_id", "#{merId,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getAvatar() != null) { |
||||
sql.VALUES("avatar", "#{avatar,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getName() != null) { |
||||
sql.VALUES("`name`", "#{name,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getTelephone() != null) { |
||||
sql.VALUES("telephone", "#{telephone,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getPositionType() != null) { |
||||
sql.VALUES("position_type", "#{positionType,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getPositionName() != null) { |
||||
sql.VALUES("position_name", "#{positionName,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getQrCodeImgUrl() != null) { |
||||
sql.VALUES("qr_code_img_url", "#{qrCodeImgUrl,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getStatus() != null) { |
||||
sql.VALUES("`status`", "#{status,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getCreateTime() != null) { |
||||
sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}"); |
||||
} |
||||
|
||||
if (record.getUpdateTime() != null) { |
||||
sql.VALUES("update_time", "#{updateTime,jdbcType=TIMESTAMP}"); |
||||
} |
||||
|
||||
if (record.getExt1() != null) { |
||||
sql.VALUES("ext_1", "#{ext1,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getExt2() != null) { |
||||
sql.VALUES("ext_2", "#{ext2,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getExt3() != null) { |
||||
sql.VALUES("ext_3", "#{ext3,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String selectByExample(BsGasStaffExample example) { |
||||
SQL sql = new SQL(); |
||||
if (example != null && example.isDistinct()) { |
||||
sql.SELECT_DISTINCT("id"); |
||||
} else { |
||||
sql.SELECT("id"); |
||||
} |
||||
sql.SELECT("mer_id"); |
||||
sql.SELECT("avatar"); |
||||
sql.SELECT("`name`"); |
||||
sql.SELECT("telephone"); |
||||
sql.SELECT("position_type"); |
||||
sql.SELECT("position_name"); |
||||
sql.SELECT("qr_code_img_url"); |
||||
sql.SELECT("`status`"); |
||||
sql.SELECT("create_time"); |
||||
sql.SELECT("update_time"); |
||||
sql.SELECT("ext_1"); |
||||
sql.SELECT("ext_2"); |
||||
sql.SELECT("ext_3"); |
||||
sql.FROM("bs_gas_staff"); |
||||
applyWhere(sql, example, false); |
||||
|
||||
if (example != null && example.getOrderByClause() != null) { |
||||
sql.ORDER_BY(example.getOrderByClause()); |
||||
} |
||||
|
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String updateByExampleSelective(Map<String, Object> parameter) { |
||||
BsGasStaff record = (BsGasStaff) parameter.get("record"); |
||||
BsGasStaffExample example = (BsGasStaffExample) parameter.get("example"); |
||||
|
||||
SQL sql = new SQL(); |
||||
sql.UPDATE("bs_gas_staff"); |
||||
|
||||
if (record.getId() != null) { |
||||
sql.SET("id = #{record.id,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getMerId() != null) { |
||||
sql.SET("mer_id = #{record.merId,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getAvatar() != null) { |
||||
sql.SET("avatar = #{record.avatar,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getName() != null) { |
||||
sql.SET("`name` = #{record.name,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getTelephone() != null) { |
||||
sql.SET("telephone = #{record.telephone,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getPositionType() != null) { |
||||
sql.SET("position_type = #{record.positionType,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getPositionName() != null) { |
||||
sql.SET("position_name = #{record.positionName,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getQrCodeImgUrl() != null) { |
||||
sql.SET("qr_code_img_url = #{record.qrCodeImgUrl,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getStatus() != null) { |
||||
sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getCreateTime() != null) { |
||||
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); |
||||
} |
||||
|
||||
if (record.getUpdateTime() != null) { |
||||
sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}"); |
||||
} |
||||
|
||||
if (record.getExt1() != null) { |
||||
sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getExt2() != null) { |
||||
sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getExt3() != null) { |
||||
sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
applyWhere(sql, example, true); |
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String updateByExample(Map<String, Object> parameter) { |
||||
SQL sql = new SQL(); |
||||
sql.UPDATE("bs_gas_staff"); |
||||
|
||||
sql.SET("id = #{record.id,jdbcType=BIGINT}"); |
||||
sql.SET("mer_id = #{record.merId,jdbcType=BIGINT}"); |
||||
sql.SET("avatar = #{record.avatar,jdbcType=VARCHAR}"); |
||||
sql.SET("`name` = #{record.name,jdbcType=VARCHAR}"); |
||||
sql.SET("telephone = #{record.telephone,jdbcType=VARCHAR}"); |
||||
sql.SET("position_type = #{record.positionType,jdbcType=INTEGER}"); |
||||
sql.SET("position_name = #{record.positionName,jdbcType=VARCHAR}"); |
||||
sql.SET("qr_code_img_url = #{record.qrCodeImgUrl,jdbcType=VARCHAR}"); |
||||
sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); |
||||
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); |
||||
sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}"); |
||||
sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); |
||||
sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); |
||||
sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}"); |
||||
|
||||
BsGasStaffExample example = (BsGasStaffExample) parameter.get("example"); |
||||
applyWhere(sql, example, true); |
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String updateByPrimaryKeySelective(BsGasStaff record) { |
||||
SQL sql = new SQL(); |
||||
sql.UPDATE("bs_gas_staff"); |
||||
|
||||
if (record.getMerId() != null) { |
||||
sql.SET("mer_id = #{merId,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getAvatar() != null) { |
||||
sql.SET("avatar = #{avatar,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getName() != null) { |
||||
sql.SET("`name` = #{name,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getTelephone() != null) { |
||||
sql.SET("telephone = #{telephone,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getPositionType() != null) { |
||||
sql.SET("position_type = #{positionType,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getPositionName() != null) { |
||||
sql.SET("position_name = #{positionName,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getQrCodeImgUrl() != null) { |
||||
sql.SET("qr_code_img_url = #{qrCodeImgUrl,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getStatus() != null) { |
||||
sql.SET("`status` = #{status,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getCreateTime() != null) { |
||||
sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}"); |
||||
} |
||||
|
||||
if (record.getUpdateTime() != null) { |
||||
sql.SET("update_time = #{updateTime,jdbcType=TIMESTAMP}"); |
||||
} |
||||
|
||||
if (record.getExt1() != null) { |
||||
sql.SET("ext_1 = #{ext1,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getExt2() != null) { |
||||
sql.SET("ext_2 = #{ext2,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getExt3() != null) { |
||||
sql.SET("ext_3 = #{ext3,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
sql.WHERE("id = #{id,jdbcType=BIGINT}"); |
||||
|
||||
return sql.toString(); |
||||
} |
||||
|
||||
protected void applyWhere(SQL sql, BsGasStaffExample example, boolean includeExamplePhrase) { |
||||
if (example == null) { |
||||
return; |
||||
} |
||||
|
||||
String parmPhrase1; |
||||
String parmPhrase1_th; |
||||
String parmPhrase2; |
||||
String parmPhrase2_th; |
||||
String parmPhrase3; |
||||
String parmPhrase3_th; |
||||
if (includeExamplePhrase) { |
||||
parmPhrase1 = "%s #{example.oredCriteria[%d].allCriteria[%d].value}"; |
||||
parmPhrase1_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}"; |
||||
parmPhrase2 = "%s #{example.oredCriteria[%d].allCriteria[%d].value} and #{example.oredCriteria[%d].criteria[%d].secondValue}"; |
||||
parmPhrase2_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{example.oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}"; |
||||
parmPhrase3 = "#{example.oredCriteria[%d].allCriteria[%d].value[%d]}"; |
||||
parmPhrase3_th = "#{example.oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}"; |
||||
} else { |
||||
parmPhrase1 = "%s #{oredCriteria[%d].allCriteria[%d].value}"; |
||||
parmPhrase1_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}"; |
||||
parmPhrase2 = "%s #{oredCriteria[%d].allCriteria[%d].value} and #{oredCriteria[%d].criteria[%d].secondValue}"; |
||||
parmPhrase2_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}"; |
||||
parmPhrase3 = "#{oredCriteria[%d].allCriteria[%d].value[%d]}"; |
||||
parmPhrase3_th = "#{oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}"; |
||||
} |
||||
|
||||
StringBuilder sb = new StringBuilder(); |
||||
List<Criteria> oredCriteria = example.getOredCriteria(); |
||||
boolean firstCriteria = true; |
||||
for (int i = 0; i < oredCriteria.size(); i++) { |
||||
Criteria criteria = oredCriteria.get(i); |
||||
if (criteria.isValid()) { |
||||
if (firstCriteria) { |
||||
firstCriteria = false; |
||||
} else { |
||||
sb.append(" or "); |
||||
} |
||||
|
||||
sb.append('('); |
||||
List<Criterion> criterions = criteria.getAllCriteria(); |
||||
boolean firstCriterion = true; |
||||
for (int j = 0; j < criterions.size(); j++) { |
||||
Criterion criterion = criterions.get(j); |
||||
if (firstCriterion) { |
||||
firstCriterion = false; |
||||
} else { |
||||
sb.append(" and "); |
||||
} |
||||
|
||||
if (criterion.isNoValue()) { |
||||
sb.append(criterion.getCondition()); |
||||
} else if (criterion.isSingleValue()) { |
||||
if (criterion.getTypeHandler() == null) { |
||||
sb.append(String.format(parmPhrase1, criterion.getCondition(), i, j)); |
||||
} else { |
||||
sb.append(String.format(parmPhrase1_th, criterion.getCondition(), i, j,criterion.getTypeHandler())); |
||||
} |
||||
} else if (criterion.isBetweenValue()) { |
||||
if (criterion.getTypeHandler() == null) { |
||||
sb.append(String.format(parmPhrase2, criterion.getCondition(), i, j, i, j)); |
||||
} else { |
||||
sb.append(String.format(parmPhrase2_th, criterion.getCondition(), i, j, criterion.getTypeHandler(), i, j, criterion.getTypeHandler())); |
||||
} |
||||
} else if (criterion.isListValue()) { |
||||
sb.append(criterion.getCondition()); |
||||
sb.append(" ("); |
||||
List<?> listItems = (List<?>) criterion.getValue(); |
||||
boolean comma = false; |
||||
for (int k = 0; k < listItems.size(); k++) { |
||||
if (comma) { |
||||
sb.append(", "); |
||||
} else { |
||||
comma = true; |
||||
} |
||||
if (criterion.getTypeHandler() == null) { |
||||
sb.append(String.format(parmPhrase3, i, j, k)); |
||||
} else { |
||||
sb.append(String.format(parmPhrase3_th, i, j, k, criterion.getTypeHandler())); |
||||
} |
||||
} |
||||
sb.append(')'); |
||||
} |
||||
} |
||||
sb.append(')'); |
||||
} |
||||
} |
||||
|
||||
if (sb.length() > 0) { |
||||
sql.WHERE(sb.toString()); |
||||
} |
||||
} |
||||
} |
@ -1,7 +1,43 @@ |
||||
package com.hfkj.dao; |
||||
|
||||
import com.hfkj.model.GasListModel; |
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.apache.ibatis.annotations.Select; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* mapper扩展类 |
||||
*/ |
||||
public interface BsMerchantMapperExt { |
||||
} |
||||
|
||||
@Select("<script>" + |
||||
" select * from (SELECT" + |
||||
" b.mer_no merNo," + |
||||
" b.mer_name merName," + |
||||
" b.address," + |
||||
" b.longitude," + |
||||
" b.latitude," + |
||||
" round(ST_Distance_Sphere(" + |
||||
" point(#{longitude}, #{latitude})," + |
||||
" point(b.longitude, b.latitude)" + |
||||
" ) / 1000, 2) as distance," + |
||||
" a.oil_no oilNo," + |
||||
" a.price_official priceOfficial," + |
||||
" a.price_gun priceGun," + |
||||
" a.price_vip priceVip," + |
||||
" a.gas_station_drop gasStationDrop" + |
||||
" FROM" + |
||||
" bs_gas_oil_price a" + |
||||
" LEFT JOIN bs_merchant b on b.id = a.mer_id" + |
||||
" where a.oil_no = #{oilNo} and a.`status` = 1" + |
||||
" ORDER BY distance asc) a where 1 = 1" + |
||||
"<if test='gasName != null'> and a.merName like concat('%',#{gasName},'%') </if>" + |
||||
"<if test='distanceLimit != null'> <![CDATA[ and a.distance <= #{distanceLimit} ]]> </if>" + |
||||
"</script>") |
||||
List<GasListModel> queryGasList(@Param("longitude") String longitude, |
||||
@Param("latitude") String latitude, |
||||
@Param("oilNo") String oilNo, |
||||
@Param("gasName") String gasName, |
||||
@Param("distanceLimit") Integer distanceLimit); |
||||
} |
||||
|
@ -0,0 +1,264 @@ |
||||
package com.hfkj.entity; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* bs_gas_staff |
||||
* @author |
||||
*/ |
||||
/** |
||||
* |
||||
* 代码由工具生成 |
||||
* |
||||
**/ |
||||
public class BsGasStaff implements Serializable { |
||||
/** |
||||
* 主键 |
||||
*/ |
||||
private Long id; |
||||
|
||||
/** |
||||
* 商户id |
||||
*/ |
||||
private Long merId; |
||||
|
||||
/** |
||||
* 员工头像 |
||||
*/ |
||||
private String avatar; |
||||
|
||||
/** |
||||
* 员工名称 |
||||
*/ |
||||
private String name; |
||||
|
||||
/** |
||||
* 员工电话 |
||||
*/ |
||||
private String telephone; |
||||
|
||||
/** |
||||
* 职位类型 1:加油员 |
||||
*/ |
||||
private Integer positionType; |
||||
|
||||
/** |
||||
* 职位类型名称 |
||||
*/ |
||||
private String positionName; |
||||
|
||||
/** |
||||
* 二维码图片地址 |
||||
*/ |
||||
private String qrCodeImgUrl; |
||||
|
||||
/** |
||||
* 状态 0:删除 1:正常 2:禁用 |
||||
*/ |
||||
private Integer status; |
||||
|
||||
/** |
||||
* 创建时间 |
||||
*/ |
||||
private Date createTime; |
||||
|
||||
/** |
||||
* 修改时间 |
||||
*/ |
||||
private Date updateTime; |
||||
|
||||
private String ext1; |
||||
|
||||
private String ext2; |
||||
|
||||
private String ext3; |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
public Long getId() { |
||||
return id; |
||||
} |
||||
|
||||
public void setId(Long id) { |
||||
this.id = id; |
||||
} |
||||
|
||||
public Long getMerId() { |
||||
return merId; |
||||
} |
||||
|
||||
public void setMerId(Long merId) { |
||||
this.merId = merId; |
||||
} |
||||
|
||||
public String getAvatar() { |
||||
return avatar; |
||||
} |
||||
|
||||
public void setAvatar(String avatar) { |
||||
this.avatar = avatar; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
public String getTelephone() { |
||||
return telephone; |
||||
} |
||||
|
||||
public void setTelephone(String telephone) { |
||||
this.telephone = telephone; |
||||
} |
||||
|
||||
public Integer getPositionType() { |
||||
return positionType; |
||||
} |
||||
|
||||
public void setPositionType(Integer positionType) { |
||||
this.positionType = positionType; |
||||
} |
||||
|
||||
public String getPositionName() { |
||||
return positionName; |
||||
} |
||||
|
||||
public void setPositionName(String positionName) { |
||||
this.positionName = positionName; |
||||
} |
||||
|
||||
public String getQrCodeImgUrl() { |
||||
return qrCodeImgUrl; |
||||
} |
||||
|
||||
public void setQrCodeImgUrl(String qrCodeImgUrl) { |
||||
this.qrCodeImgUrl = qrCodeImgUrl; |
||||
} |
||||
|
||||
public Integer getStatus() { |
||||
return status; |
||||
} |
||||
|
||||
public void setStatus(Integer status) { |
||||
this.status = status; |
||||
} |
||||
|
||||
public Date getCreateTime() { |
||||
return createTime; |
||||
} |
||||
|
||||
public void setCreateTime(Date createTime) { |
||||
this.createTime = createTime; |
||||
} |
||||
|
||||
public Date getUpdateTime() { |
||||
return updateTime; |
||||
} |
||||
|
||||
public void setUpdateTime(Date updateTime) { |
||||
this.updateTime = updateTime; |
||||
} |
||||
|
||||
public String getExt1() { |
||||
return ext1; |
||||
} |
||||
|
||||
public void setExt1(String ext1) { |
||||
this.ext1 = ext1; |
||||
} |
||||
|
||||
public String getExt2() { |
||||
return ext2; |
||||
} |
||||
|
||||
public void setExt2(String ext2) { |
||||
this.ext2 = ext2; |
||||
} |
||||
|
||||
public String getExt3() { |
||||
return ext3; |
||||
} |
||||
|
||||
public void setExt3(String ext3) { |
||||
this.ext3 = ext3; |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object that) { |
||||
if (this == that) { |
||||
return true; |
||||
} |
||||
if (that == null) { |
||||
return false; |
||||
} |
||||
if (getClass() != that.getClass()) { |
||||
return false; |
||||
} |
||||
BsGasStaff other = (BsGasStaff) that; |
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) |
||||
&& (this.getMerId() == null ? other.getMerId() == null : this.getMerId().equals(other.getMerId())) |
||||
&& (this.getAvatar() == null ? other.getAvatar() == null : this.getAvatar().equals(other.getAvatar())) |
||||
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName())) |
||||
&& (this.getTelephone() == null ? other.getTelephone() == null : this.getTelephone().equals(other.getTelephone())) |
||||
&& (this.getPositionType() == null ? other.getPositionType() == null : this.getPositionType().equals(other.getPositionType())) |
||||
&& (this.getPositionName() == null ? other.getPositionName() == null : this.getPositionName().equals(other.getPositionName())) |
||||
&& (this.getQrCodeImgUrl() == null ? other.getQrCodeImgUrl() == null : this.getQrCodeImgUrl().equals(other.getQrCodeImgUrl())) |
||||
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) |
||||
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) |
||||
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())) |
||||
&& (this.getExt1() == null ? other.getExt1() == null : this.getExt1().equals(other.getExt1())) |
||||
&& (this.getExt2() == null ? other.getExt2() == null : this.getExt2().equals(other.getExt2())) |
||||
&& (this.getExt3() == null ? other.getExt3() == null : this.getExt3().equals(other.getExt3())); |
||||
} |
||||
|
||||
@Override |
||||
public int hashCode() { |
||||
final int prime = 31; |
||||
int result = 1; |
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); |
||||
result = prime * result + ((getMerId() == null) ? 0 : getMerId().hashCode()); |
||||
result = prime * result + ((getAvatar() == null) ? 0 : getAvatar().hashCode()); |
||||
result = prime * result + ((getName() == null) ? 0 : getName().hashCode()); |
||||
result = prime * result + ((getTelephone() == null) ? 0 : getTelephone().hashCode()); |
||||
result = prime * result + ((getPositionType() == null) ? 0 : getPositionType().hashCode()); |
||||
result = prime * result + ((getPositionName() == null) ? 0 : getPositionName().hashCode()); |
||||
result = prime * result + ((getQrCodeImgUrl() == null) ? 0 : getQrCodeImgUrl().hashCode()); |
||||
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); |
||||
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); |
||||
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); |
||||
result = prime * result + ((getExt1() == null) ? 0 : getExt1().hashCode()); |
||||
result = prime * result + ((getExt2() == null) ? 0 : getExt2().hashCode()); |
||||
result = prime * result + ((getExt3() == null) ? 0 : getExt3().hashCode()); |
||||
return result; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
StringBuilder sb = new StringBuilder(); |
||||
sb.append(getClass().getSimpleName()); |
||||
sb.append(" ["); |
||||
sb.append("Hash = ").append(hashCode()); |
||||
sb.append(", id=").append(id); |
||||
sb.append(", merId=").append(merId); |
||||
sb.append(", avatar=").append(avatar); |
||||
sb.append(", name=").append(name); |
||||
sb.append(", telephone=").append(telephone); |
||||
sb.append(", positionType=").append(positionType); |
||||
sb.append(", positionName=").append(positionName); |
||||
sb.append(", qrCodeImgUrl=").append(qrCodeImgUrl); |
||||
sb.append(", status=").append(status); |
||||
sb.append(", createTime=").append(createTime); |
||||
sb.append(", updateTime=").append(updateTime); |
||||
sb.append(", ext1=").append(ext1); |
||||
sb.append(", ext2=").append(ext2); |
||||
sb.append(", ext3=").append(ext3); |
||||
sb.append(", serialVersionUID=").append(serialVersionUID); |
||||
sb.append("]"); |
||||
return sb.toString(); |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,59 @@ |
||||
package com.hfkj.model; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.math.BigDecimal; |
||||
|
||||
/** |
||||
* 油站列表模型 |
||||
* @className: GasListModel |
||||
* @author: HuRui |
||||
* @date: 2024/6/4 |
||||
**/ |
||||
@Data |
||||
public class GasListModel { |
||||
/** |
||||
* 商户号 |
||||
*/ |
||||
private String merNo; |
||||
/** |
||||
* 商户名称 |
||||
*/ |
||||
private String merName; |
||||
/** |
||||
* 商户地址 |
||||
*/ |
||||
private String address; |
||||
/** |
||||
* 商户经度 |
||||
*/ |
||||
private String longitude; |
||||
/** |
||||
* 商户纬度 |
||||
*/ |
||||
private String latitude; |
||||
/** |
||||
* 距离 |
||||
*/ |
||||
private String distance; |
||||
/** |
||||
* 油品 |
||||
*/ |
||||
private String oilNo; |
||||
/** |
||||
* 国标价 |
||||
*/ |
||||
private BigDecimal priceOfficial; |
||||
/** |
||||
* 枪价 |
||||
*/ |
||||
private BigDecimal priceGun; |
||||
/** |
||||
* VIP价 |
||||
*/ |
||||
private BigDecimal priceVip; |
||||
/** |
||||
* 油站直降 |
||||
*/ |
||||
private BigDecimal gasStationDrop; |
||||
} |
@ -0,0 +1,22 @@ |
||||
package com.hfkj.model; |
||||
|
||||
import com.hfkj.entity.BsMerchant; |
||||
import lombok.Data; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 油站信息模型 |
||||
* @className: GasModel |
||||
* @author: HuRui |
||||
* @date: 2024/6/4 |
||||
**/ |
||||
@Data |
||||
public class GasModel extends BsMerchant { |
||||
|
||||
/** |
||||
* 油站油品 |
||||
*/ |
||||
private List<GasOilPriceModel> gasOilPrice; |
||||
|
||||
} |
@ -0,0 +1,23 @@ |
||||
package com.hfkj.model; |
||||
|
||||
import com.hfkj.entity.BsGasOilGunNo; |
||||
import com.hfkj.entity.BsGasOilPrice; |
||||
import lombok.Data; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 油站油品 |
||||
* @className: GasOilPriceModel |
||||
* @author: HuRui |
||||
* @date: 2024/6/4 |
||||
**/ |
||||
@Data |
||||
public class GasOilPriceModel extends BsGasOilPrice { |
||||
|
||||
/** |
||||
* 油站抢号 |
||||
*/ |
||||
public List<BsGasOilGunNo> gasOilGunNo; |
||||
|
||||
} |
@ -0,0 +1,84 @@ |
||||
package com.hfkj.model; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.math.BigDecimal; |
||||
|
||||
/** |
||||
* 团购支付价格模型 |
||||
* @author hurui |
||||
*/ |
||||
@Data |
||||
public class GasPayPriceModel { |
||||
|
||||
/** |
||||
* 加油金额 |
||||
*/ |
||||
private BigDecimal oilingPrice; |
||||
|
||||
/** |
||||
* 优惠价 |
||||
*/ |
||||
private BigDecimal priceVip; |
||||
|
||||
/** |
||||
* 枪价 |
||||
*/ |
||||
private BigDecimal priceGun; |
||||
|
||||
/** |
||||
* 成本价 |
||||
*/ |
||||
private BigDecimal priceCost; |
||||
|
||||
/** |
||||
* 国标价 |
||||
*/ |
||||
private BigDecimal priceOfficial; |
||||
|
||||
/** |
||||
* 平台价 |
||||
*/ |
||||
private BigDecimal pricePlatform; |
||||
|
||||
/** |
||||
* 油站直降 |
||||
*/ |
||||
private BigDecimal gasStationDrop; |
||||
|
||||
/** |
||||
* 平台补贴 |
||||
*/ |
||||
private BigDecimal preferentialMargin; |
||||
|
||||
/** |
||||
* 加油升数,计算方式:加油金额 / 国标价 |
||||
*/ |
||||
private BigDecimal oilLiters; |
||||
|
||||
/** |
||||
* 平台折扣,我们平台或者代理商设置的折扣 |
||||
*/ |
||||
private BigDecimal discount; |
||||
|
||||
/** |
||||
* 每升优惠 |
||||
*/ |
||||
private BigDecimal litersPreferences; |
||||
|
||||
/** |
||||
* 优惠价格 |
||||
*/ |
||||
private BigDecimal pricePreferences; |
||||
|
||||
/** |
||||
* 本次优惠 |
||||
*/ |
||||
private BigDecimal totalPreferences; |
||||
|
||||
/** |
||||
* 支付价格,计算方式:加油金额 - 本次优惠 |
||||
*/ |
||||
private BigDecimal payPrice; |
||||
|
||||
} |
@ -1,4 +1,4 @@ |
||||
package com.hfkj.service; |
||||
package com.hfkj.service.gas; |
||||
|
||||
import com.hfkj.entity.BsGasOilGunNo; |
||||
import com.hfkj.entity.BsGasOilPrice; |
@ -1,4 +1,4 @@ |
||||
package com.hfkj.service; |
||||
package com.hfkj.service.gas; |
||||
|
||||
import com.hfkj.entity.BsGasOilPriceOfficial; |
||||
|
@ -1,4 +1,4 @@ |
||||
package com.hfkj.service; |
||||
package com.hfkj.service.gas; |
||||
|
||||
import com.hfkj.entity.BsGasOilPriceTask; |
||||
|
@ -0,0 +1,54 @@ |
||||
package com.hfkj.service.gas; |
||||
|
||||
import com.hfkj.model.GasListModel; |
||||
import com.hfkj.model.GasModel; |
||||
import com.hfkj.model.GasPayPriceModel; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @className: BsGasService |
||||
* @author: HuRui |
||||
* @date: 2024/6/4 |
||||
**/ |
||||
public interface BsGasService { |
||||
|
||||
/** |
||||
* 更新缓存 |
||||
* @param data |
||||
*/ |
||||
void cache(GasModel data); |
||||
|
||||
/** |
||||
* 清除缓存 |
||||
* @param merNo |
||||
*/ |
||||
void clean(String merNo); |
||||
|
||||
/** |
||||
* 加油计算 |
||||
* @param refuelPrice |
||||
* @param merNo |
||||
* @param oilNo |
||||
* @param isTyAgent |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
GasPayPriceModel refuelPriceCompute(BigDecimal refuelPrice, String merNo, String oilNo, Boolean isTyAgent) ; |
||||
|
||||
/** |
||||
* 查询油站信息 |
||||
* @param merNo 商户号 |
||||
* @return |
||||
*/ |
||||
GasModel getGasDetail(String merNo); |
||||
|
||||
/** |
||||
* 查询油站列表 |
||||
* @param |
||||
* @return |
||||
*/ |
||||
List<GasListModel> getGasList(String longitude,String latitude,String oilNo,String gasName,Integer distanceLimit); |
||||
} |
@ -0,0 +1,51 @@ |
||||
package com.hfkj.service.gas; |
||||
|
||||
import com.hfkj.entity.BsGasStaff; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 加油站员工 |
||||
* @author hurui |
||||
*/ |
||||
public interface BsGasStaffService { |
||||
|
||||
/** |
||||
* 编辑员工数据 |
||||
* @param gasStaff |
||||
*/ |
||||
void editData(BsGasStaff gasStaff); |
||||
|
||||
/** |
||||
* 增加员工 |
||||
* @param gasStaff |
||||
*/ |
||||
void addStaff(BsGasStaff gasStaff) throws Exception; |
||||
|
||||
/** |
||||
* 修改员工 |
||||
* @param gasStaff |
||||
*/ |
||||
void updateStaff(BsGasStaff gasStaff); |
||||
|
||||
/** |
||||
* 删除员工 |
||||
* @param id |
||||
*/ |
||||
void delStaff(Long id); |
||||
|
||||
/** |
||||
* 根据id查询 |
||||
* @param id |
||||
* @return |
||||
*/ |
||||
BsGasStaff getStaffDetailById(Long id); |
||||
|
||||
/** |
||||
* 查询员工列表 |
||||
* @param param |
||||
* @return |
||||
*/ |
||||
List<BsGasStaff> getStaffList(Map<String, Object> param); |
||||
} |
@ -1,12 +1,12 @@ |
||||
package com.hfkj.service.impl; |
||||
package com.hfkj.service.gas.impl; |
||||
|
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hfkj.common.utils.HttpsUtils; |
||||
import com.hfkj.dao.BsGasOilPriceOfficialMapper; |
||||
import com.hfkj.entity.*; |
||||
import com.hfkj.service.BsGasOilPriceOfficialService; |
||||
import com.hfkj.service.BsGasOilPriceService; |
||||
import com.hfkj.service.gas.BsGasOilPriceOfficialService; |
||||
import com.hfkj.service.gas.BsGasOilPriceService; |
||||
import com.hfkj.service.CommonService; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.apache.commons.lang3.StringUtils; |
@ -0,0 +1,180 @@ |
||||
package com.hfkj.service.gas.impl; |
||||
|
||||
import com.hfkj.common.exception.ErrorCode; |
||||
import com.hfkj.common.exception.ErrorHelp; |
||||
import com.hfkj.common.exception.SysCode; |
||||
import com.hfkj.common.utils.RedisUtil; |
||||
import com.hfkj.dao.BsMerchantMapper; |
||||
import com.hfkj.entity.BsGasOilPrice; |
||||
import com.hfkj.entity.BsMerchant; |
||||
import com.hfkj.model.GasListModel; |
||||
import com.hfkj.model.GasModel; |
||||
import com.hfkj.model.GasOilPriceModel; |
||||
import com.hfkj.model.GasPayPriceModel; |
||||
import com.hfkj.service.gas.BsGasOilGunNoService; |
||||
import com.hfkj.service.gas.BsGasOilPriceService; |
||||
import com.hfkj.service.gas.BsGasService; |
||||
import com.hfkj.service.BsMerchantService; |
||||
import org.springframework.beans.BeanUtils; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.math.BigDecimal; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @className: BsGasServiceImpl |
||||
* @author: HuRui |
||||
* @date: 2024/6/4 |
||||
**/ |
||||
@Service("gasService") |
||||
public class BsGasServiceImpl implements BsGasService { |
||||
@Resource |
||||
private BsMerchantMapper merchantMapper; |
||||
@Resource |
||||
private BsMerchantService merchantService; |
||||
@Resource |
||||
private BsGasOilPriceService gasOilPriceService; |
||||
@Resource |
||||
private BsGasOilGunNoService gasOilGunNoService; |
||||
@Resource |
||||
private RedisUtil redisUtil; |
||||
private final static String CACHE_GAS_KEY = "GAS:"; |
||||
|
||||
@Override |
||||
public void cache(GasModel data) { |
||||
redisUtil.set(CACHE_GAS_KEY + data.getMerNo(), data); |
||||
} |
||||
|
||||
@Override |
||||
public void clean(String merNo) { |
||||
redisUtil.del(CACHE_GAS_KEY+merNo); |
||||
} |
||||
|
||||
@Override |
||||
public GasPayPriceModel refuelPriceCompute(BigDecimal refuelPrice, String merNo, String oilNo, Boolean isTyAgent) { |
||||
// 查询油站信息
|
||||
BsMerchant merchant = merchantService.getMerchant(merNo); |
||||
if (merchant == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到油站"); |
||||
} |
||||
|
||||
// 优惠比例
|
||||
BigDecimal discount = new BigDecimal("100"); |
||||
|
||||
if (isTyAgent != null && isTyAgent.equals(true)) { |
||||
|
||||
} |
||||
|
||||
discount = discount.divide(new BigDecimal("100")); |
||||
|
||||
// 查询油站价格
|
||||
BsGasOilPrice gasOilPrice = gasOilPriceService.getGasOilPrice(merchant.getId(), oilNo); |
||||
if (gasOilPrice == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到油站价格"); |
||||
} |
||||
// 国标价
|
||||
BigDecimal priceOfficial = gasOilPrice.getPriceOfficial(); |
||||
// 油站价
|
||||
BigDecimal priceGun = gasOilPrice.getPriceGun(); |
||||
// 油站直降
|
||||
BigDecimal gasStationDrop = gasOilPrice.getGasStationDrop(); |
||||
// 油站优惠价
|
||||
BigDecimal priceVip = gasOilPrice.getPriceVip(); |
||||
|
||||
GasPayPriceModel payPriceModel = new GasPayPriceModel(); |
||||
|
||||
// 嗨森逛平台价 油枪价 * 折扣
|
||||
BigDecimal pricePlatform = priceGun.multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP); |
||||
|
||||
// 加油金额
|
||||
payPriceModel.setOilingPrice(refuelPrice); |
||||
|
||||
// 油站枪价
|
||||
payPriceModel.setPriceGun(priceGun); |
||||
|
||||
// 油站优惠价
|
||||
payPriceModel.setPriceVip(priceVip); |
||||
|
||||
// 油站国标价
|
||||
payPriceModel.setPriceOfficial(priceOfficial); |
||||
|
||||
// 油站直降
|
||||
payPriceModel.setGasStationDrop(gasStationDrop); |
||||
|
||||
// 平台补贴
|
||||
payPriceModel.setPreferentialMargin(gasOilPrice.getPreferentialMargin()); |
||||
|
||||
// 平台价
|
||||
payPriceModel.setPricePlatform(pricePlatform); |
||||
|
||||
// 加油升数,计算方式:加油金额 / 枪价
|
||||
payPriceModel.setOilLiters(refuelPrice.divide(priceGun, 2, BigDecimal.ROUND_HALF_DOWN)); |
||||
|
||||
// 平台折扣,我们平台或者代理商设置的折扣
|
||||
payPriceModel.setDiscount(discount.compareTo(new BigDecimal("1.00")) == 0 ? new BigDecimal("1.00") : discount); |
||||
|
||||
// 加油补贴, 计算方式:加油站枪价 - 加油站VIP价
|
||||
// payPriceModel.setOilSubsidy(priceGun.subtract(priceVip));
|
||||
|
||||
// 折扣,1 -平台折扣
|
||||
BigDecimal decimal1 = new BigDecimal("1").subtract(discount); |
||||
|
||||
// 油枪价 - 平台补贴
|
||||
// BigDecimal price = payPriceModel.getPriceGun().subtract(preferentialMargin);
|
||||
|
||||
// 优惠价格 油站VIP价 * 系统折扣
|
||||
payPriceModel.setPricePreferences(priceVip.multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP)); |
||||
|
||||
// 每升优惠 油站价 - 优惠价格
|
||||
payPriceModel.setLitersPreferences(payPriceModel.getPriceGun().subtract(payPriceModel.getPricePreferences())); |
||||
|
||||
// 本次优惠 加油升数 * 每升优惠
|
||||
payPriceModel.setTotalPreferences(payPriceModel.getOilLiters().multiply(payPriceModel.getLitersPreferences()).setScale(2, BigDecimal.ROUND_HALF_UP)); |
||||
|
||||
// 支付价格 加油金额 - 本次优惠
|
||||
payPriceModel.setPayPrice(refuelPrice.subtract(payPriceModel.getTotalPreferences())); |
||||
|
||||
return payPriceModel; |
||||
} |
||||
|
||||
@Override |
||||
public GasModel getGasDetail(String merNo) { |
||||
// 缓存
|
||||
Object cacheObj = redisUtil.get(CACHE_GAS_KEY + merNo); |
||||
if (cacheObj != null) { |
||||
return (GasModel) cacheObj; |
||||
} |
||||
// 查询商户
|
||||
BsMerchant merchant = merchantService.getMerchant(merNo); |
||||
if (merchant == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到油站"); |
||||
} |
||||
GasModel gasModel = new GasModel(); |
||||
BeanUtils.copyProperties(merchant, gasModel); |
||||
|
||||
// 查询油品
|
||||
List<BsGasOilPrice> oilNoList = gasOilPriceService.getGasOilPriceList(merchant.getId()); |
||||
|
||||
List<GasOilPriceModel> oilNoModelList = new ArrayList<>(); |
||||
for (BsGasOilPrice gasOilPrice : oilNoList) { |
||||
GasOilPriceModel oilNo = new GasOilPriceModel(); |
||||
BeanUtils.copyProperties(gasOilPrice, oilNo); |
||||
// 查询抢号
|
||||
oilNo.setGasOilGunNo(gasOilGunNoService.getOilGunNoList(merNo)); |
||||
|
||||
oilNoModelList.add(oilNo); |
||||
} |
||||
gasModel.setGasOilPrice(oilNoModelList); |
||||
// 存入缓存
|
||||
cache(gasModel); |
||||
return gasModel; |
||||
} |
||||
|
||||
@Override |
||||
public List<GasListModel> getGasList(String longitude, String latitude, String oilNo, String gasName, Integer distanceLimit) { |
||||
return merchantMapper.queryGasList(longitude,latitude,oilNo,gasName,distanceLimit); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,150 @@ |
||||
package com.hfkj.service.gas.impl; |
||||
|
||||
import com.hfkj.common.exception.ErrorCode; |
||||
import com.hfkj.common.exception.ErrorHelp; |
||||
import com.hfkj.common.exception.SysCode; |
||||
import com.hfkj.common.utils.MD5Util; |
||||
import com.hfkj.dao.BsGasStaffMapper; |
||||
import com.hfkj.entity.BsGasStaff; |
||||
import com.hfkj.entity.BsGasStaffExample; |
||||
import com.hfkj.entity.SecUser; |
||||
import com.hfkj.service.gas.BsGasStaffService; |
||||
import com.hfkj.service.sec.SecUserService; |
||||
import com.hfkj.sysenum.SecUserObjectTypeEnum; |
||||
import com.hfkj.sysenum.gas.GasStaffStatus; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Propagation; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Service("gasStaffService") |
||||
public class BsGasStaffServiceImpl implements BsGasStaffService { |
||||
|
||||
@Resource |
||||
private BsGasStaffMapper gasStaffMapper; |
||||
|
||||
@Resource |
||||
private SecUserService userService; |
||||
|
||||
@Override |
||||
public void editData(BsGasStaff gasStaff) { |
||||
if (gasStaff.getId() == null) { |
||||
gasStaff.setCreateTime(new Date()); |
||||
gasStaff.setUpdateTime(new Date()); |
||||
gasStaff.setStatus(GasStaffStatus.status1.getStatus()); |
||||
gasStaffMapper.insert(gasStaff); |
||||
} else { |
||||
gasStaff.setUpdateTime(new Date()); |
||||
gasStaffMapper.updateByPrimaryKey(gasStaff); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
@Transactional(propagation= Propagation.REQUIRES_NEW) |
||||
public void addStaff(BsGasStaff gasStaff) throws Exception { |
||||
if (userService.getDetailByLoginName(gasStaff.getTelephone()) != null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "电话已存在,请更换"); |
||||
} |
||||
editData(gasStaff); |
||||
|
||||
SecUser secUser = new SecUser(); |
||||
secUser.setAvatar(gasStaff.getAvatar()); |
||||
secUser.setUserName(gasStaff.getName()); |
||||
secUser.setLoginName(gasStaff.getTelephone()); |
||||
secUser.setPassword(MD5Util.encode("123456".getBytes())); |
||||
secUser.setStatus(1); |
||||
secUser.setRoleId(4L); |
||||
secUser.setObjectType(SecUserObjectTypeEnum.type3.getCode()); |
||||
secUser.setObjectId(gasStaff.getId()); |
||||
secUser.setCreateTime(new Date()); |
||||
secUser.setUpdateTime(new Date()); |
||||
userService.editUser(secUser); |
||||
} |
||||
|
||||
@Override |
||||
@Transactional(propagation= Propagation.REQUIRES_NEW) |
||||
public void updateStaff(BsGasStaff gasStaff) { |
||||
BsGasStaff detail = getStaffDetailById(gasStaff.getId()); |
||||
if (detail == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
if (!detail.getTelephone().equals(gasStaff.getTelephone())) { |
||||
if (userService.getDetailByLoginName(gasStaff.getTelephone()) != null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "电话已存在,请更换"); |
||||
} |
||||
} |
||||
|
||||
editData(gasStaff); |
||||
|
||||
// 查询账户
|
||||
SecUser account = userService.getDetail(SecUserObjectTypeEnum.type3, gasStaff.getId()); |
||||
if (account == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到账户"); |
||||
} |
||||
account.setAvatar(gasStaff.getAvatar()); |
||||
account.setUserName(gasStaff.getName()); |
||||
account.setLoginName(gasStaff.getTelephone()); |
||||
account.setUpdateTime(new Date()); |
||||
userService.editUser(account); |
||||
} |
||||
|
||||
@Override |
||||
@Transactional(propagation= Propagation.REQUIRES_NEW) |
||||
public void delStaff(Long id) { |
||||
BsGasStaff gasStaff = getStaffDetailById(id); |
||||
if (gasStaff == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到员工"); |
||||
} |
||||
gasStaff.setStatus(GasStaffStatus.status0.getStatus()); |
||||
editData(gasStaff); |
||||
|
||||
// 查询账户
|
||||
SecUser account = userService.getDetail(SecUserObjectTypeEnum.type3, gasStaff.getId()); |
||||
if (account == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到账户"); |
||||
} |
||||
account.setStatus(0); |
||||
userService.editUser(account); |
||||
} |
||||
|
||||
@Override |
||||
public BsGasStaff getStaffDetailById(Long id) { |
||||
return gasStaffMapper.selectByPrimaryKey(id); |
||||
} |
||||
|
||||
@Override |
||||
public List<BsGasStaff> getStaffList(Map<String, Object> param) { |
||||
BsGasStaffExample example = new BsGasStaffExample(); |
||||
BsGasStaffExample.Criteria criteria = example.createCriteria().andStatusNotEqualTo(0); |
||||
|
||||
if (MapUtils.getLong(param, "merchantStoreId") != null) { |
||||
criteria.andMerchantStoreIdEqualTo(MapUtils.getLong(param, "merchantStoreId")); |
||||
} |
||||
|
||||
if (StringUtils.isNotBlank(MapUtils.getString(param, "name"))) { |
||||
criteria.andNameLike("%" + MapUtils.getString(param, "name") + "%"); |
||||
} |
||||
|
||||
if (StringUtils.isNotBlank(MapUtils.getString(param, "telephone"))) { |
||||
criteria.andTelephoneLike("%" + MapUtils.getString(param, "telephone") + "%"); |
||||
} |
||||
|
||||
if (MapUtils.getInteger(param, "positionType") != null) { |
||||
criteria.andPositionTypeEqualTo(MapUtils.getInteger(param, "positionType")); |
||||
} |
||||
|
||||
if (MapUtils.getInteger(param, "status") != null) { |
||||
criteria.andStatusEqualTo(MapUtils.getInteger(param, "status")); |
||||
} |
||||
|
||||
example.setOrderByClause("create_time desc"); |
||||
return gasStaffMapper.selectByExample(example); |
||||
} |
||||
} |
@ -1,4 +1,4 @@ |
||||
package com.hfkj.sysenum; |
||||
package com.hfkj.sysenum.gas; |
||||
|
||||
import java.util.Objects; |
||||
|
@ -1,4 +1,4 @@ |
||||
package com.hfkj.sysenum; |
||||
package com.hfkj.sysenum.gas; |
||||
|
||||
import java.util.Objects; |
||||
|
@ -0,0 +1,36 @@ |
||||
package com.hfkj.sysenum.gas; |
||||
|
||||
/** |
||||
* 加油站员工状态 |
||||
* @author hurui |
||||
*/ |
||||
public enum GasStaffStatus { |
||||
status0(0 , "删除"), |
||||
status1(1 , "正常"), |
||||
status2(2 , "禁用"), |
||||
; |
||||
|
||||
private Integer status; |
||||
private String name; |
||||
|
||||
GasStaffStatus(int status , String name) { |
||||
this.status = status; |
||||
this.name = name; |
||||
} |
||||
|
||||
public Integer getStatus() { |
||||
return status; |
||||
} |
||||
|
||||
public void setStatus(Integer status) { |
||||
this.status = status; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
} |
@ -1,4 +1,4 @@ |
||||
package com.hfkj.sysenum; |
||||
package com.hfkj.sysenum.gas; |
||||
|
||||
/** |
||||
* 加油站价格任务 |
@ -1,4 +1,4 @@ |
||||
package com.hfkj.sysenum; |
||||
package com.hfkj.sysenum.gas; |
||||
|
||||
/** |
||||
* 加油站价格任务 |
@ -1,4 +1,4 @@ |
||||
package com.hfkj.sysenum; |
||||
package com.hfkj.sysenum.gas; |
||||
|
||||
/** |
||||
* 加油站价格任务 |
Loading…
Reference in new issue