Commit 87d08780 authored by Peter Cheng's avatar Peter Cheng

1.移除GoMyPay

2.程式優化
parent 2103989e
// Code generated by protoc-gen-go.
// source: gomypay.proto
// DO NOT EDIT!
/*
Package beans is a generated protocol buffer package.
It is generated from these files:
gomypay.proto
punchclock.proto
redis.proto
sendMail.proto
It has these top-level messages:
CreditCard
Punchclock
TimeStruct
Redis
SendMail
*/
package beans
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type CreditCard struct {
SendType string `protobuf:"bytes,1,opt,name=SendType" json:"Send_Type,omitempty"`
PayModeNo string `protobuf:"bytes,2,opt,name=PayModeNo" json:"Pay_Mode_No,omitempty"`
CustomerId string `protobuf:"bytes,3,opt,name=CustomerId" json:"CustomerId,omitempty"`
OrderNo string `protobuf:"bytes,4,opt,name=OrderNo" json:"Order_No,omitempty"`
Amount string `protobuf:"bytes,5,opt,name=Amount" json:"Amount,omitempty"`
TransCode string `protobuf:"bytes,6,opt,name=TransCode" json:"TransCode,omitempty"`
BuyerName string `protobuf:"bytes,7,opt,name=BuyerName" json:"Buyer_Name,omitempty"`
BuyerTelm string `protobuf:"bytes,8,opt,name=BuyerTelm" json:"Buyer_Telm,omitempty"`
BuyerMail string `protobuf:"bytes,9,opt,name=BuyerMail" json:"Buyer_Mail,omitempty"`
BuyerMemo string `protobuf:"bytes,10,opt,name=BuyerMemo" json:"Buyer_Memo,omitempty"`
CardNo string `protobuf:"bytes,11,opt,name=CardNo" json:"CardNo,omitempty"`
ExpireDate string `protobuf:"bytes,12,opt,name=ExpireDate" json:"ExpireDate,omitempty"`
CVV string `protobuf:"bytes,13,opt,name=CVV" json:"CVV,omitempty"`
TransMode string `protobuf:"bytes,14,opt,name=TransMode" json:"TransMode,omitempty"`
Installment string `protobuf:"bytes,15,opt,name=Installment" json:"Installment,omitempty"`
ReturnURL string `protobuf:"bytes,16,opt,name=ReturnURL" json:"Return_url,omitempty"`
CallbackURL string `protobuf:"bytes,17,opt,name=CallbackURL" json:"Callback_Url,omitempty"`
EReturn string `protobuf:"bytes,18,opt,name=EReturn" json:"e_return,omitempty"`
StrCheck string `protobuf:"bytes,19,opt,name=StrCheck" json:"Str_Check,omitempty"`
}
func (m *CreditCard) Reset() { *m = CreditCard{} }
func (m *CreditCard) String() string { return proto.CompactTextString(m) }
func (*CreditCard) ProtoMessage() {}
func (*CreditCard) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *CreditCard) GetSendType() string {
if m != nil {
return m.SendType
}
return ""
}
func (m *CreditCard) GetPayModeNo() string {
if m != nil {
return m.PayModeNo
}
return ""
}
func (m *CreditCard) GetCustomerId() string {
if m != nil {
return m.CustomerId
}
return ""
}
func (m *CreditCard) GetOrderNo() string {
if m != nil {
return m.OrderNo
}
return ""
}
func (m *CreditCard) GetAmount() string {
if m != nil {
return m.Amount
}
return ""
}
func (m *CreditCard) GetTransCode() string {
if m != nil {
return m.TransCode
}
return ""
}
func (m *CreditCard) GetBuyerName() string {
if m != nil {
return m.BuyerName
}
return ""
}
func (m *CreditCard) GetBuyerTelm() string {
if m != nil {
return m.BuyerTelm
}
return ""
}
func (m *CreditCard) GetBuyerMail() string {
if m != nil {
return m.BuyerMail
}
return ""
}
func (m *CreditCard) GetBuyerMemo() string {
if m != nil {
return m.BuyerMemo
}
return ""
}
func (m *CreditCard) GetCardNo() string {
if m != nil {
return m.CardNo
}
return ""
}
func (m *CreditCard) GetExpireDate() string {
if m != nil {
return m.ExpireDate
}
return ""
}
func (m *CreditCard) GetCVV() string {
if m != nil {
return m.CVV
}
return ""
}
func (m *CreditCard) GetTransMode() string {
if m != nil {
return m.TransMode
}
return ""
}
func (m *CreditCard) GetInstallment() string {
if m != nil {
return m.Installment
}
return ""
}
func (m *CreditCard) GetReturnURL() string {
if m != nil {
return m.ReturnURL
}
return ""
}
func (m *CreditCard) GetCallbackURL() string {
if m != nil {
return m.CallbackURL
}
return ""
}
func (m *CreditCard) GetEReturn() string {
if m != nil {
return m.EReturn
}
return ""
}
func (m *CreditCard) GetStrCheck() string {
if m != nil {
return m.StrCheck
}
return ""
}
func init() {
proto.RegisterType((*CreditCard)(nil), "beans.CreditCard")
}
func init() { proto.RegisterFile("gomypay.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 326 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x92, 0xcf, 0x4a, 0x03, 0x31,
0x10, 0x87, 0xa9, 0xfd, 0x9f, 0x5a, 0xad, 0x11, 0x64, 0x10, 0x91, 0xe2, 0xc9, 0x93, 0x17, 0x9f,
0x40, 0x63, 0x0f, 0x05, 0xbb, 0x4a, 0xad, 0xbd, 0xa7, 0xcd, 0xa0, 0xa5, 0x9b, 0x64, 0xc9, 0x66,
0xc1, 0x7d, 0x29, 0x9f, 0x51, 0x92, 0xac, 0xd9, 0xdc, 0xf6, 0xf7, 0x7d, 0x3b, 0x24, 0x93, 0x19,
0x32, 0xfd, 0xd2, 0xb2, 0x2e, 0x78, 0xfd, 0x50, 0x18, 0x6d, 0x35, 0xed, 0xef, 0x90, 0xab, 0xf2,
0xee, 0xb7, 0x47, 0x08, 0x33, 0x28, 0x0e, 0x96, 0x71, 0x23, 0xe8, 0x35, 0x19, 0x7d, 0xa0, 0x12,
0x9b, 0xba, 0x40, 0xe8, 0xcc, 0x3b, 0xf7, 0xe3, 0x75, 0xcc, 0xf4, 0x86, 0x8c, 0xdf, 0x79, 0xbd,
0xd2, 0x02, 0x33, 0x0d, 0x27, 0x5e, 0xb6, 0x80, 0xde, 0x12, 0xc2, 0xaa, 0xd2, 0x6a, 0x89, 0x66,
0x29, 0xa0, 0xe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ff, 0xff, 0xaa, 0x8b,
0x78, 0xde, 0x4f, 0x02, 0x00, 0x00,
}
syntax = "proto3";
package beans;
message CreditCard {
string SendType = 1; //`json:"Send_Type,omitempty"`
string PayModeNo = 2; //`json:"Pay_Mode_No,omitempty"`
string CustomerId = 3; //`json:"CustomerId,omitempty"`
string OrderNo = 4; //`json:"Order_No,omitempty"`
string Amount = 5; //`json:"Amount,omitempty"`
string TransCode = 6; //`json:"TransCode,omitempty"`
string BuyerName = 7; //`json:"Buyer_Name,omitempty"`
string BuyerTelm = 8; //`json:"Buyer_Telm,omitempty"`
string BuyerMail = 9; //`json:"Buyer_Mail,omitempty"`
string BuyerMemo = 10; //`json:"Buyer_Memo,omitempty"`
string CardNo = 11; //`json:"CardNo,omitempty"`
string ExpireDate = 12; //`json:"ExpireDate,omitempty"`
string CVV = 13; //`json:"CVV,omitempty"`
string TransMode = 14; //`json:"TransMode,omitempty"`
string Installment = 15; //`json:"Installment,omitempty"`
string ReturnURL = 16; //`json:"Return_url,omitempty"`
string CallbackURL = 17; //`json:"Callback_Url,omitempty"`
string EReturn = 18; //`json:"e_return,omitempty"`
string StrCheck = 19; //`json:"Str_Check,omitempty"`
}
\ No newline at end of file
package base package controllers
import ( import (
"bytes" "bytes"
"io/ioutil" "io/ioutil"
"log" "log"
"net/http" "net/http"
"github.com/teed7334-restore/homekeeper/env"
) )
var cfg = env.GetEnv()
//GetURL 透過HTTP GET取得網頁資料 //GetURL 透過HTTP GET取得網頁資料
func GetURL(url string) []byte { func GetURL(url string) []byte {
request, err := http.NewRequest("GET", url, nil) request, err := http.NewRequest("GET", url, nil)
......
package controllers
import (
"encoding/json"
"log"
"net/http"
"github.com/gin-gonic/gin"
"github.com/teed7334-restore/homekeeper/base"
"github.com/teed7334-restore/homekeeper/beans"
"github.com/teed7334-restore/homekeeper/env"
)
//PayCreditCard 使用信用卡付款
func PayCreditCard(c *gin.Context) {
cfg := env.GetEnv()
params := getCreditCardParams(c)
params.CustomerId = cfg.GoMyPay.CustomerID
jsonStr, _ := json.Marshal(params)
jsonByte := []byte(jsonStr)
url := cfg.GoMyPay.URL
jsonByte = base.PostURL(url, jsonByte)
c.JSON(http.StatusOK, jsonByte)
}
//getCreditCardParams 取得HTTP POST帶過來之參數
func getCreditCardParams(c *gin.Context) *beans.CreditCard {
params := &beans.CreditCard{}
err := c.BindJSON(params)
if err != nil {
log.Println(err)
}
return params
}
...@@ -5,7 +5,6 @@ import ( ...@@ -5,7 +5,6 @@ import (
"net/http" "net/http"
"github.com/teed7334-restore/homekeeper/beans" "github.com/teed7334-restore/homekeeper/beans"
"github.com/teed7334-restore/homekeeper/env"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"gopkg.in/gomail.v2" "gopkg.in/gomail.v2"
...@@ -24,7 +23,6 @@ func SendMail(c *gin.Context) { ...@@ -24,7 +23,6 @@ func SendMail(c *gin.Context) {
//doSendMail 寄發通知郵件 //doSendMail 寄發通知郵件
func doSendMail(params *beans.SendMail) { func doSendMail(params *beans.SendMail) {
cfg := env.GetEnv()
mail := gomail.NewMessage() mail := gomail.NewMessage()
mail.SetHeader("From", cfg.Mail.From) mail.SetHeader("From", cfg.Mail.From)
mail.SetHeader("To", params.GetTo()) mail.SetHeader("To", params.GetTo())
......
...@@ -10,13 +10,11 @@ import ( ...@@ -10,13 +10,11 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/teed7334-restore/homekeeper/beans" "github.com/teed7334-restore/homekeeper/beans"
"github.com/teed7334-restore/homekeeper/env"
"github.com/teed7334-restore/homekeeper/models" "github.com/teed7334-restore/homekeeper/models"
) )
//ResetAllUseMinute 重新計算所有請假時間 //ResetAllUseMinute 重新計算所有請假時間
func ResetAllUseMinute(c *gin.Context) { func ResetAllUseMinute(c *gin.Context) {
cfg := env.GetEnv()
models.SetUseMinuteToZero() models.SetUseMinuteToZero()
result := models.GetLeaveHistory() result := models.GetLeaveHistory()
for _, item := range result { for _, item := range result {
...@@ -51,7 +49,6 @@ func CalcTime(c *gin.Context) { ...@@ -51,7 +49,6 @@ func CalcTime(c *gin.Context) {
} }
func combinTimeParams(beginTime time.Time, endTime time.Time) *beans.Punchclock { func combinTimeParams(beginTime time.Time, endTime time.Time) *beans.Punchclock {
cfg := env.GetEnv()
beginStr := beginTime.Format(cfg.TimeFormat) beginStr := beginTime.Format(cfg.TimeFormat)
beginArr := strings.Split(beginStr, " ") beginArr := strings.Split(beginStr, " ")
beginDateArr := strings.Split(beginArr[0], "-") beginDateArr := strings.Split(beginArr[0], "-")
...@@ -136,7 +133,6 @@ func setCarry(diffDay int, diffHour int, diffMinute int) (_diffDay int, _diffHou ...@@ -136,7 +133,6 @@ func setCarry(diffDay int, diffHour int, diffMinute int) (_diffDay int, _diffHou
//getHoliday 取得休假日期 //getHoliday 取得休假日期
func getHoliday() map[string]int { func getHoliday() map[string]int {
cfg := env.GetEnv()
list := models.GetHoliday() list := models.GetHoliday()
data := make(map[string]int) data := make(map[string]int)
for _, item := range list { for _, item := range list {
...@@ -169,7 +165,6 @@ func isHoliday(year string, month string, day string) bool { ...@@ -169,7 +165,6 @@ func isHoliday(year string, month string, day string) bool {
//calcDate 計算跨日天數 //calcDate 計算跨日天數
func calcDate(beginYear string, beginMonth string, beginDay string, endYear string, endMonth string, endDay string) int { func calcDate(beginYear string, beginMonth string, beginDay string, endYear string, endMonth string, endDay string) int {
cfg := env.GetEnv()
diffDay := 0 diffDay := 0
_beginMonth := beginMonth _beginMonth := beginMonth
_beginDay := beginDay _beginDay := beginDay
......
...@@ -7,8 +7,6 @@ import ( ...@@ -7,8 +7,6 @@ import (
"github.com/teed7334-restore/homekeeper/beans" "github.com/teed7334-restore/homekeeper/beans"
"github.com/teed7334-restore/homekeeper/env"
"github.com/garyburd/redigo/redis" "github.com/garyburd/redigo/redis"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
...@@ -161,7 +159,6 @@ func LRangeRedis(c *gin.Context) { ...@@ -161,7 +159,6 @@ func LRangeRedis(c *gin.Context) {
} }
func initRedis() redis.Conn { func initRedis() redis.Conn {
cfg := env.GetEnv()
client, err := redis.Dial(cfg.Redis.Protocol, cfg.Redis.Host) client, err := redis.Dial(cfg.Redis.Protocol, cfg.Redis.Host)
if err != nil { if err != nil {
log.Panic(err) log.Panic(err)
......
...@@ -24,10 +24,6 @@ type Config struct { ...@@ -24,10 +24,6 @@ type Config struct {
Host string Host string
Protocol string Protocol string
} }
GoMyPay struct {
URL string
CustomerID string
}
} }
var cfg = &Config{} var cfg = &Config{}
...@@ -49,8 +45,6 @@ func init() { ...@@ -49,8 +45,6 @@ func init() {
cfg.Mail.Password = "" cfg.Mail.Password = ""
cfg.Redis.Host = "127.0.0.1:6379" cfg.Redis.Host = "127.0.0.1:6379"
cfg.Redis.Protocol = "tcp" cfg.Redis.Protocol = "tcp"
cfg.GoMyPay.URL = "https://n.gomypay.asia/TestShuntClass.aspx"
cfg.GoMyPay.CustomerID = ""
} }
//GetEnv 取得環境參數 //GetEnv 取得環境參數
......
...@@ -28,6 +28,5 @@ func API() *gin.Engine { ...@@ -28,6 +28,5 @@ func API() *gin.Engine {
route.POST("/Redis/LRange", controllers.LRangeRedis) route.POST("/Redis/LRange", controllers.LRangeRedis)
route.POST("/PunchClock/CalcTime", controllers.CalcTime) route.POST("/PunchClock/CalcTime", controllers.CalcTime)
route.POST("/PunchClock/ResetAllUseMinute", controllers.ResetAllUseMinute) route.POST("/PunchClock/ResetAllUseMinute", controllers.ResetAllUseMinute)
route.POST("/GoMyPay/PayCreditCard", controllers.PayCreditCard)
return route return route
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment