parent
14a6bbce12
commit
058d13bb98
@ -0,0 +1,181 @@ |
||||
package com.openapi.controller; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
import com.hfkj.common.exception.ErrorCode; |
||||
import com.hfkj.common.exception.ErrorHelp; |
||||
import com.hfkj.common.exception.SysCode; |
||||
import com.hfkj.common.pay.util.SignatureUtil; |
||||
import com.hfkj.common.security.AESEncodeUtil; |
||||
import com.hfkj.common.utils.ResponseMsgUtil; |
||||
import com.hfkj.entity.BsAgentApiAccount; |
||||
import com.hfkj.entity.BsAgentApiLogWithBLOBs; |
||||
import com.hfkj.entity.BsAgentApiParam; |
||||
import com.hfkj.entity.BsAgentMer; |
||||
import com.hfkj.model.ResponseData; |
||||
import com.hfkj.openapi.model.request.*; |
||||
import com.hfkj.openapi.model.response.ResponseOrderDetailModel; |
||||
import com.hfkj.openapi.model.response.ResponseOrderPushModel; |
||||
import com.hfkj.openapi.model.response.ResponseQueryGasInfoModel; |
||||
import com.hfkj.openapi.service.ApiGasOrderService; |
||||
import com.hfkj.openapi.service.ApiGasService; |
||||
import com.hfkj.service.agent.BsAgentApiAccountService; |
||||
import com.hfkj.service.agent.BsAgentApiLogService; |
||||
import com.hfkj.service.agent.BsAgentApiParamService; |
||||
import com.hfkj.service.agent.BsAgentMerService; |
||||
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.validation.annotation.Validated; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestMethod; |
||||
import org.springframework.web.bind.annotation.ResponseBody; |
||||
|
||||
import javax.annotation.Resource; |
||||
|
||||
@Controller |
||||
@RequestMapping(value = "/gasOrder") |
||||
@Api(value = "油站管理") |
||||
public class BsGasOrderController { |
||||
private static Logger log = LoggerFactory.getLogger(BsGasOrderController.class); |
||||
@Resource |
||||
private BsAgentApiParamService agentApiParamService; |
||||
@Resource |
||||
private BsAgentMerService agentMerService; |
||||
@Resource |
||||
private ApiGasOrderService apiGasOrderService; |
||||
@Resource |
||||
private BsAgentApiAccountService agentApiAccountService; |
||||
@Resource |
||||
private BsAgentApiLogService agentApiLogService; |
||||
|
||||
@RequestMapping(value="/push",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "推送订单") |
||||
public ResponseData push(@Validated @RequestBody RequestOrderPushModel body) { |
||||
log.info("========= Start 推送订单 Start ==========="); |
||||
log.info("请求参数:" + JSONObject.toJSONString(body)); |
||||
BsAgentApiLogWithBLOBs apiLog = new BsAgentApiLogWithBLOBs(); |
||||
try { |
||||
// 验证签名
|
||||
BsAgentApiParam apiParam = agentApiParamService.getParamByAppId(body.getAppId()); |
||||
if (!SignatureUtil.checkSign(body.getSign(), body, apiParam.getAppSecret())) { |
||||
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_SIGN_ERR, ""); |
||||
} |
||||
apiLog.setAppId(body.getAppId()); |
||||
apiLog.setRequestUrl("gasOrder/push"); |
||||
apiLog.setRequestParam(JSONObject.toJSONString(body)); |
||||
|
||||
// 查询账户
|
||||
BsAgentApiAccount account = agentApiAccountService.getAccount(apiParam.getAgentId()); |
||||
if (account == null) { |
||||
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_COMMON, "未知的交易账户"); |
||||
} |
||||
// 余额是否小于消费余额
|
||||
if (account.getAmount().compareTo(body.getRefuelingAmount()) == -1) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "账户余额不足"); |
||||
} |
||||
ResponseOrderPushModel response = apiGasOrderService.pushOrder(apiParam.getAgentId(), body); |
||||
|
||||
log.info("返回参数:" + JSONObject.toJSONString(response)); |
||||
apiLog.setResponseParam(JSONObject.toJSONString(response)); |
||||
|
||||
return ResponseMsgUtil.success(response); |
||||
|
||||
} catch (Exception e) { |
||||
log.info("出现异常:", e); |
||||
// 异常内容
|
||||
ResponseData exception = ResponseMsgUtil.exception(e); |
||||
apiLog.setErrorContent(JSONObject.toJSONString(exception)); |
||||
return exception; |
||||
} finally { |
||||
// 记录日志
|
||||
if (apiLog.getAppId() != null) { |
||||
agentApiLogService.edit(apiLog); |
||||
} |
||||
log.info("========= END 推送订单 END ==========="); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/queryOrderDetail",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询订单详情") |
||||
public ResponseData queryOrderDetail(@Validated @RequestBody RequestOrderDetailModel body) { |
||||
log.info("========= Start 查询订单详情 Start ==========="); |
||||
log.info("请求参数:" + JSONObject.toJSONString(body)); |
||||
BsAgentApiLogWithBLOBs apiLog = new BsAgentApiLogWithBLOBs(); |
||||
try { |
||||
// 验证签名
|
||||
BsAgentApiParam apiParam = agentApiParamService.getParamByAppId(body.getAppId()); |
||||
if (!SignatureUtil.checkSign(body.getSign(), body, apiParam.getAppSecret())) { |
||||
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_SIGN_ERR, ""); |
||||
} |
||||
apiLog.setAppId(body.getAppId()); |
||||
apiLog.setRequestUrl("gasOrder/queryOrderDetail"); |
||||
apiLog.setRequestParam(JSONObject.toJSONString(body)); |
||||
|
||||
ResponseOrderDetailModel response = apiGasOrderService.queryOrderDetail(body); |
||||
|
||||
log.info("返回参数:" + JSONObject.toJSONString(response)); |
||||
apiLog.setResponseParam(JSONObject.toJSONString(response)); |
||||
|
||||
return ResponseMsgUtil.success(response); |
||||
|
||||
} catch (Exception e) { |
||||
log.info("出现异常:", e); |
||||
// 异常内容
|
||||
ResponseData exception = ResponseMsgUtil.exception(e); |
||||
apiLog.setErrorContent(JSONObject.toJSONString(exception)); |
||||
return exception; |
||||
} finally { |
||||
// 记录日志
|
||||
if (apiLog.getAppId() != null) { |
||||
agentApiLogService.edit(apiLog); |
||||
} |
||||
log.info("========= END 查询订单详情 END ==========="); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/refund",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "退款申请") |
||||
public ResponseData refund(@Validated @RequestBody RequestOrderRefundModel body) { |
||||
log.info("========= Start 退款申请 Start ==========="); |
||||
log.info("请求参数:" + JSONObject.toJSONString(body)); |
||||
BsAgentApiLogWithBLOBs apiLog = new BsAgentApiLogWithBLOBs(); |
||||
try { |
||||
// 验证签名
|
||||
BsAgentApiParam apiParam = agentApiParamService.getParamByAppId(body.getAppId()); |
||||
if (!SignatureUtil.checkSign(body.getSign(), body, apiParam.getAppSecret())) { |
||||
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_SIGN_ERR, ""); |
||||
} |
||||
apiLog.setAppId(body.getAppId()); |
||||
apiLog.setRequestUrl("gasOrder/refund"); |
||||
apiLog.setRequestParam(JSONObject.toJSONString(body)); |
||||
|
||||
String response = apiGasOrderService.refundOrder(body); |
||||
|
||||
log.info("返回参数:" + response); |
||||
apiLog.setResponseParam(response); |
||||
return ResponseMsgUtil.success(response); |
||||
|
||||
} catch (Exception e) { |
||||
log.info("出现异常:", e); |
||||
// 异常内容
|
||||
ResponseData exception = ResponseMsgUtil.exception(e); |
||||
apiLog.setErrorContent(JSONObject.toJSONString(exception)); |
||||
return exception; |
||||
} finally { |
||||
// 记录日志
|
||||
if (apiLog.getAppId() != null) { |
||||
agentApiLogService.edit(apiLog); |
||||
} |
||||
log.info("========= END 退款申请 END ==========="); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,159 @@ |
||||
package com.hfkj.dao; |
||||
|
||||
import com.hfkj.entity.BsAgentApiAccountRecord; |
||||
import com.hfkj.entity.BsAgentApiAccountRecordExample; |
||||
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 BsAgentApiAccountRecordMapper extends BsAgentApiAccountRecordMapperExt { |
||||
@SelectProvider(type=BsAgentApiAccountRecordSqlProvider.class, method="countByExample") |
||||
long countByExample(BsAgentApiAccountRecordExample example); |
||||
|
||||
@DeleteProvider(type=BsAgentApiAccountRecordSqlProvider.class, method="deleteByExample") |
||||
int deleteByExample(BsAgentApiAccountRecordExample example); |
||||
|
||||
@Delete({ |
||||
"delete from bs_agent_api_account_record", |
||||
"where id = #{id,jdbcType=BIGINT}" |
||||
}) |
||||
int deleteByPrimaryKey(Long id); |
||||
|
||||
@Insert({ |
||||
"insert into bs_agent_api_account_record (agent_api_account_id, agent_id, ", |
||||
"`type`, transaction_amount, ", |
||||
"before_amount, after_amount, ", |
||||
"source_type, source_id, ", |
||||
"source_order_no, source_content, ", |
||||
"`status`, create_time, ", |
||||
"op_user_type, op_user_id, ", |
||||
"op_user_name, op_user_phone, ", |
||||
"ext_1, ext_2, ext_3)", |
||||
"values (#{agentApiAccountId,jdbcType=BIGINT}, #{agentId,jdbcType=BIGINT}, ", |
||||
"#{type,jdbcType=INTEGER}, #{transactionAmount,jdbcType=DECIMAL}, ", |
||||
"#{beforeAmount,jdbcType=DECIMAL}, #{afterAmount,jdbcType=DECIMAL}, ", |
||||
"#{sourceType,jdbcType=INTEGER}, #{sourceId,jdbcType=BIGINT}, ", |
||||
"#{sourceOrderNo,jdbcType=VARCHAR}, #{sourceContent,jdbcType=VARCHAR}, ", |
||||
"#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ", |
||||
"#{opUserType,jdbcType=INTEGER}, #{opUserId,jdbcType=BIGINT}, ", |
||||
"#{opUserName,jdbcType=VARCHAR}, #{opUserPhone,jdbcType=VARCHAR}, ", |
||||
"#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" |
||||
}) |
||||
@Options(useGeneratedKeys=true,keyProperty="id") |
||||
int insert(BsAgentApiAccountRecord record); |
||||
|
||||
@InsertProvider(type=BsAgentApiAccountRecordSqlProvider.class, method="insertSelective") |
||||
@Options(useGeneratedKeys=true,keyProperty="id") |
||||
int insertSelective(BsAgentApiAccountRecord record); |
||||
|
||||
@SelectProvider(type=BsAgentApiAccountRecordSqlProvider.class, method="selectByExample") |
||||
@Results({ |
||||
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), |
||||
@Result(column="agent_api_account_id", property="agentApiAccountId", jdbcType=JdbcType.BIGINT), |
||||
@Result(column="agent_id", property="agentId", jdbcType=JdbcType.BIGINT), |
||||
@Result(column="type", property="type", jdbcType=JdbcType.INTEGER), |
||||
@Result(column="transaction_amount", property="transactionAmount", jdbcType=JdbcType.DECIMAL), |
||||
@Result(column="before_amount", property="beforeAmount", jdbcType=JdbcType.DECIMAL), |
||||
@Result(column="after_amount", property="afterAmount", jdbcType=JdbcType.DECIMAL), |
||||
@Result(column="source_type", property="sourceType", jdbcType=JdbcType.INTEGER), |
||||
@Result(column="source_id", property="sourceId", jdbcType=JdbcType.BIGINT), |
||||
@Result(column="source_order_no", property="sourceOrderNo", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="source_content", property="sourceContent", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER), |
||||
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), |
||||
@Result(column="op_user_type", property="opUserType", jdbcType=JdbcType.INTEGER), |
||||
@Result(column="op_user_id", property="opUserId", jdbcType=JdbcType.BIGINT), |
||||
@Result(column="op_user_name", property="opUserName", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="op_user_phone", property="opUserPhone", jdbcType=JdbcType.VARCHAR), |
||||
@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<BsAgentApiAccountRecord> selectByExample(BsAgentApiAccountRecordExample example); |
||||
|
||||
@Select({ |
||||
"select", |
||||
"id, agent_api_account_id, agent_id, `type`, transaction_amount, before_amount, ", |
||||
"after_amount, source_type, source_id, source_order_no, source_content, `status`, ", |
||||
"create_time, op_user_type, op_user_id, op_user_name, op_user_phone, ext_1, ext_2, ", |
||||
"ext_3", |
||||
"from bs_agent_api_account_record", |
||||
"where id = #{id,jdbcType=BIGINT}" |
||||
}) |
||||
@Results({ |
||||
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), |
||||
@Result(column="agent_api_account_id", property="agentApiAccountId", jdbcType=JdbcType.BIGINT), |
||||
@Result(column="agent_id", property="agentId", jdbcType=JdbcType.BIGINT), |
||||
@Result(column="type", property="type", jdbcType=JdbcType.INTEGER), |
||||
@Result(column="transaction_amount", property="transactionAmount", jdbcType=JdbcType.DECIMAL), |
||||
@Result(column="before_amount", property="beforeAmount", jdbcType=JdbcType.DECIMAL), |
||||
@Result(column="after_amount", property="afterAmount", jdbcType=JdbcType.DECIMAL), |
||||
@Result(column="source_type", property="sourceType", jdbcType=JdbcType.INTEGER), |
||||
@Result(column="source_id", property="sourceId", jdbcType=JdbcType.BIGINT), |
||||
@Result(column="source_order_no", property="sourceOrderNo", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="source_content", property="sourceContent", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER), |
||||
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), |
||||
@Result(column="op_user_type", property="opUserType", jdbcType=JdbcType.INTEGER), |
||||
@Result(column="op_user_id", property="opUserId", jdbcType=JdbcType.BIGINT), |
||||
@Result(column="op_user_name", property="opUserName", jdbcType=JdbcType.VARCHAR), |
||||
@Result(column="op_user_phone", property="opUserPhone", jdbcType=JdbcType.VARCHAR), |
||||
@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) |
||||
}) |
||||
BsAgentApiAccountRecord selectByPrimaryKey(Long id); |
||||
|
||||
@UpdateProvider(type=BsAgentApiAccountRecordSqlProvider.class, method="updateByExampleSelective") |
||||
int updateByExampleSelective(@Param("record") BsAgentApiAccountRecord record, @Param("example") BsAgentApiAccountRecordExample example); |
||||
|
||||
@UpdateProvider(type=BsAgentApiAccountRecordSqlProvider.class, method="updateByExample") |
||||
int updateByExample(@Param("record") BsAgentApiAccountRecord record, @Param("example") BsAgentApiAccountRecordExample example); |
||||
|
||||
@UpdateProvider(type=BsAgentApiAccountRecordSqlProvider.class, method="updateByPrimaryKeySelective") |
||||
int updateByPrimaryKeySelective(BsAgentApiAccountRecord record); |
||||
|
||||
@Update({ |
||||
"update bs_agent_api_account_record", |
||||
"set agent_api_account_id = #{agentApiAccountId,jdbcType=BIGINT},", |
||||
"agent_id = #{agentId,jdbcType=BIGINT},", |
||||
"`type` = #{type,jdbcType=INTEGER},", |
||||
"transaction_amount = #{transactionAmount,jdbcType=DECIMAL},", |
||||
"before_amount = #{beforeAmount,jdbcType=DECIMAL},", |
||||
"after_amount = #{afterAmount,jdbcType=DECIMAL},", |
||||
"source_type = #{sourceType,jdbcType=INTEGER},", |
||||
"source_id = #{sourceId,jdbcType=BIGINT},", |
||||
"source_order_no = #{sourceOrderNo,jdbcType=VARCHAR},", |
||||
"source_content = #{sourceContent,jdbcType=VARCHAR},", |
||||
"`status` = #{status,jdbcType=INTEGER},", |
||||
"create_time = #{createTime,jdbcType=TIMESTAMP},", |
||||
"op_user_type = #{opUserType,jdbcType=INTEGER},", |
||||
"op_user_id = #{opUserId,jdbcType=BIGINT},", |
||||
"op_user_name = #{opUserName,jdbcType=VARCHAR},", |
||||
"op_user_phone = #{opUserPhone,jdbcType=VARCHAR},", |
||||
"ext_1 = #{ext1,jdbcType=VARCHAR},", |
||||
"ext_2 = #{ext2,jdbcType=VARCHAR},", |
||||
"ext_3 = #{ext3,jdbcType=VARCHAR}", |
||||
"where id = #{id,jdbcType=BIGINT}" |
||||
}) |
||||
int updateByPrimaryKey(BsAgentApiAccountRecord record); |
||||
} |
@ -0,0 +1,7 @@ |
||||
package com.hfkj.dao; |
||||
|
||||
/** |
||||
* mapper扩展类 |
||||
*/ |
||||
public interface BsAgentApiAccountRecordMapperExt { |
||||
} |
@ -0,0 +1,444 @@ |
||||
package com.hfkj.dao; |
||||
|
||||
import com.hfkj.entity.BsAgentApiAccountRecord; |
||||
import com.hfkj.entity.BsAgentApiAccountRecordExample.Criteria; |
||||
import com.hfkj.entity.BsAgentApiAccountRecordExample.Criterion; |
||||
import com.hfkj.entity.BsAgentApiAccountRecordExample; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import org.apache.ibatis.jdbc.SQL; |
||||
|
||||
public class BsAgentApiAccountRecordSqlProvider { |
||||
|
||||
public String countByExample(BsAgentApiAccountRecordExample example) { |
||||
SQL sql = new SQL(); |
||||
sql.SELECT("count(*)").FROM("bs_agent_api_account_record"); |
||||
applyWhere(sql, example, false); |
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String deleteByExample(BsAgentApiAccountRecordExample example) { |
||||
SQL sql = new SQL(); |
||||
sql.DELETE_FROM("bs_agent_api_account_record"); |
||||
applyWhere(sql, example, false); |
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String insertSelective(BsAgentApiAccountRecord record) { |
||||
SQL sql = new SQL(); |
||||
sql.INSERT_INTO("bs_agent_api_account_record"); |
||||
|
||||
if (record.getAgentApiAccountId() != null) { |
||||
sql.VALUES("agent_api_account_id", "#{agentApiAccountId,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getAgentId() != null) { |
||||
sql.VALUES("agent_id", "#{agentId,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getType() != null) { |
||||
sql.VALUES("`type`", "#{type,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getTransactionAmount() != null) { |
||||
sql.VALUES("transaction_amount", "#{transactionAmount,jdbcType=DECIMAL}"); |
||||
} |
||||
|
||||
if (record.getBeforeAmount() != null) { |
||||
sql.VALUES("before_amount", "#{beforeAmount,jdbcType=DECIMAL}"); |
||||
} |
||||
|
||||
if (record.getAfterAmount() != null) { |
||||
sql.VALUES("after_amount", "#{afterAmount,jdbcType=DECIMAL}"); |
||||
} |
||||
|
||||
if (record.getSourceType() != null) { |
||||
sql.VALUES("source_type", "#{sourceType,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getSourceId() != null) { |
||||
sql.VALUES("source_id", "#{sourceId,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getSourceOrderNo() != null) { |
||||
sql.VALUES("source_order_no", "#{sourceOrderNo,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getSourceContent() != null) { |
||||
sql.VALUES("source_content", "#{sourceContent,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.getOpUserType() != null) { |
||||
sql.VALUES("op_user_type", "#{opUserType,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getOpUserId() != null) { |
||||
sql.VALUES("op_user_id", "#{opUserId,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getOpUserName() != null) { |
||||
sql.VALUES("op_user_name", "#{opUserName,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getOpUserPhone() != null) { |
||||
sql.VALUES("op_user_phone", "#{opUserPhone,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
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(BsAgentApiAccountRecordExample example) { |
||||
SQL sql = new SQL(); |
||||
if (example != null && example.isDistinct()) { |
||||
sql.SELECT_DISTINCT("id"); |
||||
} else { |
||||
sql.SELECT("id"); |
||||
} |
||||
sql.SELECT("agent_api_account_id"); |
||||
sql.SELECT("agent_id"); |
||||
sql.SELECT("`type`"); |
||||
sql.SELECT("transaction_amount"); |
||||
sql.SELECT("before_amount"); |
||||
sql.SELECT("after_amount"); |
||||
sql.SELECT("source_type"); |
||||
sql.SELECT("source_id"); |
||||
sql.SELECT("source_order_no"); |
||||
sql.SELECT("source_content"); |
||||
sql.SELECT("`status`"); |
||||
sql.SELECT("create_time"); |
||||
sql.SELECT("op_user_type"); |
||||
sql.SELECT("op_user_id"); |
||||
sql.SELECT("op_user_name"); |
||||
sql.SELECT("op_user_phone"); |
||||
sql.SELECT("ext_1"); |
||||
sql.SELECT("ext_2"); |
||||
sql.SELECT("ext_3"); |
||||
sql.FROM("bs_agent_api_account_record"); |
||||
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) { |
||||
BsAgentApiAccountRecord record = (BsAgentApiAccountRecord) parameter.get("record"); |
||||
BsAgentApiAccountRecordExample example = (BsAgentApiAccountRecordExample) parameter.get("example"); |
||||
|
||||
SQL sql = new SQL(); |
||||
sql.UPDATE("bs_agent_api_account_record"); |
||||
|
||||
if (record.getId() != null) { |
||||
sql.SET("id = #{record.id,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getAgentApiAccountId() != null) { |
||||
sql.SET("agent_api_account_id = #{record.agentApiAccountId,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getAgentId() != null) { |
||||
sql.SET("agent_id = #{record.agentId,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getType() != null) { |
||||
sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getTransactionAmount() != null) { |
||||
sql.SET("transaction_amount = #{record.transactionAmount,jdbcType=DECIMAL}"); |
||||
} |
||||
|
||||
if (record.getBeforeAmount() != null) { |
||||
sql.SET("before_amount = #{record.beforeAmount,jdbcType=DECIMAL}"); |
||||
} |
||||
|
||||
if (record.getAfterAmount() != null) { |
||||
sql.SET("after_amount = #{record.afterAmount,jdbcType=DECIMAL}"); |
||||
} |
||||
|
||||
if (record.getSourceType() != null) { |
||||
sql.SET("source_type = #{record.sourceType,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getSourceId() != null) { |
||||
sql.SET("source_id = #{record.sourceId,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getSourceOrderNo() != null) { |
||||
sql.SET("source_order_no = #{record.sourceOrderNo,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getSourceContent() != null) { |
||||
sql.SET("source_content = #{record.sourceContent,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.getOpUserType() != null) { |
||||
sql.SET("op_user_type = #{record.opUserType,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getOpUserId() != null) { |
||||
sql.SET("op_user_id = #{record.opUserId,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getOpUserName() != null) { |
||||
sql.SET("op_user_name = #{record.opUserName,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getOpUserPhone() != null) { |
||||
sql.SET("op_user_phone = #{record.opUserPhone,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
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_agent_api_account_record"); |
||||
|
||||
sql.SET("id = #{record.id,jdbcType=BIGINT}"); |
||||
sql.SET("agent_api_account_id = #{record.agentApiAccountId,jdbcType=BIGINT}"); |
||||
sql.SET("agent_id = #{record.agentId,jdbcType=BIGINT}"); |
||||
sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); |
||||
sql.SET("transaction_amount = #{record.transactionAmount,jdbcType=DECIMAL}"); |
||||
sql.SET("before_amount = #{record.beforeAmount,jdbcType=DECIMAL}"); |
||||
sql.SET("after_amount = #{record.afterAmount,jdbcType=DECIMAL}"); |
||||
sql.SET("source_type = #{record.sourceType,jdbcType=INTEGER}"); |
||||
sql.SET("source_id = #{record.sourceId,jdbcType=BIGINT}"); |
||||
sql.SET("source_order_no = #{record.sourceOrderNo,jdbcType=VARCHAR}"); |
||||
sql.SET("source_content = #{record.sourceContent,jdbcType=VARCHAR}"); |
||||
sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); |
||||
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); |
||||
sql.SET("op_user_type = #{record.opUserType,jdbcType=INTEGER}"); |
||||
sql.SET("op_user_id = #{record.opUserId,jdbcType=BIGINT}"); |
||||
sql.SET("op_user_name = #{record.opUserName,jdbcType=VARCHAR}"); |
||||
sql.SET("op_user_phone = #{record.opUserPhone,jdbcType=VARCHAR}"); |
||||
sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); |
||||
sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); |
||||
sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}"); |
||||
|
||||
BsAgentApiAccountRecordExample example = (BsAgentApiAccountRecordExample) parameter.get("example"); |
||||
applyWhere(sql, example, true); |
||||
return sql.toString(); |
||||
} |
||||
|
||||
public String updateByPrimaryKeySelective(BsAgentApiAccountRecord record) { |
||||
SQL sql = new SQL(); |
||||
sql.UPDATE("bs_agent_api_account_record"); |
||||
|
||||
if (record.getAgentApiAccountId() != null) { |
||||
sql.SET("agent_api_account_id = #{agentApiAccountId,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getAgentId() != null) { |
||||
sql.SET("agent_id = #{agentId,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getType() != null) { |
||||
sql.SET("`type` = #{type,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getTransactionAmount() != null) { |
||||
sql.SET("transaction_amount = #{transactionAmount,jdbcType=DECIMAL}"); |
||||
} |
||||
|
||||
if (record.getBeforeAmount() != null) { |
||||
sql.SET("before_amount = #{beforeAmount,jdbcType=DECIMAL}"); |
||||
} |
||||
|
||||
if (record.getAfterAmount() != null) { |
||||
sql.SET("after_amount = #{afterAmount,jdbcType=DECIMAL}"); |
||||
} |
||||
|
||||
if (record.getSourceType() != null) { |
||||
sql.SET("source_type = #{sourceType,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getSourceId() != null) { |
||||
sql.SET("source_id = #{sourceId,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getSourceOrderNo() != null) { |
||||
sql.SET("source_order_no = #{sourceOrderNo,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getSourceContent() != null) { |
||||
sql.SET("source_content = #{sourceContent,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.getOpUserType() != null) { |
||||
sql.SET("op_user_type = #{opUserType,jdbcType=INTEGER}"); |
||||
} |
||||
|
||||
if (record.getOpUserId() != null) { |
||||
sql.SET("op_user_id = #{opUserId,jdbcType=BIGINT}"); |
||||
} |
||||
|
||||
if (record.getOpUserName() != null) { |
||||
sql.SET("op_user_name = #{opUserName,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
if (record.getOpUserPhone() != null) { |
||||
sql.SET("op_user_phone = #{opUserPhone,jdbcType=VARCHAR}"); |
||||
} |
||||
|
||||
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, BsAgentApiAccountRecordExample 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,23 @@ |
||||
package com.hfkj.dao; |
||||
|
||||
import com.hfkj.entity.BsAgentApiParam; |
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.apache.ibatis.annotations.Select; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* mapper扩展类 |
||||
*/ |
||||
public interface BsAgentApiParamMapperExt { |
||||
} |
||||
@Select("select " + |
||||
"id," + |
||||
"agent_id agentId," + |
||||
"app_id appId," + |
||||
"app_secret appSecret," + |
||||
"mer_info_notify merInfoNotify," + |
||||
"order_refund_notify orderRefundNotify" + |
||||
"from bs_agent_api_param " + |
||||
"where agent_id in (select agent_id from bs_agent_mer where mer_no = #{gasNo} and `status` = 1 GROUP BY agent_id)") |
||||
List<BsAgentApiParam> selectParamListByGasNo(@Param("gasNo") String gasNo); |
||||
} |
||||
|
@ -0,0 +1,358 @@ |
||||
package com.hfkj.entity; |
||||
|
||||
import java.io.Serializable; |
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* bs_agent_api_account_record |
||||
* @author |
||||
*/ |
||||
/** |
||||
* |
||||
* 代码由工具生成 |
||||
* |
||||
**/ |
||||
public class BsAgentApiAccountRecord implements Serializable { |
||||
private Long id; |
||||
|
||||
/** |
||||
* 代理商API账户id |
||||
*/ |
||||
private Long agentApiAccountId; |
||||
|
||||
/** |
||||
* 代理商id |
||||
*/ |
||||
private Long agentId; |
||||
|
||||
/** |
||||
* 类型 1:进账 2:出账 |
||||
*/ |
||||
private Integer type; |
||||
|
||||
/** |
||||
* 交易金额 |
||||
*/ |
||||
private BigDecimal transactionAmount; |
||||
|
||||
/** |
||||
* 变更前金额 |
||||
*/ |
||||
private BigDecimal beforeAmount; |
||||
|
||||
/** |
||||
* 变更后金额 |
||||
*/ |
||||
private BigDecimal afterAmount; |
||||
|
||||
/** |
||||
* 来源类型 1. 充值金额 2. 订单扣除 |
||||
*/ |
||||
private Integer sourceType; |
||||
|
||||
/** |
||||
* 来源id |
||||
*/ |
||||
private Long sourceId; |
||||
|
||||
/** |
||||
* 来源订单号 |
||||
*/ |
||||
private String sourceOrderNo; |
||||
|
||||
/** |
||||
* 来源内容 |
||||
*/ |
||||
private String sourceContent; |
||||
|
||||
/** |
||||
* 状态 0:删除 1:正常 |
||||
*/ |
||||
private Integer status; |
||||
|
||||
/** |
||||
* 创建时间 |
||||
*/ |
||||
private Date createTime; |
||||
|
||||
/** |
||||
* 操作人类型 1:管理员 2:客户 |
||||
*/ |
||||
private Integer opUserType; |
||||
|
||||
/** |
||||
* 操作人id |
||||
*/ |
||||
private Long opUserId; |
||||
|
||||
/** |
||||
* 操作人名称 |
||||
*/ |
||||
private String opUserName; |
||||
|
||||
/** |
||||
* 操作人电话 |
||||
*/ |
||||
private String opUserPhone; |
||||
|
||||
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 getAgentApiAccountId() { |
||||
return agentApiAccountId; |
||||
} |
||||
|
||||
public void setAgentApiAccountId(Long agentApiAccountId) { |
||||
this.agentApiAccountId = agentApiAccountId; |
||||
} |
||||
|
||||
public Long getAgentId() { |
||||
return agentId; |
||||
} |
||||
|
||||
public void setAgentId(Long agentId) { |
||||
this.agentId = agentId; |
||||
} |
||||
|
||||
public Integer getType() { |
||||
return type; |
||||
} |
||||
|
||||
public void setType(Integer type) { |
||||
this.type = type; |
||||
} |
||||
|
||||
public BigDecimal getTransactionAmount() { |
||||
return transactionAmount; |
||||
} |
||||
|
||||
public void setTransactionAmount(BigDecimal transactionAmount) { |
||||
this.transactionAmount = transactionAmount; |
||||
} |
||||
|
||||
public BigDecimal getBeforeAmount() { |
||||
return beforeAmount; |
||||
} |
||||
|
||||
public void setBeforeAmount(BigDecimal beforeAmount) { |
||||
this.beforeAmount = beforeAmount; |
||||
} |
||||
|
||||
public BigDecimal getAfterAmount() { |
||||
return afterAmount; |
||||
} |
||||
|
||||
public void setAfterAmount(BigDecimal afterAmount) { |
||||
this.afterAmount = afterAmount; |
||||
} |
||||
|
||||
public Integer getSourceType() { |
||||
return sourceType; |
||||
} |
||||
|
||||
public void setSourceType(Integer sourceType) { |
||||
this.sourceType = sourceType; |
||||
} |
||||
|
||||
public Long getSourceId() { |
||||
return sourceId; |
||||
} |
||||
|
||||
public void setSourceId(Long sourceId) { |
||||
this.sourceId = sourceId; |
||||
} |
||||
|
||||
public String getSourceOrderNo() { |
||||
return sourceOrderNo; |
||||
} |
||||
|
||||
public void setSourceOrderNo(String sourceOrderNo) { |
||||
this.sourceOrderNo = sourceOrderNo; |
||||
} |
||||
|
||||
public String getSourceContent() { |
||||
return sourceContent; |
||||
} |
||||
|
||||
public void setSourceContent(String sourceContent) { |
||||
this.sourceContent = sourceContent; |
||||
} |
||||
|
||||
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 Integer getOpUserType() { |
||||
return opUserType; |
||||
} |
||||
|
||||
public void setOpUserType(Integer opUserType) { |
||||
this.opUserType = opUserType; |
||||
} |
||||
|
||||
public Long getOpUserId() { |
||||
return opUserId; |
||||
} |
||||
|
||||
public void setOpUserId(Long opUserId) { |
||||
this.opUserId = opUserId; |
||||
} |
||||
|
||||
public String getOpUserName() { |
||||
return opUserName; |
||||
} |
||||
|
||||
public void setOpUserName(String opUserName) { |
||||
this.opUserName = opUserName; |
||||
} |
||||
|
||||
public String getOpUserPhone() { |
||||
return opUserPhone; |
||||
} |
||||
|
||||
public void setOpUserPhone(String opUserPhone) { |
||||
this.opUserPhone = opUserPhone; |
||||
} |
||||
|
||||
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; |
||||
} |
||||
BsAgentApiAccountRecord other = (BsAgentApiAccountRecord) that; |
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) |
||||
&& (this.getAgentApiAccountId() == null ? other.getAgentApiAccountId() == null : this.getAgentApiAccountId().equals(other.getAgentApiAccountId())) |
||||
&& (this.getAgentId() == null ? other.getAgentId() == null : this.getAgentId().equals(other.getAgentId())) |
||||
&& (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType())) |
||||
&& (this.getTransactionAmount() == null ? other.getTransactionAmount() == null : this.getTransactionAmount().equals(other.getTransactionAmount())) |
||||
&& (this.getBeforeAmount() == null ? other.getBeforeAmount() == null : this.getBeforeAmount().equals(other.getBeforeAmount())) |
||||
&& (this.getAfterAmount() == null ? other.getAfterAmount() == null : this.getAfterAmount().equals(other.getAfterAmount())) |
||||
&& (this.getSourceType() == null ? other.getSourceType() == null : this.getSourceType().equals(other.getSourceType())) |
||||
&& (this.getSourceId() == null ? other.getSourceId() == null : this.getSourceId().equals(other.getSourceId())) |
||||
&& (this.getSourceOrderNo() == null ? other.getSourceOrderNo() == null : this.getSourceOrderNo().equals(other.getSourceOrderNo())) |
||||
&& (this.getSourceContent() == null ? other.getSourceContent() == null : this.getSourceContent().equals(other.getSourceContent())) |
||||
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) |
||||
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) |
||||
&& (this.getOpUserType() == null ? other.getOpUserType() == null : this.getOpUserType().equals(other.getOpUserType())) |
||||
&& (this.getOpUserId() == null ? other.getOpUserId() == null : this.getOpUserId().equals(other.getOpUserId())) |
||||
&& (this.getOpUserName() == null ? other.getOpUserName() == null : this.getOpUserName().equals(other.getOpUserName())) |
||||
&& (this.getOpUserPhone() == null ? other.getOpUserPhone() == null : this.getOpUserPhone().equals(other.getOpUserPhone())) |
||||
&& (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 + ((getAgentApiAccountId() == null) ? 0 : getAgentApiAccountId().hashCode()); |
||||
result = prime * result + ((getAgentId() == null) ? 0 : getAgentId().hashCode()); |
||||
result = prime * result + ((getType() == null) ? 0 : getType().hashCode()); |
||||
result = prime * result + ((getTransactionAmount() == null) ? 0 : getTransactionAmount().hashCode()); |
||||
result = prime * result + ((getBeforeAmount() == null) ? 0 : getBeforeAmount().hashCode()); |
||||
result = prime * result + ((getAfterAmount() == null) ? 0 : getAfterAmount().hashCode()); |
||||
result = prime * result + ((getSourceType() == null) ? 0 : getSourceType().hashCode()); |
||||
result = prime * result + ((getSourceId() == null) ? 0 : getSourceId().hashCode()); |
||||
result = prime * result + ((getSourceOrderNo() == null) ? 0 : getSourceOrderNo().hashCode()); |
||||
result = prime * result + ((getSourceContent() == null) ? 0 : getSourceContent().hashCode()); |
||||
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); |
||||
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); |
||||
result = prime * result + ((getOpUserType() == null) ? 0 : getOpUserType().hashCode()); |
||||
result = prime * result + ((getOpUserId() == null) ? 0 : getOpUserId().hashCode()); |
||||
result = prime * result + ((getOpUserName() == null) ? 0 : getOpUserName().hashCode()); |
||||
result = prime * result + ((getOpUserPhone() == null) ? 0 : getOpUserPhone().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(", agentApiAccountId=").append(agentApiAccountId); |
||||
sb.append(", agentId=").append(agentId); |
||||
sb.append(", type=").append(type); |
||||
sb.append(", transactionAmount=").append(transactionAmount); |
||||
sb.append(", beforeAmount=").append(beforeAmount); |
||||
sb.append(", afterAmount=").append(afterAmount); |
||||
sb.append(", sourceType=").append(sourceType); |
||||
sb.append(", sourceId=").append(sourceId); |
||||
sb.append(", sourceOrderNo=").append(sourceOrderNo); |
||||
sb.append(", sourceContent=").append(sourceContent); |
||||
sb.append(", status=").append(status); |
||||
sb.append(", createTime=").append(createTime); |
||||
sb.append(", opUserType=").append(opUserType); |
||||
sb.append(", opUserId=").append(opUserId); |
||||
sb.append(", opUserName=").append(opUserName); |
||||
sb.append(", opUserPhone=").append(opUserPhone); |
||||
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,24 @@ |
||||
package com.hfkj.openapi.model.request; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import javax.validation.constraints.NotBlank; |
||||
import javax.validation.constraints.NotNull; |
||||
import java.math.BigDecimal; |
||||
|
||||
/** |
||||
* 推送订单模型 |
||||
*/ |
||||
@Data |
||||
public class RequestOrderDetailModel { |
||||
|
||||
@NotBlank(message = "appId必填项") |
||||
private String appId; |
||||
|
||||
@NotNull(message = "订单号必填项") |
||||
private String orderNo; |
||||
|
||||
@NotBlank(message = "签名必填项") |
||||
private String sign; |
||||
|
||||
} |
@ -0,0 +1,40 @@ |
||||
package com.hfkj.openapi.model.request; |
||||
|
||||
import lombok.Data; |
||||
import org.hibernate.validator.constraints.Range; |
||||
|
||||
import javax.validation.constraints.NotBlank; |
||||
import javax.validation.constraints.NotNull; |
||||
import java.math.BigDecimal; |
||||
|
||||
/** |
||||
* 推送订单模型 |
||||
*/ |
||||
@Data |
||||
public class RequestOrderPushModel { |
||||
|
||||
@NotBlank(message = "appId必填项") |
||||
private String appId; |
||||
|
||||
@NotNull(message = "订单号必填项") |
||||
private String orderNo; |
||||
|
||||
@NotNull(message = "加油金额必填项") |
||||
private BigDecimal refuelingAmount; |
||||
|
||||
@NotNull(message = "油站编号必填项") |
||||
private String gasNo; |
||||
|
||||
@NotNull(message = "油号必填项") |
||||
private String oilNo; |
||||
|
||||
@NotNull(message = "枪号必填项") |
||||
private String gunNo; |
||||
|
||||
@NotNull(message = "用户手机号必填项") |
||||
private String userPhone; |
||||
|
||||
@NotBlank(message = "签名必填项") |
||||
private String sign; |
||||
|
||||
} |
@ -0,0 +1,26 @@ |
||||
package com.hfkj.openapi.model.request; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import javax.validation.constraints.NotBlank; |
||||
import javax.validation.constraints.NotNull; |
||||
import java.math.BigDecimal; |
||||
|
||||
/** |
||||
* 推送订单模型 |
||||
*/ |
||||
@Data |
||||
public class RequestOrderRefundModel { |
||||
|
||||
@NotBlank(message = "appId必填项") |
||||
private String appId; |
||||
|
||||
@NotNull(message = "订单号必填项") |
||||
private String orderNo; |
||||
|
||||
private String refundReason; |
||||
|
||||
@NotBlank(message = "签名必填项") |
||||
private String sign; |
||||
|
||||
} |
@ -0,0 +1,38 @@ |
||||
package com.hfkj.openapi.model.response; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* 订单退款通知 |
||||
* @className: OrderRefundNotifyModel |
||||
* @author: HuRui |
||||
* @date: 2024/11/21 |
||||
**/ |
||||
@Data |
||||
public class OrderRefundNotifyModel { |
||||
/** |
||||
* 订单号 |
||||
*/ |
||||
private String orderNo; |
||||
/** |
||||
* 渠道类型 |
||||
*/ |
||||
private Integer channelType; |
||||
/** |
||||
* 渠道单号 |
||||
*/ |
||||
private String channelOrderNo; |
||||
/** |
||||
* 退款状态 |
||||
*/ |
||||
private boolean refundResult; |
||||
/** |
||||
* 退款失败原因 |
||||
*/ |
||||
private String refundFailReason; |
||||
/** |
||||
* 签名 |
||||
*/ |
||||
private String sign; |
||||
|
||||
} |
@ -1,21 +0,0 @@ |
||||
package com.hfkj.openapi.model.response; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @className: RequestQueryGasListModel |
||||
* @author: HuRui |
||||
* @date: 2024/9/18 |
||||
**/ |
||||
@Data |
||||
public class QueryGasGun { |
||||
/** |
||||
* 油站编号 |
||||
*/ |
||||
private String gasNo; |
||||
/** |
||||
* 油站名称 |
||||
*/ |
||||
private String gasName; |
||||
|
||||
} |
@ -0,0 +1,69 @@ |
||||
package com.hfkj.openapi.model.response; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* 推送订单模型 |
||||
*/ |
||||
@Data |
||||
public class ResponseOrderDetailModel { |
||||
/** |
||||
* 订单号 |
||||
*/ |
||||
private String orderNo; |
||||
/** |
||||
* 用户手机号 |
||||
*/ |
||||
private String userPhone; |
||||
/** |
||||
* 油站编号 |
||||
*/ |
||||
private String gasNo; |
||||
/** |
||||
* 油站名称 |
||||
*/ |
||||
private String gasName; |
||||
/** |
||||
* 加油金额 |
||||
*/ |
||||
private BigDecimal refuelPrice; |
||||
/** |
||||
* 油号 |
||||
*/ |
||||
private String oilNo; |
||||
/** |
||||
* 枪号 |
||||
*/ |
||||
private String gunNo; |
||||
/** |
||||
* 升数 |
||||
*/ |
||||
private BigDecimal litre; |
||||
/** |
||||
* 国标价 |
||||
*/ |
||||
private BigDecimal priceOfficial; |
||||
/** |
||||
* 油枪价 |
||||
*/ |
||||
private BigDecimal priceGun; |
||||
/** |
||||
* 状态 |
||||
*/ |
||||
private Integer status; |
||||
/** |
||||
* 渠道类型 |
||||
*/ |
||||
private Integer channelType; |
||||
/** |
||||
* 渠道单号 |
||||
*/ |
||||
private String channelOrderNo; |
||||
/** |
||||
* 创建时间 |
||||
*/ |
||||
private Date createTime; |
||||
} |
@ -0,0 +1,27 @@ |
||||
package com.hfkj.openapi.model.response; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import javax.validation.constraints.NotBlank; |
||||
import javax.validation.constraints.NotNull; |
||||
import java.math.BigDecimal; |
||||
|
||||
/** |
||||
* 推送订单模型 |
||||
*/ |
||||
@Data |
||||
public class ResponseOrderPushModel { |
||||
/** |
||||
* 订单号 |
||||
*/ |
||||
private String orderNo; |
||||
/** |
||||
* 渠道类型 |
||||
*/ |
||||
private Integer channelType; |
||||
|
||||
/** |
||||
* 渠道单号 |
||||
*/ |
||||
private String channelOrderNo; |
||||
} |
@ -0,0 +1,423 @@ |
||||
package com.hfkj.openapi.service; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hfkj.channel.gas.newlink.NewLinkRequestService; |
||||
import com.hfkj.channel.gas.shell.CqShellPetroleumRequestService; |
||||
import com.hfkj.common.exception.BaseException; |
||||
import com.hfkj.common.exception.ErrorCode; |
||||
import com.hfkj.common.exception.ErrorHelp; |
||||
import com.hfkj.common.exception.SysCode; |
||||
import com.hfkj.common.pay.util.SignatureUtil; |
||||
import com.hfkj.common.utils.DateUtil; |
||||
import com.hfkj.common.utils.HttpsUtils; |
||||
import com.hfkj.common.utils.RandomUtils; |
||||
import com.hfkj.entity.*; |
||||
import com.hfkj.model.GasModel; |
||||
import com.hfkj.model.GasOilPriceModel; |
||||
import com.hfkj.openapi.model.request.RequestOrderDetailModel; |
||||
import com.hfkj.openapi.model.request.RequestOrderPushModel; |
||||
import com.hfkj.openapi.model.request.RequestOrderRefundModel; |
||||
import com.hfkj.openapi.model.response.OrderRefundNotifyModel; |
||||
import com.hfkj.openapi.model.response.ResponseOrderDetailModel; |
||||
import com.hfkj.openapi.model.response.ResponseOrderPushModel; |
||||
import com.hfkj.service.BsDeviceService; |
||||
import com.hfkj.service.agent.BsAgentApiAccountService; |
||||
import com.hfkj.service.agent.BsAgentApiParamService; |
||||
import com.hfkj.service.agent.BsAgentMerService; |
||||
import com.hfkj.service.agent.BsAgentService; |
||||
import com.hfkj.service.gas.BsGasClassGroupTaskService; |
||||
import com.hfkj.service.gas.BsGasOrderService; |
||||
import com.hfkj.service.gas.BsGasService; |
||||
import com.hfkj.service.merchant.BsMerchantAccountService; |
||||
import com.hfkj.service.merchant.BsMerchantChainBrandAccountService; |
||||
import com.hfkj.service.merchant.BsMerchantService; |
||||
import com.hfkj.service.order.BsOrderRefundService; |
||||
import com.hfkj.service.order.BsOrderService; |
||||
import com.hfkj.service.sec.SecDictionaryService; |
||||
import com.hfkj.sysenum.gas.GasOrderCreateType; |
||||
import com.hfkj.sysenum.gas.GasOrderReceiptStatusEnum; |
||||
import com.hfkj.sysenum.gas.OrderOilStatus; |
||||
import com.hfkj.sysenum.merchant.MerchantAccountRecordSourceTypeEnum; |
||||
import com.hfkj.sysenum.merchant.MerchantChainBrandSettleTypeEnum; |
||||
import com.hfkj.sysenum.merchant.MerchantSourceTypeEnum; |
||||
import com.hfkj.sysenum.merchant.MerchantStatusEnum; |
||||
import com.hfkj.sysenum.order.OrderPayTypeEnum; |
||||
import com.hfkj.sysenum.order.OrderRefundStatusEnum; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.transaction.annotation.Propagation; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.math.BigDecimal; |
||||
import java.util.*; |
||||
import java.util.concurrent.ExecutorService; |
||||
import java.util.concurrent.Executors; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* @className: ApiGasOrderService |
||||
* @author: HuRui |
||||
* @date: 2024/11/12 |
||||
**/ |
||||
@Component("apiGasOrderService") |
||||
public class ApiGasOrderService { |
||||
@Resource |
||||
private BsAgentMerService agentMerService; |
||||
@Resource |
||||
private BsAgentService agentService; |
||||
@Resource |
||||
private BsMerchantService merchantService; |
||||
@Resource |
||||
private BsMerchantAccountService merchantAccountService; |
||||
@Resource |
||||
private BsMerchantChainBrandAccountService merchantChainBrandAccountService; |
||||
@Resource |
||||
private BsGasService gasService; |
||||
@Resource |
||||
private BsOrderService orderService; |
||||
@Resource |
||||
private BsGasOrderService gasOrderService; |
||||
@Resource |
||||
private BsGasClassGroupTaskService gasClassGroupTaskService; |
||||
@Resource |
||||
private BsDeviceService deviceService; |
||||
@Resource |
||||
private SecDictionaryService dictionaryService; |
||||
@Resource |
||||
private BsAgentApiAccountService agentApiAccountService; |
||||
@Resource |
||||
private BsAgentApiParamService agentApiParamService; |
||||
|
||||
@Resource |
||||
private BsOrderRefundService orderRefundService; |
||||
/** |
||||
* 推送加油订单 |
||||
* @param request |
||||
* @return |
||||
*/ |
||||
@Transactional(propagation= Propagation.REQUIRES_NEW,rollbackFor= {RuntimeException.class}) |
||||
public ResponseOrderPushModel pushOrder(Long agentId,RequestOrderPushModel request) throws Exception { |
||||
// 交易油站权限
|
||||
BsAgentMer agentMer = agentMerService.getDetailByAgent(agentId, request.getGasNo()); |
||||
if (agentMer == null) { |
||||
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.COMMON_ERROR, "油站不可用"); |
||||
} |
||||
// 查询油站
|
||||
GasModel gasDetail = gasService.getGasDetail(request.getGasNo()); |
||||
if (gasDetail == null) { |
||||
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.COMMON_ERROR, "未找到油站信息"); |
||||
} |
||||
if (!gasDetail.getStatus().equals(MerchantStatusEnum.status1.getNumber())) { |
||||
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.COMMON_ERROR, "油站不可用"); |
||||
} |
||||
// 校验油品
|
||||
List<GasOilPriceModel> gasOilPriceModels = gasDetail.getGasOilPrice().stream().filter(o -> o.getOilNo().equals(request.getOilNo())).collect(Collectors.toList()); |
||||
if (gasOilPriceModels.isEmpty()) { |
||||
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.COMMON_ERROR, "油品不可用"); |
||||
} |
||||
// 油价
|
||||
GasOilPriceModel oilPrice = gasOilPriceModels.get(0); |
||||
// 校验枪号
|
||||
if (oilPrice.getGasOilGunNo().stream().noneMatch(o -> o.getGunNo().equals(request.getGunNo()))) { |
||||
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.COMMON_ERROR, "枪号不可用"); |
||||
} |
||||
// 交易订单号
|
||||
if (gasOrderService.getDetailByOrderNo(request.getOrderNo()) != null) { |
||||
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.COMMON_ERROR, "订单号已存在"); |
||||
} |
||||
// 查询代理商
|
||||
BsAgent agent = agentService.getAgentById(agentId); |
||||
if (agent == null) { |
||||
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.COMMON_ERROR, "未知的接入方"); |
||||
} |
||||
// 创建加油订单
|
||||
BsGasOrder gasOrder = new BsGasOrder(); |
||||
gasOrder.setAgentId(agent.getId()); |
||||
gasOrder.setAgentName(agent.getName()); |
||||
gasOrder.setAbnormal(false); |
||||
gasOrder.setMerNo(gasDetail.getMerNo()); |
||||
gasOrder.setChannelType(gasDetail.getSourceType()); |
||||
gasOrder.setOrderNo(request.getOrderNo()); |
||||
gasOrder.setUserPhone(request.getUserPhone()); |
||||
gasOrder.setMerChainBrandId(gasDetail.getChainBrandId()); |
||||
gasOrder.setMerChainBrandName(gasDetail.getChainBrandName()); |
||||
gasOrder.setMerId(gasDetail.getId()); |
||||
gasOrder.setMerName(gasDetail.getMerName()); |
||||
gasOrder.setMerAddress(gasDetail.getAddress()); |
||||
gasOrder.setStatus(OrderOilStatus.STATUS2.getNumber()); |
||||
gasOrder.setReceiptStatus(GasOrderReceiptStatusEnum.status0.getStatus()); |
||||
|
||||
// 结算信息
|
||||
gasOrder.setTotalDeductionPrice(new BigDecimal("0")); |
||||
gasOrder.setDeductionCouponPrice(new BigDecimal("0")); |
||||
gasOrder.setDeductionOilPrice(new BigDecimal("0")); |
||||
gasOrder.setPayablePrice(request.getRefuelingAmount()); |
||||
gasOrder.setPayablePrice(request.getRefuelingAmount()); |
||||
gasOrder.setGasRefuelPrice(request.getRefuelingAmount()); |
||||
gasOrder.setGasSettlePrice(gasOrder.getGasRefuelPrice()); |
||||
gasOrder.setGasAgentSettlePrice(gasOrder.getGasRefuelPrice()); |
||||
|
||||
// 油价信息
|
||||
gasOrder.setGasRefuelPrice(request.getRefuelingAmount()); |
||||
gasOrder.setGasOilNo(request.getOilNo()); |
||||
gasOrder.setGasGunNo(request.getGunNo()); |
||||
gasOrder.setGasOilType(oilPrice.getOilType()); |
||||
gasOrder.setGasPriceGun(oilPrice.getPriceGun()); |
||||
gasOrder.setGasPriceVip(oilPrice.getPriceGun()); |
||||
gasOrder.setGasPriceCost(oilPrice.getPriceGun()); |
||||
gasOrder.setGasPriceOfficial(oilPrice.getPriceOfficial()); |
||||
gasOrder.setGasPricePlatform(oilPrice.getPriceGun()); |
||||
gasOrder.setGasOilLiters(gasOrder.getGasSettlePrice().divide(gasOrder.getGasPriceGun(), 2, BigDecimal.ROUND_HALF_UP)); |
||||
gasOrder.setGasDiscount(new BigDecimal("0")); |
||||
gasOrder.setGasOilSubsidy(new BigDecimal("0")); |
||||
gasOrder.setGasLitersPreferences(new BigDecimal("0")); |
||||
gasOrder.setGasPricePreferences(new BigDecimal("0")); |
||||
gasOrder.setCreateType(GasOrderCreateType.TYPE2.getNumber()); |
||||
|
||||
// 油站是否开启班组
|
||||
BsGasClassGroupTask groupTask = gasClassGroupTaskService.getCurrentTaskByMerId(gasDetail.getId()); |
||||
if (groupTask != null) { |
||||
gasOrder.setGasClassGroupId(groupTask.getGasClassGroupId()); |
||||
gasOrder.setGasClassGroupName(groupTask.getGasClassGroupName()); |
||||
gasOrder.setGasClassGroupTaskId(groupTask.getId()); |
||||
} |
||||
gasOrderService.addGasOrder(gasOrder); |
||||
|
||||
// 代理商扣款
|
||||
Map<String,Object> consumeParam = new HashMap<>(); |
||||
consumeParam.put("sourceType", MerchantAccountRecordSourceTypeEnum.type2.getType()); |
||||
consumeParam.put("sourceOrderNo", gasOrder.getOrderNo()); |
||||
consumeParam.put("sourceOrderContent", "加油订单:"+gasOrder.getOrderNo()); |
||||
agentApiAccountService.consume(agentId, gasOrder.getGasAgentSettlePrice(), consumeParam); |
||||
|
||||
// 处理支付后的加油业务
|
||||
oilHandle(gasOrder); |
||||
// 加油业务是否异常
|
||||
if (gasOrder.getAbnormal().equals(true)) { |
||||
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.COMMON_ERROR, gasOrder.getAbnormalContent()); |
||||
} |
||||
ResponseOrderPushModel response = new ResponseOrderPushModel(); |
||||
response.setOrderNo(gasOrder.getOrderNo()); |
||||
response.setChannelType(gasOrder.getChannelType()); |
||||
response.setChannelOrderNo(gasOrder.getChannelOrderNo()); |
||||
return response; |
||||
} |
||||
|
||||
/** |
||||
* 退款订单 |
||||
* @param request |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
@Transactional(propagation= Propagation.REQUIRES_NEW,rollbackFor= {RuntimeException.class}) |
||||
public String refundOrder(RequestOrderRefundModel request) { |
||||
// 查询加油订单
|
||||
BsGasOrder gasOrder = gasOrderService.getDetailByOrderNo(request.getOrderNo()); |
||||
if (gasOrder == null) { |
||||
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.COMMON_ERROR, "未找到订单号"); |
||||
} |
||||
if (!gasOrder.getStatus().equals(OrderOilStatus.STATUS2.getNumber()) |
||||
|| gasOrder.getStatus().equals(OrderOilStatus.STATUS6.getNumber())) { |
||||
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.COMMON_ERROR, "订单无法退款"); |
||||
} |
||||
// 创建退款订单
|
||||
BsOrderRefund orderRefund = new BsOrderRefund(); |
||||
orderRefund.setMerId(gasOrder.getMerId()); |
||||
orderRefund.setMerNo(gasOrder.getMerNo()); |
||||
orderRefund.setOrderNo(gasOrder.getOrderNo()); |
||||
orderRefund.setUserPhone(gasOrder.getUserPhone()); |
||||
// 退款订单号 退款标识:R + 时间 + 随机3位数字
|
||||
orderRefund.setRefundOrderNo("R"+ DateUtil.date2String(new Date(), "yyMMddHHmmss") + RandomUtils.number(3, false)); |
||||
orderRefund.setRefundPayType(gasOrder.getPayType()); |
||||
// 全部退款
|
||||
orderRefund.setRefundPrice(gasOrder.getGasRefuelPrice()); |
||||
orderRefund.setRefundIntegral(0L); |
||||
orderRefund.setRefundRemark(request.getRefundReason()); |
||||
orderRefund.setRefundStatus(OrderRefundStatusEnum.status1.getCode()); |
||||
orderRefund.setCreateType(GasOrderCreateType.TYPE2.getNumber()); |
||||
orderRefundService.editData(orderRefund); |
||||
|
||||
ResponseOrderPushModel response = new ResponseOrderPushModel(); |
||||
response.setOrderNo(gasOrder.getOrderNo()); |
||||
response.setChannelType(gasOrder.getChannelType()); |
||||
response.setChannelOrderNo(gasOrder.getChannelOrderNo()); |
||||
|
||||
// 创建一个单线程的线程池
|
||||
ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor(); |
||||
// 异步记录登录信息
|
||||
singleThreadExecutor.submit(new Runnable() { |
||||
@Override |
||||
public void run() { |
||||
if (!gasOrder.getChannelType().equals(MerchantSourceTypeEnum.type2.getNumber())) { |
||||
try { |
||||
// 退款
|
||||
agentApiAccountService.refund(gasOrder.getAgentId(),gasOrder.getGasRefuelPrice(), orderRefund); |
||||
orderRefund.setRefundStatus(OrderRefundStatusEnum.status2.getCode()); |
||||
orderRefund.setFinishTime(new Date()); |
||||
orderRefundService.editData(orderRefund); |
||||
} catch (Exception e) { |
||||
orderRefund.setRefundStatus(OrderRefundStatusEnum.status3.getCode()); |
||||
orderRefund.setRefundFailReason("退款失败!"); |
||||
orderRefundService.editData(orderRefund); |
||||
} |
||||
// 退款通知
|
||||
// 代理参数
|
||||
BsAgentApiParam apiParam = agentApiParamService.getParamByAppId(request.getAppId()); |
||||
if (apiParam != null && StringUtils.isNotBlank(apiParam.getOrderRefundNotify())) { |
||||
// 通知数据
|
||||
OrderRefundNotifyModel refundNotify = new OrderRefundNotifyModel(); |
||||
refundNotify.setOrderNo(orderRefund.getOrderNo()); |
||||
refundNotify.setChannelType(gasOrder.getChannelType()); |
||||
refundNotify.setChannelOrderNo(gasOrder.getChannelOrderNo()); |
||||
refundNotify.setRefundResult(orderRefund.getRefundStatus() == 2 ? true : false); |
||||
refundNotify.setRefundFailReason(orderRefund.getRefundFailReason()); |
||||
refundNotify.setSign(SignatureUtil.createSign(refundNotify, apiParam.getAppSecret())); |
||||
HttpsUtils.doPost(apiParam.getOrderRefundNotify(), JSONObject.toJSONString(refundNotify)); |
||||
} |
||||
} |
||||
} |
||||
}); |
||||
return "ok"; |
||||
} |
||||
|
||||
/** |
||||
* 查询订单详情 |
||||
* @param request |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public ResponseOrderDetailModel queryOrderDetail(RequestOrderDetailModel request) throws Exception { |
||||
// 查询加油订单
|
||||
BsGasOrder gasOrder = gasOrderService.getDetailByOrderNo(request.getOrderNo()); |
||||
if (gasOrder == null) { |
||||
throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.COMMON_ERROR, "未找到订单号"); |
||||
} |
||||
ResponseOrderDetailModel response = new ResponseOrderDetailModel(); |
||||
response.setOrderNo(gasOrder.getOrderNo()); |
||||
response.setUserPhone(gasOrder.getUserPhone()); |
||||
response.setRefuelPrice(gasOrder.getGasRefuelPrice()); |
||||
response.setGasNo(gasOrder.getMerNo()); |
||||
response.setGasName(gasOrder.getMerName()); |
||||
response.setOilNo(gasOrder.getGasOilNo()); |
||||
response.setGunNo(gasOrder.getGasGunNo()); |
||||
response.setLitre(gasOrder.getGasOilLiters()); |
||||
response.setPriceOfficial(gasOrder.getGasPriceOfficial()); |
||||
response.setPriceGun(gasOrder.getGasPriceGun()); |
||||
response.setStatus(gasOrder.getStatus()); |
||||
response.setChannelType(gasOrder.getChannelType()); |
||||
response.setChannelOrderNo(gasOrder.getChannelOrderNo()); |
||||
response.setCreateTime(gasOrder.getCreateTime()); |
||||
return response; |
||||
} |
||||
|
||||
/** |
||||
* 油站业务 |
||||
* @param gasOrder |
||||
*/ |
||||
public BsGasOrder oilHandle(BsGasOrder gasOrder) throws Exception { |
||||
// 查询加油订单
|
||||
if (gasOrder != null) { |
||||
gasOrder.setActualPayPrice(gasOrder.getGasRefuelPrice()); |
||||
gasOrder.setPayType(OrderPayTypeEnum.type4.getCode()); |
||||
gasOrder.setPayTime(new Date()); |
||||
gasOrderService.updateGasOrder(gasOrder); |
||||
|
||||
if (gasOrder.getChannelType().equals(MerchantSourceTypeEnum.type1.getNumber())) { |
||||
// 自建站
|
||||
// 打印小票
|
||||
if (gasOrder.getChannelType().equals(MerchantSourceTypeEnum.type1.getNumber())) { |
||||
deviceService.printGasOrder(gasOrder.getMerId(), gasOrder, false); |
||||
} |
||||
// 查询油站
|
||||
BsMerchant merchant = merchantService.getMerchant(gasOrder.getMerNo()); |
||||
if (merchant != null) { |
||||
// 连锁商户
|
||||
if (merchant.getChainBrandId() != null) { |
||||
if (merchant.getChainBrandSettleType().equals(MerchantChainBrandSettleTypeEnum.type1.getNumber())) { |
||||
// 连锁额度
|
||||
Map<String,Object> consumeMap = new HashMap<>(); |
||||
consumeMap.put("sourceType", MerchantAccountRecordSourceTypeEnum.type2.getType()); |
||||
consumeMap.put("sourceId", gasOrder.getId()); |
||||
consumeMap.put("sourceOrderNo", gasOrder.getOrderNo()); |
||||
merchantChainBrandAccountService.consume(merchant.getChainBrandId(), gasOrder.getMerNo(), gasOrder.getGasSettlePrice(), consumeMap); |
||||
|
||||
} else if (merchant.getChainBrandSettleType().equals(MerchantChainBrandSettleTypeEnum.type2.getNumber())) { |
||||
// 商户额度
|
||||
Map<String,Object> consumeMap = new HashMap<>(); |
||||
consumeMap.put("sourceType", MerchantAccountRecordSourceTypeEnum.type2.getType()); |
||||
consumeMap.put("sourceId", gasOrder.getId()); |
||||
consumeMap.put("sourceOrderNo", gasOrder.getOrderNo()); |
||||
merchantAccountService.consume(gasOrder.getMerNo(), gasOrder.getGasSettlePrice(), consumeMap); |
||||
} |
||||
} else { |
||||
// 商户额度
|
||||
Map<String,Object> consumeMap = new HashMap<>(); |
||||
consumeMap.put("sourceType", MerchantAccountRecordSourceTypeEnum.type2.getType()); |
||||
consumeMap.put("sourceId", gasOrder.getId()); |
||||
consumeMap.put("sourceOrderNo", gasOrder.getOrderNo()); |
||||
merchantAccountService.consume(gasOrder.getMerNo(), gasOrder.getGasSettlePrice(), consumeMap); |
||||
} |
||||
} |
||||
|
||||
} else if (gasOrder.getChannelType().equals(MerchantSourceTypeEnum.type2.getNumber())) { |
||||
try { |
||||
// 能链【团油】
|
||||
Map<String, Object> param = new HashMap<>(); |
||||
param.put("gasId", gasOrder.getMerNo()); |
||||
param.put("oilNo", gasOrder.getGasOilNo()); |
||||
param.put("gunNo", Integer.parseInt(gasOrder.getGasGunNo())); |
||||
param.put("priceGun", gasOrder.getGasPriceGun()); // 油站价
|
||||
param.put("priceVip", gasOrder.getGasPriceCost()); // 成本价
|
||||
param.put("driverPhone", gasOrder.getUserPhone()); |
||||
param.put("thirdSerialNo", gasOrder.getOrderNo()); |
||||
param.put("refuelingAmount", gasOrder.getGasRefuelPrice()); |
||||
// 查询账户
|
||||
SecDictionary newLinkAccount = dictionaryService.getDictionary("NEW_LINK_ACCOUNT", "" + gasOrder.getGasOilType()); |
||||
if (newLinkAccount != null) { |
||||
param.put("accountNo", newLinkAccount.getCodeName()); |
||||
} |
||||
JSONObject pushResult = NewLinkRequestService.refuelingOrderPush(param); |
||||
if (pushResult != null && pushResult.getString("code").equals("200")) { |
||||
gasOrder.setChannelOrderNo(pushResult.getJSONObject("result").getString("orderNo")); |
||||
gasOrder.setAbnormal(false); |
||||
gasOrder.setAbnormalContent(null); |
||||
} else { |
||||
gasOrder.setAbnormal(true); |
||||
gasOrder.setAbnormalContent(pushResult.getString("message")); |
||||
} |
||||
} catch (Exception e) { |
||||
gasOrder.setAbnormal(true); |
||||
gasOrder.setAbnormalContent("推送订单未知异常!请稍后重新推送"); |
||||
} |
||||
gasOrderService.updateGasOrder(gasOrder); |
||||
|
||||
} else if (gasOrder.getChannelType().equals(MerchantSourceTypeEnum.type3.getNumber())) { |
||||
try { |
||||
// 推送加好油【重庆壳牌】
|
||||
CqShellPetroleumRequestService.gasSyncPayment(gasOrder.getOrderNo(), |
||||
gasOrder.getMerNo(), |
||||
gasOrder.getPayTime(), |
||||
gasOrder.getGasRefuelPrice(), |
||||
gasOrder.getGasOilNo(), |
||||
gasOrder.getGasGunNo(), |
||||
gasOrder.getPayablePrice(), |
||||
gasOrder.getTotalDeductionPrice() |
||||
); |
||||
gasOrder.setAbnormal(false); |
||||
gasOrder.setAbnormalContent(null); |
||||
|
||||
} catch (BaseException e) { |
||||
gasOrder.setAbnormal(true); |
||||
gasOrder.setAbnormalContent(e.getErrorMsg()); |
||||
} catch (Exception e) { |
||||
gasOrder.setAbnormal(true); |
||||
gasOrder.setAbnormalContent("推送订单未知错误!请稍后重新推送"); |
||||
} |
||||
gasOrderService.updateGasOrder(gasOrder); |
||||
} |
||||
} |
||||
return gasOrder; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,24 @@ |
||||
package com.hfkj.service.agent; |
||||
|
||||
import com.hfkj.entity.BsAgentApiAccountRecord; |
||||
import com.hfkj.entity.BsAgentMerAccountRecord; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
|
||||
public interface BsAgentApiAccountRecordService { |
||||
|
||||
/** |
||||
* 创建 |
||||
* @param data |
||||
*/ |
||||
void create(BsAgentApiAccountRecord data); |
||||
|
||||
/** |
||||
* 查询列表 |
||||
* @param param |
||||
* @return |
||||
*/ |
||||
List<BsAgentApiAccountRecord> getList(Map<String,Object> param); |
||||
} |
@ -0,0 +1,92 @@ |
||||
package com.hfkj.service.agent.impl; |
||||
|
||||
import com.hfkj.common.security.UserCenter; |
||||
import com.hfkj.dao.BsAgentApiAccountRecordMapper; |
||||
import com.hfkj.entity.BsAgentApiAccountRecord; |
||||
import com.hfkj.entity.BsAgentApiAccountRecordExample; |
||||
import com.hfkj.entity.BsAgentMerAccountRecord; |
||||
import com.hfkj.entity.BsAgentMerAccountRecordExample; |
||||
import com.hfkj.model.SecUserSessionObject; |
||||
import com.hfkj.model.UserSessionObject; |
||||
import com.hfkj.service.agent.BsAgentApiAccountRecordService; |
||||
import com.hfkj.service.agent.BsAgentMerAccountRecordService; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @className: BsAgentApiAccountRecordServiceImpl |
||||
* @author: HuRui |
||||
* @date: 2024/11/19 |
||||
**/ |
||||
@Service("agentApiAccountRecordService") |
||||
public class BsAgentApiAccountRecordServiceImpl implements BsAgentApiAccountRecordService { |
||||
@Resource |
||||
private BsAgentApiAccountRecordMapper agentApiAccountRecordMapper; |
||||
@Resource |
||||
private UserCenter userCenter; |
||||
|
||||
@Override |
||||
public void create(BsAgentApiAccountRecord data) { |
||||
try { |
||||
SecUserSessionObject secUserSessionObject = userCenter.getSessionModel(SecUserSessionObject.class); |
||||
if (secUserSessionObject != null) { |
||||
data.setOpUserType(1); |
||||
data.setOpUserId(secUserSessionObject.getAccount().getId()); |
||||
data.setOpUserName(secUserSessionObject.getAccount().getUserName()); |
||||
data.setOpUserPhone(secUserSessionObject.getAccount().getTelephone()); |
||||
} |
||||
} catch (Exception e) { |
||||
System.out.println("获取管理员信息失败"); |
||||
} |
||||
|
||||
try { |
||||
UserSessionObject userModel = userCenter.getSessionModel(UserSessionObject.class); |
||||
if (userModel != null) { |
||||
data.setOpUserType(2); |
||||
data.setOpUserId(userModel.getUser().getId()); |
||||
data.setOpUserName(userModel.getUser().getUserName()); |
||||
data.setOpUserPhone(userModel.getUser().getPhone()); |
||||
} |
||||
} catch (Exception e) { |
||||
System.out.println("获取客户信息失败"); |
||||
} |
||||
data.setStatus(1); |
||||
data.setCreateTime(new Date()); |
||||
agentApiAccountRecordMapper.insert(data); |
||||
} |
||||
|
||||
@Override |
||||
public List<BsAgentApiAccountRecord> getList(Map<String, Object> param) { |
||||
BsAgentApiAccountRecordExample example = new BsAgentApiAccountRecordExample(); |
||||
BsAgentApiAccountRecordExample.Criteria criteria = example.createCriteria().andStatusNotEqualTo(0); |
||||
|
||||
if (MapUtils.getLong(param, "agentApiAccountId") != null) { |
||||
criteria.andAgentApiAccountIdEqualTo(MapUtils.getLong(param, "agentApiAccountId")); |
||||
} |
||||
|
||||
if (MapUtils.getLong(param, "agentId") != null) { |
||||
criteria.andAgentIdEqualTo(MapUtils.getLong(param, "agentId")); |
||||
} |
||||
|
||||
if (MapUtils.getInteger(param, "type") != null) { |
||||
criteria.andTypeEqualTo(MapUtils.getInteger(param, "type")); |
||||
} |
||||
|
||||
if (MapUtils.getInteger(param, "sourceType") != null) { |
||||
criteria.andSourceTypeEqualTo(MapUtils.getInteger(param, "sourceType")); |
||||
} |
||||
|
||||
if (StringUtils.isNotBlank(MapUtils.getString(param, "sourceOrderNo"))) { |
||||
criteria.andSourceOrderNoEqualTo(MapUtils.getString(param, "sourceOrderNo")); |
||||
} |
||||
|
||||
example.setOrderByClause("create_time desc"); |
||||
return agentApiAccountRecordMapper.selectByExample(example); |
||||
} |
||||
} |
@ -0,0 +1,59 @@ |
||||
package com.hfkj.sysenum.gas; |
||||
|
||||
import java.util.Objects; |
||||
|
||||
public enum GasOrderCreateType { |
||||
/** |
||||
* 平台创建 |
||||
*/ |
||||
TYPE1(1, "平台创建"), |
||||
/** |
||||
* API创建 |
||||
*/ |
||||
TYPE2(2, "API创建"), |
||||
; |
||||
|
||||
private Integer number; |
||||
|
||||
private String name; |
||||
|
||||
GasOrderCreateType(int number, String name) { |
||||
this.number = number; |
||||
this.name = name; |
||||
} |
||||
|
||||
/** |
||||
* 根据类型查询数据 |
||||
* @param type |
||||
* @return |
||||
*/ |
||||
public static GasOrderCreateType getDataByType(Integer type) { |
||||
for (GasOrderCreateType ele : values()) { |
||||
if(Objects.equals(type,ele.getNumber())) return ele; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public static String getNameByType(Integer type) { |
||||
for (GasOrderCreateType ele : values()) { |
||||
if(Objects.equals(type,ele.getNumber())) return ele.getName(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public Integer getNumber() { |
||||
return number; |
||||
} |
||||
|
||||
public void setNumber(Integer number) { |
||||
this.number = number; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
} |
Loading…
Reference in new issue