/home/mjc1/public_html/j3demo/adm/ajax.order_process.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
<?php
$sub_menu 
"400100";
$dir ".";
include_once(
$dir."/_common.php");
include(
"./auth_check.php"); // 관리자 권한 체크

$mode_ok "Y";

$deposit_price preg_replace("/[^0-9]/"""$deposit_price);

if(
$omode=='item_delete'){ // 주문상품 개별 삭제 처리

    
$midx2 $midx[0];
    
$seq2 $seq[0];
    
$pcode2 $pcode[0];
    
$oinfo order_info_get($midx2); // 주문정보를 가져온다.

    
$rtn sale_ord_del_change($oinfo$midx2$seq2$pcode2);
    if(
$rtn!=''){
        
$mode_ok "N";
        
$msg $rtn;
    }
}

if(
$omode=='item_change'){ // 주문상품 수량 변경

    //_pr($_REQUEST);

    
$cancel_qty preg_replace("/[^0-9]/"""$cancel_qty);
    
    
$midx2 $midx[0];
    
$seq2 $seq[0];
    
$pcode2 $pcode[0];
    
$oinfo order_info_get($midx2); // 주문정보를 가져온다.
    //_pr($oinfo);
    
$rtn sale_ord_qty_change($oinfo$midx2$seq2$cancel_qty);
    if(
$rtn!=''){
        
$mode_ok "N";
        
$msg $rtn;
    }
}

if(
$omode=='state_change'){ // 주문상태 변경
    
$cos substr($ch_ordstate,0,1);
    if(
strlen($ch_ordstate)>1){
        
$cod substr($ch_ordstate,1,1);
        
$where_deposit ", deposit = '{$cod}' ";
    }
    if(
$pg_cancel=='true'){ $pg_cancel "pgc"; } // PG취소 체크시
    
$his date("Ymd His",time())." 주문상태변경 -> {$od_state_tit[$ch_ordstate]} {$pg_cancel}\n";
    if(
$ch_ordstate=='9'){ // 취소일 경우

        
$oinfo order_info_get($midx); // 주문정보를 가져온다.
        
if($pg_cancel=='true'){
            if(
$oinfo['s_pg']=='uplus'){
                include 
$j3_shop_path."/xpay/Cancel.php";
                if(
$cancel_ok=='1'){
                    
$deposit_price 0// pg취소 완료면 입금금액 0으로 처리
                
} else {
                    
$msg "PG결제 취소에 문제가 있습니다.5";
                    
$mode_ok "N";
                }
            }
        } else { 
$deposit_price $oinfo['deposit_price']; $cancel_ok '1'; }
        
        if(
$cancel_ok=='1'){
            
$sql "update sale_ord_m set
                        ordstate = '0' 
                    where midx = '
{$midx}' ";
            
mysql_query($sql,$connect_j3); $all_sql .= $sql;

            
$where_update "ordstate = '0' ";
            
update_del_log("sale_ord_m""midx"$midx,""); // 업데이트 로그 처리
            
$where_update "";

            
$sql "update sale_ord_s set
                        deposit = 0, deposit_price = '
{$deposit_price}', ord_cancel = '1', ord_cancel_time = '".G5_TIME_YMDHIS."', s_order_his = concat(s_order_his,'{$his}') 
                    where midx = '
{$midx}' ";
            
mysql_query($sql,$connect_j3); $all_sql .= $sql;

            
$where_update "deposit = 0, deposit_price = '{$deposit_price}', ord_cancel = '1', ord_cancel_time = '".G5_TIME_YMDHIS."', s_order_his = concat(s_order_his,'{$his}') ";
            
update_del_log("sale_ord_s""midx"$midx,""); // 업데이트 로그 처리
            
$where_update "";

            
$sql "update shop_cart set
                        ct_state = '3' where midx = '
{$midx}'";
            
mysql_query($sql,$connect_j3); $all_sql .= $sql// 장바구니 상태 취소 처리

            
$where_update "ct_state = '3'";
            
update_del_log("shop_cart""midx"$midx,""); // 업데이트 로그 처리
            
$where_update "";
        } 
    } else {
        
$sql "update sale_ord_m set 
                    ordstate = '
{$cos}'
                where midx = '
{$midx}' ";
        
mysql_query($sql,$connect_j3); $all_sql .= $sql;

        
$where_update "ordstate = '{$cos}'";
        
update_del_log("sale_ord_m""midx"$midx,""); // 업데이트 로그 처리
        
$where_update "";

        
$sql "update sale_ord_s set
                    ord_cancel = '0', ord_cancel_time = NULL, s_order_his = concat(s_order_his,'
{$his}') {$where_deposit}
                where midx = '
{$midx}' ";
        
mysql_query($sql,$connect_j3); $all_sql .= $sql;

        
$where_update "ord_cancel = '0', ord_cancel_time = NULL, s_order_his = concat(s_order_his,'{$his}') {$where_deposit}";
        
update_del_log("sale_ord_s""midx"$midx,""); // 업데이트 로그 처리
        
$where_update "";

        
$sql "update shop_cart set
                    ct_state = '2' where midx = '
{$midx}'";
        
mysql_query($sql,$connect_j3); $all_sql .= $sql// 장바구니 주문시 처리

        
$where_update "ct_state = '2'";
        
update_del_log("shop_cart""midx"$midx,""); // 업데이트 로그 처리
        
$where_update "";
    }
}

if(
$omode=='deli_change'){ // 일괄 주문상태 변경
    
foreach($code_idx as $key=>$val){
        
$midx $codes[$val];
        
$cos substr($ch_od_state,0,1);
        if(
strlen($ch_od_state)>1){
            
$cod substr($ch_od_state,1,1);
            
$where_deposit ", deposit = '{$cod}' ";
        }
        if(
$ch_od_state==='2'){ // 배송처리일때 업체와 운송장번호 입력
            
$where_deli1 ", tracking_number = '{$tracking_number[$val]}' ";
            
$where_deli2 ", deli_company = '{$deli_company[$val]}', deli_time = '".G5_TIME_YMDHIS."' ";
        }
        if(
$ch_od_state==='01'){ // 입금처리 일때 입금금액과 입금일시 처리
            
$where_deli2 ", deposit_price = cart_price+deli_price-dc_price-use_point, deposit_time = '".G5_TIME_YMDHIS."' ";
        }
        
$his date("Ymd His",time())." 주문상태변경 -> {$od_state_tit[$ch_od_state]} \n";
        
$sql "update sale_ord_m set 
                    ordstate = '
{$cos}{$where_deli1}
                where midx = '
{$midx}' ";
        
mysql_query($sql,$connect_j3); $all_sql .= $sql;

        
$where_update "ordstate = '{$cos}{$where_deli1}";
        
update_del_log("sale_ord_m""midx"$midx,""); // 업데이트 로그 처리
        
$where_update "";

        
$sql "update sale_ord_s set
                    s_order_his = concat(s_order_his,'
{$his}') {$where_deposit} {$where_deli2}
                where midx = '
{$midx}' ";
        
mysql_query($sql,$connect_j3); $all_sql .= $sql;

        
$where_update "s_order_his = concat(s_order_his,'{$his}') {$where_deposit} {$where_deli2}";
        
update_del_log("sale_ord_s""midx"$midx,""); // 업데이트 로그 처리
        
$where_update "";

        
// 아래 메일과 sms변경시 order_deli_xls_process.php쪽 부분도 확인하기 바랍니다.
        
if($s_mail=='Y' || $s_sms=='Y'){    $oinfo order_info_get($midx);    }

        include(
"order_mail_sms.inc.php");
        
    }
}

if(
$omode=='pay_edit'){
    
$his date("Ymd His",time())." 주문변경 -> 입금 {$deposit_price}원 \n";

    if(
$deposit=='1'){
        
$where1 " deposit_time = '{$deposit_time}', deposit = '1', ord_cancel = '0', ";
    }
    if(
$pay_type!=''){
        
$where2 " pay_type = '{$pay_type}',  ";
    }

    
$sql "update sale_ord_s set
                deposit_price = '
{$deposit_price}', {$where1} {$where2} s_order_his = concat(s_order_his,'{$his}')
            where midx = '
{$midx}' ";
    
mysql_query($sql,$connect_j3); $all_sql .= $sql;

    
$where_update "deposit_price = '{$deposit_price}', {$where1} {$where2} s_order_his = concat(s_order_his,'{$his}')";
    
update_del_log("sale_ord_s""midx"$midx,""); // 업데이트 로그 처리
    
$where_update "";

    if(
$s_mail=='Y' || $s_sms=='Y'){    $oinfo order_info_get($midx);    }
    if(
$s_mail=='Y'){ // 입금완료 메일 전송시 처리
        
ob_start();
        include_once (
"{$j3_shop_path}/mail/order_mail.php");
        
$ma_content ob_get_contents();
        
ob_end_clean();

        
$ma_subject "{$oinfo['od_id']} 주문의 입금확인이 되었습니다.";

        
$snd_email $config['admin_email'];
        
$rcv_email $oinfo['s_email'];
        
$mail = new PHPMailer;
        
$rtn email_send($mail$ma_subject$ma_content$snd_email$rcv_email);
    }
    if(
$s_sms=='Y'){ // 입금완료 SMS 전송시 처리
        
if($config['shop_sms_use4']=='1'){ // 입금완료시 SMS 전송
            
$sms_msg sms_send_msg_conv("4"$oinfo); // 입금완료시 메시지 변환
            
$rtn call_sms_send($oinfo['s_hpno'], $config['send_hp'], $sms_msg);
        }

        if(
$config['shop_kakao_use4']=='1'){ // 입금완료시 알림톡 전송
            
$rtn call_kakako_send($oinfo['s_hpno'], $config['kakao_sender'], $oinfo'4');
        }
    }
}

if(
$omode=='deli_edit'){ // 배송정보 수정
    
if($ch_ordstate!=''){ // 주문상태 변경 체크되어 있으면 적용
        
$where_os ", ordstate = '{$ch_ordstate}' "
        
$where_cd ", ord_cancel = '0' "
        
$his date("Ymd His",time())." 주문상태변경 -> {$od_state_tit[$ch_ordstate]}\n";
        
$where_his ", s_order_his = concat(s_order_his,'{$his}')";
    } 
    
$sql "update sale_ord_m set 
                    consignee_name = '
{$consignee_name}'    , consignee_telno = '{$consignee_telno}'    , consignee_hpno = '{$consignee_hpno}'    , consignee_zipcode = '{$consignee_zipcode}'    , 
                    consignee_addr_m = '
{$consignee_addr_m}'    , consignee_addr_d = '{$consignee_addr_d}'    , transport_msg = '{$transport_msg}'    , tracking_number = '{$tracking_number}'    , 
                    remarks = '
{$remarks}'    {$where_os}
            where midx = '
{$midx}' ";
    
mysql_query($sql,$connect_j3); $all_sql .= $sql;

    
$where_update "consignee_name = '{$consignee_name}'    , consignee_telno = '{$consignee_telno}'    , consignee_hpno = '{$consignee_hpno}'    , consignee_zipcode = '{$consignee_zipcode}'    , 
                    consignee_addr_m = '
{$consignee_addr_m}'    , consignee_addr_d = '{$consignee_addr_d}'    , transport_msg = '{$transport_msg}'    , tracking_number = '{$tracking_number}'    , 
                    remarks = '
{$remarks}'    {$where_os}";
    
update_del_log("sale_ord_m""midx"$midx,""); // 업데이트 로그 처리
    
$where_update "";

    
$sql "update sale_ord_s set
                deli_company = '
{$deli_company}', deli_time = '".G5_TIME_YMDHIS."' {$where_his} {$where_cd}
            where midx = '
{$midx}' ";
    
mysql_query($sql,$connect_j3); $all_sql .= $sql;

    
$where_update "deli_company = '{$deli_company}', deli_time = '".G5_TIME_YMDHIS."' {$where_his} {$where_cd}";
    
update_del_log("sale_ord_s""midx"$midx,""); // 업데이트 로그 처리
    
$where_update "";

    if(
$s_mail=='Y' || $s_sms=='Y'){    $oinfo order_info_get($midx);    }
    if(
$s_mail=='Y'){ // 입금완료 메일 전송시 처리
        
ob_start();
        include_once (
"{$j3_shop_path}/mail/order_mail.php");
        
$ma_content ob_get_contents();
        
ob_end_clean();

        
$ma_subject "{$oinfo['od_id']} 주문의 배송처리가 되었습니다.";

        
$snd_email $config['admin_email'];
        
$rcv_email $oinfo['s_email'];
        
$mail = new PHPMailer;
        
$rtn email_send($mail$ma_subject$ma_content$snd_email$rcv_email);
    }
    if(
$s_sms=='Y'){ // 입금완료/ 배송확인 SMS 전송시 처리
        
if($config['deli_sms_who']=='1'){ // 배송안내시 배송자에게 SMS나 알림톡 처리시
            
$oinfo['s_hpno'] = $oinfo['consignee_hpno'];
        }
        if(
$config['shop_sms_use5']=='1'){ // 배송시 SMS 전송
            
$sms_msg sms_send_msg_conv("5"$oinfo); // 입금완료시 메시지 변환
            
$rtn call_sms_send($oinfo['s_hpno'], $config['send_hp'], $sms_msg);
        }

        if(
$config['shop_kakao_use5']=='1'){ // 배송시 알림톡 전송
            
$rtn call_kakako_send($oinfo['s_hpno'], $config['kakao_sender'], $oinfo'5');
        }
    }
}



if(
$omode=='ord_delete'){ // 주문삭제
    
foreach($code_idx as $key=>$val){
        
$midx $codes[$val];
        
$sql "select ordstate, deposit from sale_ord_m a left join sale_ord_s b on a.midx = b.midx where a.midx = '{$midx}' ";
        
$oinfo sql_fetch($sql,$connect_j3);
        if(
$single_del!='Y'){
            if(!(
$oinfo['ordstate']=='0' && $oinfo['deposit']=='0')){ // 싱글주문 삭제일때는 미입금상태 아니더래도 삭제가능 선택삭제일때는 미입금상태인지를 체크함
                
$mode_ok "N";
            }
        }
        if(
$mode_ok=='Y'){
            
update_del_log("sale_ord_d""midx"$midx,"del"); // 삭제 로그 처리
            
$sql "delete from sale_ord_d where midx = '{$midx}' ";
            
$res mysql_query($sql,$connect_j3); $all_sql .= $sql;

            
update_del_log("sale_ord_s""midx"$midx,"del"); // 삭제 로그 처리
            
$sql "delete from sale_ord_s where midx = '{$midx}' ";
            
$res mysql_query($sql,$connect_j3); $all_sql .= $sql;

            
update_del_log("sale_ord_m""midx"$midx,"del"); // 삭제 로그 처리
            
$sql "delete from sale_ord_m where midx = '{$midx}' ";
            
$res mysql_query($sql,$connect_j3); $all_sql .= $sql;
        }
    }
}

echo 
"<?php xml version='1.0' encoding='utf-8'?><output>";
echo 
"<mode>".$mode."</mode>";
echo 
"<mode_ok>".$mode_ok."</mode_ok>";
echo 
"<rtn_url>".$rtn_url."</rtn_url>";
echo 
"<msg>".$msg."</msg>";
echo 
"<sql>".$all_sql."</sql>";
echo 
"</output>";
?>